mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-03 10:21:46 +02:00
30307 plus tweak suggsted by Wayne: use %lld for zlong when long long
This commit is contained in:
parent
7614be7fe1
commit
86f8e8de69
7 changed files with 87 additions and 5 deletions
|
@ -1,3 +1,10 @@
|
|||
2012-03-05 Peter Stephenson <pws@csr.com>
|
||||
|
||||
* 30307 plus change suggested by Wayne in 30309: configure.ac,
|
||||
Src/exec.c, Src/glob.c, Src/prompt.c, Src/utils.c,
|
||||
Src/Modules/parameter.c: use %lld format where available when
|
||||
zlong is long long.
|
||||
|
||||
2012-03-01 Peter Stephenson <pws@csr.com>
|
||||
|
||||
* 30303: Doc/builtins.yo, Src/options.c: emulate executed inside
|
||||
|
@ -16055,5 +16062,5 @@
|
|||
|
||||
*****************************************************
|
||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||
* $Revision: 1.5600 $
|
||||
* $Revision: 1.5601 $
|
||||
*****************************************************
|
||||
|
|
|
@ -531,7 +531,11 @@ functracegetfn(UNUSED(Param pm))
|
|||
char *colonpair;
|
||||
|
||||
colonpair = zhalloc(strlen(f->caller) + (f->lineno > 9999 ? 24 : 6));
|
||||
#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD)
|
||||
sprintf(colonpair, "%s:%lld", f->caller, f->lineno);
|
||||
#else
|
||||
sprintf(colonpair, "%s:%ld", f->caller, (long)f->lineno);
|
||||
#endif
|
||||
|
||||
*p = colonpair;
|
||||
}
|
||||
|
@ -559,7 +563,11 @@ funcsourcetracegetfn(UNUSED(Param pm))
|
|||
char *fname = f->filename ? f->filename : "";
|
||||
|
||||
colonpair = zhalloc(strlen(fname) + (f->flineno > 9999 ? 24 : 6));
|
||||
#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD)
|
||||
sprintf(colonpair, "%s:%lld", fname, f->flineno);
|
||||
#else
|
||||
sprintf(colonpair, "%s:%ld", fname, (long)f->flineno);
|
||||
#endif
|
||||
|
||||
*p = colonpair;
|
||||
}
|
||||
|
@ -594,7 +602,11 @@ funcfiletracegetfn(UNUSED(Param pm))
|
|||
*/
|
||||
colonpair = zhalloc(strlen(f->caller) +
|
||||
(f->lineno > 9999 ? 24 : 6));
|
||||
#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD)
|
||||
sprintf(colonpair, "%s:%lld", f->caller, f->lineno);
|
||||
#else
|
||||
sprintf(colonpair, "%s:%ld", f->caller, (long)f->lineno);
|
||||
#endif
|
||||
} else {
|
||||
/*
|
||||
* Calling context is a function or eval; we need to find
|
||||
|
@ -604,7 +616,7 @@ funcfiletracegetfn(UNUSED(Param pm))
|
|||
* together with the $functrace line number for the current
|
||||
* context.
|
||||
*/
|
||||
long flineno = (long)(f->prev->flineno + f->lineno);
|
||||
zlong flineno = f->prev->flineno + f->lineno;
|
||||
/*
|
||||
* Line numbers in eval start from 1, not zero,
|
||||
* so offset by one to get line in file.
|
||||
|
@ -614,7 +626,11 @@ funcfiletracegetfn(UNUSED(Param pm))
|
|||
fname = f->prev->filename ? f->prev->filename : "";
|
||||
|
||||
colonpair = zhalloc(strlen(fname) + (flineno > 9999 ? 24 : 6));
|
||||
sprintf(colonpair, "%s:%ld", fname, flineno);
|
||||
#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD)
|
||||
sprintf(colonpair, "%s:%lld", fname, flineno);
|
||||
#else
|
||||
sprintf(colonpair, "%s:%ld", fname, (long)flineno);
|
||||
#endif
|
||||
}
|
||||
|
||||
*p = colonpair;
|
||||
|
|
|
@ -3252,7 +3252,11 @@ execcmd(Estate state, int input, int output, int how, int last1)
|
|||
}
|
||||
if (isset(PRINTEXITVALUE) && isset(SHINSTDIN) &&
|
||||
lastval && !subsh) {
|
||||
#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD)
|
||||
fprintf(stderr, "zsh: exit %lld\n", lastval);
|
||||
#else
|
||||
fprintf(stderr, "zsh: exit %ld\n", (long)lastval);
|
||||
#endif
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
|
|
|
@ -2148,7 +2148,11 @@ xpandbraces(LinkList list, LinkNode *np)
|
|||
for (; rend >= rstart; rend -= rincr) {
|
||||
/* Node added in at end, so do highest first */
|
||||
p = dupstring(str3);
|
||||
#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD)
|
||||
sprintf(p + strp, "%0*lld", minw, rend);
|
||||
#else
|
||||
sprintf(p + strp, "%0*ld", minw, (long)rend);
|
||||
#endif
|
||||
strcat(p + strp, str2 + 1);
|
||||
insertlinknode(list, last, p);
|
||||
if (rev) /* decreasing: add in reverse order. */
|
||||
|
|
16
Src/prompt.c
16
Src/prompt.c
|
@ -663,12 +663,20 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep)
|
|||
break;
|
||||
case 'L':
|
||||
addbufspc(DIGBUFSIZE);
|
||||
#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD)
|
||||
sprintf(bv->bp, "%lld", shlvl);
|
||||
#else
|
||||
sprintf(bv->bp, "%ld", (long)shlvl);
|
||||
#endif
|
||||
bv->bp += strlen(bv->bp);
|
||||
break;
|
||||
case '?':
|
||||
addbufspc(DIGBUFSIZE);
|
||||
#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD)
|
||||
sprintf(bv->bp, "%lld", lastval);
|
||||
#else
|
||||
sprintf(bv->bp, "%ld", (long)lastval);
|
||||
#endif
|
||||
bv->bp += strlen(bv->bp);
|
||||
break;
|
||||
case '%':
|
||||
|
@ -764,7 +772,11 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep)
|
|||
if (funcstack->tp == FS_EVAL)
|
||||
lineno--;
|
||||
addbufspc(DIGBUFSIZE);
|
||||
#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD)
|
||||
sprintf(bv->bp, "%lld", flineno);
|
||||
#else
|
||||
sprintf(bv->bp, "%ld", (long)flineno);
|
||||
#endif
|
||||
bv->bp += strlen(bv->bp);
|
||||
break;
|
||||
}
|
||||
|
@ -772,7 +784,11 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep)
|
|||
/* FALLTHROUGH */
|
||||
case 'i':
|
||||
addbufspc(DIGBUFSIZE);
|
||||
#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD)
|
||||
sprintf(bv->bp, "%lld", lineno);
|
||||
#else
|
||||
sprintf(bv->bp, "%ld", (long)lineno);
|
||||
#endif
|
||||
bv->bp += strlen(bv->bp);
|
||||
break;
|
||||
case 'x':
|
||||
|
|
|
@ -275,9 +275,13 @@ zerrmsg(FILE *file, const char *fmt, va_list ap)
|
|||
#endif
|
||||
char *errmsg;
|
||||
|
||||
if ((unset(SHINSTDIN) || locallevel) && lineno)
|
||||
if ((unset(SHINSTDIN) || locallevel) && lineno) {
|
||||
#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD)
|
||||
fprintf(file, "%lld: ", lineno);
|
||||
#else
|
||||
fprintf(file, "%ld: ", (long)lineno);
|
||||
else
|
||||
#endif
|
||||
} else
|
||||
fputc((unsigned char)' ', file);
|
||||
|
||||
while (*fmt)
|
||||
|
|
31
configure.ac
31
configure.ac
|
@ -1010,6 +1010,37 @@ main() { return sizeof(ino_t) < 8; }
|
|||
fi
|
||||
fi
|
||||
fi
|
||||
AH_TEMPLATE([ZLONG_IS_LONG_LONG],
|
||||
[Define to 1 if the zlong type uses long long int.])
|
||||
if test "$zsh_cv_64_bit_type" = "long long"; then
|
||||
dnl Remember this so we can get (s)printf output right.
|
||||
AC_DEFINE(ZLONG_IS_LONG_LONG)
|
||||
fi
|
||||
|
||||
dnl We'll blithely assume (f)printf supports the same types as sprintf.
|
||||
AC_CACHE_CHECK(for %lld printf support, zsh_cv_printf_has_lld,
|
||||
[AC_TRY_RUN(
|
||||
[#include <stdio.h>
|
||||
#include <string.h>
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
long long foo = ((long long)0xdead << 40) | 0xf00d;
|
||||
char buf[80];
|
||||
sprintf(buf, "before%lldafter", foo);
|
||||
if (!strcmp(buf, "before62677660341432333after")) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
],
|
||||
zsh_cv_printf_has_lld=yes,
|
||||
zsh_cv_printf_has_lld=no,
|
||||
zsh_cv_printf_has_lld=no)])
|
||||
AH_TEMPLATE(PRINTF_HAS_LLD,
|
||||
[Define to 1 if printf and sprintf support %lld for long long.])
|
||||
if test x$zsh_cv_printf_has_lld = xyes; then
|
||||
AC_DEFINE(PRINTF_HAS_LLD)
|
||||
fi
|
||||
|
||||
dnl Check for sigset_t. Currently I'm looking in
|
||||
dnl <sys/types.h> and <signal.h>. Others might need
|
||||
|
|
Loading…
Reference in a new issue