diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2012-08-02 08:58:48 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2012-08-02 08:58:48 +0000 |
commit | 3a6d7bc4bc41d4ebbd74f149130d054f6bcb942c (patch) | |
tree | ccd1258874f894441b0bb8dcf88e738148daa763 /Build/source/texk/web2c/mplibdir/mp.w | |
parent | 7b1f86886de719653324e1fa02f55271fd6b2234 (diff) |
mplibdir: Drop replacement function for snprintf()
git-svn-id: svn://tug.org/texlive/trunk@27284 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/mplibdir/mp.w')
-rw-r--r-- | Build/source/texk/web2c/mplibdir/mp.w | 156 |
1 files changed, 0 insertions, 156 deletions
diff --git a/Build/source/texk/web2c/mplibdir/mp.w b/Build/source/texk/web2c/mplibdir/mp.w index 1bf72630447..af5230845a0 100644 --- a/Build/source/texk/web2c/mplibdir/mp.w +++ b/Build/source/texk/web2c/mplibdir/mp.w @@ -2793,163 +2793,7 @@ char *mp_xstrdup (MP mp, const char *s) { @ @<Internal library declarations@>= -#ifdef HAVE_SNPRINTF # define mp_snprintf (void)snprintf -#else -static void mp_snprintf (char *str, int size, const char *fmt, ...); -#endif - -@ This internal version is rather stupid, but good enough for its purpose. - -@c -#ifndef HAVE_SNPRINTF -static char *mp_itoa (int i) { - char res[32]; - unsigned idx = 30; - unsigned v = (unsigned) abs (i); - memset (res, 0, 32 * sizeof (char)); - while (v >= 10) { - char d = (char) (v % 10); - v = v / 10; - res[idx--] = (char) (d + '0'); - } - res[idx--] = (char) (v + '0'); - if (i < 0) { - res[idx--] = '-'; - } - return mp_strdup ((res + idx + 1)); -} -static char *mp_utoa (unsigned v) { - char res[32]; - unsigned idx = 30; - memset (res, 0, 32 * sizeof (char)); - while (v >= 10) { - char d = (char) (v % 10); - v = v / 10; - res[idx--] = (char) (d + '0'); - } - res[idx--] = (char) (v + '0'); - return mp_strdup ((res + idx + 1)); -} -static void mp_snprintf (char *str, int size, const char *format, ...) { - const char *fmt; - char *res; - int fw, pad; - va_list ap; - va_start (ap, format); - res = str; - for (fmt = format; *fmt != '\0'; fmt++) { - if (*fmt == '%') { - fw = 0; - pad = 0; - RESTART: - fmt++; - switch (*fmt) { - case '0': - pad = 1; - goto RESTART; - break; - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - assert (fw == 0); - fw = *fmt - '0'; - goto RESTART; - break; - case 's': - { - char *s = va_arg (ap, char *); - while (*s) { - *res = *s++; - if (size-- > 0) - res++; - } - } - break; - case 'c': - { - int s = va_arg (ap, int); - *res = (char) s; - if (size-- > 0) - res++; - } - break; - case 'i': - case 'd': - { - char *sstart, *s = mp_itoa (va_arg (ap, int)); - sstart = s; - if (fw) { - int ffw = fw - (int) strlen (s); - while (ffw-- > 0) { - *res = (char) (pad ? '0' : ' '); - if (size-- > 0) - res++; - } - } - if (s != NULL) { - while (*s) { - *res = *s++; - if (size-- > 0) - res++; - } - mp_xfree (sstart); - } - } - break; - case 'u': - { - char *sstart, *s = mp_utoa (va_arg (ap, unsigned)); - sstart = s; - if (fw) { - int ffw = fw - (int) strlen (s); - while (ffw-- > 0) { - *res = (char) (pad ? '0' : ' '); - if (size-- > 0) - res++; - } - } - if (s != NULL) { - while (*s) { - *res = *s++; - if (size-- > 0) - res++; - } - mp_xfree (sstart); - } - } - break; - case '%': - *res = '%'; - if (size-- > 0) - res++; - break; - default: - *res = '%'; - if (size-- > 0) - res++; - *res = *fmt; - if (size-- > 0) - res++; - break; - } - } else { - *res = *fmt; - if (size-- > 0) - res++; - } - } - *res = '\0'; - va_end (ap); -} -#endif - @* Dynamic memory allocation. |