From: David Given Date: Sun, 15 Mar 2015 13:20:47 +0000 (+0100) Subject: Minor tweaks to produce less code. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=3b8e1ac20be177c97ca9822a10270f174a68a57d;p=FUZIX.git Minor tweaks to produce less code. --HG-- extra : source : 428c10531d28c32a1dab12ea81717c5fcd3db62b --- diff --git a/Library/libs/vfprintf.c b/Library/libs/vfprintf.c index 3e7a28a8..40680e24 100644 --- a/Library/libs/vfprintf.c +++ b/Library/libs/vfprintf.c @@ -60,7 +60,7 @@ static int prtfld(FILE * op, size_t maxlen, size_t ct, unsigned char *buf, int l --width; } if (ct++ < maxlen) - putc(ch, op); + fputc(ch, op); if (ch == '\n' && buffer_mode == _IOLBF) fflush(op); } @@ -253,7 +253,7 @@ int _vfnprintf(FILE * op, size_t maxlen, const char *fmt, va_list ap) charout: /* normal char out */ if (cnt < maxlen) - putc(*fmt, op); + fputc(*fmt, op); ++cnt; if (*fmt == '\n' && buffer_mode == _IOLBF) fflush(op); diff --git a/Library/libs/vfscanf.c b/Library/libs/vfscanf.c index 0ee07e96..41a105f7 100644 --- a/Library/libs/vfscanf.c +++ b/Library/libs/vfscanf.c @@ -17,13 +17,14 @@ */ #include +#include #include #include #include /* #define skip() do{c=getc(fp); if (c<1) goto done;}while(isspace(c))*/ -#define skip() while(isspace(c)) { if ((c=getc(fp))<1) goto done; } +#define skip() while(isspace(c)) { if ((c=fgetc(fp))<1) goto done; } /* fp scan actions */ #define F_NADA 0 /* just change state */ @@ -50,7 +51,7 @@ #define FC_SIGN 3 /* given transition,state do what action? */ -int fp_do[][NSTATE] = { +static const uint8_t fp_do[][NSTATE] = { {F_INT,F_INT,F_INT, F_FRAC,F_FRAC, F_EXP,F_EXP,F_EXP}, /* see digit */ @@ -63,7 +64,7 @@ int fp_do[][NSTATE] = { F_ESIGN,F_QUIT,F_QUIT}, /* see sign */ }; /* given transition,state what is new state? */ -int fp_ns[][NSTATE] = { +static const uint8_t fp_ns[][NSTATE] = { {FS_DIGS,FS_DIGS,FS_DIGS, FS_DD,FS_DD, FS_EDIGS,FS_EDIGS,FS_EDIGS}, /* see digit */ @@ -76,7 +77,7 @@ int fp_ns[][NSTATE] = { FS_ESIGN,0,0}, /* see sign */ }; /* which states are valid terminators? */ -int fp_sval[NSTATE] = { +static const uint8_t fp_sval[NSTATE] = { 0,0,1,0,1,0,0,1 }; @@ -124,7 +125,7 @@ int vfscanf(FILE *fp, const char *fmt, va_list ap) if (!*fmt) return (0); - c = getc(fp); + c = fgetc(fp); while (c > 0) { store = 0; @@ -207,7 +208,7 @@ int vfscanf(FILE *fp, const char *fmt, va_list ap) } else if (c == '0') { - c = getc(fp); + c = fgetc(fp); if (c < 1) goto savnum; if ((c != 'x') @@ -409,7 +410,7 @@ int vfscanf(FILE *fp, const char *fmt, va_list ap) { if (store) *p++ = c; - if (((c = getc(fp)) < 1) || + if (((c = fgetc(fp)) < 1) || (--width == 0)) break; @@ -444,7 +445,7 @@ int vfscanf(FILE *fp, const char *fmt, va_list ap) cmatch: if (c != *fmt) break; - c = getc(fp); + c = fgetc(fp); } if (!*++fmt)