diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/calendar/Makefile | 4 | ||||
-rw-r--r-- | usr.bin/calendar/calendar.c | 10 | ||||
-rw-r--r-- | usr.bin/calendar/calendar.h | 7 | ||||
-rw-r--r-- | usr.bin/calendar/events.c | 134 | ||||
-rw-r--r-- | usr.bin/calendar/io.c | 3 | ||||
-rw-r--r-- | usr.bin/mkuzip/mkuzip.8 | 66 | ||||
-rw-r--r-- | usr.bin/svn/Makefile.inc | 41 | ||||
-rw-r--r-- | usr.bin/svn/svn/Makefile | 34 | ||||
-rw-r--r-- | usr.bin/svn/svnadmin/Makefile | 18 | ||||
-rw-r--r-- | usr.bin/svn/svnbench/Makefile | 34 | ||||
-rw-r--r-- | usr.bin/svn/svndumpfilter/Makefile | 18 | ||||
-rw-r--r-- | usr.bin/svn/svnfsfs/Makefile | 18 | ||||
-rw-r--r-- | usr.bin/svn/svnlook/Makefile | 20 | ||||
-rw-r--r-- | usr.bin/svn/svnmucc/Makefile | 34 | ||||
-rw-r--r-- | usr.bin/svn/svnrdump/Makefile | 34 | ||||
-rw-r--r-- | usr.bin/svn/svnserve/Makefile | 28 | ||||
-rw-r--r-- | usr.bin/svn/svnsync/Makefile | 28 | ||||
-rw-r--r-- | usr.bin/svn/svnversion/Makefile | 12 | ||||
-rw-r--r-- | usr.bin/top/display.c | 54 |
19 files changed, 360 insertions, 237 deletions
diff --git a/usr.bin/calendar/Makefile b/usr.bin/calendar/Makefile index 81401f57b8ee..2a51b3319a39 100644 --- a/usr.bin/calendar/Makefile +++ b/usr.bin/calendar/Makefile @@ -13,6 +13,10 @@ INTER= de_AT.ISO_8859-15 de_DE.ISO8859-1 fr_FR.ISO8859-1 \ DE_LINKS= de_DE.ISO8859-15 FR_LINKS= fr_FR.ISO8859-15 +.if ${MK_ICONV} == "yes" +CFLAGS+= -DWITH_ICONV +.endif + FILESGROUPS+= CALS CALS= calendars/calendar.all \ calendars/calendar.australia \ diff --git a/usr.bin/calendar/calendar.c b/usr.bin/calendar/calendar.c index d0c42f424267..a9e6c19e9a0d 100644 --- a/usr.bin/calendar/calendar.c +++ b/usr.bin/calendar/calendar.c @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include <err.h> #include <errno.h> #include <locale.h> +#include <langinfo.h> #include <pwd.h> #include <stdio.h> #include <stdlib.h> @@ -66,6 +67,9 @@ static char *DEBUG = NULL; static time_t f_time = 0; double UTCOffset = UTCOFFSET_NOTSET; int EastLongitude = LONGITUDE_NOTSET; +#ifdef WITH_ICONV +const char *outputEncoding; +#endif static void usage(void) __dead2; @@ -80,6 +84,12 @@ main(int argc, char *argv[]) struct tm tp1, tp2; (void)setlocale(LC_ALL, ""); +#ifdef WITH_ICONV + /* save the information about the encoding used in the terminal */ + outputEncoding = strdup(nl_langinfo(CODESET)); + if (outputEncoding == NULL) + errx(1, "cannot allocate memory"); +#endif while ((ch = getopt(argc, argv, "-A:aB:D:dF:f:l:t:U:W:?")) != -1) switch (ch) { diff --git a/usr.bin/calendar/calendar.h b/usr.bin/calendar/calendar.h index 2b00a66f248e..2604568352b5 100644 --- a/usr.bin/calendar/calendar.h +++ b/usr.bin/calendar/calendar.h @@ -59,6 +59,9 @@ extern struct fixs neaster, npaskha, ncny, nfullmoon, nnewmoon; extern struct fixs nmarequinox, nsepequinox, njunsolstice, ndecsolstice; extern double UTCOffset; extern int EastLongitude; +#ifdef WITH_ICONV +extern const char *outputEncoding; +#endif #define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0) @@ -197,3 +200,7 @@ void fpom(int year, double utcoffset, double *ffms, double *fnms); void equinoxsolstice(int year, double UTCoffset, int *equinoxdays, int *solsticedays); void fequinoxsolstice(int year, double UTCoffset, double *equinoxdays, double *solsticedays); int calculatesunlongitude30(int year, int degreeGMToffset, int *ichinesemonths); + +#ifdef WITH_ICONV +void set_new_encoding(void); +#endif diff --git a/usr.bin/calendar/events.c b/usr.bin/calendar/events.c index 113962bc8a03..84f8f2b41a8b 100644 --- a/usr.bin/calendar/events.c +++ b/usr.bin/calendar/events.c @@ -35,10 +35,120 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> #include <stdlib.h> #include <string.h> +#ifdef WITH_ICONV +#include <iconv.h> +#include <errno.h> +#include <langinfo.h> + +static iconv_t conv = (iconv_t)-1; +static char *currentEncoding = NULL; + +#endif #include "pathnames.h" #include "calendar.h" +#ifdef WITH_ICONV +void +set_new_encoding(void) +{ + const char *newenc; + + newenc = nl_langinfo(CODESET); + if (currentEncoding == NULL) { + currentEncoding = strdup(newenc); + if (currentEncoding == NULL) + errx(1, "set_new_encoding: cannot allocate memory"); + return; + } + if (strcmp(currentEncoding, newenc) == 0) + return; + free(currentEncoding); + currentEncoding = strdup(newenc); + if (currentEncoding == NULL) + errx(1, "set_new_encoding: cannot allocate memory"); + if (conv != (iconv_t) -1) { + iconv_close(conv); + conv = (iconv_t) -1; + } +} +#endif + +static char * +convert(char *input) +{ + char *output; +#ifdef WITH_ICONV + size_t inleft, outleft, converted = 0; + char *outbuf, *tmp; + char *inbuf; + size_t outlen; + + if (currentEncoding == NULL) { + output = strdup(input); + if (output == NULL) + errx(1, "convert: cannot allocate memory"); + return (output); + } + if (conv == (iconv_t)-1) { + conv = iconv_open(outputEncoding, currentEncoding); + if (conv == (iconv_t)-1) { + if (errno == EINVAL) + errx(1, "Conversion is not supported"); + else + err(1, "Initialization failure"); + } + } + + inleft = strlen(input); + inbuf = input; + + outlen = inleft; + if ((output = malloc(outlen + 1)) == NULL) + errx(1, "convert: cannot allocate memory"); + + for (;;) { + errno = 0; + outbuf = output + converted; + outleft = outlen - converted; + + converted = iconv(conv, (char **) &inbuf, &inleft, &outbuf, &outleft); + if (converted != (size_t) -1 || errno == EINVAL) { + /* finished or invalid multibyte, so truncate and ignore */ + break; + } + + if (errno != E2BIG) { + free(output); + err(1, "convert"); + } + + converted = outbuf - output; + outlen += inleft * 2; + + if ((tmp = realloc(output, outlen + 1)) == NULL) { + free(output); + errx(1, "convert: cannot allocate memory"); + } + + output = tmp; + outbuf = output + converted; + } + + /* flush the iconv conversion */ + iconv(conv, NULL, NULL, &outbuf, &outleft); + + /* null terminate the string */ + *outbuf = '\0'; +#else + output = strdup(input); + if (output == NULL) + errx(1, "convert: cannot allocate memory"); +#endif + + return (output); +} + struct event * event_add(int year, int month, int day, char *date, int var, char *txt, char *extra) @@ -58,15 +168,15 @@ event_add(int year, int month, int day, char *date, int var, char *txt, e->month = month; e->day = day; e->var = var; - e->date = strdup(date); + e->date = convert(date); if (e->date == NULL) errx(1, "event_add: cannot allocate memory"); - e->text = strdup(txt); + e->text = convert(txt); if (e->text == NULL) errx(1, "event_add: cannot allocate memory"); e->extra = NULL; if (extra != NULL && extra[0] != '\0') - e->extra = strdup(extra); + e->extra = convert(extra); addtodate(e, year, month, day); return (e); } @@ -74,23 +184,17 @@ event_add(int year, int month, int day, char *date, int var, char *txt, void event_continue(struct event *e, char *txt) { - char *text; + char *oldtext, *text; - /* - * Adding text to the event: - * - Save a copy of the old text (unknown length, so strdup()) - * - Allocate enough space for old text + \n + new text + 0 - * - Store the old text + \n + new text - * - Destroy the saved copy. - */ - text = strdup(e->text); - if (text == NULL) + text = convert(txt); + oldtext = e->text; + if (oldtext == NULL) errx(1, "event_continue: cannot allocate memory"); - free(e->text); - asprintf(&e->text, "%s\n%s", text, txt); + asprintf(&e->text, "%s\n%s", oldtext, text); if (e->text == NULL) errx(1, "event_continue: cannot allocate memory"); + free(oldtext); free(text); return; diff --git a/usr.bin/calendar/io.c b/usr.bin/calendar/io.c index 0b894f0b8945..191c86bd7706 100644 --- a/usr.bin/calendar/io.c +++ b/usr.bin/calendar/io.c @@ -294,6 +294,9 @@ cal_parse(FILE *in, FILE *out) if (strncmp(buf, "LANG=", 5) == 0) { (void)setlocale(LC_ALL, buf + 5); d_first = (*nl_langinfo(D_MD_ORDER) == 'd'); +#ifdef WITH_ICONV + set_new_encoding(); +#endif setnnames(); continue; } diff --git a/usr.bin/mkuzip/mkuzip.8 b/usr.bin/mkuzip/mkuzip.8 index ec0732a408f2..8a54aee7ba57 100644 --- a/usr.bin/mkuzip/mkuzip.8 +++ b/usr.bin/mkuzip/mkuzip.8 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 17, 2006 +.Dd February 19, 2019 .Dt MKUZIP 8 .Os .Sh NAME @@ -35,10 +35,10 @@ class .Sh SYNOPSIS .Nm -.Op Fl v +.Op Fl dLSsvZ +.Op Fl j Ar compression_jobs .Op Fl o Ar outfile .Op Fl s Ar cluster_size -.Op Fl j Ar compression_jobs .Ar infile .Sh DESCRIPTION The @@ -68,6 +68,33 @@ locating each individual cluster is written to the output file. .Pp The options are: .Bl -tag -width indent +.It Fl j Ar compression_jobs +Specify the number of compression jobs that +.Nm +runs in parallel to speed up compression. +When option is not specified the number of jobs set to be equal +to the value of +.Va hw.ncpu +.Xr sysctl 8 +variable. +.It Fl d +Enable de-duplication. +When the option is enabled the +.Nm +detects identical blocks in the input and replaces each subsequent occurence +of such block with pointer to the very first one in the output. +Setting this option results is moderate decrease of compressed image size, +typically around 3-5% of a final size of the compressed image. +.It Fl L +Use +.Xr lzma 3 +compression algorithm instead of the default +.Xr zlib 3 . +The +.Xr lzma 3 +provides noticeable better compression levels on the same data set +at the expense of much slower compression speed (10-20x) and somewhat slower +decompression (2-3x). .It Fl o Ar outfile Name of the output file .Ar outfile . @@ -79,16 +106,9 @@ compression or .Pa .ulzma for the .Xr lzma 3 . -.It Fl L -Use -.Xr lzma 3 -compression algorithm instead of the default -.Xr zlib 3 . -The -.Xr lzma 3 -provides noticeable better compression levels on the same data set -at the expense of much slower compression speed (10-20x) and somewhat slower -decompression (2-3x). +.It Fl S +Print summary about the compression ratio as well as output +file size after file has been processed. .It Fl s Ar cluster_size Split the image into clusters of .Ar cluster_size @@ -111,26 +131,6 @@ Setting .Fl Z results is slight increase of compressed image size, typically less than 0.1% of a final size of the compressed image. -.It Fl d -Enable de-duplication. -When the option is enabled the -.Nm -detects identical blocks in the input and replaces each subsequent occurence -of such block with pointer to the very first one in the output. -Setting this option results is moderate decrease of compressed image size, -typically around 3-5% of a final size of the compressed image. -.It Fl S -Print summary about the compression ratio as well as output -file size after file has been processed. -.It Fl j Ar compression_jobs -Specify the number of compression jobs that -.Nm -runs in parallel to speed up compression. -When option is not specified the number of jobs set to be equal -to the value of -.Va hw.ncpu -.Xr sysctl 8 -variable. .El .Sh NOTES The compression ratio largely depends on the cluster size used. diff --git a/usr.bin/svn/Makefile.inc b/usr.bin/svn/Makefile.inc index 32eee3399ceb..8a6458fc0419 100644 --- a/usr.bin/svn/Makefile.inc +++ b/usr.bin/svn/Makefile.inc @@ -2,13 +2,14 @@ .include <src.opts.mk> -MK_PIE:= no # Explicit libXXX.a references - .if ${MK_SVN} == "yes" SVNLITE?= .else SVNLITE?= lite .endif +.if ${MK_PIE} != "no" +PIE_SUFFIX= _pie +.endif PACKAGE= svn @@ -40,23 +41,23 @@ LIBSVN_REPOSDIR= ${.OBJDIR:H}/lib/libsvn_repos LIBSVN_SUBRDIR= ${.OBJDIR:H}/lib/libsvn_subr LIBSVN_WCDIR= ${.OBJDIR:H}/lib/libsvn_wc -LIBAPR= ${LIBAPRDIR}/libapr.a -LIBAPR_UTIL= ${LIBAPR_UTILDIR}/libapr-util.a -LIBSERF= ${LIBSERFDIR}/libserf.a - -LIBSVN_CLIENT= ${LIBSVN_CLIENTDIR}/libsvn_client.a -LIBSVN_DELTA= ${LIBSVN_DELTADIR}/libsvn_delta.a -LIBSVN_DIFF= ${LIBSVN_DIFFDIR}/libsvn_diff.a -LIBSVN_FS= ${LIBSVN_FSDIR}/libsvn_fs.a -LIBSVN_FS_FS= ${LIBSVN_FS_FSDIR}/libsvn_fs_fs.a -LIBSVN_FS_UTIL= ${LIBSVN_FS_UTILDIR}/libsvn_fs_util.a -LIBSVN_FS_X= ${LIBSVN_FS_XDIR}/libsvn_fs_x.a -LIBSVN_RA= ${LIBSVN_RADIR}/libsvn_ra.a -LIBSVN_RA_LOCAL= ${LIBSVN_RA_LOCALDIR}/libsvn_ra_local.a -LIBSVN_RA_SVN= ${LIBSVN_RA_SVNDIR}/libsvn_ra_svn.a -LIBSVN_RA_SERF= ${LIBSVN_RA_SERFDIR}/libsvn_ra_serf.a -LIBSVN_REPOS= ${LIBSVN_REPOSDIR}/libsvn_repos.a -LIBSVN_SUBR= ${LIBSVN_SUBRDIR}/libsvn_subr.a -LIBSVN_WC= ${LIBSVN_WCDIR}/libsvn_wc.a +LIBAPR= ${LIBAPRDIR}/libapr${PIE_SUFFIX}.a +LIBAPR_UTIL= ${LIBAPR_UTILDIR}/libapr-util${PIE_SUFFIX}.a +LIBSERF= ${LIBSERFDIR}/libserf${PIE_SUFFIX}.a + +LIBSVN_CLIENT= ${LIBSVN_CLIENTDIR}/libsvn_client${PIE_SUFFIX}.a +LIBSVN_DELTA= ${LIBSVN_DELTADIR}/libsvn_delta${PIE_SUFFIX}.a +LIBSVN_DIFF= ${LIBSVN_DIFFDIR}/libsvn_diff${PIE_SUFFIX}.a +LIBSVN_FS= ${LIBSVN_FSDIR}/libsvn_fs${PIE_SUFFIX}.a +LIBSVN_FS_FS= ${LIBSVN_FS_FSDIR}/libsvn_fs_fs${PIE_SUFFIX}.a +LIBSVN_FS_UTIL= ${LIBSVN_FS_UTILDIR}/libsvn_fs_util${PIE_SUFFIX}.a +LIBSVN_FS_X= ${LIBSVN_FS_XDIR}/libsvn_fs_x${PIE_SUFFIX}.a +LIBSVN_RA= ${LIBSVN_RADIR}/libsvn_ra${PIE_SUFFIX}.a +LIBSVN_RA_LOCAL= ${LIBSVN_RA_LOCALDIR}/libsvn_ra_local${PIE_SUFFIX}.a +LIBSVN_RA_SVN= ${LIBSVN_RA_SVNDIR}/libsvn_ra_svn${PIE_SUFFIX}.a +LIBSVN_RA_SERF= ${LIBSVN_RA_SERFDIR}/libsvn_ra_serf${PIE_SUFFIX}.a +LIBSVN_REPOS= ${LIBSVN_REPOSDIR}/libsvn_repos${PIE_SUFFIX}.a +LIBSVN_SUBR= ${LIBSVN_SUBRDIR}/libsvn_subr${PIE_SUFFIX}.a +LIBSVN_WC= ${LIBSVN_WCDIR}/libsvn_wc${PIE_SUFFIX}.a .endif diff --git a/usr.bin/svn/svn/Makefile b/usr.bin/svn/svn/Makefile index 261ed25f606f..a9f57cce2f22 100644 --- a/usr.bin/svn/svn/Makefile +++ b/usr.bin/svn/svn/Makefile @@ -26,23 +26,23 @@ CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \ -I${APRU}/include/private \ -I${APRU}/include -LDADD= -L${LIBSVN_CLIENTDIR} -lsvn_client \ - -L${LIBSVN_WCDIR} -lsvn_wc \ - -L${LIBSVN_RADIR} -lsvn_ra \ - -L${LIBSVN_RA_LOCALDIR} -lsvn_ra_local \ - -L${LIBSVN_RA_SVNDIR} -lsvn_ra_svn \ - -L${LIBSVN_RA_SERFDIR} -lsvn_ra_serf \ - -L${LIBSVN_REPOSDIR} -lsvn_repos \ - -L${LIBSVN_FSDIR} -lsvn_fs \ - -L${LIBSVN_FS_FSDIR} -lsvn_fs_fs \ - -L${LIBSVN_FS_XDIR} -lsvn_fs_x \ - -L${LIBSVN_FS_UTILDIR} -lsvn_fs_util \ - -L${LIBSVN_DELTADIR} -lsvn_delta \ - -L${LIBSVN_DIFFDIR} -lsvn_diff \ - -L${LIBSVN_SUBRDIR} -lsvn_subr \ - -L${LIBSERFDIR} -lserf \ - -L${LIBAPR_UTILDIR} -lapr-util \ - -L${LIBAPRDIR} -lapr +LDADD= -L${LIBSVN_CLIENTDIR} -lsvn_client${PIE_SUFFIX} \ + -L${LIBSVN_WCDIR} -lsvn_wc${PIE_SUFFIX} \ + -L${LIBSVN_RADIR} -lsvn_ra${PIE_SUFFIX} \ + -L${LIBSVN_RA_LOCALDIR} -lsvn_ra_local${PIE_SUFFIX} \ + -L${LIBSVN_RA_SVNDIR} -lsvn_ra_svn${PIE_SUFFIX} \ + -L${LIBSVN_RA_SERFDIR} -lsvn_ra_serf${PIE_SUFFIX} \ + -L${LIBSVN_REPOSDIR} -lsvn_repos${PIE_SUFFIX} \ + -L${LIBSVN_FSDIR} -lsvn_fs${PIE_SUFFIX} \ + -L${LIBSVN_FS_FSDIR} -lsvn_fs_fs${PIE_SUFFIX} \ + -L${LIBSVN_FS_XDIR} -lsvn_fs_x${PIE_SUFFIX} \ + -L${LIBSVN_FS_UTILDIR} -lsvn_fs_util${PIE_SUFFIX} \ + -L${LIBSVN_DELTADIR} -lsvn_delta${PIE_SUFFIX} \ + -L${LIBSVN_DIFFDIR} -lsvn_diff${PIE_SUFFIX} \ + -L${LIBSVN_SUBRDIR} -lsvn_subr${PIE_SUFFIX} \ + -L${LIBSERFDIR} -lserf${PIE_SUFFIX} \ + -L${LIBAPR_UTILDIR} -lapr-util${PIE_SUFFIX} \ + -L${LIBAPRDIR} -lapr${PIE_SUFFIX} LIBADD+= bsdxml sqlite3 z magic crypto ssl pthread DPADD= ${LIBSVN_CLIENT} ${LIBSVN_WC} ${LIBSVN_RA} ${LIBSVN_RA_LOCAL} \ diff --git a/usr.bin/svn/svnadmin/Makefile b/usr.bin/svn/svnadmin/Makefile index eab3b2c89be9..8fe3dfc15d4c 100644 --- a/usr.bin/svn/svnadmin/Makefile +++ b/usr.bin/svn/svnadmin/Makefile @@ -18,15 +18,15 @@ CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \ -I${APRU}/include/private \ -I${APRU}/include -LDADD= -L${LIBSVN_REPOSDIR} -lsvn_repos \ - -L${LIBSVN_FSDIR} -lsvn_fs \ - -L${LIBSVN_FS_FSDIR} -lsvn_fs_fs \ - -L${LIBSVN_FS_XDIR} -lsvn_fs_x \ - -L${LIBSVN_FS_UTILDIR} -lsvn_fs_util \ - -L${LIBSVN_DELTADIR} -lsvn_delta \ - -L${LIBSVN_SUBRDIR} -lsvn_subr \ - -L${LIBAPR_UTILDIR} -lapr-util \ - -L${LIBAPRDIR} -lapr +LDADD= -L${LIBSVN_REPOSDIR} -lsvn_repos${PIE_SUFFIX} \ + -L${LIBSVN_FSDIR} -lsvn_fs${PIE_SUFFIX} \ + -L${LIBSVN_FS_FSDIR} -lsvn_fs_fs${PIE_SUFFIX} \ + -L${LIBSVN_FS_XDIR} -lsvn_fs_x${PIE_SUFFIX} \ + -L${LIBSVN_FS_UTILDIR} -lsvn_fs_util${PIE_SUFFIX} \ + -L${LIBSVN_DELTADIR} -lsvn_delta${PIE_SUFFIX} \ + -L${LIBSVN_SUBRDIR} -lsvn_subr${PIE_SUFFIX} \ + -L${LIBAPR_UTILDIR} -lapr-util${PIE_SUFFIX} \ + -L${LIBAPRDIR} -lapr${PIE_SUFFIX} LIBADD+= bsdxml sqlite3 z pthread DPADD= ${LIBSVN_REPOS} ${LIBSVN_FS} ${LIBSVN_FS_FS} ${LIBSVN_FS_UTIL} \ diff --git a/usr.bin/svn/svnbench/Makefile b/usr.bin/svn/svnbench/Makefile index 8fe07d7f40c5..728de8802d7f 100644 --- a/usr.bin/svn/svnbench/Makefile +++ b/usr.bin/svn/svnbench/Makefile @@ -19,23 +19,23 @@ CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \ -I${APRU}/include/private \ -I${APRU}/include -LDADD= -L${LIBSVN_CLIENTDIR} -lsvn_client \ - -L${LIBSVN_WCDIR} -lsvn_wc \ - -L${LIBSVN_RADIR} -lsvn_ra \ - -L${LIBSVN_RA_LOCALDIR} -lsvn_ra_local \ - -L${LIBSVN_RA_SVNDIR} -lsvn_ra_svn \ - -L${LIBSVN_RA_SERFDIR} -lsvn_ra_serf \ - -L${LIBSVN_REPOSDIR} -lsvn_repos \ - -L${LIBSVN_FSDIR} -lsvn_fs \ - -L${LIBSVN_FS_FSDIR} -lsvn_fs_fs \ - -L${LIBSVN_FS_XDIR} -lsvn_fs_x \ - -L${LIBSVN_FS_UTILDIR} -lsvn_fs_util \ - -L${LIBSVN_DELTADIR} -lsvn_delta \ - -L${LIBSVN_DIFFDIR} -lsvn_diff \ - -L${LIBSVN_SUBRDIR} -lsvn_subr \ - -L${LIBSERFDIR} -lserf \ - -L${LIBAPR_UTILDIR} -lapr-util \ - -L${LIBAPRDIR} -lapr +LDADD= -L${LIBSVN_CLIENTDIR} -lsvn_client${PIE_SUFFIX} \ + -L${LIBSVN_WCDIR} -lsvn_wc${PIE_SUFFIX} \ + -L${LIBSVN_RADIR} -lsvn_ra${PIE_SUFFIX} \ + -L${LIBSVN_RA_LOCALDIR} -lsvn_ra_local${PIE_SUFFIX} \ + -L${LIBSVN_RA_SVNDIR} -lsvn_ra_svn${PIE_SUFFIX} \ + -L${LIBSVN_RA_SERFDIR} -lsvn_ra_serf${PIE_SUFFIX} \ + -L${LIBSVN_REPOSDIR} -lsvn_repos${PIE_SUFFIX} \ + -L${LIBSVN_FSDIR} -lsvn_fs${PIE_SUFFIX} \ + -L${LIBSVN_FS_FSDIR} -lsvn_fs_fs${PIE_SUFFIX} \ + -L${LIBSVN_FS_XDIR} -lsvn_fs_x${PIE_SUFFIX} \ + -L${LIBSVN_FS_UTILDIR} -lsvn_fs_util${PIE_SUFFIX} \ + -L${LIBSVN_DELTADIR} -lsvn_delta${PIE_SUFFIX} \ + -L${LIBSVN_DIFFDIR} -lsvn_diff${PIE_SUFFIX} \ + -L${LIBSVN_SUBRDIR} -lsvn_subr${PIE_SUFFIX} \ + -L${LIBSERFDIR} -lserf${PIE_SUFFIX} \ + -L${LIBAPR_UTILDIR} -lapr-util${PIE_SUFFIX} \ + -L${LIBAPRDIR} -lapr${PIE_SUFFIX} LIBADD+= bsdxml sqlite3 z magic crypto ssl pthread diff --git a/usr.bin/svn/svndumpfilter/Makefile b/usr.bin/svn/svndumpfilter/Makefile index ccb54eb35f19..113a004a6784 100644 --- a/usr.bin/svn/svndumpfilter/Makefile +++ b/usr.bin/svn/svndumpfilter/Makefile @@ -18,15 +18,15 @@ CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \ -I${APRU}/include/private \ -I${APRU}/include -LDADD= -L${LIBSVN_REPOSDIR} -lsvn_repos \ - -L${LIBSVN_FSDIR} -lsvn_fs \ - -L${LIBSVN_FS_FSDIR} -lsvn_fs_fs \ - -L${LIBSVN_FS_XDIR} -lsvn_fs_x \ - -L${LIBSVN_FS_UTILDIR} -lsvn_fs_util \ - -L${LIBSVN_DELTADIR} -lsvn_delta \ - -L${LIBSVN_SUBRDIR} -lsvn_subr \ - -L${LIBAPR_UTILDIR} -lapr-util \ - -L${LIBAPRDIR} -lapr +LDADD= -L${LIBSVN_REPOSDIR} -lsvn_repos${PIE_SUFFIX} \ + -L${LIBSVN_FSDIR} -lsvn_fs${PIE_SUFFIX} \ + -L${LIBSVN_FS_FSDIR} -lsvn_fs_fs${PIE_SUFFIX} \ + -L${LIBSVN_FS_XDIR} -lsvn_fs_x${PIE_SUFFIX} \ + -L${LIBSVN_FS_UTILDIR} -lsvn_fs_util${PIE_SUFFIX} \ + -L${LIBSVN_DELTADIR} -lsvn_delta${PIE_SUFFIX} \ + -L${LIBSVN_SUBRDIR} -lsvn_subr${PIE_SUFFIX} \ + -L${LIBAPR_UTILDIR} -lapr-util${PIE_SUFFIX} \ + -L${LIBAPRDIR} -lapr${PIE_SUFFIX} LIBADD+= bsdxml sqlite3 z crypt pthread DPADD= ${LIBSVN_REPOS} ${LIBSVN_FS} ${LIBSVN_FS_FS} ${LIBSVN_FS_UTIL} \ diff --git a/usr.bin/svn/svnfsfs/Makefile b/usr.bin/svn/svnfsfs/Makefile index 2a465b6038b4..f5c6da38ccec 100644 --- a/usr.bin/svn/svnfsfs/Makefile +++ b/usr.bin/svn/svnfsfs/Makefile @@ -18,15 +18,15 @@ CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \ -I${APRU}/include/private \ -I${APRU}/include -LDADD= -L${LIBSVN_REPOSDIR} -lsvn_repos \ - -L${LIBSVN_FSDIR} -lsvn_fs \ - -L${LIBSVN_FS_FSDIR} -lsvn_fs_fs \ - -L${LIBSVN_FS_XDIR} -lsvn_fs_x \ - -L${LIBSVN_FS_UTILDIR} -lsvn_fs_util \ - -L${LIBSVN_DELTADIR} -lsvn_delta \ - -L${LIBSVN_SUBRDIR} -lsvn_subr \ - -L${LIBAPR_UTILDIR} -lapr-util \ - -L${LIBAPRDIR} -lapr +LDADD= -L${LIBSVN_REPOSDIR} -lsvn_repos${PIE_SUFFIX} \ + -L${LIBSVN_FSDIR} -lsvn_fs${PIE_SUFFIX} \ + -L${LIBSVN_FS_FSDIR} -lsvn_fs_fs${PIE_SUFFIX} \ + -L${LIBSVN_FS_XDIR} -lsvn_fs_x${PIE_SUFFIX} \ + -L${LIBSVN_FS_UTILDIR} -lsvn_fs_util${PIE_SUFFIX} \ + -L${LIBSVN_DELTADIR} -lsvn_delta${PIE_SUFFIX} \ + -L${LIBSVN_SUBRDIR} -lsvn_subr${PIE_SUFFIX} \ + -L${LIBAPR_UTILDIR} -lapr-util${PIE_SUFFIX} \ + -L${LIBAPRDIR} -lapr${PIE_SUFFIX} LIBADD+= bsdxml sqlite3 z pthread DPADD= ${LIBSVN_REPOS} ${LIBSVN_FS} ${LIBSVN_FS_FS} ${LIBSVN_FS_UTIL} \ diff --git a/usr.bin/svn/svnlook/Makefile b/usr.bin/svn/svnlook/Makefile index b4c3929bfbb0..4e631c2e6ca8 100644 --- a/usr.bin/svn/svnlook/Makefile +++ b/usr.bin/svn/svnlook/Makefile @@ -18,16 +18,16 @@ CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \ -I${APRU}/include/private \ -I${APRU}/include -LDADD= -L${LIBSVN_REPOSDIR} -lsvn_repos \ - -L${LIBSVN_FSDIR} -lsvn_fs \ - -L${LIBSVN_FS_FSDIR} -lsvn_fs_fs \ - -L${LIBSVN_FS_XDIR} -lsvn_fs_x \ - -L${LIBSVN_FS_UTILDIR} -lsvn_fs_util \ - -L${LIBSVN_DELTADIR} -lsvn_delta \ - -L${LIBSVN_DIFFDIR} -lsvn_diff \ - -L${LIBSVN_SUBRDIR} -lsvn_subr \ - -L${LIBAPR_UTILDIR} -lapr-util \ - -L${LIBAPRDIR} -lapr +LDADD= -L${LIBSVN_REPOSDIR} -lsvn_repos${PIE_SUFFIX} \ + -L${LIBSVN_FSDIR} -lsvn_fs${PIE_SUFFIX} \ + -L${LIBSVN_FS_FSDIR} -lsvn_fs_fs${PIE_SUFFIX} \ + -L${LIBSVN_FS_XDIR} -lsvn_fs_x${PIE_SUFFIX} \ + -L${LIBSVN_FS_UTILDIR} -lsvn_fs_util${PIE_SUFFIX} \ + -L${LIBSVN_DELTADIR} -lsvn_delta${PIE_SUFFIX} \ + -L${LIBSVN_DIFFDIR} -lsvn_diff${PIE_SUFFIX} \ + -L${LIBSVN_SUBRDIR} -lsvn_subr${PIE_SUFFIX} \ + -L${LIBAPR_UTILDIR} -lapr-util${PIE_SUFFIX} \ + -L${LIBAPRDIR} -lapr${PIE_SUFFIX} LIBADD+= bsdxml sqlite3 z pthread DPADD= ${LIBSVN_REPOS} ${LIBSVN_FS} ${LIBSVN_FS_FS} ${LIBSVN_FS_UTIL} \ diff --git a/usr.bin/svn/svnmucc/Makefile b/usr.bin/svn/svnmucc/Makefile index f2bd597aafd3..fba151bfa91a 100644 --- a/usr.bin/svn/svnmucc/Makefile +++ b/usr.bin/svn/svnmucc/Makefile @@ -18,23 +18,23 @@ CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \ -I${APRU}/include/private \ -I${APRU}/include -LDADD= -L${LIBSVN_CLIENTDIR} -lsvn_client \ - -L${LIBSVN_WCDIR} -lsvn_wc \ - -L${LIBSVN_RADIR} -lsvn_ra \ - -L${LIBSVN_RA_LOCALDIR} -lsvn_ra_local \ - -L${LIBSVN_RA_SVNDIR} -lsvn_ra_svn \ - -L${LIBSVN_RA_SERFDIR} -lsvn_ra_serf \ - -L${LIBSVN_REPOSDIR} -lsvn_repos \ - -L${LIBSVN_FSDIR} -lsvn_fs \ - -L${LIBSVN_FS_FSDIR} -lsvn_fs_fs \ - -L${LIBSVN_FS_XDIR} -lsvn_fs_x \ - -L${LIBSVN_FS_UTILDIR} -lsvn_fs_util \ - -L${LIBSVN_DELTADIR} -lsvn_delta \ - -L${LIBSVN_DIFFDIR} -lsvn_diff \ - -L${LIBSVN_SUBRDIR} -lsvn_subr \ - -L${LIBSERFDIR} -lserf \ - -L${LIBAPR_UTILDIR} -lapr-util \ - -L${LIBAPRDIR} -lapr +LDADD= -L${LIBSVN_CLIENTDIR} -lsvn_client${PIE_SUFFIX} \ + -L${LIBSVN_WCDIR} -lsvn_wc${PIE_SUFFIX} \ + -L${LIBSVN_RADIR} -lsvn_ra${PIE_SUFFIX} \ + -L${LIBSVN_RA_LOCALDIR} -lsvn_ra_local${PIE_SUFFIX} \ + -L${LIBSVN_RA_SVNDIR} -lsvn_ra_svn${PIE_SUFFIX} \ + -L${LIBSVN_RA_SERFDIR} -lsvn_ra_serf${PIE_SUFFIX} \ + -L${LIBSVN_REPOSDIR} -lsvn_repos${PIE_SUFFIX} \ + -L${LIBSVN_FSDIR} -lsvn_fs${PIE_SUFFIX} \ + -L${LIBSVN_FS_FSDIR} -lsvn_fs_fs${PIE_SUFFIX} \ + -L${LIBSVN_FS_XDIR} -lsvn_fs_x${PIE_SUFFIX} \ + -L${LIBSVN_FS_UTILDIR} -lsvn_fs_util${PIE_SUFFIX} \ + -L${LIBSVN_DELTADIR} -lsvn_delta${PIE_SUFFIX} \ + -L${LIBSVN_DIFFDIR} -lsvn_diff${PIE_SUFFIX} \ + -L${LIBSVN_SUBRDIR} -lsvn_subr${PIE_SUFFIX} \ + -L${LIBSERFDIR} -lserf${PIE_SUFFIX} \ + -L${LIBAPR_UTILDIR} -lapr-util${PIE_SUFFIX} \ + -L${LIBAPRDIR} -lapr${PIE_SUFFIX} LIBADD+= bsdxml sqlite3 z crypto ssl pthread DPADD= ${LIBSVN_CLIENT} ${LIBSVN_RA} ${LIBSVN_RA_LOCAL} ${LIBSVN_RA_SVN} \ diff --git a/usr.bin/svn/svnrdump/Makefile b/usr.bin/svn/svnrdump/Makefile index f1dd5e7e16d4..66aaea3180fb 100644 --- a/usr.bin/svn/svnrdump/Makefile +++ b/usr.bin/svn/svnrdump/Makefile @@ -18,23 +18,23 @@ CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \ -I${APRU}/include/private \ -I${APRU}/include -LDADD= -L${LIBSVN_CLIENTDIR} -lsvn_client \ - -L${LIBSVN_WCDIR} -lsvn_wc \ - -L${LIBSVN_RADIR} -lsvn_ra \ - -L${LIBSVN_RA_LOCALDIR} -lsvn_ra_local \ - -L${LIBSVN_RA_SVNDIR} -lsvn_ra_svn \ - -L${LIBSVN_RA_SERFDIR} -lsvn_ra_serf \ - -L${LIBSVN_REPOSDIR} -lsvn_repos \ - -L${LIBSVN_FSDIR} -lsvn_fs \ - -L${LIBSVN_FS_FSDIR} -lsvn_fs_fs \ - -L${LIBSVN_FS_XDIR} -lsvn_fs_x \ - -L${LIBSVN_FS_UTILDIR} -lsvn_fs_util \ - -L${LIBSVN_DELTADIR} -lsvn_delta \ - -L${LIBSVN_DIFFDIR} -lsvn_diff \ - -L${LIBSVN_SUBRDIR} -lsvn_subr \ - -L${LIBSERFDIR} -lserf \ - -L${LIBAPR_UTILDIR} -lapr-util \ - -L${LIBAPRDIR} -lapr +LDADD= -L${LIBSVN_CLIENTDIR} -lsvn_client${PIE_SUFFIX} \ + -L${LIBSVN_WCDIR} -lsvn_wc${PIE_SUFFIX} \ + -L${LIBSVN_RADIR} -lsvn_ra${PIE_SUFFIX} \ + -L${LIBSVN_RA_LOCALDIR} -lsvn_ra_local${PIE_SUFFIX} \ + -L${LIBSVN_RA_SVNDIR} -lsvn_ra_svn${PIE_SUFFIX} \ + -L${LIBSVN_RA_SERFDIR} -lsvn_ra_serf${PIE_SUFFIX} \ + -L${LIBSVN_REPOSDIR} -lsvn_repos${PIE_SUFFIX} \ + -L${LIBSVN_FSDIR} -lsvn_fs${PIE_SUFFIX} \ + -L${LIBSVN_FS_FSDIR} -lsvn_fs_fs${PIE_SUFFIX} \ + -L${LIBSVN_FS_XDIR} -lsvn_fs_x${PIE_SUFFIX} \ + -L${LIBSVN_FS_UTILDIR} -lsvn_fs_util${PIE_SUFFIX} \ + -L${LIBSVN_DELTADIR} -lsvn_delta${PIE_SUFFIX} \ + -L${LIBSVN_DIFFDIR} -lsvn_diff${PIE_SUFFIX} \ + -L${LIBSVN_SUBRDIR} -lsvn_subr${PIE_SUFFIX} \ + -L${LIBSERFDIR} -lserf${PIE_SUFFIX} \ + -L${LIBAPR_UTILDIR} -lapr-util${PIE_SUFFIX} \ + -L${LIBAPRDIR} -lapr${PIE_SUFFIX} LIBADD+= bsdxml sqlite3 z crypto ssl pthread DPADD= ${LIBSVN_CLIENT} ${LIBSVN_WC} ${LIBSVN_RA} ${LIBSVN_RA_LOCAL} \ diff --git a/usr.bin/svn/svnserve/Makefile b/usr.bin/svn/svnserve/Makefile index 5e2c79cd37c3..34e348092058 100644 --- a/usr.bin/svn/svnserve/Makefile +++ b/usr.bin/svn/svnserve/Makefile @@ -18,20 +18,20 @@ CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \ -I${APRU}/include/private \ -I${APRU}/include -LDADD= -L${LIBSVN_RADIR} -lsvn_ra \ - -L${LIBSVN_RA_LOCALDIR} -lsvn_ra_local \ - -L${LIBSVN_RA_SVNDIR} -lsvn_ra_svn \ - -L${LIBSVN_RA_SERFDIR} -lsvn_ra_serf \ - -L${LIBSVN_REPOSDIR} -lsvn_repos \ - -L${LIBSVN_FSDIR} -lsvn_fs \ - -L${LIBSVN_FS_FSDIR} -lsvn_fs_fs \ - -L${LIBSVN_FS_XDIR} -lsvn_fs_x \ - -L${LIBSVN_FS_UTILDIR} -lsvn_fs_util \ - -L${LIBSVN_DELTADIR} -lsvn_delta \ - -L${LIBSVN_SUBRDIR} -lsvn_subr \ - -L${LIBSERFDIR} -lserf \ - -L${LIBAPR_UTILDIR} -lapr-util \ - -L${LIBAPRDIR} -lapr +LDADD= -L${LIBSVN_RADIR} -lsvn_ra${PIE_SUFFIX} \ + -L${LIBSVN_RA_LOCALDIR} -lsvn_ra_local${PIE_SUFFIX} \ + -L${LIBSVN_RA_SVNDIR} -lsvn_ra_svn${PIE_SUFFIX} \ + -L${LIBSVN_RA_SERFDIR} -lsvn_ra_serf${PIE_SUFFIX} \ + -L${LIBSVN_REPOSDIR} -lsvn_repos${PIE_SUFFIX} \ + -L${LIBSVN_FSDIR} -lsvn_fs${PIE_SUFFIX} \ + -L${LIBSVN_FS_FSDIR} -lsvn_fs_fs${PIE_SUFFIX} \ + -L${LIBSVN_FS_XDIR} -lsvn_fs_x${PIE_SUFFIX} \ + -L${LIBSVN_FS_UTILDIR} -lsvn_fs_util${PIE_SUFFIX} \ + -L${LIBSVN_DELTADIR} -lsvn_delta${PIE_SUFFIX} \ + -L${LIBSVN_SUBRDIR} -lsvn_subr${PIE_SUFFIX} \ + -L${LIBSERFDIR} -lserf${PIE_SUFFIX} \ + -L${LIBAPR_UTILDIR} -lapr-util${PIE_SUFFIX} \ + -L${LIBAPRDIR} -lapr${PIE_SUFFIX} LIBADD= bsdxml sqlite3 z pthread DPADD= ${LIBSVN_RA} ${LIBSVN_RA_LOCAL} ${LIBSVN_RA_SVN} ${LIBSVN_RA_SERF} \ diff --git a/usr.bin/svn/svnsync/Makefile b/usr.bin/svn/svnsync/Makefile index 7867611cf6e2..7bfefdc78132 100644 --- a/usr.bin/svn/svnsync/Makefile +++ b/usr.bin/svn/svnsync/Makefile @@ -18,20 +18,20 @@ CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \ -I${APRU}/include/private \ -I${APRU}/include -LDADD= -L${LIBSVN_RADIR} -lsvn_ra \ - -L${LIBSVN_RA_LOCALDIR} -lsvn_ra_local \ - -L${LIBSVN_RA_SVNDIR} -lsvn_ra_svn \ - -L${LIBSVN_RA_SERFDIR} -lsvn_ra_serf \ - -L${LIBSVN_REPOSDIR} -lsvn_repos \ - -L${LIBSVN_FSDIR} -lsvn_fs \ - -L${LIBSVN_FS_FSDIR} -lsvn_fs_fs \ - -L${LIBSVN_FS_XDIR} -lsvn_fs_x \ - -L${LIBSVN_FS_UTILDIR} -lsvn_fs_util \ - -L${LIBSVN_DELTADIR} -lsvn_delta \ - -L${LIBSVN_SUBRDIR} -lsvn_subr \ - -L${LIBSERFDIR} -lserf \ - -L${LIBAPR_UTILDIR} -lapr-util \ - -L${LIBAPRDIR} -lapr +LDADD= -L${LIBSVN_RADIR} -lsvn_ra${PIE_SUFFIX} \ + -L${LIBSVN_RA_LOCALDIR} -lsvn_ra_local${PIE_SUFFIX} \ + -L${LIBSVN_RA_SVNDIR} -lsvn_ra_svn${PIE_SUFFIX} \ + -L${LIBSVN_RA_SERFDIR} -lsvn_ra_serf${PIE_SUFFIX} \ + -L${LIBSVN_REPOSDIR} -lsvn_repos${PIE_SUFFIX} \ + -L${LIBSVN_FSDIR} -lsvn_fs${PIE_SUFFIX} \ + -L${LIBSVN_FS_FSDIR} -lsvn_fs_fs${PIE_SUFFIX} \ + -L${LIBSVN_FS_XDIR} -lsvn_fs_x${PIE_SUFFIX} \ + -L${LIBSVN_FS_UTILDIR} -lsvn_fs_util${PIE_SUFFIX} \ + -L${LIBSVN_DELTADIR} -lsvn_delta${PIE_SUFFIX} \ + -L${LIBSVN_SUBRDIR} -lsvn_subr${PIE_SUFFIX} \ + -L${LIBSERFDIR} -lserf${PIE_SUFFIX} \ + -L${LIBAPR_UTILDIR} -lapr-util${PIE_SUFFIX} \ + -L${LIBAPRDIR} -lapr${PIE_SUFFIX} LIBADD= bsdxml sqlite3 z crypto ssl pthread DPADD= ${LIBSVN_RA} ${LIBSVN_RA_LOCAL} ${LIBSVN_RA_SVN} ${LIBSVN_RA_SERF} \ diff --git a/usr.bin/svn/svnversion/Makefile b/usr.bin/svn/svnversion/Makefile index 29e5b339f6bf..d620ba42abfb 100644 --- a/usr.bin/svn/svnversion/Makefile +++ b/usr.bin/svn/svnversion/Makefile @@ -18,12 +18,12 @@ CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \ -I${APRU}/include/private \ -I${APRU}/include -LDADD= -L${LIBSVN_WCDIR} -lsvn_wc \ - -L${LIBSVN_DELTADIR} -lsvn_delta \ - -L${LIBSVN_DIFFDIR} -lsvn_diff \ - -L${LIBSVN_SUBRDIR} -lsvn_subr \ - -L${LIBAPR_UTILDIR} -lapr-util \ - -L${LIBAPRDIR} -lapr +LDADD= -L${LIBSVN_WCDIR} -lsvn_wc${PIE_SUFFIX} \ + -L${LIBSVN_DELTADIR} -lsvn_delta${PIE_SUFFIX} \ + -L${LIBSVN_DIFFDIR} -lsvn_diff${PIE_SUFFIX} \ + -L${LIBSVN_SUBRDIR} -lsvn_subr${PIE_SUFFIX} \ + -L${LIBAPR_UTILDIR} -lapr-util${PIE_SUFFIX} \ + -L${LIBAPRDIR} -lapr${PIE_SUFFIX} LIBADD+= bsdxml sqlite3 z pthread DPADD= ${LIBSVN_WC} ${LIBSVN_DELTA} ${LIBSVN_DIFF} ${LIBSVN_SUBR} \ diff --git a/usr.bin/top/display.c b/usr.bin/top/display.c index b17be6e83569..708855fb095f 100644 --- a/usr.bin/top/display.c +++ b/usr.bin/top/display.c @@ -378,13 +378,13 @@ u_procstates(int total, int *brkdn) if (ltotal != total) { /* move and overwrite */ -if (x_procstate == 0) { - Move_to(x_procstate, y_procstate); -} -else { - /* cursor is already there...no motion needed */ - assert(lastline == 1); -} + if (x_procstate == 0) { + Move_to(x_procstate, y_procstate); + } + else { + /* cursor is already there...no motion needed */ + assert(lastline == 1); + } printf("%d", total); /* if number of digits differs, rewrite the label */ @@ -1205,7 +1205,7 @@ line_update(char *old, char *new, int start, int line) cursor_on_line = true; putchar(ch); *old = ch; - lastcol = 1; + lastcol = start + 1; } old++; @@ -1341,33 +1341,27 @@ i_uptime(struct timeval *bt, time_t *tod) } } +#define SETUPBUFFER_MIN_SCREENWIDTH 80 #define SETUPBUFFER_REQUIRED_ADDBUFSIZ 2 static char * setup_buffer(char *buffer, int addlen) { - char *b = NULL; - - if (NULL == buffer) { - setup_buffer_bufsiz = screen_width; - b = calloc(setup_buffer_bufsiz + addlen + - SETUPBUFFER_REQUIRED_ADDBUFSIZ, - sizeof(char)); - } else { - if (screen_width > setup_buffer_bufsiz) { - setup_buffer_bufsiz = screen_width; - free(buffer); - b = calloc(setup_buffer_bufsiz + addlen + - SETUPBUFFER_REQUIRED_ADDBUFSIZ, - sizeof(char)); - } else { - b = buffer; - } - } + size_t len; - if (NULL == b) { - errx(4, "can't allocate sufficient memory"); - } + setup_buffer_bufsiz = screen_width; + if (setup_buffer_bufsiz < SETUPBUFFER_MIN_SCREENWIDTH) + { + setup_buffer_bufsiz = SETUPBUFFER_MIN_SCREENWIDTH; + } + + free(buffer); + len = setup_buffer_bufsiz + addlen + SETUPBUFFER_REQUIRED_ADDBUFSIZ; + buffer = calloc(len, sizeof(char)); + if (buffer == NULL) + { + errx(4, "can't allocate sufficient memory"); + } - return b; + return buffer; } |