Using saved parent location: http://bzr.savannah.gnu.org/r/emacs/trunk/ Now on revision 103064. ------------------------------------------------------------ revno: 103064 [merge] committer: Paul Eggert branch nick: trunk timestamp: Mon 2011-01-31 23:24:37 -0800 message: Merge: format-time-string now supports subsecond time stamp resolution diff: === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2011-01-31 23:54:50 +0000 +++ doc/lispref/ChangeLog 2011-02-01 07:23:48 +0000 @@ -1,3 +1,8 @@ +2011-02-01 Paul Eggert + + format-time-string now supports subsecond time stamp resolution + * os.texi (Time Parsing): Document %N. + 2011-01-28 Chong Yidong * vol1.texi (Top): === modified file 'doc/lispref/os.texi' --- doc/lispref/os.texi 2011-01-25 04:08:28 +0000 +++ doc/lispref/os.texi 2011-02-01 07:23:48 +0000 @@ -21,7 +21,7 @@ * System Environment:: Distinguish the name and kind of system. * User Identification:: Finding the name and user id of the user. * Time of Day:: Getting the current time. -* Time Conversion:: Converting a time from numeric form to +* Time Conversion:: Converting a time from numeric form to calendrical data and vice versa. * Time Parsing:: Converting a time from numeric form to text and vice versa. @@ -1336,6 +1336,12 @@ This stands for the minute (00-59). @item %n This stands for a newline. +@item %N +This stands for the nanoseconds (000000000-999999999). To ask for +fewer digits, use @samp{%3N} for milliseconds, @samp{%6N} for +microseconds, etc. Any excess digits are discarded, without rounding. +Currently Emacs time stamps are at best microsecond resolution so the +last three digits generated by plain @samp{%N} are always zero. @item %p This stands for @samp{AM} or @samp{PM}, as appropriate. @item %r === modified file 'etc/ChangeLog' --- etc/ChangeLog 2011-01-28 01:51:41 +0000 +++ etc/ChangeLog 2011-02-01 07:23:48 +0000 @@ -1,3 +1,8 @@ +2011-02-01 Paul Eggert + + format-time-string now supports subsecond time stamp resolution + * NEWS: Document this. + 2011-01-28 Paul Eggert Redo spelling of Makefile variables to conform to POSIX. === modified file 'etc/NEWS' --- etc/NEWS 2011-01-29 03:12:32 +0000 +++ etc/NEWS 2011-02-01 07:23:48 +0000 @@ -169,6 +169,10 @@ *** Tramp offers handlers for file-selinux-context and set-file-selinux-context for remote machines which support SELinux. ++++ +** The function format-time-string now supports the %N directive, for +higher-resolution time stamps. + ** The function kill-emacs is now run upon receipt of the signals SIGTERM and SIGHUP, and upon SIGINT in batch mode. === modified file 'src/ChangeLog' --- src/ChangeLog 2011-01-31 23:54:50 +0000 +++ src/ChangeLog 2011-02-01 07:23:48 +0000 @@ -1,3 +1,13 @@ +2011-02-01 Paul Eggert + + format-time-string now supports subsecond time stamp resolution + * editfns.c (emacs_nmemftime): Renamed from emacs_memftimeu, + for consistency with its new argument and with gnulib nstrftime. + All callers changed. New argument NS. + (Fformat_time_string): Check that the time argument's microseconds + component, if any, is in range; this avoids integer overflow and + also nstrftime needs this. Document %N. + 2011-01-31 Andreas Schwab * image.c (DEF_IMGLIB_FN): Add parameter rettype, use it instead === modified file 'src/editfns.c' --- src/editfns.c 2011-01-30 23:34:18 +0000 +++ src/editfns.c 2011-02-01 07:23:48 +0000 @@ -92,8 +92,8 @@ EMACS_INT *, Lisp_Object, EMACS_INT *); static void update_buffer_properties (EMACS_INT, EMACS_INT); static Lisp_Object region_limit (int); -static size_t emacs_memftimeu (char *, size_t, const char *, - size_t, const struct tm *, int); +static size_t emacs_nmemftime (char *, size_t, const char *, + size_t, const struct tm *, int, int); static void general_insert_function (void (*) (const unsigned char *, EMACS_INT), void (*) (Lisp_Object, EMACS_INT, EMACS_INT, EMACS_INT, @@ -1549,6 +1549,7 @@ /* Write information into buffer S of size MAXSIZE, according to the FORMAT of length FORMAT_LEN, using time information taken from *TP. Default to Universal Time if UT is nonzero, local time otherwise. + Use NS as the number of nanoseconds in the %N directive. Return the number of bytes written, not including the terminating '\0'. If S is NULL, nothing will be written anywhere; so to determine how many bytes would be written, use NULL for S and @@ -1557,7 +1558,8 @@ This function behaves like nstrftime, except it allows null bytes in FORMAT and it does not support nanoseconds. */ static size_t -emacs_memftimeu (char *s, size_t maxsize, const char *format, size_t format_len, const struct tm *tp, int ut) +emacs_nmemftime (char *s, size_t maxsize, const char *format, + size_t format_len, const struct tm *tp, int ut, int ns) { size_t total = 0; @@ -1574,7 +1576,7 @@ if (s) s[0] = '\1'; - result = nstrftime (s, maxsize, format, tp, ut, 0); + result = nstrftime (s, maxsize, format, tp, ut, ns); if (s) { @@ -1620,6 +1622,7 @@ %p is the locale's equivalent of either AM or PM. %M is the minute. %S is the second. +%N is the nanosecond, %6N the microsecond, %3N the millisecond, etc. %Z is the time zone name, %z is the numeric form. %s is the number of seconds since 1970-01-01 00:00:00 +0000. @@ -1649,13 +1652,17 @@ { time_t value; int size; + int usec; + int ns; struct tm *tm; int ut = ! NILP (universal); CHECK_STRING (format_string); - if (! lisp_time_argument (time, &value, NULL)) + if (! (lisp_time_argument (time, &value, &usec) + && 0 <= usec && usec < 1000000)) error ("Invalid time specification"); + ns = usec * 1000; format_string = code_convert_string_norecord (format_string, Vlocale_coding_system, 1); @@ -1678,9 +1685,9 @@ buf[0] = '\1'; BLOCK_INPUT; - result = emacs_memftimeu (buf, size, SSDATA (format_string), + result = emacs_nmemftime (buf, size, SSDATA (format_string), SBYTES (format_string), - tm, ut); + tm, ut, ns); UNBLOCK_INPUT; if ((result > 0 && result < size) || (result == 0 && buf[0] == '\0')) return code_convert_string_norecord (make_unibyte_string (buf, result), @@ -1688,10 +1695,10 @@ /* If buffer was too small, make it bigger and try again. */ BLOCK_INPUT; - result = emacs_memftimeu (NULL, (size_t) -1, + result = emacs_nmemftime (NULL, (size_t) -1, SSDATA (format_string), SBYTES (format_string), - tm, ut); + tm, ut, ns); UNBLOCK_INPUT; size = result + 1; } ------------------------------------------------------------ revno: 103063 author: Lars Ingebrigtsen committer: Katsumi Yamaoka branch nick: trunk timestamp: Tue 2011-02-01 03:54:46 +0000 message: shr.el (shr-render-td): Only do colours at the final rendering. Should be slightly faster. (shr-insert-table): Fix up TD background colours when doing the vertical padding. gnus-art.el (article-update-date-lapsed): Don't use current-column to find the horizontal position. It's fragile in the presence of \003 characters. diff: === modified file 'lisp/gnus/ChangeLog' --- lisp/gnus/ChangeLog 2011-02-01 02:23:24 +0000 +++ lisp/gnus/ChangeLog 2011-02-01 03:54:46 +0000 @@ -1,7 +1,14 @@ 2011-02-01 Lars Ingebrigtsen + * shr.el (shr-render-td): Only do colours at the final rendering. + Should be slightly faster. + (shr-insert-table): Fix up TD background colours when doing the + vertical padding. + * gnus-art.el (article-date-ut): Protect against articles with no Date header. + (article-update-date-lapsed): Don't use current-column to find the + horizontal position. It's fragile in the presence of \003 characters. * gnus-start.el (gnus-read-active-file-1): Remove dead parameter infos. === modified file 'lisp/gnus/gnus-art.el' --- lisp/gnus/gnus-art.el 2011-02-01 02:23:24 +0000 +++ lisp/gnus/gnus-art.el 2011-02-01 03:54:46 +0000 @@ -3645,7 +3645,7 @@ (set-buffer (window-buffer w)) (when (eq major-mode 'gnus-article-mode) (let ((old-line (count-lines (point-min) (point))) - (old-column (current-column))) + (old-column (- (point) (line-beginning-position)))) (goto-char (point-min)) (while (re-search-forward "^Date:" nil t) (let ((type (get-text-property (match-beginning 0) 'gnus-date-type))) === modified file 'lisp/gnus/shr.el' --- lisp/gnus/shr.el 2011-01-27 13:20:55 +0000 +++ lisp/gnus/shr.el 2011-02-01 03:54:46 +0000 @@ -1055,8 +1055,11 @@ ;; possibly. (dotimes (i (- height (length lines))) (end-of-line) - (insert (make-string (string-width (car lines)) ? ) - shr-table-vertical-line) + (let ((start (point))) + (insert (make-string (string-width (car lines)) ? ) + shr-table-vertical-line) + (when (nth 4 column) + (shr-put-color start (1- (point)) :background (nth 4 column)))) (forward-line 1))))) (shr-insert-table-ruler widths))) @@ -1173,17 +1176,18 @@ (end-of-line) (when (> (- width (current-column)) 0) (insert (make-string (- width (current-column)) ? ))) - (forward-line 1)))) - (when style - (shr-colorize-region - (point-min) (point-max) - (cdr (assq 'color shr-stylesheet)) - (cdr (assq 'background-color shr-stylesheet)))) + (forward-line 1))) + (when style + (shr-colorize-region + (point-min) (point-max) + (cdr (assq 'color shr-stylesheet)) + (cdr (assq 'background-color shr-stylesheet))))) (if fill (list max (count-lines (point-min) (point-max)) (split-string (buffer-string) "\n") - (shr-collect-overlays)) + (shr-collect-overlays) + (cdr (assq 'background-color shr-stylesheet))) (list max (shr-natural-width))))))) ------------------------------------------------------------ revno: 103062 author: Lars Ingebrigtsen committer: Katsumi Yamaoka branch nick: trunk timestamp: Tue 2011-02-01 02:23:24 +0000 message: gnus-art.el (article-date-ut): Protect against articles with no Date header. diff: === modified file 'lisp/gnus/ChangeLog' --- lisp/gnus/ChangeLog 2011-02-01 02:19:04 +0000 +++ lisp/gnus/ChangeLog 2011-02-01 02:23:24 +0000 @@ -1,5 +1,8 @@ 2011-02-01 Lars Ingebrigtsen + * gnus-art.el (article-date-ut): Protect against articles with no Date + header. + * gnus-start.el (gnus-read-active-file-1): Remove dead parameter infos. 2011-01-31 Lars Ingebrigtsen === modified file 'lisp/gnus/gnus-art.el' --- lisp/gnus/gnus-art.el 2011-01-31 12:29:31 +0000 +++ lisp/gnus/gnus-art.el 2011-02-01 02:23:24 +0000 @@ -3443,7 +3443,8 @@ (delete-region (point-at-bol) (progn (gnus-article-forward-header) (point)))) - (article-transform-date date type bface eface)))))) + (when date + (article-transform-date date type bface eface))))))) (defun article-transform-date (date type bface eface) (dolist (this-type (cond ------------------------------------------------------------ revno: 103061 author: Lars Ingebrigtsen committer: Katsumi Yamaoka branch nick: trunk timestamp: Tue 2011-02-01 02:19:04 +0000 message: gnus-start.el (gnus-read-active-file-1): Remove dead parameter infos. diff: === modified file 'lisp/gnus/ChangeLog' --- lisp/gnus/ChangeLog 2011-01-31 12:29:31 +0000 +++ lisp/gnus/ChangeLog 2011-02-01 02:19:04 +0000 @@ -1,3 +1,7 @@ +2011-02-01 Lars Ingebrigtsen + + * gnus-start.el (gnus-read-active-file-1): Remove dead parameter infos. + 2011-01-31 Lars Ingebrigtsen * gnus-art.el (article-transform-date): Rewrite to still work when === modified file 'lisp/gnus/gnus-start.el' --- lisp/gnus/gnus-start.el 2011-01-31 02:19:13 +0000 +++ lisp/gnus/gnus-start.el 2011-02-01 02:19:04 +0000 @@ -1700,6 +1700,8 @@ 'retrieve-group-data-early (car method))) (when (gnus-check-backend-function 'request-scan (car method)) (gnus-request-scan nil method)) + ;; Store the token we get back from -early so that we + ;; can pass it to -finish later. (setcar (nthcdr 3 elem) (gnus-retrieve-group-data-early method infos))))))) @@ -1741,6 +1743,8 @@ (defun gnus-read-active-for-groups (method infos early-data) (with-current-buffer nntp-server-buffer (cond + ;; Finish up getting the data from the methods that have -early + ;; methods. ((and (gnus-check-backend-function 'finish-retrieve-group-infos (car method)) infos @@ -1748,6 +1752,7 @@ (gnus-online method))) (gnus-finish-retrieve-group-infos method infos early-data) (gnus-agent-save-active method)) + ;; Most backends have -retrieve-groups. ((and (gnus-check-backend-function 'retrieve-groups (car method)) infos) (when (gnus-check-backend-function 'request-scan (car method)) @@ -1757,8 +1762,11 @@ (dolist (info infos (nreverse groups)) (push (gnus-group-real-name (gnus-info-group info)) groups)) method))) + ;; Virtually all backends have -request-list. ((gnus-check-backend-function 'request-list (car method)) - (gnus-read-active-file-1 method nil infos)) + (gnus-read-active-file-1 method nil)) + ;; Except nnvirtual and friends, where we request each group, one + ;; by one. (t (dolist (info infos) (gnus-activate-group (gnus-info-group info) nil nil method t)))))) @@ -1987,7 +1995,7 @@ (message "Quit reading the active file") nil)))))))) -(defun gnus-read-active-file-1 (method force &optional infos) +(defun gnus-read-active-file-1 (method force) (let (where mesg) (setq where (nth 1 method) mesg (format "Reading active file%s via %s..." ------------------------------------------------------------ revno: 103060 committer: Jay Belanger branch nick: trunk timestamp: Mon 2011-01-31 20:15:52 -0600 message: * calc/calc-mtx.el (math-lud-pivot-check): New function. (math-do-matrix-lud): Use `math-lud-pivot-check' to check the size of potential pivots. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-01-31 23:54:50 +0000 +++ lisp/ChangeLog 2011-02-01 02:15:52 +0000 @@ -1,3 +1,9 @@ +2011-02-01 Jay Belanger + + * calc/calc-mtx.el (math-lud-pivot-check): New function. + (math-do-matrix-lud): Use `math-lud-pivot-check' to check the size + of potential pivots. + 2011-01-31 Alan Mackenzie * progmodes/cc-cmds.el (c-forward-over-illiterals): Continue === modified file 'lisp/calc/calc-mtx.el' --- lisp/calc/calc-mtx.el 2011-01-25 04:08:28 +0000 +++ lisp/calc/calc-mtx.el 2011-02-01 02:15:52 +0000 @@ -232,6 +232,20 @@ (setq math-lud-cache (cons (cons m entry) math-lud-cache))) lud)))) + +(defun math-lud-pivot-check (a) + "Determine a useful value for checking the size of potential pivots +in LUD decomposition." + (cond ((eq (car-safe a) 'mod) + (if (and (math-integerp (nth 1 a)) + (math-integerp (nth 2 a)) + (eq (math-gcd (nth 1 a) (nth 2 a)) 1)) + 1 + 0)) + (t + (math-abs-approx a)))) + + ;;; Numerical Recipes section 2.3; implicit pivoting omitted. (defun math-do-matrix-lud (m) (let* ((lu (math-copy-matrix m)) @@ -261,7 +275,7 @@ (nth j (nth k lu)))) k (1+ k))) (setcar (nthcdr j (nth i lu)) sum) - (let ((dum (math-abs-approx sum))) + (let ((dum (math-lud-pivot-check sum))) (if (Math-lessp big dum) (setq big dum imax i))) ------------------------------------------------------------ revno: 103059 [merge] committer: Chong Yidong branch nick: trunk timestamp: Mon 2011-01-31 18:57:36 -0500 message: Merge changes from emacs-23 branch diff: === modified file 'ChangeLog' --- ChangeLog 2011-01-31 19:36:08 +0000 +++ ChangeLog 2011-01-31 23:54:50 +0000 @@ -1,10 +1,15 @@ +2011-01-31 Chong Yidong + + * configure.in: Test existence of xaw3d library, not just the + header (Bug#7642). + 2011-01-31 Eli Zaretskii * lib/makefile.w32-in (GNULIBOBJS): Add $(BLD)/strftime.$(O) and $(BLD)/time_r.$(O). ($(BLD)/dtoastr.$(O)): Depend on $(EMACS_ROOT)/src/s/ms-w32.h and $(EMACS_ROOT)/src/m/intel386.h. - ($(BLD)/strftime.$(O)): + ($(BLD)/strftime.$(O)): ($(BLD)/time_r.$(O)): Define prerequisites. 2011-01-31 Paul Eggert === modified file 'configure' --- configure 2011-01-31 08:12:52 +0000 +++ configure 2011-01-31 23:54:50 +0000 @@ -10595,10 +10595,51 @@ } _ACEOF if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XawScrollbarSetThumb in -lXaw3d" >&5 +$as_echo_n "checking for XawScrollbarSetThumb in -lXaw3d... " >&6; } +if test "${ac_cv_lib_Xaw3d_XawScrollbarSetThumb+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lXaw3d $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char XawScrollbarSetThumb (); +int +main () +{ +return XawScrollbarSetThumb (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_Xaw3d_XawScrollbarSetThumb=yes +else + ac_cv_lib_Xaw3d_XawScrollbarSetThumb=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xaw3d_XawScrollbarSetThumb" >&5 +$as_echo "$ac_cv_lib_Xaw3d_XawScrollbarSetThumb" >&6; } +if test "x$ac_cv_lib_Xaw3d_XawScrollbarSetThumb" = x""yes; then : emacs_cv_xaw3d=yes else emacs_cv_xaw3d=no fi + +else + emacs_cv_xaw3d=no +fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi === modified file 'configure.in' --- configure.in 2011-01-31 08:12:52 +0000 +++ configure.in 2011-01-31 23:54:50 +0000 @@ -2006,7 +2006,8 @@ #include #include ], [], - emacs_cv_xaw3d=yes, + [AC_CHECK_LIB(Xaw3d, XawScrollbarSetThumb, + emacs_cv_xaw3d=yes, emacs_cv_xaw3d=no)], emacs_cv_xaw3d=no)]) else emacs_cv_xaw3d=no === modified file 'doc/emacs/ChangeLog' --- doc/emacs/ChangeLog 2011-01-29 14:48:19 +0000 +++ doc/emacs/ChangeLog 2011-01-31 23:54:50 +0000 @@ -1,3 +1,11 @@ +2011-01-31 Chong Yidong + + * search.texi (Regexps): Copyedits. Mention character classes + (Bug#7809). + + * files.texi (File Aliases): Restore explanatory text from Eli + Zaretskii, accidentally removed in 2011-01-08 commit. + 2011-01-29 Eli Zaretskii * makefile.w32-in (MAKEINFO): Remove options, leave only program name. === modified file 'doc/emacs/files.texi' --- doc/emacs/files.texi 2011-01-25 04:08:28 +0000 +++ doc/emacs/files.texi 2011-01-31 23:54:50 +0000 @@ -1183,26 +1183,23 @@ @cindex directory name abbreviation @vindex directory-abbrev-alist Sometimes, a directory is ordinarily accessed through a symbolic -link, and you may want Emacs to preferentially display its ``linked'' -name instead of its truename. To do this, customize the variable -@code{directory-abbrev-alist}. Each element in this list should have -the form @code{(@var{from} . @var{to})}, which says to replace -@var{from} with @var{to} when it appears in a directory name. For -this feature to work properly, @var{from} and @var{to} should point to -the same file. The @var{from} string is actually a regular expression -(@pxref{Regexps}); it should always start with @samp{\`}, to avoid -matching to an incorrect part of the original directory name. The -@var{to} string should be an ordinary absolute directory name. Do not -use @samp{~} to stand for a home directory in the @var{to} string; -Emacs performs these substitutions separately. - - Here's an example, from a system on which file system -@file{/home/fsf} and so on are normally accessed through symbolic -links named @file{/fsf} and so on. +link, and you may want Emacs to preferentially show its ``linked'' +name. To do this, customize @code{directory-abbrev-alist}. Each +element in this list should have the form @code{(@var{from} +. @var{to})}, which means to replace @var{from} with @var{to} whenever +@var{from} appears in a directory name. The @var{from} string is a +regular expression (@pxref{Regexps}). It is matched against directory +names anchored at the first character, and should start with @samp{\`} +(to support directory names with embedded newlines, which would defeat +@samp{^}). The @var{to} string should be an ordinary absolute +directory name pointing to the same directory. Do not use @samp{~} to +stand for a home directory in the @var{to} string; Emacs performs +these substitutions separately. Here's an example, from a system on +which @file{/home/fsf} is normally accessed through a symbolic link +named @file{/fsf}: @example -(("\\`/home/fsf" . "/fsf") - ("\\`/home/gd" . "/gd")) +(("\\`/home/fsf" . "/fsf")) @end example @node Directories === modified file 'doc/emacs/search.texi' --- doc/emacs/search.texi 2011-01-25 04:08:28 +0000 +++ doc/emacs/search.texi 2011-01-31 23:54:50 +0000 @@ -545,21 +545,20 @@ @cindex syntax of regexps This manual describes regular expression features that users -typically want to use. There are additional features that are -mainly used in Lisp programs; see @ref{Regular Expressions,,, -elisp, The Emacs Lisp Reference Manual}. +typically use. @xref{Regular Expressions,,, elisp, The Emacs Lisp +Reference Manual}, for additional features used mainly in Lisp +programs. Regular expressions have a syntax in which a few characters are special constructs and the rest are @dfn{ordinary}. An ordinary -character is a simple regular expression which matches that same -character and nothing else. The special characters are @samp{$}, -@samp{^}, @samp{.}, @samp{*}, @samp{+}, @samp{?}, @samp{[}, and -@samp{\}. The character @samp{]} is special if it ends a character -alternative (see later). The character @samp{-} is special inside a -character alternative. Any other character appearing in a regular -expression is ordinary, unless a @samp{\} precedes it. (When you use -regular expressions in a Lisp program, each @samp{\} must be doubled, -see the example near the end of this section.) +character matches that same character and nothing else. The special +characters are @samp{$^.*+?[\}. The character @samp{]} is special if +it ends a character alternative (see later). The character @samp{-} +is special inside a character alternative. Any other character +appearing in a regular expression is ordinary, unless a @samp{\} +precedes it. (When you use regular expressions in a Lisp program, +each @samp{\} must be doubled, see the example near the end of this +section.) For example, @samp{f} is not a special character, so it is ordinary, and therefore @samp{f} is a regular expression that matches the string @@ -569,28 +568,27 @@ also match @samp{F} and @samp{O}, but we consider this a generalization of ``the same string,'' rather than an exception.) - Any two regular expressions @var{a} and @var{b} can be concatenated. The -result is a regular expression which matches a string if @var{a} matches -some amount of the beginning of that string and @var{b} matches the rest of -the string.@refill - - As a simple example, we can concatenate the regular expressions @samp{f} -and @samp{o} to get the regular expression @samp{fo}, which matches only -the string @samp{fo}. Still trivial. To do something nontrivial, you -need to use one of the special characters. Here is a list of them. + Any two regular expressions @var{a} and @var{b} can be concatenated. +The result is a regular expression which matches a string if @var{a} +matches some amount of the beginning of that string and @var{b} +matches the rest of the string. For example, concatenating the +regular expressions @samp{f} and @samp{o} gives the regular expression +@samp{fo}, which matches only the string @samp{fo}. Still trivial. +To do something nontrivial, you need to use one of the special +characters. Here is a list of them. @table @asis @item @kbd{.}@: @r{(Period)} -is a special character that matches any single character except a newline. -Using concatenation, we can make regular expressions like @samp{a.b}, which -matches any three-character string that begins with @samp{a} and ends with -@samp{b}.@refill +is a special character that matches any single character except a +newline. For example, the regular expressions @samp{a.b} matches any +three-character string that begins with @samp{a} and ends with +@samp{b}. @item @kbd{*} is not a construct by itself; it is a postfix operator that means to -match the preceding regular expression repetitively as many times as -possible. Thus, @samp{o*} matches any number of @samp{o}s (including no -@samp{o}s). +match the preceding regular expression repetitively any number of +times, as many times as possible. Thus, @samp{o*} matches any number +of @samp{o}s, including no @samp{o}s. @samp{*} always applies to the @emph{smallest} possible preceding expression. Thus, @samp{fo*} has a repeating @samp{o}, not a repeating @@ -609,22 +607,21 @@ @item @kbd{+} is a postfix operator, similar to @samp{*} except that it must match -the preceding expression at least once. So, for example, @samp{ca+r} -matches the strings @samp{car} and @samp{caaaar} but not the string -@samp{cr}, whereas @samp{ca*r} matches all three strings. +the preceding expression at least once. Thus, @samp{ca+r} matches the +strings @samp{car} and @samp{caaaar} but not the string @samp{cr}, +whereas @samp{ca*r} matches all three strings. @item @kbd{?} -is a postfix operator, similar to @samp{*} except that it can match the -preceding expression either once or not at all. For example, -@samp{ca?r} matches @samp{car} or @samp{cr}; nothing else. +is a postfix operator, similar to @samp{*} except that it can match +the preceding expression either once or not at all. Thus, @samp{ca?r} +matches @samp{car} or @samp{cr}, and nothing else. @item @kbd{*?}, @kbd{+?}, @kbd{??} @cindex non-greedy regexp matching -are non-greedy variants of the operators above. The normal operators -@samp{*}, @samp{+}, @samp{?} are @dfn{greedy} in that they match as -much as they can, as long as the overall regexp can still match. With -a following @samp{?}, they are non-greedy: they will match as little -as possible. +are non-@dfn{greedy} variants of the operators above. The normal +operators @samp{*}, @samp{+}, @samp{?} match as much as they can, as +long as the overall regexp can still match. With a following +@samp{?}, they will match as little as possible. Thus, both @samp{ab*} and @samp{ab*?} can match the string @samp{a} and the string @samp{abbbb}; but if you try to match them both against @@ -640,29 +637,30 @@ starting at the first @samp{a}, it does. @item @kbd{\@{@var{n}\@}} -is a postfix operator that specifies repetition @var{n} times---that -is, the preceding regular expression must match exactly @var{n} times -in a row. For example, @samp{x\@{4\@}} matches the string @samp{xxxx} -and nothing else. +is a postfix operator specifying @var{n} repetitions---that is, the +preceding regular expression must match exactly @var{n} times in a +row. For example, @samp{x\@{4\@}} matches the string @samp{xxxx} and +nothing else. @item @kbd{\@{@var{n},@var{m}\@}} -is a postfix operator that specifies repetition between @var{n} and -@var{m} times---that is, the preceding regular expression must match -at least @var{n} times, but no more than @var{m} times. If @var{m} is +is a postfix operator specifying between @var{n} and @var{m} +repetitions---that is, the preceding regular expression must match at +least @var{n} times, but no more than @var{m} times. If @var{m} is omitted, then there is no upper limit, but the preceding regular expression must match at least @var{n} times.@* @samp{\@{0,1\@}} is equivalent to @samp{?}. @* @samp{\@{0,\@}} is equivalent to @samp{*}. @* @samp{\@{1,\@}} is equivalent to @samp{+}. @item @kbd{[ @dots{} ]} -is a @dfn{character set}, which begins with @samp{[} and is terminated -by @samp{]}. In the simplest case, the characters between the two -brackets are what this set can match. +is a @dfn{character set}, beginning with @samp{[} and terminated by +@samp{]}. -Thus, @samp{[ad]} matches either one @samp{a} or one @samp{d}, and -@samp{[ad]*} matches any string composed of just @samp{a}s and @samp{d}s -(including the empty string), from which it follows that @samp{c[ad]*r} -matches @samp{cr}, @samp{car}, @samp{cdr}, @samp{caddaar}, etc. +In the simplest case, the characters between the two brackets are what +this set can match. Thus, @samp{[ad]} matches either one @samp{a} or +one @samp{d}, and @samp{[ad]*} matches any string composed of just +@samp{a}s and @samp{d}s (including the empty string). It follows that +@samp{c[ad]*r} matches @samp{cr}, @samp{car}, @samp{cdr}, +@samp{caddaar}, etc. You can also include character ranges in a character set, by writing the starting and ending characters with a @samp{-} between them. Thus, @@ -671,9 +669,12 @@ which matches any lower-case @acronym{ASCII} letter or @samp{$}, @samp{%} or period. -Note that the usual regexp special characters are not special inside a -character set. A completely different set of special characters exists -inside character sets: @samp{]}, @samp{-} and @samp{^}. +You can also include certain special @dfn{character classes} in a +character set. A @samp{[:} and balancing @samp{:]} enclose a +character class inside a character alternative. For instance, +@samp{[[:alnum:]]} matches any letter or digit. @xref{Char Classes,,, +elisp, The Emacs Lisp Reference Manual}, for a list of character +classes. To include a @samp{]} in a character set, you must make it the first character. For example, @samp{[]a]} matches @samp{]} or @samp{a}. To === modified file 'doc/lispref/ChangeLog' --- doc/lispref/ChangeLog 2011-01-29 14:48:19 +0000 +++ doc/lispref/ChangeLog 2011-01-31 23:54:50 +0000 @@ -1,3 +1,14 @@ +2011-01-28 Chong Yidong + + * vol1.texi (Top): + * vol2.texi (Top): + * elisp.texi (Top): + * display.texi (Display Property): Shorten the menu description of + the "Other Display Specs" node (Bug#7816). + + * keymaps.texi (Defining Menus): Add "menu item" and "extended + menu item" concept index entries (Bug#7805). + 2011-01-29 Eli Zaretskii * makefile.w32-in (texinfodir): New variable. === modified file 'doc/lispref/display.texi' --- doc/lispref/display.texi 2011-01-25 04:08:28 +0000 +++ doc/lispref/display.texi 2011-01-31 23:54:50 +0000 @@ -3657,9 +3657,8 @@ * Replacing Specs:: Display specs that replace the text. * Specified Space:: Displaying one space with a specified width. * Pixel Specification:: Specifying space width or height in pixels. -* Other Display Specs:: Displaying an image; magnifying text; moving it - up or down on the page; adjusting the width - of spaces within text. +* Other Display Specs:: Displaying an image; adjusting the height, + spacing, and other properties of text. * Display Margins:: Displaying text or images to the side of the main text. @end menu === modified file 'doc/lispref/elisp.texi' --- doc/lispref/elisp.texi 2011-01-25 04:08:28 +0000 +++ doc/lispref/elisp.texi 2011-01-31 23:54:50 +0000 @@ -1330,9 +1330,8 @@ * Replacing Specs:: Display specs that replace the text. * Specified Space:: Displaying one space with a specified width. * Pixel Specification:: Specifying space width or height in pixels. -* Other Display Specs:: Displaying an image; magnifying text; moving it - up or down on the page; adjusting the width - of spaces within text. +* Other Display Specs:: Displaying an image; adjusting the height, + spacing, and other properties of text. * Display Margins:: Displaying text or images to the side of the main text. === modified file 'doc/lispref/keymaps.texi' --- doc/lispref/keymaps.texi 2011-01-25 04:08:28 +0000 +++ doc/lispref/keymaps.texi 2011-01-31 23:54:50 +0000 @@ -1972,6 +1972,7 @@ @cindex defining menus @cindex menu prompt string @cindex prompt string (of menu) +@cindex menu item A keymap acts as a menu if it has an @dfn{overall prompt string}, which is a string that appears as an element of the keymap. @@ -2073,6 +2074,7 @@ @node Extended Menu Items @subsubsection Extended Menu Items @kindex menu-item +@cindex extended menu item An extended-format menu item is a more flexible and also cleaner alternative to the simple format. You define an event type with a === modified file 'doc/lispref/vol1.texi' --- doc/lispref/vol1.texi 2011-01-25 04:08:28 +0000 +++ doc/lispref/vol1.texi 2011-01-31 23:54:50 +0000 @@ -1351,9 +1351,8 @@ * Replacing Specs:: Display specs that replace the text. * Specified Space:: Displaying one space with a specified width. * Pixel Specification:: Specifying space width or height in pixels. -* Other Display Specs:: Displaying an image; magnifying text; moving it - up or down on the page; adjusting the width - of spaces within text. +* Other Display Specs:: Displaying an image; adjusting the height, + spacing, and other properties of text. * Display Margins:: Displaying text or images to the side of the main text. === modified file 'doc/lispref/vol2.texi' --- doc/lispref/vol2.texi 2011-01-25 04:08:28 +0000 +++ doc/lispref/vol2.texi 2011-01-31 23:54:50 +0000 @@ -1350,9 +1350,8 @@ * Replacing Specs:: Display specs that replace the text. * Specified Space:: Displaying one space with a specified width. * Pixel Specification:: Specifying space width or height in pixels. -* Other Display Specs:: Displaying an image; magnifying text; moving it - up or down on the page; adjusting the width - of spaces within text. +* Other Display Specs:: Displaying an image; adjusting the height, + spacing, and other properties of text. * Display Margins:: Displaying text or images to the side of the main text. === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-01-31 20:44:45 +0000 +++ lisp/ChangeLog 2011-01-31 23:54:50 +0000 @@ -1,3 +1,51 @@ +2011-01-31 Alan Mackenzie + + * progmodes/cc-cmds.el (c-forward-over-illiterals): Continue + parsing if we encounter a naked # (Bug#7595). + (c-beginning-of-statement): Avoid loop in locating the beginning + of a macro. + +2011-01-31 Chong Yidong + + * files.el (copy-directory): Fix arguments to recursive call. + +2011-01-31 Chong Yidong + + * files.el (copy-directory): If destination is an existing + directory, copy into a subdirectory there. + +2011-01-31 Andreas Schwab + + * emacs-lisp/shadow.el (load-path-shadows-find): Ignore leim-list + files. + +2011-01-31 Chong Yidong + + * image-dired.el (image-dired-mouse-display-image): No-op if no + file is found (Bug#7817). + + * mouse.el (mouse-menu-non-singleton): Doc fix (Bug#7801). + +2011-01-31 Kenichi Handa + + * international/quail.el (quail-keyboard-layout-alist): Remove + superfluous SPC for "pc105-uk" (bug#7927). + +2011-01-31 Glenn Morris + + * msb.el (msb-menu-bar-update-buffers): Update for changed + argument handling of menu-bar-select-frame. (Bug#7902) + +2011-01-31 Chong Yidong + + * progmodes/cc-engine.el (c-forward-<>-arglist-recur): Set a limit + to the recursion depth (Bug#7722). + +2011-01-31 Roy Liu (tiny change) + + * term/ns-win.el (ns-find-file): Expand ns-input-file with + command-line-default-directory (Bug#7872). + 2011-01-31 Stefan Monnier * progmodes/compile.el (compilation--flush-directory-cache): === modified file 'lisp/emacs-lisp/shadow.el' --- lisp/emacs-lisp/shadow.el 2011-01-25 04:08:28 +0000 +++ lisp/emacs-lisp/shadow.el 2011-01-31 23:54:50 +0000 @@ -115,7 +115,7 @@ ;; FILE now contains the current file name, with no suffix. (unless (or (member file files-seen-this-dir) ;; Ignore these files. - (member file '("subdirs"))) + (member file '("subdirs" "leim-list"))) ;; File has not been seen yet in this directory. ;; This test prevents us declaring that XXX.el shadows ;; XXX.elc (or vice-versa) when they are in the same directory. === modified file 'lisp/erc/ChangeLog' --- lisp/erc/ChangeLog 2011-01-25 04:08:28 +0000 +++ lisp/erc/ChangeLog 2011-01-31 23:54:50 +0000 @@ -1,3 +1,8 @@ +2011-01-31 Antoine Levitt (tiny change) + + * erc-track.el (track): Don't reset erc-modified-channels-object + each time erc-track-mode is activated. + 2011-01-13 Stefan Monnier * erc.el (erc-mode): === modified file 'lisp/erc/erc-track.el' --- lisp/erc/erc-track.el 2011-01-25 04:08:28 +0000 +++ lisp/erc/erc-track.el 2011-01-31 23:54:50 +0000 @@ -648,7 +648,6 @@ (add-hook 'erc-send-completed-hook 'erc-user-is-active) (add-hook 'erc-server-001-functions 'erc-user-is-active)) (erc-track-add-to-mode-line erc-track-position-in-mode-line) - (setq erc-modified-channels-object (erc-modified-channels-object nil)) (erc-update-mode-line) (if (featurep 'xemacs) (defadvice switch-to-buffer (after erc-update (&rest args) activate) === modified file 'lisp/files.el' --- lisp/files.el 2011-01-25 04:08:28 +0000 +++ lisp/files.el 2011-01-31 23:54:50 +0000 @@ -4855,22 +4855,35 @@ ;; Compute target name. (setq directory (directory-file-name (expand-file-name directory)) newname (directory-file-name (expand-file-name newname))) - (if (not (file-directory-p newname)) (make-directory newname parents)) + + (if (not (file-directory-p newname)) + ;; If NEWNAME is not an existing directory, create it; that + ;; is where we will copy the files of DIRECTORY. + (make-directory newname parents) + ;; If NEWNAME is an existing directory, we will copy into + ;; NEWNAME/[DIRECTORY-BASENAME]. + (setq newname (expand-file-name + (file-name-nondirectory + (directory-file-name directory)) + newname)) + (and (file-exists-p newname) + (not (file-directory-p newname)) + (error "Cannot overwrite non-directory %s with a directory" + newname)) + (make-directory newname t)) ;; Copy recursively. - (mapc - (lambda (file) - (let ((target (expand-file-name - (file-name-nondirectory file) newname)) - (attrs (file-attributes file))) - (cond ((file-directory-p file) - (copy-directory file target keep-time parents)) - ((stringp (car attrs)) ; Symbolic link - (make-symbolic-link (car attrs) target t)) - (t - (copy-file file target t keep-time))))) - ;; We do not want to copy "." and "..". - (directory-files directory 'full directory-files-no-dot-files-regexp)) + (dolist (file + ;; We do not want to copy "." and "..". + (directory-files directory 'full + directory-files-no-dot-files-regexp)) + (if (file-directory-p file) + (copy-directory file newname keep-time parents) + (let ((target (expand-file-name (file-name-nondirectory file) newname)) + (attrs (file-attributes file))) + (if (stringp (car attrs)) ; Symbolic link + (make-symbolic-link (car attrs) target t) + (copy-file file target t keep-time))))) ;; Set directory attributes. (set-file-modes newname (file-modes directory)) === modified file 'lisp/image-dired.el' --- lisp/image-dired.el 2011-01-25 04:08:28 +0000 +++ lisp/image-dired.el 2011-01-31 23:54:50 +0000 @@ -2194,15 +2194,15 @@ Track this in associated dired buffer if `image-dired-track-movement' is non-nil." (interactive "e") - (let (file) - (mouse-set-point event) - (goto-char (posn-point (event-end event))) - (setq file (image-dired-original-file-name)) - (if image-dired-track-movement - (image-dired-track-original-file)) - (image-dired-create-display-image-buffer) - (display-buffer image-dired-display-image-buffer) - (image-dired-display-image file))) + (mouse-set-point event) + (goto-char (posn-point (event-end event))) + (let ((file (image-dired-original-file-name))) + (when file + (if image-dired-track-movement + (image-dired-track-original-file)) + (image-dired-create-display-image-buffer) + (display-buffer image-dired-display-image-buffer) + (image-dired-display-image file)))) (defun image-dired-mouse-select-thumbnail (event) "Use mouse EVENT to select thumbnail image. === modified file 'lisp/international/quail.el' --- lisp/international/quail.el 2011-01-25 04:08:28 +0000 +++ lisp/international/quail.el 2011-01-31 23:54:50 +0000 @@ -662,7 +662,7 @@ ") '("pc105-uk" . "\ \ -`\2541!2\"3\2434$5%6^7&8*9(0)-_=+ \ +`\2541!2\"3\2434$5%6^7&8*9(0)-_=+ \ qQwWeErRtTyYuUiIoOpP[{]} \ aAsSdDfFgGhHjJkKlL;:'@#~ \ \\|zZxXcCvVbBnNmM,<.>/? \ === modified file 'lisp/mouse.el' --- lisp/mouse.el 2011-01-25 04:08:28 +0000 +++ lisp/mouse.el 2011-01-31 23:54:50 +0000 @@ -201,9 +201,9 @@ newmap)) (defun mouse-menu-non-singleton (menubar) - "Given menu keymap, -if it defines exactly one submenu, return just that submenu. -Otherwise return the whole menu." + "Return menu keybar MENUBAR, or a lone submenu inside it. +If MENUBAR defines exactly one submenu, return just that submenu. +Otherwise, return MENUBAR." (if menubar (let (submap) (map-keymap === modified file 'lisp/msb.el' --- lisp/msb.el 2011-01-27 07:54:04 +0000 +++ lisp/msb.el 2011-01-31 23:54:50 +0000 @@ -1114,7 +1114,8 @@ (list (frame-parameter frame 'name) (frame-parameter frame 'name) (cons nil nil)) - 'menu-bar-select-frame)) + `(lambda () + (interactive) (menu-bar-select-frame ,frame)))) frames))))) (setcdr global-buffers-menu-map (if (and buffers-menu frames-menu) === modified file 'lisp/progmodes/cc-cmds.el' --- lisp/progmodes/cc-cmds.el 2011-01-26 08:36:39 +0000 +++ lisp/progmodes/cc-cmds.el 2011-01-31 23:54:50 +0000 @@ -2440,13 +2440,15 @@ (goto-char last) (throw 'done '(nil . nil))) - ;; Stop if we encounter a preprocessor line. - ((and (not macro-end) + ;; Stop if we encounter a preprocessor line. Continue if we + ;; hit a naked # + ((and c-opt-cpp-prefix + (not macro-end) (eq (char-after) ?#) (= (point) (c-point 'boi))) - (goto-char last) - ;(throw 'done (cons (eq (point) here) 'macro-boundary))) ; Changed 2003/3/26 - (throw 'done '(t . macro-boundary))) + (if (= (point) here) ; Not a macro, therefore naked #. + (forward-char) + (throw 'done '(t . macro-boundary)))) ;; Stop after a ';', '}', or "};" ((looking-at ";\\|};?") @@ -2560,14 +2562,21 @@ (c-backward-syntactic-ws)) (or (bobp) (c-after-statement-terminator-p))))))) ;; Are we about to move backwards into or out of a - ;; preprocessor command? If so, locate it's beginning. + ;; preprocessor command? If so, locate its beginning. (when (eq (cdr res) 'macro-boundary) - (save-excursion - (beginning-of-line) - (setq macro-fence - (and (not (bobp)) - (progn (c-skip-ws-backward) (c-beginning-of-macro)) - (point))))) + (setq macro-fence + (save-excursion + (if macro-fence + (progn + (end-of-line) + (and (not (eobp)) + (progn (c-skip-ws-forward) + (c-beginning-of-macro)) + (progn (c-end-of-macro) + (point)))) + (and (not (eobp)) + (c-beginning-of-macro) + (progn (c-end-of-macro) (point))))))) ;; Are we about to move backwards into a literal? (when (memq (cdr res) '(macro-boundary literal)) (setq range (c-ascertain-preceding-literal))) === modified file 'lisp/progmodes/cc-engine.el' --- lisp/progmodes/cc-engine.el 2011-01-25 04:08:28 +0000 +++ lisp/progmodes/cc-engine.el 2011-01-31 23:54:50 +0000 @@ -5371,6 +5371,8 @@ ;; cc-mode requires cc-fonts. (declare-function c-fontify-recorded-types-and-refs "cc-fonts" ()) +(defvar c-forward-<>-arglist-recur-depth) + (defun c-forward-<>-arglist (all-types) ;; The point is assumed to be at a "<". Try to treat it as the open ;; paren of an angle bracket arglist and move forward to the @@ -5396,7 +5398,8 @@ ;; If `c-record-type-identifiers' is set then activate ;; recording of any found types that constitute an argument in ;; the arglist. - (c-record-found-types (if c-record-type-identifiers t))) + (c-record-found-types (if c-record-type-identifiers t)) + (c-forward-<>-arglist-recur--depth 0)) (if (catch 'angle-bracket-arglist-escape (setq c-record-found-types (c-forward-<>-arglist-recur all-types))) @@ -5413,6 +5416,14 @@ nil))) (defun c-forward-<>-arglist-recur (all-types) + + ;; Temporary workaround for Bug#7722. + (when (boundp 'c-forward-<>-arglist-recur--depth) + (if (> c-forward-<>-arglist-recur--depth 200) + (error "Max recursion depth reached in <> arglist") + (setq c-forward-<>-arglist-recur--depth + (1+ c-forward-<>-arglist-recur--depth)))) + ;; Recursive part of `c-forward-<>-arglist'. ;; ;; This function might do hidden buffer changes. === modified file 'lisp/term/ns-win.el' --- lisp/term/ns-win.el 2011-01-26 08:36:39 +0000 +++ lisp/term/ns-win.el 2011-01-31 23:54:50 +0000 @@ -487,7 +487,9 @@ (defun ns-find-file () "Do a `find-file' with the `ns-input-file' as argument." (interactive) - (let* ((f (file-truename (pop ns-input-file))) + (let* ((f (file-truename + (expand-file-name (pop ns-input-file) + command-line-default-directory))) (file (find-file-noselect f)) (bufwin1 (get-buffer-window file 'visible)) (bufwin2 (get-buffer-window "*scratch*" 'visibile))) === modified file 'src/ChangeLog' --- src/ChangeLog 2011-01-31 20:00:40 +0000 +++ src/ChangeLog 2011-01-31 23:54:50 +0000 @@ -1,3 +1,18 @@ +2011-01-31 Andreas Schwab + + * image.c (DEF_IMGLIB_FN): Add parameter rettype, use it instead + of int. All uses adjusted. + (PNG_JMPBUF, png_load, jpeg_load, tiff_load, gif_load) + (svg_load_image): Remove casts. + +2011-01-31 Chong Yidong + + * image.c (fn_png_longjmp, fn_png_set_longjmp_fn): New png + function definitions for compiling with libpng-1.5. + (PNG_LONGJMP, PNG_JMPBUF): New macros for libpng-1.5. + (my_png_error, png_load): Use them. Suggested by Thomas Klausner + (Bug#7908). + 2011-01-31 Eli Zaretskii * s/ms-w32.h (HAVE_STRFTIME): Don't define. === modified file 'src/image.c' --- src/image.c 2011-01-30 22:17:44 +0000 +++ src/image.c 2011-01-31 23:54:50 +0000 @@ -1896,7 +1896,7 @@ #ifdef HAVE_NTGUI /* Macro for defining functions that will be loaded from image DLLs. */ -#define DEF_IMGLIB_FN(func,args) int (FAR CDECL *fn_##func)args +#define DEF_IMGLIB_FN(rettype,func,args) rettype (FAR CDECL *fn_##func)args /* Macro for loading those image functions from the library. */ #define LOAD_IMGLIB_FN(lib,func) { \ @@ -3251,12 +3251,12 @@ /* XPM library details. */ -DEF_IMGLIB_FN (XpmFreeAttributes, (XpmAttributes *)); -DEF_IMGLIB_FN (XpmCreateImageFromBuffer, (Display *, char *, xpm_XImage **, +DEF_IMGLIB_FN (void, XpmFreeAttributes, (XpmAttributes *)); +DEF_IMGLIB_FN (int, XpmCreateImageFromBuffer, (Display *, char *, xpm_XImage **, xpm_XImage **, XpmAttributes *)); -DEF_IMGLIB_FN (XpmReadFileToImage, (Display *, char *, xpm_XImage **, +DEF_IMGLIB_FN (int, XpmReadFileToImage, (Display *, char *, xpm_XImage **, xpm_XImage **, XpmAttributes *)); -DEF_IMGLIB_FN (XImageFree, (xpm_XImage *)); +DEF_IMGLIB_FN (void, XImageFree, (xpm_XImage *)); static int init_xpm_functions (Lisp_Object libraries) @@ -5419,31 +5419,36 @@ #ifdef HAVE_NTGUI /* PNG library details. */ -DEF_IMGLIB_FN (png_get_io_ptr, (png_structp)); -DEF_IMGLIB_FN (png_sig_cmp, (png_bytep, png_size_t, png_size_t)); -DEF_IMGLIB_FN (png_create_read_struct, (png_const_charp, png_voidp, - png_error_ptr, png_error_ptr)); -DEF_IMGLIB_FN (png_create_info_struct, (png_structp)); -DEF_IMGLIB_FN (png_destroy_read_struct, (png_structpp, png_infopp, png_infopp)); -DEF_IMGLIB_FN (png_set_read_fn, (png_structp, png_voidp, png_rw_ptr)); -DEF_IMGLIB_FN (png_set_sig_bytes, (png_structp, int)); -DEF_IMGLIB_FN (png_read_info, (png_structp, png_infop)); -DEF_IMGLIB_FN (png_get_IHDR, (png_structp, png_infop, +DEF_IMGLIB_FN (png_voidp, png_get_io_ptr, (png_structp)); +DEF_IMGLIB_FN (int, png_sig_cmp, (png_bytep, png_size_t, png_size_t)); +DEF_IMGLIB_FN (png_structp, png_create_read_struct, (png_const_charp, png_voidp, + png_error_ptr, png_error_ptr)); +DEF_IMGLIB_FN (png_infop, png_create_info_struct, (png_structp)); +DEF_IMGLIB_FN (void, png_destroy_read_struct, (png_structpp, png_infopp, png_infopp)); +DEF_IMGLIB_FN (void, png_set_read_fn, (png_structp, png_voidp, png_rw_ptr)); +DEF_IMGLIB_FN (void, png_set_sig_bytes, (png_structp, int)); +DEF_IMGLIB_FN (void, png_read_info, (png_structp, png_infop)); +DEF_IMGLIB_FN (png_uint_32, png_get_IHDR, (png_structp, png_infop, png_uint_32 *, png_uint_32 *, int *, int *, int *, int *, int *)); -DEF_IMGLIB_FN (png_get_valid, (png_structp, png_infop, png_uint_32)); -DEF_IMGLIB_FN (png_set_strip_16, (png_structp)); -DEF_IMGLIB_FN (png_set_expand, (png_structp)); -DEF_IMGLIB_FN (png_set_gray_to_rgb, (png_structp)); -DEF_IMGLIB_FN (png_set_background, (png_structp, png_color_16p, +DEF_IMGLIB_FN (png_uint_32, png_get_valid, (png_structp, png_infop, png_uint_32)); +DEF_IMGLIB_FN (void, png_set_strip_16, (png_structp)); +DEF_IMGLIB_FN (void, png_set_expand, (png_structp)); +DEF_IMGLIB_FN (void, png_set_gray_to_rgb, (png_structp)); +DEF_IMGLIB_FN (void, png_set_background, (png_structp, png_color_16p, int, int, double)); -DEF_IMGLIB_FN (png_get_bKGD, (png_structp, png_infop, png_color_16p *)); -DEF_IMGLIB_FN (png_read_update_info, (png_structp, png_infop)); -DEF_IMGLIB_FN (png_get_channels, (png_structp, png_infop)); -DEF_IMGLIB_FN (png_get_rowbytes, (png_structp, png_infop)); -DEF_IMGLIB_FN (png_read_image, (png_structp, png_bytepp)); -DEF_IMGLIB_FN (png_read_end, (png_structp, png_infop)); -DEF_IMGLIB_FN (png_error, (png_structp, png_const_charp)); +DEF_IMGLIB_FN (png_uint_32, png_get_bKGD, (png_structp, png_infop, png_color_16p *)); +DEF_IMGLIB_FN (void, png_read_update_info, (png_structp, png_infop)); +DEF_IMGLIB_FN (png_byte, png_get_channels, (png_structp, png_infop)); +DEF_IMGLIB_FN (png_size_t, png_get_rowbytes, (png_structp, png_infop)); +DEF_IMGLIB_FN (void, png_read_image, (png_structp, png_bytepp)); +DEF_IMGLIB_FN (void, png_read_end, (png_structp, png_infop)); +DEF_IMGLIB_FN (void, png_error, (png_structp, png_const_charp)); + +#if (PNG_LIBPNG_VER >= 10500) +DEF_IMGLIB_FN (void, png_longjmp, (png_structp, int)); +DEF_IMGLIB_FN (jmp_buf *, png_set_longjmp_fn, (png_structp, png_longjmp_ptr, size_t)); +#endif /* libpng version >= 1.5 */ static int init_png_functions (Lisp_Object libraries) @@ -5475,6 +5480,12 @@ LOAD_IMGLIB_FN (library, png_read_image); LOAD_IMGLIB_FN (library, png_read_end); LOAD_IMGLIB_FN (library, png_error); + +#if (PNG_LIBPNG_VER >= 10500) + LOAD_IMGLIB_FN (library, png_longjmp); + LOAD_IMGLIB_FN (library, png_set_longjmp_fn); +#endif /* libpng version >= 1.5 */ + return 1; } #else @@ -5501,8 +5512,24 @@ #define fn_png_read_end png_read_end #define fn_png_error png_error +#if (PNG_LIBPNG_VER >= 10500) +#define fn_png_longjmp png_longjmp +#define fn_png_set_longjmp_fn png_set_longjmp_fn +#endif /* libpng version >= 1.5 */ + #endif /* HAVE_NTGUI */ + +#if (PNG_LIBPNG_VER < 10500) +#define PNG_LONGJMP(ptr) (longjmp ((ptr)->jmpbuf, 1)) +#define PNG_JMPBUF(ptr) ((ptr)->jmpbuf) +#else +/* In libpng version 1.5, the jmpbuf member is hidden. (Bug#7908) */ +#define PNG_LONGJMP(ptr) (fn_png_longjmp ((ptr), 1)) +#define PNG_JMPBUF(ptr) \ + (*fn_png_set_longjmp_fn((ptr), longjmp, sizeof (jmp_buf))) +#endif + /* Error and warning handlers installed when the PNG library is initialized. */ @@ -5513,7 +5540,7 @@ /* Avoid compiler warning about deprecated direct access to png_ptr's fields in libpng versions 1.4.x. */ image_error ("PNG error: %s", build_string (msg), Qnil); - longjmp (png_ptr->jmpbuf, 1); + PNG_LONGJMP (png_ptr); } @@ -5644,19 +5671,17 @@ tbr.bytes += sizeof (sig); } - /* Initialize read and info structs for PNG lib. Casting return - value avoids a GCC warning on W32. */ - png_ptr = (png_structp)fn_png_create_read_struct (PNG_LIBPNG_VER_STRING, - NULL, my_png_error, - my_png_warning); + /* Initialize read and info structs for PNG lib. */ + png_ptr = fn_png_create_read_struct (PNG_LIBPNG_VER_STRING, + NULL, my_png_error, + my_png_warning); if (!png_ptr) { if (fp) fclose (fp); return 0; } - /* Casting return value avoids a GCC warning on W32. */ - info_ptr = (png_infop)fn_png_create_info_struct (png_ptr); + info_ptr = fn_png_create_info_struct (png_ptr); if (!info_ptr) { fn_png_destroy_read_struct (&png_ptr, NULL, NULL); @@ -5664,8 +5689,7 @@ return 0; } - /* Casting return value avoids a GCC warning on W32. */ - end_info = (png_infop)fn_png_create_info_struct (png_ptr); + end_info = fn_png_create_info_struct (png_ptr); if (!end_info) { fn_png_destroy_read_struct (&png_ptr, &info_ptr, NULL); @@ -5675,7 +5699,7 @@ /* Set error jump-back. We come back here when the PNG library detects an error. */ - if (setjmp (png_ptr->jmpbuf)) + if (setjmp (PNG_JMPBUF (png_ptr))) { error: if (png_ptr) @@ -6028,14 +6052,14 @@ #ifdef HAVE_NTGUI /* JPEG library details. */ -DEF_IMGLIB_FN (jpeg_CreateDecompress, (j_decompress_ptr, int, size_t)); -DEF_IMGLIB_FN (jpeg_start_decompress, (j_decompress_ptr)); -DEF_IMGLIB_FN (jpeg_finish_decompress, (j_decompress_ptr)); -DEF_IMGLIB_FN (jpeg_destroy_decompress, (j_decompress_ptr)); -DEF_IMGLIB_FN (jpeg_read_header, (j_decompress_ptr, boolean)); -DEF_IMGLIB_FN (jpeg_read_scanlines, (j_decompress_ptr, JSAMPARRAY, JDIMENSION)); -DEF_IMGLIB_FN (jpeg_std_error, (struct jpeg_error_mgr *)); -DEF_IMGLIB_FN (jpeg_resync_to_restart, (j_decompress_ptr, int)); +DEF_IMGLIB_FN (void, jpeg_CreateDecompress, (j_decompress_ptr, int, size_t)); +DEF_IMGLIB_FN (boolean, jpeg_start_decompress, (j_decompress_ptr)); +DEF_IMGLIB_FN (boolean, jpeg_finish_decompress, (j_decompress_ptr)); +DEF_IMGLIB_FN (void, jpeg_destroy_decompress, (j_decompress_ptr)); +DEF_IMGLIB_FN (int, jpeg_read_header, (j_decompress_ptr, boolean)); +DEF_IMGLIB_FN (JDIMENSION, jpeg_read_scanlines, (j_decompress_ptr, JSAMPARRAY, JDIMENSION)); +DEF_IMGLIB_FN (struct jpeg_error_mgr *, jpeg_std_error, (struct jpeg_error_mgr *)); +DEF_IMGLIB_FN (boolean, jpeg_resync_to_restart, (j_decompress_ptr, int)); static int init_jpeg_functions (Lisp_Object libraries) @@ -6335,9 +6359,8 @@ } /* Customize libjpeg's error handling to call my_error_exit when an - error is detected. This function will perform a longjmp. - Casting return value avoids a GCC warning on W32. */ - cinfo.err = (struct jpeg_error_mgr *)fn_jpeg_std_error (&mgr.pub); + error is detected. This function will perform a longjmp. */ + cinfo.err = fn_jpeg_std_error (&mgr.pub); mgr.pub.error_exit = my_error_exit; if ((rc = setjmp (mgr.setjmp_buffer)) != 0) @@ -6561,17 +6584,17 @@ #ifdef HAVE_NTGUI /* TIFF library details. */ -DEF_IMGLIB_FN (TIFFSetErrorHandler, (TIFFErrorHandler)); -DEF_IMGLIB_FN (TIFFSetWarningHandler, (TIFFErrorHandler)); -DEF_IMGLIB_FN (TIFFOpen, (const char *, const char *)); -DEF_IMGLIB_FN (TIFFClientOpen, (const char *, const char *, thandle_t, +DEF_IMGLIB_FN (TIFFErrorHandler, TIFFSetErrorHandler, (TIFFErrorHandler)); +DEF_IMGLIB_FN (TIFFErrorHandler, TIFFSetWarningHandler, (TIFFErrorHandler)); +DEF_IMGLIB_FN (TIFF *, TIFFOpen, (const char *, const char *)); +DEF_IMGLIB_FN (TIFF *, TIFFClientOpen, (const char *, const char *, thandle_t, TIFFReadWriteProc, TIFFReadWriteProc, TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, TIFFMapFileProc, TIFFUnmapFileProc)); -DEF_IMGLIB_FN (TIFFGetField, (TIFF *, ttag_t, ...)); -DEF_IMGLIB_FN (TIFFReadRGBAImage, (TIFF *, uint32, uint32, uint32 *, int)); -DEF_IMGLIB_FN (TIFFClose, (TIFF *)); -DEF_IMGLIB_FN (TIFFSetDirectory, (TIFF *, tdir_t)); +DEF_IMGLIB_FN (int, TIFFGetField, (TIFF *, ttag_t, ...)); +DEF_IMGLIB_FN (int, TIFFReadRGBAImage, (TIFF *, uint32, uint32, uint32 *, int)); +DEF_IMGLIB_FN (void, TIFFClose, (TIFF *)); +DEF_IMGLIB_FN (int, TIFFSetDirectory, (TIFF *, tdir_t)); static int init_tiff_functions (Lisp_Object libraries) @@ -6754,9 +6777,8 @@ return 0; } - /* Try to open the image file. Casting return value avoids a - GCC warning on W32. */ - tiff = (TIFF *)fn_TIFFOpen (SSDATA (file), "r"); + /* Try to open the image file. */ + tiff = fn_TIFFOpen (SDATA (file), "r"); if (tiff == NULL) { image_error ("Cannot open `%s'", file, Qnil); @@ -6776,16 +6798,14 @@ memsrc.len = SBYTES (specified_data); memsrc.index = 0; - /* Casting arguments return value avoids a GCC warning on W32. */ - tiff = (TIFF *)fn_TIFFClientOpen ("memory_source", "r", - (thandle_t) &memsrc, - (TIFFReadWriteProc) tiff_read_from_memory, - (TIFFReadWriteProc) tiff_write_from_memory, - tiff_seek_in_memory, - tiff_close_memory, - tiff_size_of_memory, - tiff_mmap_memory, - tiff_unmap_memory); + tiff = fn_TIFFClientOpen ("memory_source", "r", &memsrc, + (TIFFReadWriteProc) tiff_read_from_memory, + (TIFFReadWriteProc) tiff_write_from_memory, + tiff_seek_in_memory, + tiff_close_memory, + tiff_size_of_memory, + tiff_mmap_memory, + tiff_unmap_memory); if (!tiff) { @@ -7014,10 +7034,10 @@ #ifdef HAVE_NTGUI /* GIF library details. */ -DEF_IMGLIB_FN (DGifCloseFile, (GifFileType *)); -DEF_IMGLIB_FN (DGifSlurp, (GifFileType *)); -DEF_IMGLIB_FN (DGifOpen, (void *, InputFunc)); -DEF_IMGLIB_FN (DGifOpenFileName, (const char *)); +DEF_IMGLIB_FN (int, DGifCloseFile, (GifFileType *)); +DEF_IMGLIB_FN (int, DGifSlurp, (GifFileType *)); +DEF_IMGLIB_FN (GifFileType *, DGifOpen, (void *, InputFunc)); +DEF_IMGLIB_FN (GifFileType *, DGifOpenFileName, (const char *)); static int init_gif_functions (Lisp_Object libraries) @@ -7110,9 +7130,8 @@ return 0; } - /* Open the GIF file. Casting return value avoids a GCC warning - on W32. */ - gif = (GifFileType *)fn_DGifOpenFileName (SDATA (file)); + /* Open the GIF file. */ + gif = fn_DGifOpenFileName (SDATA (file)); if (gif == NULL) { image_error ("Cannot open `%s'", file, Qnil); @@ -7133,8 +7152,7 @@ memsrc.len = SBYTES (specified_data); memsrc.index = 0; - /* Casting return value avoids a GCC warning on W32. */ - gif = (GifFileType *) fn_DGifOpen (&memsrc, gif_read_from_memory); + gif = fn_DGifOpen (&memsrc, gif_read_from_memory); if (!gif) { image_error ("Cannot open memory source `%s'", img->spec, Qnil); @@ -7982,25 +8000,25 @@ #ifdef HAVE_NTGUI /* SVG library functions. */ -DEF_IMGLIB_FN (rsvg_handle_new); -DEF_IMGLIB_FN (rsvg_handle_get_dimensions); -DEF_IMGLIB_FN (rsvg_handle_write); -DEF_IMGLIB_FN (rsvg_handle_close); -DEF_IMGLIB_FN (rsvg_handle_get_pixbuf); -DEF_IMGLIB_FN (rsvg_handle_free); - -DEF_IMGLIB_FN (gdk_pixbuf_get_width); -DEF_IMGLIB_FN (gdk_pixbuf_get_height); -DEF_IMGLIB_FN (gdk_pixbuf_get_pixels); -DEF_IMGLIB_FN (gdk_pixbuf_get_rowstride); -DEF_IMGLIB_FN (gdk_pixbuf_get_colorspace); -DEF_IMGLIB_FN (gdk_pixbuf_get_n_channels); -DEF_IMGLIB_FN (gdk_pixbuf_get_has_alpha); -DEF_IMGLIB_FN (gdk_pixbuf_get_bits_per_sample); - -DEF_IMGLIB_FN (g_type_init); -DEF_IMGLIB_FN (g_object_unref); -DEF_IMGLIB_FN (g_error_free); +DEF_IMGLIB_FN (RsvgHandle *, rsvg_handle_new); +DEF_IMGLIB_FN (void, rsvg_handle_get_dimensions); +DEF_IMGLIB_FN (gboolean, rsvg_handle_write); +DEF_IMGLIB_FN (gboolean, rsvg_handle_close); +DEF_IMGLIB_FN (GdkPixbuf *, rsvg_handle_get_pixbuf); +DEF_IMGLIB_FN (void, rsvg_handle_free); + +DEF_IMGLIB_FN (int, gdk_pixbuf_get_width); +DEF_IMGLIB_FN (int, gdk_pixbuf_get_height); +DEF_IMGLIB_FN (guchar *, gdk_pixbuf_get_pixels); +DEF_IMGLIB_FN (int, gdk_pixbuf_get_rowstride); +DEF_IMGLIB_FN (GdkColorspace, gdk_pixbuf_get_colorspace); +DEF_IMGLIB_FN (int, gdk_pixbuf_get_n_channels); +DEF_IMGLIB_FN (gboolean, gdk_pixbuf_get_has_alpha); +DEF_IMGLIB_FN (int, gdk_pixbuf_get_bits_per_sample); + +DEF_IMGLIB_FN (void, g_type_init); +DEF_IMGLIB_FN (void, g_object_unref); +DEF_IMGLIB_FN (void, g_error_free); Lisp_Object Qgdk_pixbuf, Qglib, Qgobject; @@ -8147,7 +8165,7 @@ gnome type library functions. */ fn_g_type_init (); /* Make a handle to a new rsvg object. */ - rsvg_handle = (RsvgHandle *) fn_rsvg_handle_new (); + rsvg_handle = fn_rsvg_handle_new (); /* Parse the contents argument and fill in the rsvg_handle. */ fn_rsvg_handle_write (rsvg_handle, contents, size, &error); @@ -8167,14 +8185,14 @@ /* We can now get a valid pixel buffer from the svg file, if all went ok. */ - pixbuf = (GdkPixbuf *) fn_rsvg_handle_get_pixbuf (rsvg_handle); + pixbuf = fn_rsvg_handle_get_pixbuf (rsvg_handle); if (!pixbuf) goto rsvg_error; fn_g_object_unref (rsvg_handle); /* Extract some meta data from the svg handle. */ width = fn_gdk_pixbuf_get_width (pixbuf); height = fn_gdk_pixbuf_get_height (pixbuf); - pixels = (const guint8 *) fn_gdk_pixbuf_get_pixels (pixbuf); + pixels = fn_gdk_pixbuf_get_pixels (pixbuf); rowstride = fn_gdk_pixbuf_get_rowstride (pixbuf); /* Validate the svg meta data. */ ------------------------------------------------------------ revno: 103058 committer: Deniz Dogan branch nick: emacs-trunk timestamp: Mon 2011-01-31 21:44:45 +0100 message: * lisp/net/rcirc.el: New customizable nick completion format. (rcirc-nick-completion-format): New defcustom. (rcirc-complete): Use it. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-01-31 17:09:42 +0000 +++ lisp/ChangeLog 2011-01-31 20:44:45 +0000 @@ -17,6 +17,12 @@ 2011-01-31 Deniz Dogan + * net/rcirc.el: New customizable nick completion format. + (rcirc-nick-completion-format): New defcustom. + (rcirc-complete): Use it. + +2011-01-31 Deniz Dogan + * net/rcirc.el: Clean log filenames (Bug#7933). (rcirc-log-write): Use convert-standard-filename. (rcirc-log-filename-function): Documentation updates. === modified file 'lisp/net/rcirc.el' --- lisp/net/rcirc.el 2011-01-31 15:19:57 +0000 +++ lisp/net/rcirc.el 2011-01-31 20:44:45 +0000 @@ -322,6 +322,15 @@ :type 'function :group 'rcirc) +(defcustom rcirc-nick-completion-format "%s: " + "Format string to use in nick completions. + +The format string is only used when completing at the beginning +of a line. The string is passed as the first argument to +`format' with the nickname as the second argument." + :type 'string + :group 'rcirc) + (defvar rcirc-nick nil) (defvar rcirc-prompt-start-marker nil) @@ -827,11 +836,11 @@ (when completion (delete-region rcirc-completion-start (point)) (insert - (concat completion - (cond - ((= (aref completion 0) ?/) " ") - ((= rcirc-completion-start rcirc-prompt-end-marker) ": ") - (t ""))))))) + (cond + ((= (aref completion 0) ?/) (concat completion " ")) + ((= rcirc-completion-start rcirc-prompt-end-marker) + (format rcirc-nick-completion-format completion)) + (t completion)))))) (defun set-rcirc-decode-coding-system (coding-system) "Set the decode coding system used in this channel." ------------------------------------------------------------ revno: 103057 committer: Eli Zaretskii branch nick: trunk timestamp: Mon 2011-01-31 22:04:42 +0200 message: Commit changes in nt/ChangeLog for r103055. diff: === modified file 'nt/ChangeLog' --- nt/ChangeLog 2011-01-31 19:36:08 +0000 +++ nt/ChangeLog 2011-01-31 20:04:42 +0000 @@ -1,5 +1,8 @@ 2011-01-31 Eli Zaretskii + * config.nt (VERSION): Uncomment definition. + (restrict): Define. + * inc/stdbool.h: New file. 2011-01-29 Eli Zaretskii ------------------------------------------------------------ revno: 103056 committer: Eli Zaretskii branch nick: trunk timestamp: Mon 2011-01-31 22:00:40 +0200 message: Don't define HAVE_STRFTIME on MS-Windows. s/ms-w32.h (HAVE_STRFTIME): Don't define. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-01-31 19:36:08 +0000 +++ src/ChangeLog 2011-01-31 20:00:40 +0000 @@ -1,5 +1,7 @@ 2011-01-31 Eli Zaretskii + * s/ms-w32.h (HAVE_STRFTIME): Don't define. + * makefile.w32-in (OBJ2): Remove strftime.$(O). ($(BLD)/strftime.$(O)): Remove prerequisites. === modified file 'src/s/ms-w32.h' --- src/s/ms-w32.h 2011-01-29 12:36:11 +0000 +++ src/s/ms-w32.h 2011-01-31 20:00:40 +0000 @@ -159,7 +159,6 @@ #undef HAVE_SETPGID #undef HAVE_GETCWD #define HAVE_SHUTDOWN 1 -#define HAVE_STRFTIME 1 #define LOCALTIME_CACHE #define HAVE_INET_SOCKETS 1 ------------------------------------------------------------ revno: 103055 committer: Eli Zaretskii branch nick: trunk timestamp: Mon 2011-01-31 21:36:08 +0200 message: Fix the MS-Windows build broken by r103037 and r103047. lib/makefile.w32-in (GNULIBOBJS): Add $(BLD)/strftime.$(O) and $(BLD)/time_r.$(O). ($(BLD)/dtoastr.$(O)): Depend on $(EMACS_ROOT)/src/s/ms-w32.h and $(EMACS_ROOT)/src/m/intel386.h. ($(BLD)/strftime.$(O)): ($(BLD)/time_r.$(O)): Define prerequisites. src/makefile.w32-in (OBJ2): Remove strftime.$(O). ($(BLD)/strftime.$(O)): Remove prerequisites. lib-src/makefile.w32-in (VERSION): Don't define, defined on nt/config.nt. (ECLIENT_CFLAGS): Remove -DVERSION. ($(BLD)/emacsclient.$(O)): Don't depend on makefile.w32-in. nt/config.nt (VERSION): Uncomment definition. (restrict): Define. nt/inc/stdbool.h: New file. admin/admin.el (set-version): Remove lib-src/makefile.w32-in. Add nt/config.nt. diff: === modified file 'ChangeLog' --- ChangeLog 2011-01-31 08:12:52 +0000 +++ ChangeLog 2011-01-31 19:36:08 +0000 @@ -1,3 +1,12 @@ +2011-01-31 Eli Zaretskii + + * lib/makefile.w32-in (GNULIBOBJS): Add $(BLD)/strftime.$(O) and + $(BLD)/time_r.$(O). + ($(BLD)/dtoastr.$(O)): Depend on $(EMACS_ROOT)/src/s/ms-w32.h and + $(EMACS_ROOT)/src/m/intel386.h. + ($(BLD)/strftime.$(O)): + ($(BLD)/time_r.$(O)): Define prerequisites. + 2011-01-31 Paul Eggert src/emacs.c now gets version number from configure.in === modified file 'admin/ChangeLog' --- admin/ChangeLog 2011-01-31 08:12:52 +0000 +++ admin/ChangeLog 2011-01-31 19:36:08 +0000 @@ -1,3 +1,8 @@ +2011-01-31 Eli Zaretskii + + * admin.el (set-version): Remove lib-src/makefile.w32-in. Add + nt/config.nt. + 2011-01-31 Paul Eggert src/emacs.c now gets version number from configure.in === modified file 'admin/admin.el' --- admin/admin.el 2011-01-31 08:12:52 +0000 +++ admin/admin.el 2011-01-31 19:36:08 +0000 @@ -73,8 +73,9 @@ (rx (and ".TH EMACS" (1+ not-newline) "GNU Emacs" (1+ space) (submatch (1+ (in "0-9.")))))) - (set-version-in-file root "lib-src/makefile.w32-in" version - (rx (and "VERSION" (0+ space) "=" (0+ space) + (set-version-in-file root "nt/config.nt" version + (rx (and bol "#" (0+ blank) "define" (1+ blank) + "VERSION" (1+ blank) (submatch (1+ (in "0-9.")))))) (set-version-in-file root "nt/makefile.w32-in" version (rx (and "VERSION" (0+ space) "=" (0+ space) === modified file 'lib-src/ChangeLog' --- lib-src/ChangeLog 2011-01-31 08:12:52 +0000 +++ lib-src/ChangeLog 2011-01-31 19:36:08 +0000 @@ -1,3 +1,9 @@ +2011-01-31 Eli Zaretskii + + * makefile.w32-in (VERSION): Don't define, defined on nt/config.nt. + (ECLIENT_CFLAGS): Remove -DVERSION. + ($(BLD)/emacsclient.$(O)): Don't depend on makefile.w32-in. + 2011-01-31 Paul Eggert src/emacs.c now gets version number from configure.in === modified file 'lib-src/makefile.w32-in' --- lib-src/makefile.w32-in 2011-01-29 12:36:11 +0000 +++ lib-src/makefile.w32-in 2011-01-31 19:36:08 +0000 @@ -21,8 +21,6 @@ .PHONY: $(ALL) -VERSION = 24.0.50 - LOCAL_FLAGS = -DWINDOWSNT -DDOS_NT -DSTDC_HEADERS=1 -DNO_LDAV=1 \ -DNO_ARCHIVES=1 -DHAVE_CONFIG_H=1 -I../lib \ -I../nt/inc -I../src @@ -59,7 +57,7 @@ # put wsock32.lib before $(LIBS) to ensure we don't link to ws2_32.lib $(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(MOVEMAILOBJS) $(WSOCK32) $(LIBS) -ECLIENT_CFLAGS = -DHAVE_GETCWD -DHAVE_STRERROR -DVERSION="\"$(VERSION)\"" +ECLIENT_CFLAGS = -DHAVE_GETCWD -DHAVE_STRERROR ECLIENTOBJS = $(BLD)/emacsclient.$(O) \ $(BLD)/ntlib.$(O) \ ../lib/$(BLD)/libgnu.$(A) @@ -77,9 +75,7 @@ # put wsock32.lib before $(LIBS) to ensure we don't link to ws2_32.lib $(LINK) $(LINK_OUT)$@ $(CLIENTRES) -mwindows $(LINK_FLAGS) $(ECLIENTOBJS) $(WSOCK32) $(USER32) $(COMCTL32) $(LIBS) -# emacsclient.$(O) depends on makefile.w32-in because makefile.w32-in -# can be edited to define VERSION string, which is part of ECLIENT_CFLAGS. -$(BLD)/emacsclient.$(O): emacsclient.c makefile.w32-in +$(BLD)/emacsclient.$(O): emacsclient.c $(CC) $(CFLAGS) $(ECLIENT_CFLAGS) $(CC_OUT)$@ emacsclient.c ETAGSOBJ = $(BLD)/etags.$(O) \ === modified file 'lib/makefile.w32-in' --- lib/makefile.w32-in 2011-01-29 12:36:11 +0000 +++ lib/makefile.w32-in 2011-01-31 19:36:08 +0000 @@ -23,7 +23,11 @@ LOCAL_FLAGS = -DHAVE_CONFIG_H=1 -I. -I../nt/inc -I../src LIBS = -GNULIBOBJS = $(BLD)/dtoastr.$(O) $(BLD)/getopt.$(O) $(BLD)/getopt1.$(O) +GNULIBOBJS = $(BLD)/dtoastr.$(O) \ + $(BLD)/getopt.$(O) \ + $(BLD)/getopt1.$(O) \ + $(BLD)/strftime.$(O) \ + $(BLD)/time_r.$(O) # # Build the library @@ -54,6 +58,8 @@ $(SRC)/ftoastr.c \ $(SRC)/ftoastr.h \ $(SRC)/intprops.h \ + $(EMACS_ROOT)/src/s/ms-w32.h \ + $(EMACS_ROOT)/src/m/intel386.h \ $(EMACS_ROOT)/src/config.h $(BLD)/getopt.$(O) : \ @@ -72,10 +78,26 @@ $(EMACS_ROOT)/src/m/intel386.h \ $(EMACS_ROOT)/src/config.h +$(BLD)/strftime.$(O) : \ + $(SRC)/strftime.c \ + $(SRC)/strftime.h \ + $(EMACS_ROOT)/nt/inc/stdbool.h \ + $(EMACS_ROOT)/src/s/ms-w32.h \ + $(EMACS_ROOT)/src/m/intel386.h \ + $(EMACS_ROOT)/src/config.h + +$(BLD)/time_r.$(O) : \ + $(SRC)/time_r.c \ + $(EMACS_ROOT)/nt/inc/stdbool.h \ + $(EMACS_ROOT)/src/s/ms-w32.h \ + $(EMACS_ROOT)/src/m/intel386.h \ + $(EMACS_ROOT)/src/config.h + # The following dependencies are for supporting parallel builds, where # we must make sure $(BLD) exists before any compilation starts. # $(BLD)/dtoastr.$(O) $(BLD)/getopt.$(O) $(BLD)/getopt1.$(O): stamp_BLD +$(BLD)/strftime.$(O) $(BLD)/time_r.$(O): stamp_BLD # # Headers we would preprocess if we could. === modified file 'nt/ChangeLog' --- nt/ChangeLog 2011-01-29 13:41:34 +0000 +++ nt/ChangeLog 2011-01-31 19:36:08 +0000 @@ -1,3 +1,7 @@ +2011-01-31 Eli Zaretskii + + * inc/stdbool.h: New file. + 2011-01-29 Eli Zaretskii * makefile.w32-in (all-other-dirs-nmake, all-other-dirs-gmake) === modified file 'nt/config.nt' --- nt/config.nt 2011-01-29 12:36:11 +0000 +++ nt/config.nt 2011-01-31 19:36:08 +0000 @@ -305,13 +305,8 @@ /* Name of package */ #define PACKAGE "emacs" -/* FIXME: This is defined by the various makefile.w32-in files for - now. Revisit if/when VERSION from config.h is used by any - Makefile.in files. */ -#if 0 /* Version number of package */ #define VERSION "24.0.50" -#endif /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ @@ -319,6 +314,15 @@ #undef inline #endif +/* Define to the equivalent of the C99 'restrict' keyword, or to + nothing if this is not supported. Do not define if restrict is + supported directly. */ +#ifdef __GNUC__ +# define restrict __restrict__ +#else +# define restrict +#endif + /* Define as a marker that can be attached to declarations that might not be used. This helps to reduce warnings, such as from GCC -Wunused-parameter. */ === added file 'nt/inc/stdbool.h' --- nt/inc/stdbool.h 1970-01-01 00:00:00 +0000 +++ nt/inc/stdbool.h 2011-01-31 19:36:08 +0000 @@ -0,0 +1,16 @@ +#ifndef _NT_STDBOOL_H_ +#define _NT_STDBOOL_H_ +/* + * stdbool.h exists in GCC, but not in MSVC. + */ + +#ifdef __GNUC__ +# include_next +#else +# define _Bool signed char +# define bool _Bool +# define false 0 +# define true 1 +#endif + +#endif /* _NT_STDBOOL_H_ */ === modified file 'src/ChangeLog' --- src/ChangeLog 2011-01-31 08:15:13 +0000 +++ src/ChangeLog 2011-01-31 19:36:08 +0000 @@ -1,3 +1,8 @@ +2011-01-31 Eli Zaretskii + + * makefile.w32-in (OBJ2): Remove strftime.$(O). + ($(BLD)/strftime.$(O)): Remove prerequisites. + 2011-01-31 Paul Eggert src/emacs.c now gets version number from configure.in === modified file 'src/makefile.w32-in' --- src/makefile.w32-in 2011-01-29 12:36:11 +0000 +++ src/makefile.w32-in 2011-01-31 19:36:08 +0000 @@ -113,7 +113,6 @@ $(BLD)/textprop.$(O) \ $(BLD)/vm-limit.$(O) \ $(BLD)/region-cache.$(O) \ - $(BLD)/strftime.$(O) \ $(BLD)/bidi.$(O) \ $(BLD)/charset.$(O) \ $(BLD)/character.$(O) \ @@ -1363,11 +1362,6 @@ $(SRC)/systime.h \ $(SRC)/w32gui.h -$(BLD)/strftime.$(O) : \ - $(SRC)/strftime.c \ - $(CONFIG_H) \ - $(EMACS_ROOT)/nt/inc/sys/time.h - $(BLD)/syntax.$(O) : \ $(SRC)/syntax.c \ $(CONFIG_H) \ ------------------------------------------------------------ revno: 103054 committer: Stefan Monnier branch nick: trunk timestamp: Mon 2011-01-31 12:11:11 -0500 message: Fix last-minute typo in last change. diff: === modified file 'lisp/progmodes/compile.el' --- lisp/progmodes/compile.el 2011-01-31 17:09:42 +0000 +++ lisp/progmodes/compile.el 2011-01-31 17:11:11 +0000 @@ -858,8 +858,8 @@ ;; ends up having to walk very far back to find the last change. (if (and compilation--previous-directory-cache (< pos (car compilation--previous-directory-cache)) - (or (null (cdr compilation--previous-directory-cache) - (< (cdr compilation--previous-directory-cache) pos)))) + (or (null (cdr compilation--previous-directory-cache)) + (< (cdr compilation--previous-directory-cache) pos))) ;; No need to call previous-single-property-change. (cdr compilation--previous-directory-cache) ------------------------------------------------------------ revno: 103053 committer: Stefan Monnier branch nick: trunk timestamp: Mon 2011-01-31 12:09:42 -0500 message: * lisp/progmodes/compile.el (compilation--flush-directory-cache): New function, extracted from compilation--remove-properties. (compilation--remove-properties, compilation--parse-region): Use it. (compilation--previous-directory): Handle one more case. (compilation-enable-debug-messages): Remove. (compilation-parse-errors, compilation--flush-parse): Just remove the left over debug messages. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-01-31 16:49:44 +0000 +++ lisp/ChangeLog 2011-01-31 17:09:42 +0000 @@ -1,3 +1,13 @@ +2011-01-31 Stefan Monnier + + * progmodes/compile.el (compilation--flush-directory-cache): + New function, extracted from compilation--remove-properties. + (compilation--remove-properties, compilation--parse-region): Use it. + (compilation--previous-directory): Handle one more case. + (compilation-enable-debug-messages): Remove. + (compilation-parse-errors, compilation--flush-parse): Just remove the + left over debug messages. + 2011-01-31 Sam Steingold * progmodes/compile.el (compilation-enable-debug-messages): @@ -5,7 +15,6 @@ revno:103013 optional. (compilation-parse-errors, compilation--flush-parse): Use it. - 2011-01-31 Deniz Dogan * net/rcirc.el: Clean log filenames (Bug#7933). @@ -14,8 +23,8 @@ 2011-01-30 Jan Djärv - * mail/emacsbug.el (report-emacs-bug-insert-to-mailer): Check - report-emacs-bug-can-use-osx-open and use that if t. + * mail/emacsbug.el (report-emacs-bug-insert-to-mailer): + Check report-emacs-bug-can-use-osx-open and use that if t. (report-emacs-bug-can-use-osx-open): New function. (report-emacs-bug): Rename can-xdg-email to can-insert-mail. Check report-emacs-bug-can-use-osx-open also for can-insert-mail. @@ -38,8 +47,8 @@ 2011-01-29 Daiki Ueno - * epg.el (epg--status-KEYEXPIRED, epg--status-KEYREVOKED): Don't - presume KEYEXPIRED and KEYREVOKED to be a fatal error status + * epg.el (epg--status-KEYEXPIRED, epg--status-KEYREVOKED): + Don't presume KEYEXPIRED and KEYREVOKED to be a fatal error status (Bug#7931). 2011-01-29 Stefan Monnier @@ -205,8 +214,8 @@ 2011-01-27 Sam Steingold - * midnight.el (clean-buffer-list-kill-never-buffer-names): Remove - "*server*" which is never created by emacs server. + * midnight.el (clean-buffer-list-kill-never-buffer-names): + Remove "*server*" which is never created by emacs server. 2011-01-27 Deniz Dogan === modified file 'lisp/progmodes/compile.el' --- lisp/progmodes/compile.el 2011-01-31 16:49:44 +0000 +++ lisp/progmodes/compile.el 2011-01-31 17:09:42 +0000 @@ -732,9 +732,6 @@ :group 'compilation :version "22.1") -(defvar compilation-enable-debug-messages nil - "Enable debug messages while parsing the compilation buffer.") - (defun compilation-set-skip-threshold (level) "Switch the `compilation-skip-threshold' level." (interactive @@ -837,38 +834,61 @@ (:conc-name compilation--message->)) loc type end-loc) -(defvar compilation--previous-directory-cache nil) +(defvar compilation--previous-directory-cache nil + "A pair (POS . RES) caching the result of previous directory search. +Basically, this pair says that calling + (previous-single-property-change POS 'compilation-directory) +returned RES, i.e. there is no change of `compilation-directory' between +POS and RES.") (make-variable-buffer-local 'compilation--previous-directory-cache) + +(defun compilation--flush-directory-cache (start end) + (cond + ((or (not compilation--previous-directory-cache) + (<= (car compilation--previous-directory-cache) start))) + ((or (not (cdr compilation--previous-directory-cache)) + (<= (cdr compilation--previous-directory-cache) start)) + (set-marker (car compilation--previous-directory-cache) start)) + (t (setq compilation--previous-directory-cache nil)))) + (defun compilation--previous-directory (pos) "Like (previous-single-property-change POS 'compilation-directory), but faster." ;; This avoids an N² behavior when there's no/few compilation-directory ;; entries, in which case each call to previous-single-property-change ;; ends up having to walk very far back to find the last change. - (let* ((cache (and compilation--previous-directory-cache - (<= (car compilation--previous-directory-cache) pos) - (car compilation--previous-directory-cache))) - (prev - (previous-single-property-change - pos 'compilation-directory nil cache))) - (cond - ((null cache) - (setq compilation--previous-directory-cache - (cons (copy-marker pos) (copy-marker prev))) - prev) - ((eq prev cache) - (if cache - (set-marker (car compilation--previous-directory-cache) pos) + (if (and compilation--previous-directory-cache + (< pos (car compilation--previous-directory-cache)) + (or (null (cdr compilation--previous-directory-cache) + (< (cdr compilation--previous-directory-cache) pos)))) + ;; No need to call previous-single-property-change. + (cdr compilation--previous-directory-cache) + + (let* ((cache (and compilation--previous-directory-cache + (<= (car compilation--previous-directory-cache) pos) + (car compilation--previous-directory-cache))) + (prev + (previous-single-property-change + pos 'compilation-directory nil cache))) + (cond + ((null cache) (setq compilation--previous-directory-cache - (cons (copy-marker pos) nil))) - (cdr compilation--previous-directory-cache)) - (t - (if cache - (progn + (cons (copy-marker pos) (copy-marker prev))) + prev) + ((eq prev cache) + (if cache (set-marker (car compilation--previous-directory-cache) pos) - (setcdr compilation--previous-directory-cache (copy-marker prev))) - (setq compilation--previous-directory-cache - (cons (copy-marker pos) (copy-marker prev)))) - prev)))) + (setq compilation--previous-directory-cache + (cons (copy-marker pos) nil))) + (cdr compilation--previous-directory-cache)) + (t + (if cache + (progn + (set-marker (car compilation--previous-directory-cache) pos) + (setcdr compilation--previous-directory-cache + (copy-marker prev))) + (setq compilation--previous-directory-cache + (cons (copy-marker pos) (copy-marker prev)))) + prev))))) ;; Internal function for calculating the text properties of a directory ;; change message. The compilation-directory property is important, because it @@ -1099,14 +1119,6 @@ (defun compilation--remove-properties (&optional start end) (with-silent-modifications - (cond - ((or (not compilation--previous-directory-cache) - (<= (car compilation--previous-directory-cache) start))) - ((or (not (cdr compilation--previous-directory-cache)) - (<= (cdr compilation--previous-directory-cache) start)) - (set-marker (car compilation--previous-directory-cache) start)) - (t (setq compilation--previous-directory-cache nil))) - ;; When compile.el used font-lock directly, we could just remove all ;; our text-properties in one go, but now that we manually place ;; font-lock-face, we have to be careful to only remove the font-lock-face @@ -1118,6 +1130,7 @@ (let (next) (unless start (setq start (point-min))) (unless end (setq end (point-max))) + (compilation--flush-directory-cache start end) (while (progn (setq next (or (next-single-property-change @@ -1155,6 +1168,7 @@ (goto-char start) (while (re-search-forward (car compilation-directory-matcher) end t) + (compilation--flush-directory-cache (match-beginning 0) (match-end 0)) (when compilation-debug (font-lock-append-text-property (match-beginning 0) (match-end 0) @@ -1172,8 +1186,6 @@ "Parse errors between START and END. The errors recognized are the ones specified in RULES which default to `compilation-error-regexp-alist' if RULES is nil." - (when compilation-enable-debug-messages - (message "compilation-parse-errors: %S %S" start end)) (dolist (item (or rules compilation-error-regexp-alist)) (if (symbolp item) (setq item (cdr (assq item @@ -1302,8 +1314,6 @@ (defun compilation--flush-parse (start end) "Mark the region between START and END for re-parsing." - (when compilation-enable-debug-messages - (message "compilation--flush-parse: %S %S" start end)) (if (markerp compilation--parsed) (move-marker compilation--parsed (min start compilation--parsed)))) ------------------------------------------------------------ revno: 103052 committer: Stefan Monnier branch nick: trunk timestamp: Mon 2011-01-31 11:54:02 -0500 message: Replace lib/strftime.c with same file but with the old strftime.c's identity diff: === removed file 'lib/strftime.c' --- lib/strftime.c 2011-01-30 23:34:18 +0000 +++ lib/strftime.c 1970-01-01 00:00:00 +0000 @@ -1,1468 +0,0 @@ -/* Copyright (C) 1991-2001, 2003-2007, 2009-2011 Free Software Foundation, Inc. - - NOTE: The canonical source of this file is maintained with the GNU C Library. - Bugs can be reported to bug-glibc@prep.ai.mit.edu. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifdef _LIBC -# define HAVE_STRUCT_ERA_ENTRY 1 -# define HAVE_TM_GMTOFF 1 -# define HAVE_TM_ZONE 1 -# define HAVE_TZNAME 1 -# define HAVE_TZSET 1 -# include "../locale/localeinfo.h" -#else -# include -# if FPRINTFTIME -# include "ignore-value.h" -# include "fprintftime.h" -# else -# include "strftime.h" -# endif -#endif - -#include -#include - -#if HAVE_TZNAME && !HAVE_DECL_TZNAME -extern char *tzname[]; -#endif - -/* Do multibyte processing if multibytes are supported, unless - multibyte sequences are safe in formats. Multibyte sequences are - safe if they cannot contain byte sequences that look like format - conversion specifications. The multibyte encodings used by the - C library on the various platforms (UTF-8, GB2312, GBK, CP936, - GB18030, EUC-TW, BIG5, BIG5-HKSCS, CP950, EUC-JP, EUC-KR, CP949, - SHIFT_JIS, CP932, JOHAB) are safe for formats, because the byte '%' - cannot occur in a multibyte character except in the first byte. - - The DEC-HANYU encoding used on OSF/1 is not safe for formats, but - this encoding has never been seen in real-life use, so we ignore - it. */ -#if !(defined __osf__ && 0) -# define MULTIBYTE_IS_FORMAT_SAFE 1 -#endif -#define DO_MULTIBYTE (! MULTIBYTE_IS_FORMAT_SAFE) - -#if DO_MULTIBYTE -# include - static const mbstate_t mbstate_zero; -#endif - -#include -#include -#include -#include -#include - -#ifdef COMPILE_WIDE -# include -# define CHAR_T wchar_t -# define UCHAR_T unsigned int -# define L_(Str) L##Str -# define NLW(Sym) _NL_W##Sym - -# define MEMCPY(d, s, n) __wmemcpy (d, s, n) -# define STRLEN(s) __wcslen (s) - -#else -# define CHAR_T char -# define UCHAR_T unsigned char -# define L_(Str) Str -# define NLW(Sym) Sym - -# define MEMCPY(d, s, n) memcpy (d, s, n) -# define STRLEN(s) strlen (s) - -#endif - -/* Shift A right by B bits portably, by dividing A by 2**B and - truncating towards minus infinity. A and B should be free of side - effects, and B should be in the range 0 <= B <= INT_BITS - 2, where - INT_BITS is the number of useful bits in an int. GNU code can - assume that INT_BITS is at least 32. - - ISO C99 says that A >> B is implementation-defined if A < 0. Some - implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift - right in the usual way when A < 0, so SHR falls back on division if - ordinary A >> B doesn't seem to be the usual signed shift. */ -#define SHR(a, b) \ - (-1 >> 1 == -1 \ - ? (a) >> (b) \ - : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0)) - -/* Bound on length of the string representing an integer type or expression T. - Subtract 1 for the sign bit if t is signed; log10 (2.0) < 146/485; - add 1 for integer division truncation; add 1 more for a minus sign - if needed. */ -#define INT_STRLEN_BOUND(t) \ - ((sizeof (t) * CHAR_BIT - 1) * 146 / 485 + 2) - -#define TM_YEAR_BASE 1900 - -#ifndef __isleap -/* Nonzero if YEAR is a leap year (every 4 years, - except every 100th isn't, and every 400th is). */ -# define __isleap(year) \ - ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) -#endif - - -#ifdef _LIBC -# define tzname __tzname -# define tzset __tzset -#endif - -#if !HAVE_TM_GMTOFF -/* Portable standalone applications should supply a "time.h" that - declares a POSIX-compliant localtime_r, for the benefit of older - implementations that lack localtime_r or have a nonstandard one. - See the gnulib time_r module for one way to implement this. */ -# undef __gmtime_r -# undef __localtime_r -# define __gmtime_r gmtime_r -# define __localtime_r localtime_r -#endif - - -#ifndef FPRINTFTIME -# define FPRINTFTIME 0 -#endif - -#if FPRINTFTIME -# define STREAM_OR_CHAR_T FILE -# define STRFTIME_ARG(x) /* empty */ -#else -# define STREAM_OR_CHAR_T CHAR_T -# define STRFTIME_ARG(x) x, -#endif - -#if FPRINTFTIME -# define memset_byte(P, Len, Byte) \ - do { size_t _i; for (_i = 0; _i < Len; _i++) fputc (Byte, P); } while (0) -# define memset_space(P, Len) memset_byte (P, Len, ' ') -# define memset_zero(P, Len) memset_byte (P, Len, '0') -#elif defined COMPILE_WIDE -# define memset_space(P, Len) (wmemset (P, L' ', Len), (P) += (Len)) -# define memset_zero(P, Len) (wmemset (P, L'0', Len), (P) += (Len)) -#else -# define memset_space(P, Len) (memset (P, ' ', Len), (P) += (Len)) -# define memset_zero(P, Len) (memset (P, '0', Len), (P) += (Len)) -#endif - -#if FPRINTFTIME -# define advance(P, N) -#else -# define advance(P, N) ((P) += (N)) -#endif - -#define add(n, f) \ - do \ - { \ - int _n = (n); \ - int _delta = width - _n; \ - int _incr = _n + (_delta > 0 ? _delta : 0); \ - if ((size_t) _incr >= maxsize - i) \ - return 0; \ - if (p) \ - { \ - if (digits == 0 && _delta > 0) \ - { \ - if (pad == L_('0')) \ - memset_zero (p, _delta); \ - else \ - memset_space (p, _delta); \ - } \ - f; \ - advance (p, _n); \ - } \ - i += _incr; \ - } while (0) - -#if FPRINTFTIME -# define add1(C) add (1, fputc (C, p)) -#else -# define add1(C) add (1, *p = C) -#endif - -#if FPRINTFTIME -# define cpy(n, s) \ - add ((n), \ - do \ - { \ - if (to_lowcase) \ - fwrite_lowcase (p, (s), _n); \ - else if (to_uppcase) \ - fwrite_uppcase (p, (s), _n); \ - else \ - { \ - /* We are ignoring the value of fwrite here, in spite of the \ - fact that technically, that may not be valid: the fwrite \ - specification in POSIX 2008 defers to that of fputc, which \ - is intended to be consistent with the one from ISO C, \ - which permits failure due to ENOMEM *without* setting the \ - stream's error indicator. */ \ - ignore_value (fwrite ((s), _n, 1, p)); \ - } \ - } \ - while (0) \ - ) -#else -# define cpy(n, s) \ - add ((n), \ - if (to_lowcase) \ - memcpy_lowcase (p, (s), _n LOCALE_ARG); \ - else if (to_uppcase) \ - memcpy_uppcase (p, (s), _n LOCALE_ARG); \ - else \ - MEMCPY ((void *) p, (void const *) (s), _n)) -#endif - -#ifdef COMPILE_WIDE -# ifndef USE_IN_EXTENDED_LOCALE_MODEL -# undef __mbsrtowcs_l -# define __mbsrtowcs_l(d, s, l, st, loc) __mbsrtowcs (d, s, l, st) -# endif -# define widen(os, ws, l) \ - { \ - mbstate_t __st; \ - const char *__s = os; \ - memset (&__st, '\0', sizeof (__st)); \ - l = __mbsrtowcs_l (NULL, &__s, 0, &__st, loc); \ - ws = (wchar_t *) alloca ((l + 1) * sizeof (wchar_t)); \ - (void) __mbsrtowcs_l (ws, &__s, l, &__st, loc); \ - } -#endif - - -#if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL -/* We use this code also for the extended locale handling where the - function gets as an additional argument the locale which has to be - used. To access the values we have to redefine the _NL_CURRENT - macro. */ -# define strftime __strftime_l -# define wcsftime __wcsftime_l -# undef _NL_CURRENT -# define _NL_CURRENT(category, item) \ - (current->values[_NL_ITEM_INDEX (item)].string) -# define LOCALE_ARG , loc -# define LOCALE_PARAM_PROTO , __locale_t loc -# define HELPER_LOCALE_ARG , current -#else -# define LOCALE_PARAM_PROTO -# define LOCALE_ARG -# ifdef _LIBC -# define HELPER_LOCALE_ARG , _NL_CURRENT_DATA (LC_TIME) -# else -# define HELPER_LOCALE_ARG -# endif -#endif - -#ifdef COMPILE_WIDE -# ifdef USE_IN_EXTENDED_LOCALE_MODEL -# define TOUPPER(Ch, L) __towupper_l (Ch, L) -# define TOLOWER(Ch, L) __towlower_l (Ch, L) -# else -# define TOUPPER(Ch, L) towupper (Ch) -# define TOLOWER(Ch, L) towlower (Ch) -# endif -#else -# ifdef USE_IN_EXTENDED_LOCALE_MODEL -# define TOUPPER(Ch, L) __toupper_l (Ch, L) -# define TOLOWER(Ch, L) __tolower_l (Ch, L) -# else -# define TOUPPER(Ch, L) toupper (Ch) -# define TOLOWER(Ch, L) tolower (Ch) -# endif -#endif -/* We don't use `isdigit' here since the locale dependent - interpretation is not what we want here. We only need to accept - the arabic digits in the ASCII range. One day there is perhaps a - more reliable way to accept other sets of digits. */ -#define ISDIGIT(Ch) ((unsigned int) (Ch) - L_('0') <= 9) - -#if FPRINTFTIME -static void -fwrite_lowcase (FILE *fp, const CHAR_T *src, size_t len) -{ - while (len-- > 0) - { - fputc (TOLOWER ((UCHAR_T) *src, loc), fp); - ++src; - } -} - -static void -fwrite_uppcase (FILE *fp, const CHAR_T *src, size_t len) -{ - while (len-- > 0) - { - fputc (TOUPPER ((UCHAR_T) *src, loc), fp); - ++src; - } -} -#else -static CHAR_T * -memcpy_lowcase (CHAR_T *dest, const CHAR_T *src, - size_t len LOCALE_PARAM_PROTO) -{ - while (len-- > 0) - dest[len] = TOLOWER ((UCHAR_T) src[len], loc); - return dest; -} - -static CHAR_T * -memcpy_uppcase (CHAR_T *dest, const CHAR_T *src, - size_t len LOCALE_PARAM_PROTO) -{ - while (len-- > 0) - dest[len] = TOUPPER ((UCHAR_T) src[len], loc); - return dest; -} -#endif - - -#if ! HAVE_TM_GMTOFF -/* Yield the difference between *A and *B, - measured in seconds, ignoring leap seconds. */ -# define tm_diff ftime_tm_diff -static int -tm_diff (const struct tm *a, const struct tm *b) -{ - /* Compute intervening leap days correctly even if year is negative. - Take care to avoid int overflow in leap day calculations, - but it's OK to assume that A and B are close to each other. */ - int a4 = SHR (a->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (a->tm_year & 3); - int b4 = SHR (b->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (b->tm_year & 3); - int a100 = a4 / 25 - (a4 % 25 < 0); - int b100 = b4 / 25 - (b4 % 25 < 0); - int a400 = SHR (a100, 2); - int b400 = SHR (b100, 2); - int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); - int years = a->tm_year - b->tm_year; - int days = (365 * years + intervening_leap_days - + (a->tm_yday - b->tm_yday)); - return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour)) - + (a->tm_min - b->tm_min)) - + (a->tm_sec - b->tm_sec)); -} -#endif /* ! HAVE_TM_GMTOFF */ - - - -/* The number of days from the first day of the first ISO week of this - year to the year day YDAY with week day WDAY. ISO weeks start on - Monday; the first ISO week has the year's first Thursday. YDAY may - be as small as YDAY_MINIMUM. */ -#define ISO_WEEK_START_WDAY 1 /* Monday */ -#define ISO_WEEK1_WDAY 4 /* Thursday */ -#define YDAY_MINIMUM (-366) -#ifdef __GNUC__ -__inline__ -#endif -static int -iso_week_days (int yday, int wday) -{ - /* Add enough to the first operand of % to make it nonnegative. */ - int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7; - return (yday - - (yday - wday + ISO_WEEK1_WDAY + big_enough_multiple_of_7) % 7 - + ISO_WEEK1_WDAY - ISO_WEEK_START_WDAY); -} - - -/* When compiling this file, GNU applications can #define my_strftime - to a symbol (typically nstrftime) to get an extended strftime with - extra arguments UT and NS. Emacs is a special case for now, but - this Emacs-specific code can be removed once Emacs's config.h - defines my_strftime. */ -#if defined emacs && !defined my_strftime -# define my_strftime nstrftime -#endif - -#if FPRINTFTIME -# undef my_strftime -# define my_strftime fprintftime -#endif - -#ifdef my_strftime -# define extra_args , ut, ns -# define extra_args_spec , int ut, int ns -#else -# if defined COMPILE_WIDE -# define my_strftime wcsftime -# define nl_get_alt_digit _nl_get_walt_digit -# else -# define my_strftime strftime -# define nl_get_alt_digit _nl_get_alt_digit -# endif -# define extra_args -# define extra_args_spec -/* We don't have this information in general. */ -# define ut 0 -# define ns 0 -#endif - - -/* Just like my_strftime, below, but with one more parameter, UPCASE, - to indicate that the result should be converted to upper case. */ -static size_t -strftime_case_ (bool upcase, STREAM_OR_CHAR_T *s, - STRFTIME_ARG (size_t maxsize) - const CHAR_T *format, - const struct tm *tp extra_args_spec LOCALE_PARAM_PROTO) -{ -#if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL - struct locale_data *const current = loc->__locales[LC_TIME]; -#endif -#if FPRINTFTIME - size_t maxsize = (size_t) -1; -#endif - - int hour12 = tp->tm_hour; -#ifdef _NL_CURRENT - /* We cannot make the following values variables since we must delay - the evaluation of these values until really needed since some - expressions might not be valid in every situation. The `struct tm' - might be generated by a strptime() call that initialized - only a few elements. Dereference the pointers only if the format - requires this. Then it is ok to fail if the pointers are invalid. */ -# define a_wkday \ - ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ABDAY_1) + tp->tm_wday)) -# define f_wkday \ - ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(DAY_1) + tp->tm_wday)) -# define a_month \ - ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ABMON_1) + tp->tm_mon)) -# define f_month \ - ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(MON_1) + tp->tm_mon)) -# define ampm \ - ((const CHAR_T *) _NL_CURRENT (LC_TIME, tp->tm_hour > 11 \ - ? NLW(PM_STR) : NLW(AM_STR))) - -# define aw_len STRLEN (a_wkday) -# define am_len STRLEN (a_month) -# define ap_len STRLEN (ampm) -#endif - const char *zone; - size_t i = 0; - STREAM_OR_CHAR_T *p = s; - const CHAR_T *f; -#if DO_MULTIBYTE && !defined COMPILE_WIDE - const char *format_end = NULL; -#endif - -#if ! defined _LIBC && ! HAVE_RUN_TZSET_TEST - /* Solaris 2.5.x and 2.6 tzset sometimes modify the storage returned - by localtime. On such systems, we must either use the tzset and - localtime wrappers to work around the bug (which sets - HAVE_RUN_TZSET_TEST) or make a copy of the structure. */ - struct tm copy = *tp; - tp = © -#endif - - zone = NULL; -#if HAVE_TM_ZONE - /* The POSIX test suite assumes that setting - the environment variable TZ to a new value before calling strftime() - will influence the result (the %Z format) even if the information in - TP is computed with a totally different time zone. - This is bogus: though POSIX allows bad behavior like this, - POSIX does not require it. Do the right thing instead. */ - zone = (const char *) tp->tm_zone; -#endif -#if HAVE_TZNAME - if (ut) - { - if (! (zone && *zone)) - zone = "GMT"; - } - else - { - /* POSIX.1 requires that local time zone information be used as - though strftime called tzset. */ -# if HAVE_TZSET - tzset (); -# endif - } -#endif - - if (hour12 > 12) - hour12 -= 12; - else - if (hour12 == 0) - hour12 = 12; - - for (f = format; *f != '\0'; ++f) - { - int pad = 0; /* Padding for number ('-', '_', or 0). */ - int modifier; /* Field modifier ('E', 'O', or 0). */ - int digits = 0; /* Max digits for numeric format. */ - int number_value; /* Numeric value to be printed. */ - unsigned int u_number_value; /* (unsigned int) number_value. */ - bool negative_number; /* The number is negative. */ - bool always_output_a_sign; /* +/- should always be output. */ - int tz_colon_mask; /* Bitmask of where ':' should appear. */ - const CHAR_T *subfmt; - CHAR_T sign_char; - CHAR_T *bufp; - CHAR_T buf[1 - + 2 /* for the two colons in a %::z or %:::z time zone */ - + (sizeof (int) < sizeof (time_t) - ? INT_STRLEN_BOUND (time_t) - : INT_STRLEN_BOUND (int))]; - int width = -1; - bool to_lowcase = false; - bool to_uppcase = upcase; - size_t colons; - bool change_case = false; - int format_char; - -#if DO_MULTIBYTE && !defined COMPILE_WIDE - switch (*f) - { - case L_('%'): - break; - - case L_('\b'): case L_('\t'): case L_('\n'): - case L_('\v'): case L_('\f'): case L_('\r'): - case L_(' '): case L_('!'): case L_('"'): case L_('#'): case L_('&'): - case L_('\''): case L_('('): case L_(')'): case L_('*'): case L_('+'): - case L_(','): case L_('-'): case L_('.'): case L_('/'): case L_('0'): - case L_('1'): case L_('2'): case L_('3'): case L_('4'): case L_('5'): - case L_('6'): case L_('7'): case L_('8'): case L_('9'): case L_(':'): - case L_(';'): case L_('<'): case L_('='): case L_('>'): case L_('?'): - case L_('A'): case L_('B'): case L_('C'): case L_('D'): case L_('E'): - case L_('F'): case L_('G'): case L_('H'): case L_('I'): case L_('J'): - case L_('K'): case L_('L'): case L_('M'): case L_('N'): case L_('O'): - case L_('P'): case L_('Q'): case L_('R'): case L_('S'): case L_('T'): - case L_('U'): case L_('V'): case L_('W'): case L_('X'): case L_('Y'): - case L_('Z'): case L_('['): case L_('\\'): case L_(']'): case L_('^'): - case L_('_'): case L_('a'): case L_('b'): case L_('c'): case L_('d'): - case L_('e'): case L_('f'): case L_('g'): case L_('h'): case L_('i'): - case L_('j'): case L_('k'): case L_('l'): case L_('m'): case L_('n'): - case L_('o'): case L_('p'): case L_('q'): case L_('r'): case L_('s'): - case L_('t'): case L_('u'): case L_('v'): case L_('w'): case L_('x'): - case L_('y'): case L_('z'): case L_('{'): case L_('|'): case L_('}'): - case L_('~'): - /* The C Standard requires these 98 characters (plus '%') to - be in the basic execution character set. None of these - characters can start a multibyte sequence, so they need - not be analyzed further. */ - add1 (*f); - continue; - - default: - /* Copy this multibyte sequence until we reach its end, find - an error, or come back to the initial shift state. */ - { - mbstate_t mbstate = mbstate_zero; - size_t len = 0; - size_t fsize; - - if (! format_end) - format_end = f + strlen (f) + 1; - fsize = format_end - f; - - do - { - size_t bytes = mbrlen (f + len, fsize - len, &mbstate); - - if (bytes == 0) - break; - - if (bytes == (size_t) -2) - { - len += strlen (f + len); - break; - } - - if (bytes == (size_t) -1) - { - len++; - break; - } - - len += bytes; - } - while (! mbsinit (&mbstate)); - - cpy (len, f); - f += len - 1; - continue; - } - } - -#else /* ! DO_MULTIBYTE */ - - /* Either multibyte encodings are not supported, they are - safe for formats, so any non-'%' byte can be copied through, - or this is the wide character version. */ - if (*f != L_('%')) - { - add1 (*f); - continue; - } - -#endif /* ! DO_MULTIBYTE */ - - /* Check for flags that can modify a format. */ - while (1) - { - switch (*++f) - { - /* This influences the number formats. */ - case L_('_'): - case L_('-'): - case L_('0'): - pad = *f; - continue; - - /* This changes textual output. */ - case L_('^'): - to_uppcase = true; - continue; - case L_('#'): - change_case = true; - continue; - - default: - break; - } - break; - } - - /* As a GNU extension we allow to specify the field width. */ - if (ISDIGIT (*f)) - { - width = 0; - do - { - if (width > INT_MAX / 10 - || (width == INT_MAX / 10 && *f - L_('0') > INT_MAX % 10)) - /* Avoid overflow. */ - width = INT_MAX; - else - { - width *= 10; - width += *f - L_('0'); - } - ++f; - } - while (ISDIGIT (*f)); - } - - /* Check for modifiers. */ - switch (*f) - { - case L_('E'): - case L_('O'): - modifier = *f++; - break; - - default: - modifier = 0; - break; - } - - /* Now do the specified format. */ - format_char = *f; - switch (format_char) - { -#define DO_NUMBER(d, v) \ - digits = d; \ - number_value = v; goto do_number -#define DO_SIGNED_NUMBER(d, negative, v) \ - digits = d; \ - negative_number = negative; \ - u_number_value = v; goto do_signed_number - - /* The mask is not what you might think. - When the ordinal i'th bit is set, insert a colon - before the i'th digit of the time zone representation. */ -#define DO_TZ_OFFSET(d, negative, mask, v) \ - digits = d; \ - negative_number = negative; \ - tz_colon_mask = mask; \ - u_number_value = v; goto do_tz_offset -#define DO_NUMBER_SPACEPAD(d, v) \ - digits = d; \ - number_value = v; goto do_number_spacepad - - case L_('%'): - if (modifier != 0) - goto bad_format; - add1 (*f); - break; - - case L_('a'): - if (modifier != 0) - goto bad_format; - if (change_case) - { - to_uppcase = true; - to_lowcase = false; - } -#ifdef _NL_CURRENT - cpy (aw_len, a_wkday); - break; -#else - goto underlying_strftime; -#endif - - case 'A': - if (modifier != 0) - goto bad_format; - if (change_case) - { - to_uppcase = true; - to_lowcase = false; - } -#ifdef _NL_CURRENT - cpy (STRLEN (f_wkday), f_wkday); - break; -#else - goto underlying_strftime; -#endif - - case L_('b'): - case L_('h'): - if (change_case) - { - to_uppcase = true; - to_lowcase = false; - } - if (modifier != 0) - goto bad_format; -#ifdef _NL_CURRENT - cpy (am_len, a_month); - break; -#else - goto underlying_strftime; -#endif - - case L_('B'): - if (modifier != 0) - goto bad_format; - if (change_case) - { - to_uppcase = true; - to_lowcase = false; - } -#ifdef _NL_CURRENT - cpy (STRLEN (f_month), f_month); - break; -#else - goto underlying_strftime; -#endif - - case L_('c'): - if (modifier == L_('O')) - goto bad_format; -#ifdef _NL_CURRENT - if (! (modifier == 'E' - && (*(subfmt = - (const CHAR_T *) _NL_CURRENT (LC_TIME, - NLW(ERA_D_T_FMT))) - != '\0'))) - subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_T_FMT)); -#else - goto underlying_strftime; -#endif - - subformat: - { - size_t len = strftime_case_ (to_uppcase, - NULL, STRFTIME_ARG ((size_t) -1) - subfmt, - tp extra_args LOCALE_ARG); - add (len, strftime_case_ (to_uppcase, p, - STRFTIME_ARG (maxsize - i) - subfmt, - tp extra_args LOCALE_ARG)); - } - break; - -#if !(defined _NL_CURRENT && HAVE_STRUCT_ERA_ENTRY) - underlying_strftime: - { - /* The relevant information is available only via the - underlying strftime implementation, so use that. */ - char ufmt[5]; - char *u = ufmt; - char ubuf[1024]; /* enough for any single format in practice */ - size_t len; - /* Make sure we're calling the actual underlying strftime. - In some cases, config.h contains something like - "#define strftime rpl_strftime". */ -# ifdef strftime -# undef strftime - size_t strftime (); -# endif - - /* The space helps distinguish strftime failure from empty - output. */ - *u++ = ' '; - *u++ = '%'; - if (modifier != 0) - *u++ = modifier; - *u++ = format_char; - *u = '\0'; - len = strftime (ubuf, sizeof ubuf, ufmt, tp); - if (len != 0) - cpy (len - 1, ubuf + 1); - } - break; -#endif - - case L_('C'): - if (modifier == L_('O')) - goto bad_format; - if (modifier == L_('E')) - { -#if HAVE_STRUCT_ERA_ENTRY - struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); - if (era) - { -# ifdef COMPILE_WIDE - size_t len = __wcslen (era->era_wname); - cpy (len, era->era_wname); -# else - size_t len = strlen (era->era_name); - cpy (len, era->era_name); -# endif - break; - } -#else - goto underlying_strftime; -#endif - } - - { - int century = tp->tm_year / 100 + TM_YEAR_BASE / 100; - century -= tp->tm_year % 100 < 0 && 0 < century; - DO_SIGNED_NUMBER (2, tp->tm_year < - TM_YEAR_BASE, century); - } - - case L_('x'): - if (modifier == L_('O')) - goto bad_format; -#ifdef _NL_CURRENT - if (! (modifier == L_('E') - && (*(subfmt = - (const CHAR_T *)_NL_CURRENT (LC_TIME, NLW(ERA_D_FMT))) - != L_('\0')))) - subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_FMT)); - goto subformat; -#else - goto underlying_strftime; -#endif - case L_('D'): - if (modifier != 0) - goto bad_format; - subfmt = L_("%m/%d/%y"); - goto subformat; - - case L_('d'): - if (modifier == L_('E')) - goto bad_format; - - DO_NUMBER (2, tp->tm_mday); - - case L_('e'): - if (modifier == L_('E')) - goto bad_format; - - DO_NUMBER_SPACEPAD (2, tp->tm_mday); - - /* All numeric formats set DIGITS and NUMBER_VALUE (or U_NUMBER_VALUE) - and then jump to one of these labels. */ - - do_tz_offset: - always_output_a_sign = true; - goto do_number_body; - - do_number_spacepad: - /* Force `_' flag unless overridden by `0' or `-' flag. */ - if (pad != L_('0') && pad != L_('-')) - pad = L_('_'); - - do_number: - /* Format NUMBER_VALUE according to the MODIFIER flag. */ - negative_number = number_value < 0; - u_number_value = number_value; - - do_signed_number: - always_output_a_sign = false; - tz_colon_mask = 0; - - do_number_body: - /* Format U_NUMBER_VALUE according to the MODIFIER flag. - NEGATIVE_NUMBER is nonzero if the original number was - negative; in this case it was converted directly to - unsigned int (i.e., modulo (UINT_MAX + 1)) without - negating it. */ - if (modifier == L_('O') && !negative_number) - { -#ifdef _NL_CURRENT - /* Get the locale specific alternate representation of - the number. If none exist NULL is returned. */ - const CHAR_T *cp = nl_get_alt_digit (u_number_value - HELPER_LOCALE_ARG); - - if (cp != NULL) - { - size_t digitlen = STRLEN (cp); - if (digitlen != 0) - { - cpy (digitlen, cp); - break; - } - } -#else - goto underlying_strftime; -#endif - } - - bufp = buf + sizeof (buf) / sizeof (buf[0]); - - if (negative_number) - u_number_value = - u_number_value; - - do - { - if (tz_colon_mask & 1) - *--bufp = ':'; - tz_colon_mask >>= 1; - *--bufp = u_number_value % 10 + L_('0'); - u_number_value /= 10; - } - while (u_number_value != 0 || tz_colon_mask != 0); - - do_number_sign_and_padding: - if (digits < width) - digits = width; - - sign_char = (negative_number ? L_('-') - : always_output_a_sign ? L_('+') - : 0); - - if (pad == L_('-')) - { - if (sign_char) - add1 (sign_char); - } - else - { - int padding = digits - (buf + (sizeof (buf) / sizeof (buf[0])) - - bufp) - !!sign_char; - - if (padding > 0) - { - if (pad == L_('_')) - { - if ((size_t) padding >= maxsize - i) - return 0; - - if (p) - memset_space (p, padding); - i += padding; - width = width > padding ? width - padding : 0; - if (sign_char) - add1 (sign_char); - } - else - { - if ((size_t) digits >= maxsize - i) - return 0; - - if (sign_char) - add1 (sign_char); - - if (p) - memset_zero (p, padding); - i += padding; - width = 0; - } - } - else - { - if (sign_char) - add1 (sign_char); - } - } - - cpy (buf + sizeof (buf) / sizeof (buf[0]) - bufp, bufp); - break; - - case L_('F'): - if (modifier != 0) - goto bad_format; - subfmt = L_("%Y-%m-%d"); - goto subformat; - - case L_('H'): - if (modifier == L_('E')) - goto bad_format; - - DO_NUMBER (2, tp->tm_hour); - - case L_('I'): - if (modifier == L_('E')) - goto bad_format; - - DO_NUMBER (2, hour12); - - case L_('k'): /* GNU extension. */ - if (modifier == L_('E')) - goto bad_format; - - DO_NUMBER_SPACEPAD (2, tp->tm_hour); - - case L_('l'): /* GNU extension. */ - if (modifier == L_('E')) - goto bad_format; - - DO_NUMBER_SPACEPAD (2, hour12); - - case L_('j'): - if (modifier == L_('E')) - goto bad_format; - - DO_SIGNED_NUMBER (3, tp->tm_yday < -1, tp->tm_yday + 1U); - - case L_('M'): - if (modifier == L_('E')) - goto bad_format; - - DO_NUMBER (2, tp->tm_min); - - case L_('m'): - if (modifier == L_('E')) - goto bad_format; - - DO_SIGNED_NUMBER (2, tp->tm_mon < -1, tp->tm_mon + 1U); - -#ifndef _LIBC - case L_('N'): /* GNU extension. */ - if (modifier == L_('E')) - goto bad_format; - - number_value = ns; - if (width == -1) - width = 9; - else - { - /* Take an explicit width less than 9 as a precision. */ - int j; - for (j = width; j < 9; j++) - number_value /= 10; - } - - DO_NUMBER (width, number_value); -#endif - - case L_('n'): - add1 (L_('\n')); - break; - - case L_('P'): - to_lowcase = true; -#ifndef _NL_CURRENT - format_char = L_('p'); -#endif - /* FALLTHROUGH */ - - case L_('p'): - if (change_case) - { - to_uppcase = false; - to_lowcase = true; - } -#ifdef _NL_CURRENT - cpy (ap_len, ampm); - break; -#else - goto underlying_strftime; -#endif - - case L_('R'): - subfmt = L_("%H:%M"); - goto subformat; - - case L_('r'): -#ifdef _NL_CURRENT - if (*(subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, - NLW(T_FMT_AMPM))) - == L_('\0')) - subfmt = L_("%I:%M:%S %p"); - goto subformat; -#else - goto underlying_strftime; -#endif - - case L_('S'): - if (modifier == L_('E')) - goto bad_format; - - DO_NUMBER (2, tp->tm_sec); - - case L_('s'): /* GNU extension. */ - { - struct tm ltm; - time_t t; - - ltm = *tp; - t = mktime (<m); - - /* Generate string value for T using time_t arithmetic; - this works even if sizeof (long) < sizeof (time_t). */ - - bufp = buf + sizeof (buf) / sizeof (buf[0]); - negative_number = t < 0; - - do - { - int d = t % 10; - t /= 10; - *--bufp = (negative_number ? -d : d) + L_('0'); - } - while (t != 0); - - digits = 1; - always_output_a_sign = false; - goto do_number_sign_and_padding; - } - - case L_('X'): - if (modifier == L_('O')) - goto bad_format; -#ifdef _NL_CURRENT - if (! (modifier == L_('E') - && (*(subfmt = - (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ERA_T_FMT))) - != L_('\0')))) - subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(T_FMT)); - goto subformat; -#else - goto underlying_strftime; -#endif - case L_('T'): - subfmt = L_("%H:%M:%S"); - goto subformat; - - case L_('t'): - add1 (L_('\t')); - break; - - case L_('u'): - DO_NUMBER (1, (tp->tm_wday - 1 + 7) % 7 + 1); - - case L_('U'): - if (modifier == L_('E')) - goto bad_format; - - DO_NUMBER (2, (tp->tm_yday - tp->tm_wday + 7) / 7); - - case L_('V'): - case L_('g'): - case L_('G'): - if (modifier == L_('E')) - goto bad_format; - { - /* YEAR is a leap year if and only if (tp->tm_year + TM_YEAR_BASE) - is a leap year, except that YEAR and YEAR - 1 both work - correctly even when (tp->tm_year + TM_YEAR_BASE) would - overflow. */ - int year = (tp->tm_year - + (tp->tm_year < 0 - ? TM_YEAR_BASE % 400 - : TM_YEAR_BASE % 400 - 400)); - int year_adjust = 0; - int days = iso_week_days (tp->tm_yday, tp->tm_wday); - - if (days < 0) - { - /* This ISO week belongs to the previous year. */ - year_adjust = -1; - days = iso_week_days (tp->tm_yday + (365 + __isleap (year - 1)), - tp->tm_wday); - } - else - { - int d = iso_week_days (tp->tm_yday - (365 + __isleap (year)), - tp->tm_wday); - if (0 <= d) - { - /* This ISO week belongs to the next year. */ - year_adjust = 1; - days = d; - } - } - - switch (*f) - { - case L_('g'): - { - int yy = (tp->tm_year % 100 + year_adjust) % 100; - DO_NUMBER (2, (0 <= yy - ? yy - : tp->tm_year < -TM_YEAR_BASE - year_adjust - ? -yy - : yy + 100)); - } - - case L_('G'): - DO_SIGNED_NUMBER (4, tp->tm_year < -TM_YEAR_BASE - year_adjust, - (tp->tm_year + (unsigned int) TM_YEAR_BASE - + year_adjust)); - - default: - DO_NUMBER (2, days / 7 + 1); - } - } - - case L_('W'): - if (modifier == L_('E')) - goto bad_format; - - DO_NUMBER (2, (tp->tm_yday - (tp->tm_wday - 1 + 7) % 7 + 7) / 7); - - case L_('w'): - if (modifier == L_('E')) - goto bad_format; - - DO_NUMBER (1, tp->tm_wday); - - case L_('Y'): - if (modifier == 'E') - { -#if HAVE_STRUCT_ERA_ENTRY - struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); - if (era) - { -# ifdef COMPILE_WIDE - subfmt = era->era_wformat; -# else - subfmt = era->era_format; -# endif - goto subformat; - } -#else - goto underlying_strftime; -#endif - } - if (modifier == L_('O')) - goto bad_format; - else - DO_SIGNED_NUMBER (4, tp->tm_year < -TM_YEAR_BASE, - tp->tm_year + (unsigned int) TM_YEAR_BASE); - - case L_('y'): - if (modifier == L_('E')) - { -#if HAVE_STRUCT_ERA_ENTRY - struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); - if (era) - { - int delta = tp->tm_year - era->start_date[0]; - DO_NUMBER (1, (era->offset - + delta * era->absolute_direction)); - } -#else - goto underlying_strftime; -#endif - } - - { - int yy = tp->tm_year % 100; - if (yy < 0) - yy = tp->tm_year < - TM_YEAR_BASE ? -yy : yy + 100; - DO_NUMBER (2, yy); - } - - case L_('Z'): - if (change_case) - { - to_uppcase = false; - to_lowcase = true; - } - -#if HAVE_TZNAME - /* The tzset() call might have changed the value. */ - if (!(zone && *zone) && tp->tm_isdst >= 0) - zone = tzname[tp->tm_isdst != 0]; -#endif - if (! zone) - zone = ""; - -#ifdef COMPILE_WIDE - { - /* The zone string is always given in multibyte form. We have - to transform it first. */ - wchar_t *wczone; - size_t len; - widen (zone, wczone, len); - cpy (len, wczone); - } -#else - cpy (strlen (zone), zone); -#endif - break; - - case L_(':'): - /* :, ::, and ::: are valid only just before 'z'. - :::: etc. are rejected later. */ - for (colons = 1; f[colons] == L_(':'); colons++) - continue; - if (f[colons] != L_('z')) - goto bad_format; - f += colons; - goto do_z_conversion; - - case L_('z'): - colons = 0; - - do_z_conversion: - if (tp->tm_isdst < 0) - break; - - { - int diff; - int hour_diff; - int min_diff; - int sec_diff; -#if HAVE_TM_GMTOFF - diff = tp->tm_gmtoff; -#else - if (ut) - diff = 0; - else - { - struct tm gtm; - struct tm ltm; - time_t lt; - - ltm = *tp; - lt = mktime (<m); - - if (lt == (time_t) -1) - { - /* mktime returns -1 for errors, but -1 is also a - valid time_t value. Check whether an error really - occurred. */ - struct tm tm; - - if (! __localtime_r (<, &tm) - || ((ltm.tm_sec ^ tm.tm_sec) - | (ltm.tm_min ^ tm.tm_min) - | (ltm.tm_hour ^ tm.tm_hour) - | (ltm.tm_mday ^ tm.tm_mday) - | (ltm.tm_mon ^ tm.tm_mon) - | (ltm.tm_year ^ tm.tm_year))) - break; - } - - if (! __gmtime_r (<, >m)) - break; - - diff = tm_diff (<m, >m); - } -#endif - - hour_diff = diff / 60 / 60; - min_diff = diff / 60 % 60; - sec_diff = diff % 60; - - switch (colons) - { - case 0: /* +hhmm */ - DO_TZ_OFFSET (5, diff < 0, 0, hour_diff * 100 + min_diff); - - case 1: tz_hh_mm: /* +hh:mm */ - DO_TZ_OFFSET (6, diff < 0, 04, hour_diff * 100 + min_diff); - - case 2: tz_hh_mm_ss: /* +hh:mm:ss */ - DO_TZ_OFFSET (9, diff < 0, 024, - hour_diff * 10000 + min_diff * 100 + sec_diff); - - case 3: /* +hh if possible, else +hh:mm, else +hh:mm:ss */ - if (sec_diff != 0) - goto tz_hh_mm_ss; - if (min_diff != 0) - goto tz_hh_mm; - DO_TZ_OFFSET (3, diff < 0, 0, hour_diff); - - default: - goto bad_format; - } - } - - case L_('\0'): /* GNU extension: % at end of format. */ - --f; - /* Fall through. */ - default: - /* Unknown format; output the format, including the '%', - since this is most likely the right thing to do if a - multibyte string has been misparsed. */ - bad_format: - { - int flen; - for (flen = 1; f[1 - flen] != L_('%'); flen++) - continue; - cpy (flen, &f[1 - flen]); - } - break; - } - } - -#if ! FPRINTFTIME - if (p && maxsize != 0) - *p = L_('\0'); -#endif - - return i; -} - -/* Write information from TP into S according to the format - string FORMAT, writing no more that MAXSIZE characters - (including the terminating '\0') and returning number of - characters written. If S is NULL, nothing will be written - anywhere, so to determine how many characters would be - written, use NULL for S and (size_t) -1 for MAXSIZE. */ -size_t -my_strftime (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) - const CHAR_T *format, - const struct tm *tp extra_args_spec LOCALE_PARAM_PROTO) -{ - return strftime_case_ (false, s, STRFTIME_ARG (maxsize) - format, tp extra_args LOCALE_ARG); -} - -#if defined _LIBC && ! FPRINTFTIME -libc_hidden_def (my_strftime) -#endif - - -#if defined emacs && ! FPRINTFTIME -/* For Emacs we have a separate interface which corresponds to the normal - strftime function plus the ut argument, but without the ns argument. */ -size_t -emacs_strftimeu (char *s, size_t maxsize, const char *format, - const struct tm *tp, int ut) -{ - return my_strftime (s, maxsize, format, tp, ut, 0); -} -#endif === added file 'lib/strftime.c' --- lib/strftime.c 1970-01-01 00:00:00 +0000 +++ lib/strftime.c 2011-01-31 16:54:02 +0000 @@ -0,0 +1,1468 @@ +/* Copyright (C) 1991-2001, 2003-2007, 2009-2011 Free Software Foundation, Inc. + + NOTE: The canonical source of this file is maintained with the GNU C Library. + Bugs can be reported to bug-glibc@prep.ai.mit.edu. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifdef _LIBC +# define HAVE_STRUCT_ERA_ENTRY 1 +# define HAVE_TM_GMTOFF 1 +# define HAVE_TM_ZONE 1 +# define HAVE_TZNAME 1 +# define HAVE_TZSET 1 +# include "../locale/localeinfo.h" +#else +# include +# if FPRINTFTIME +# include "ignore-value.h" +# include "fprintftime.h" +# else +# include "strftime.h" +# endif +#endif + +#include +#include + +#if HAVE_TZNAME && !HAVE_DECL_TZNAME +extern char *tzname[]; +#endif + +/* Do multibyte processing if multibytes are supported, unless + multibyte sequences are safe in formats. Multibyte sequences are + safe if they cannot contain byte sequences that look like format + conversion specifications. The multibyte encodings used by the + C library on the various platforms (UTF-8, GB2312, GBK, CP936, + GB18030, EUC-TW, BIG5, BIG5-HKSCS, CP950, EUC-JP, EUC-KR, CP949, + SHIFT_JIS, CP932, JOHAB) are safe for formats, because the byte '%' + cannot occur in a multibyte character except in the first byte. + + The DEC-HANYU encoding used on OSF/1 is not safe for formats, but + this encoding has never been seen in real-life use, so we ignore + it. */ +#if !(defined __osf__ && 0) +# define MULTIBYTE_IS_FORMAT_SAFE 1 +#endif +#define DO_MULTIBYTE (! MULTIBYTE_IS_FORMAT_SAFE) + +#if DO_MULTIBYTE +# include + static const mbstate_t mbstate_zero; +#endif + +#include +#include +#include +#include +#include + +#ifdef COMPILE_WIDE +# include +# define CHAR_T wchar_t +# define UCHAR_T unsigned int +# define L_(Str) L##Str +# define NLW(Sym) _NL_W##Sym + +# define MEMCPY(d, s, n) __wmemcpy (d, s, n) +# define STRLEN(s) __wcslen (s) + +#else +# define CHAR_T char +# define UCHAR_T unsigned char +# define L_(Str) Str +# define NLW(Sym) Sym + +# define MEMCPY(d, s, n) memcpy (d, s, n) +# define STRLEN(s) strlen (s) + +#endif + +/* Shift A right by B bits portably, by dividing A by 2**B and + truncating towards minus infinity. A and B should be free of side + effects, and B should be in the range 0 <= B <= INT_BITS - 2, where + INT_BITS is the number of useful bits in an int. GNU code can + assume that INT_BITS is at least 32. + + ISO C99 says that A >> B is implementation-defined if A < 0. Some + implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift + right in the usual way when A < 0, so SHR falls back on division if + ordinary A >> B doesn't seem to be the usual signed shift. */ +#define SHR(a, b) \ + (-1 >> 1 == -1 \ + ? (a) >> (b) \ + : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0)) + +/* Bound on length of the string representing an integer type or expression T. + Subtract 1 for the sign bit if t is signed; log10 (2.0) < 146/485; + add 1 for integer division truncation; add 1 more for a minus sign + if needed. */ +#define INT_STRLEN_BOUND(t) \ + ((sizeof (t) * CHAR_BIT - 1) * 146 / 485 + 2) + +#define TM_YEAR_BASE 1900 + +#ifndef __isleap +/* Nonzero if YEAR is a leap year (every 4 years, + except every 100th isn't, and every 400th is). */ +# define __isleap(year) \ + ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) +#endif + + +#ifdef _LIBC +# define tzname __tzname +# define tzset __tzset +#endif + +#if !HAVE_TM_GMTOFF +/* Portable standalone applications should supply a "time.h" that + declares a POSIX-compliant localtime_r, for the benefit of older + implementations that lack localtime_r or have a nonstandard one. + See the gnulib time_r module for one way to implement this. */ +# undef __gmtime_r +# undef __localtime_r +# define __gmtime_r gmtime_r +# define __localtime_r localtime_r +#endif + + +#ifndef FPRINTFTIME +# define FPRINTFTIME 0 +#endif + +#if FPRINTFTIME +# define STREAM_OR_CHAR_T FILE +# define STRFTIME_ARG(x) /* empty */ +#else +# define STREAM_OR_CHAR_T CHAR_T +# define STRFTIME_ARG(x) x, +#endif + +#if FPRINTFTIME +# define memset_byte(P, Len, Byte) \ + do { size_t _i; for (_i = 0; _i < Len; _i++) fputc (Byte, P); } while (0) +# define memset_space(P, Len) memset_byte (P, Len, ' ') +# define memset_zero(P, Len) memset_byte (P, Len, '0') +#elif defined COMPILE_WIDE +# define memset_space(P, Len) (wmemset (P, L' ', Len), (P) += (Len)) +# define memset_zero(P, Len) (wmemset (P, L'0', Len), (P) += (Len)) +#else +# define memset_space(P, Len) (memset (P, ' ', Len), (P) += (Len)) +# define memset_zero(P, Len) (memset (P, '0', Len), (P) += (Len)) +#endif + +#if FPRINTFTIME +# define advance(P, N) +#else +# define advance(P, N) ((P) += (N)) +#endif + +#define add(n, f) \ + do \ + { \ + int _n = (n); \ + int _delta = width - _n; \ + int _incr = _n + (_delta > 0 ? _delta : 0); \ + if ((size_t) _incr >= maxsize - i) \ + return 0; \ + if (p) \ + { \ + if (digits == 0 && _delta > 0) \ + { \ + if (pad == L_('0')) \ + memset_zero (p, _delta); \ + else \ + memset_space (p, _delta); \ + } \ + f; \ + advance (p, _n); \ + } \ + i += _incr; \ + } while (0) + +#if FPRINTFTIME +# define add1(C) add (1, fputc (C, p)) +#else +# define add1(C) add (1, *p = C) +#endif + +#if FPRINTFTIME +# define cpy(n, s) \ + add ((n), \ + do \ + { \ + if (to_lowcase) \ + fwrite_lowcase (p, (s), _n); \ + else if (to_uppcase) \ + fwrite_uppcase (p, (s), _n); \ + else \ + { \ + /* We are ignoring the value of fwrite here, in spite of the \ + fact that technically, that may not be valid: the fwrite \ + specification in POSIX 2008 defers to that of fputc, which \ + is intended to be consistent with the one from ISO C, \ + which permits failure due to ENOMEM *without* setting the \ + stream's error indicator. */ \ + ignore_value (fwrite ((s), _n, 1, p)); \ + } \ + } \ + while (0) \ + ) +#else +# define cpy(n, s) \ + add ((n), \ + if (to_lowcase) \ + memcpy_lowcase (p, (s), _n LOCALE_ARG); \ + else if (to_uppcase) \ + memcpy_uppcase (p, (s), _n LOCALE_ARG); \ + else \ + MEMCPY ((void *) p, (void const *) (s), _n)) +#endif + +#ifdef COMPILE_WIDE +# ifndef USE_IN_EXTENDED_LOCALE_MODEL +# undef __mbsrtowcs_l +# define __mbsrtowcs_l(d, s, l, st, loc) __mbsrtowcs (d, s, l, st) +# endif +# define widen(os, ws, l) \ + { \ + mbstate_t __st; \ + const char *__s = os; \ + memset (&__st, '\0', sizeof (__st)); \ + l = __mbsrtowcs_l (NULL, &__s, 0, &__st, loc); \ + ws = (wchar_t *) alloca ((l + 1) * sizeof (wchar_t)); \ + (void) __mbsrtowcs_l (ws, &__s, l, &__st, loc); \ + } +#endif + + +#if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL +/* We use this code also for the extended locale handling where the + function gets as an additional argument the locale which has to be + used. To access the values we have to redefine the _NL_CURRENT + macro. */ +# define strftime __strftime_l +# define wcsftime __wcsftime_l +# undef _NL_CURRENT +# define _NL_CURRENT(category, item) \ + (current->values[_NL_ITEM_INDEX (item)].string) +# define LOCALE_ARG , loc +# define LOCALE_PARAM_PROTO , __locale_t loc +# define HELPER_LOCALE_ARG , current +#else +# define LOCALE_PARAM_PROTO +# define LOCALE_ARG +# ifdef _LIBC +# define HELPER_LOCALE_ARG , _NL_CURRENT_DATA (LC_TIME) +# else +# define HELPER_LOCALE_ARG +# endif +#endif + +#ifdef COMPILE_WIDE +# ifdef USE_IN_EXTENDED_LOCALE_MODEL +# define TOUPPER(Ch, L) __towupper_l (Ch, L) +# define TOLOWER(Ch, L) __towlower_l (Ch, L) +# else +# define TOUPPER(Ch, L) towupper (Ch) +# define TOLOWER(Ch, L) towlower (Ch) +# endif +#else +# ifdef USE_IN_EXTENDED_LOCALE_MODEL +# define TOUPPER(Ch, L) __toupper_l (Ch, L) +# define TOLOWER(Ch, L) __tolower_l (Ch, L) +# else +# define TOUPPER(Ch, L) toupper (Ch) +# define TOLOWER(Ch, L) tolower (Ch) +# endif +#endif +/* We don't use `isdigit' here since the locale dependent + interpretation is not what we want here. We only need to accept + the arabic digits in the ASCII range. One day there is perhaps a + more reliable way to accept other sets of digits. */ +#define ISDIGIT(Ch) ((unsigned int) (Ch) - L_('0') <= 9) + +#if FPRINTFTIME +static void +fwrite_lowcase (FILE *fp, const CHAR_T *src, size_t len) +{ + while (len-- > 0) + { + fputc (TOLOWER ((UCHAR_T) *src, loc), fp); + ++src; + } +} + +static void +fwrite_uppcase (FILE *fp, const CHAR_T *src, size_t len) +{ + while (len-- > 0) + { + fputc (TOUPPER ((UCHAR_T) *src, loc), fp); + ++src; + } +} +#else +static CHAR_T * +memcpy_lowcase (CHAR_T *dest, const CHAR_T *src, + size_t len LOCALE_PARAM_PROTO) +{ + while (len-- > 0) + dest[len] = TOLOWER ((UCHAR_T) src[len], loc); + return dest; +} + +static CHAR_T * +memcpy_uppcase (CHAR_T *dest, const CHAR_T *src, + size_t len LOCALE_PARAM_PROTO) +{ + while (len-- > 0) + dest[len] = TOUPPER ((UCHAR_T) src[len], loc); + return dest; +} +#endif + + +#if ! HAVE_TM_GMTOFF +/* Yield the difference between *A and *B, + measured in seconds, ignoring leap seconds. */ +# define tm_diff ftime_tm_diff +static int +tm_diff (const struct tm *a, const struct tm *b) +{ + /* Compute intervening leap days correctly even if year is negative. + Take care to avoid int overflow in leap day calculations, + but it's OK to assume that A and B are close to each other. */ + int a4 = SHR (a->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (a->tm_year & 3); + int b4 = SHR (b->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (b->tm_year & 3); + int a100 = a4 / 25 - (a4 % 25 < 0); + int b100 = b4 / 25 - (b4 % 25 < 0); + int a400 = SHR (a100, 2); + int b400 = SHR (b100, 2); + int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); + int years = a->tm_year - b->tm_year; + int days = (365 * years + intervening_leap_days + + (a->tm_yday - b->tm_yday)); + return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour)) + + (a->tm_min - b->tm_min)) + + (a->tm_sec - b->tm_sec)); +} +#endif /* ! HAVE_TM_GMTOFF */ + + + +/* The number of days from the first day of the first ISO week of this + year to the year day YDAY with week day WDAY. ISO weeks start on + Monday; the first ISO week has the year's first Thursday. YDAY may + be as small as YDAY_MINIMUM. */ +#define ISO_WEEK_START_WDAY 1 /* Monday */ +#define ISO_WEEK1_WDAY 4 /* Thursday */ +#define YDAY_MINIMUM (-366) +#ifdef __GNUC__ +__inline__ +#endif +static int +iso_week_days (int yday, int wday) +{ + /* Add enough to the first operand of % to make it nonnegative. */ + int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7; + return (yday + - (yday - wday + ISO_WEEK1_WDAY + big_enough_multiple_of_7) % 7 + + ISO_WEEK1_WDAY - ISO_WEEK_START_WDAY); +} + + +/* When compiling this file, GNU applications can #define my_strftime + to a symbol (typically nstrftime) to get an extended strftime with + extra arguments UT and NS. Emacs is a special case for now, but + this Emacs-specific code can be removed once Emacs's config.h + defines my_strftime. */ +#if defined emacs && !defined my_strftime +# define my_strftime nstrftime +#endif + +#if FPRINTFTIME +# undef my_strftime +# define my_strftime fprintftime +#endif + +#ifdef my_strftime +# define extra_args , ut, ns +# define extra_args_spec , int ut, int ns +#else +# if defined COMPILE_WIDE +# define my_strftime wcsftime +# define nl_get_alt_digit _nl_get_walt_digit +# else +# define my_strftime strftime +# define nl_get_alt_digit _nl_get_alt_digit +# endif +# define extra_args +# define extra_args_spec +/* We don't have this information in general. */ +# define ut 0 +# define ns 0 +#endif + + +/* Just like my_strftime, below, but with one more parameter, UPCASE, + to indicate that the result should be converted to upper case. */ +static size_t +strftime_case_ (bool upcase, STREAM_OR_CHAR_T *s, + STRFTIME_ARG (size_t maxsize) + const CHAR_T *format, + const struct tm *tp extra_args_spec LOCALE_PARAM_PROTO) +{ +#if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL + struct locale_data *const current = loc->__locales[LC_TIME]; +#endif +#if FPRINTFTIME + size_t maxsize = (size_t) -1; +#endif + + int hour12 = tp->tm_hour; +#ifdef _NL_CURRENT + /* We cannot make the following values variables since we must delay + the evaluation of these values until really needed since some + expressions might not be valid in every situation. The `struct tm' + might be generated by a strptime() call that initialized + only a few elements. Dereference the pointers only if the format + requires this. Then it is ok to fail if the pointers are invalid. */ +# define a_wkday \ + ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ABDAY_1) + tp->tm_wday)) +# define f_wkday \ + ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(DAY_1) + tp->tm_wday)) +# define a_month \ + ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ABMON_1) + tp->tm_mon)) +# define f_month \ + ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(MON_1) + tp->tm_mon)) +# define ampm \ + ((const CHAR_T *) _NL_CURRENT (LC_TIME, tp->tm_hour > 11 \ + ? NLW(PM_STR) : NLW(AM_STR))) + +# define aw_len STRLEN (a_wkday) +# define am_len STRLEN (a_month) +# define ap_len STRLEN (ampm) +#endif + const char *zone; + size_t i = 0; + STREAM_OR_CHAR_T *p = s; + const CHAR_T *f; +#if DO_MULTIBYTE && !defined COMPILE_WIDE + const char *format_end = NULL; +#endif + +#if ! defined _LIBC && ! HAVE_RUN_TZSET_TEST + /* Solaris 2.5.x and 2.6 tzset sometimes modify the storage returned + by localtime. On such systems, we must either use the tzset and + localtime wrappers to work around the bug (which sets + HAVE_RUN_TZSET_TEST) or make a copy of the structure. */ + struct tm copy = *tp; + tp = © +#endif + + zone = NULL; +#if HAVE_TM_ZONE + /* The POSIX test suite assumes that setting + the environment variable TZ to a new value before calling strftime() + will influence the result (the %Z format) even if the information in + TP is computed with a totally different time zone. + This is bogus: though POSIX allows bad behavior like this, + POSIX does not require it. Do the right thing instead. */ + zone = (const char *) tp->tm_zone; +#endif +#if HAVE_TZNAME + if (ut) + { + if (! (zone && *zone)) + zone = "GMT"; + } + else + { + /* POSIX.1 requires that local time zone information be used as + though strftime called tzset. */ +# if HAVE_TZSET + tzset (); +# endif + } +#endif + + if (hour12 > 12) + hour12 -= 12; + else + if (hour12 == 0) + hour12 = 12; + + for (f = format; *f != '\0'; ++f) + { + int pad = 0; /* Padding for number ('-', '_', or 0). */ + int modifier; /* Field modifier ('E', 'O', or 0). */ + int digits = 0; /* Max digits for numeric format. */ + int number_value; /* Numeric value to be printed. */ + unsigned int u_number_value; /* (unsigned int) number_value. */ + bool negative_number; /* The number is negative. */ + bool always_output_a_sign; /* +/- should always be output. */ + int tz_colon_mask; /* Bitmask of where ':' should appear. */ + const CHAR_T *subfmt; + CHAR_T sign_char; + CHAR_T *bufp; + CHAR_T buf[1 + + 2 /* for the two colons in a %::z or %:::z time zone */ + + (sizeof (int) < sizeof (time_t) + ? INT_STRLEN_BOUND (time_t) + : INT_STRLEN_BOUND (int))]; + int width = -1; + bool to_lowcase = false; + bool to_uppcase = upcase; + size_t colons; + bool change_case = false; + int format_char; + +#if DO_MULTIBYTE && !defined COMPILE_WIDE + switch (*f) + { + case L_('%'): + break; + + case L_('\b'): case L_('\t'): case L_('\n'): + case L_('\v'): case L_('\f'): case L_('\r'): + case L_(' '): case L_('!'): case L_('"'): case L_('#'): case L_('&'): + case L_('\''): case L_('('): case L_(')'): case L_('*'): case L_('+'): + case L_(','): case L_('-'): case L_('.'): case L_('/'): case L_('0'): + case L_('1'): case L_('2'): case L_('3'): case L_('4'): case L_('5'): + case L_('6'): case L_('7'): case L_('8'): case L_('9'): case L_(':'): + case L_(';'): case L_('<'): case L_('='): case L_('>'): case L_('?'): + case L_('A'): case L_('B'): case L_('C'): case L_('D'): case L_('E'): + case L_('F'): case L_('G'): case L_('H'): case L_('I'): case L_('J'): + case L_('K'): case L_('L'): case L_('M'): case L_('N'): case L_('O'): + case L_('P'): case L_('Q'): case L_('R'): case L_('S'): case L_('T'): + case L_('U'): case L_('V'): case L_('W'): case L_('X'): case L_('Y'): + case L_('Z'): case L_('['): case L_('\\'): case L_(']'): case L_('^'): + case L_('_'): case L_('a'): case L_('b'): case L_('c'): case L_('d'): + case L_('e'): case L_('f'): case L_('g'): case L_('h'): case L_('i'): + case L_('j'): case L_('k'): case L_('l'): case L_('m'): case L_('n'): + case L_('o'): case L_('p'): case L_('q'): case L_('r'): case L_('s'): + case L_('t'): case L_('u'): case L_('v'): case L_('w'): case L_('x'): + case L_('y'): case L_('z'): case L_('{'): case L_('|'): case L_('}'): + case L_('~'): + /* The C Standard requires these 98 characters (plus '%') to + be in the basic execution character set. None of these + characters can start a multibyte sequence, so they need + not be analyzed further. */ + add1 (*f); + continue; + + default: + /* Copy this multibyte sequence until we reach its end, find + an error, or come back to the initial shift state. */ + { + mbstate_t mbstate = mbstate_zero; + size_t len = 0; + size_t fsize; + + if (! format_end) + format_end = f + strlen (f) + 1; + fsize = format_end - f; + + do + { + size_t bytes = mbrlen (f + len, fsize - len, &mbstate); + + if (bytes == 0) + break; + + if (bytes == (size_t) -2) + { + len += strlen (f + len); + break; + } + + if (bytes == (size_t) -1) + { + len++; + break; + } + + len += bytes; + } + while (! mbsinit (&mbstate)); + + cpy (len, f); + f += len - 1; + continue; + } + } + +#else /* ! DO_MULTIBYTE */ + + /* Either multibyte encodings are not supported, they are + safe for formats, so any non-'%' byte can be copied through, + or this is the wide character version. */ + if (*f != L_('%')) + { + add1 (*f); + continue; + } + +#endif /* ! DO_MULTIBYTE */ + + /* Check for flags that can modify a format. */ + while (1) + { + switch (*++f) + { + /* This influences the number formats. */ + case L_('_'): + case L_('-'): + case L_('0'): + pad = *f; + continue; + + /* This changes textual output. */ + case L_('^'): + to_uppcase = true; + continue; + case L_('#'): + change_case = true; + continue; + + default: + break; + } + break; + } + + /* As a GNU extension we allow to specify the field width. */ + if (ISDIGIT (*f)) + { + width = 0; + do + { + if (width > INT_MAX / 10 + || (width == INT_MAX / 10 && *f - L_('0') > INT_MAX % 10)) + /* Avoid overflow. */ + width = INT_MAX; + else + { + width *= 10; + width += *f - L_('0'); + } + ++f; + } + while (ISDIGIT (*f)); + } + + /* Check for modifiers. */ + switch (*f) + { + case L_('E'): + case L_('O'): + modifier = *f++; + break; + + default: + modifier = 0; + break; + } + + /* Now do the specified format. */ + format_char = *f; + switch (format_char) + { +#define DO_NUMBER(d, v) \ + digits = d; \ + number_value = v; goto do_number +#define DO_SIGNED_NUMBER(d, negative, v) \ + digits = d; \ + negative_number = negative; \ + u_number_value = v; goto do_signed_number + + /* The mask is not what you might think. + When the ordinal i'th bit is set, insert a colon + before the i'th digit of the time zone representation. */ +#define DO_TZ_OFFSET(d, negative, mask, v) \ + digits = d; \ + negative_number = negative; \ + tz_colon_mask = mask; \ + u_number_value = v; goto do_tz_offset +#define DO_NUMBER_SPACEPAD(d, v) \ + digits = d; \ + number_value = v; goto do_number_spacepad + + case L_('%'): + if (modifier != 0) + goto bad_format; + add1 (*f); + break; + + case L_('a'): + if (modifier != 0) + goto bad_format; + if (change_case) + { + to_uppcase = true; + to_lowcase = false; + } +#ifdef _NL_CURRENT + cpy (aw_len, a_wkday); + break; +#else + goto underlying_strftime; +#endif + + case 'A': + if (modifier != 0) + goto bad_format; + if (change_case) + { + to_uppcase = true; + to_lowcase = false; + } +#ifdef _NL_CURRENT + cpy (STRLEN (f_wkday), f_wkday); + break; +#else + goto underlying_strftime; +#endif + + case L_('b'): + case L_('h'): + if (change_case) + { + to_uppcase = true; + to_lowcase = false; + } + if (modifier != 0) + goto bad_format; +#ifdef _NL_CURRENT + cpy (am_len, a_month); + break; +#else + goto underlying_strftime; +#endif + + case L_('B'): + if (modifier != 0) + goto bad_format; + if (change_case) + { + to_uppcase = true; + to_lowcase = false; + } +#ifdef _NL_CURRENT + cpy (STRLEN (f_month), f_month); + break; +#else + goto underlying_strftime; +#endif + + case L_('c'): + if (modifier == L_('O')) + goto bad_format; +#ifdef _NL_CURRENT + if (! (modifier == 'E' + && (*(subfmt = + (const CHAR_T *) _NL_CURRENT (LC_TIME, + NLW(ERA_D_T_FMT))) + != '\0'))) + subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_T_FMT)); +#else + goto underlying_strftime; +#endif + + subformat: + { + size_t len = strftime_case_ (to_uppcase, + NULL, STRFTIME_ARG ((size_t) -1) + subfmt, + tp extra_args LOCALE_ARG); + add (len, strftime_case_ (to_uppcase, p, + STRFTIME_ARG (maxsize - i) + subfmt, + tp extra_args LOCALE_ARG)); + } + break; + +#if !(defined _NL_CURRENT && HAVE_STRUCT_ERA_ENTRY) + underlying_strftime: + { + /* The relevant information is available only via the + underlying strftime implementation, so use that. */ + char ufmt[5]; + char *u = ufmt; + char ubuf[1024]; /* enough for any single format in practice */ + size_t len; + /* Make sure we're calling the actual underlying strftime. + In some cases, config.h contains something like + "#define strftime rpl_strftime". */ +# ifdef strftime +# undef strftime + size_t strftime (); +# endif + + /* The space helps distinguish strftime failure from empty + output. */ + *u++ = ' '; + *u++ = '%'; + if (modifier != 0) + *u++ = modifier; + *u++ = format_char; + *u = '\0'; + len = strftime (ubuf, sizeof ubuf, ufmt, tp); + if (len != 0) + cpy (len - 1, ubuf + 1); + } + break; +#endif + + case L_('C'): + if (modifier == L_('O')) + goto bad_format; + if (modifier == L_('E')) + { +#if HAVE_STRUCT_ERA_ENTRY + struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); + if (era) + { +# ifdef COMPILE_WIDE + size_t len = __wcslen (era->era_wname); + cpy (len, era->era_wname); +# else + size_t len = strlen (era->era_name); + cpy (len, era->era_name); +# endif + break; + } +#else + goto underlying_strftime; +#endif + } + + { + int century = tp->tm_year / 100 + TM_YEAR_BASE / 100; + century -= tp->tm_year % 100 < 0 && 0 < century; + DO_SIGNED_NUMBER (2, tp->tm_year < - TM_YEAR_BASE, century); + } + + case L_('x'): + if (modifier == L_('O')) + goto bad_format; +#ifdef _NL_CURRENT + if (! (modifier == L_('E') + && (*(subfmt = + (const CHAR_T *)_NL_CURRENT (LC_TIME, NLW(ERA_D_FMT))) + != L_('\0')))) + subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_FMT)); + goto subformat; +#else + goto underlying_strftime; +#endif + case L_('D'): + if (modifier != 0) + goto bad_format; + subfmt = L_("%m/%d/%y"); + goto subformat; + + case L_('d'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (2, tp->tm_mday); + + case L_('e'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER_SPACEPAD (2, tp->tm_mday); + + /* All numeric formats set DIGITS and NUMBER_VALUE (or U_NUMBER_VALUE) + and then jump to one of these labels. */ + + do_tz_offset: + always_output_a_sign = true; + goto do_number_body; + + do_number_spacepad: + /* Force `_' flag unless overridden by `0' or `-' flag. */ + if (pad != L_('0') && pad != L_('-')) + pad = L_('_'); + + do_number: + /* Format NUMBER_VALUE according to the MODIFIER flag. */ + negative_number = number_value < 0; + u_number_value = number_value; + + do_signed_number: + always_output_a_sign = false; + tz_colon_mask = 0; + + do_number_body: + /* Format U_NUMBER_VALUE according to the MODIFIER flag. + NEGATIVE_NUMBER is nonzero if the original number was + negative; in this case it was converted directly to + unsigned int (i.e., modulo (UINT_MAX + 1)) without + negating it. */ + if (modifier == L_('O') && !negative_number) + { +#ifdef _NL_CURRENT + /* Get the locale specific alternate representation of + the number. If none exist NULL is returned. */ + const CHAR_T *cp = nl_get_alt_digit (u_number_value + HELPER_LOCALE_ARG); + + if (cp != NULL) + { + size_t digitlen = STRLEN (cp); + if (digitlen != 0) + { + cpy (digitlen, cp); + break; + } + } +#else + goto underlying_strftime; +#endif + } + + bufp = buf + sizeof (buf) / sizeof (buf[0]); + + if (negative_number) + u_number_value = - u_number_value; + + do + { + if (tz_colon_mask & 1) + *--bufp = ':'; + tz_colon_mask >>= 1; + *--bufp = u_number_value % 10 + L_('0'); + u_number_value /= 10; + } + while (u_number_value != 0 || tz_colon_mask != 0); + + do_number_sign_and_padding: + if (digits < width) + digits = width; + + sign_char = (negative_number ? L_('-') + : always_output_a_sign ? L_('+') + : 0); + + if (pad == L_('-')) + { + if (sign_char) + add1 (sign_char); + } + else + { + int padding = digits - (buf + (sizeof (buf) / sizeof (buf[0])) + - bufp) - !!sign_char; + + if (padding > 0) + { + if (pad == L_('_')) + { + if ((size_t) padding >= maxsize - i) + return 0; + + if (p) + memset_space (p, padding); + i += padding; + width = width > padding ? width - padding : 0; + if (sign_char) + add1 (sign_char); + } + else + { + if ((size_t) digits >= maxsize - i) + return 0; + + if (sign_char) + add1 (sign_char); + + if (p) + memset_zero (p, padding); + i += padding; + width = 0; + } + } + else + { + if (sign_char) + add1 (sign_char); + } + } + + cpy (buf + sizeof (buf) / sizeof (buf[0]) - bufp, bufp); + break; + + case L_('F'): + if (modifier != 0) + goto bad_format; + subfmt = L_("%Y-%m-%d"); + goto subformat; + + case L_('H'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (2, tp->tm_hour); + + case L_('I'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (2, hour12); + + case L_('k'): /* GNU extension. */ + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER_SPACEPAD (2, tp->tm_hour); + + case L_('l'): /* GNU extension. */ + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER_SPACEPAD (2, hour12); + + case L_('j'): + if (modifier == L_('E')) + goto bad_format; + + DO_SIGNED_NUMBER (3, tp->tm_yday < -1, tp->tm_yday + 1U); + + case L_('M'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (2, tp->tm_min); + + case L_('m'): + if (modifier == L_('E')) + goto bad_format; + + DO_SIGNED_NUMBER (2, tp->tm_mon < -1, tp->tm_mon + 1U); + +#ifndef _LIBC + case L_('N'): /* GNU extension. */ + if (modifier == L_('E')) + goto bad_format; + + number_value = ns; + if (width == -1) + width = 9; + else + { + /* Take an explicit width less than 9 as a precision. */ + int j; + for (j = width; j < 9; j++) + number_value /= 10; + } + + DO_NUMBER (width, number_value); +#endif + + case L_('n'): + add1 (L_('\n')); + break; + + case L_('P'): + to_lowcase = true; +#ifndef _NL_CURRENT + format_char = L_('p'); +#endif + /* FALLTHROUGH */ + + case L_('p'): + if (change_case) + { + to_uppcase = false; + to_lowcase = true; + } +#ifdef _NL_CURRENT + cpy (ap_len, ampm); + break; +#else + goto underlying_strftime; +#endif + + case L_('R'): + subfmt = L_("%H:%M"); + goto subformat; + + case L_('r'): +#ifdef _NL_CURRENT + if (*(subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, + NLW(T_FMT_AMPM))) + == L_('\0')) + subfmt = L_("%I:%M:%S %p"); + goto subformat; +#else + goto underlying_strftime; +#endif + + case L_('S'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (2, tp->tm_sec); + + case L_('s'): /* GNU extension. */ + { + struct tm ltm; + time_t t; + + ltm = *tp; + t = mktime (<m); + + /* Generate string value for T using time_t arithmetic; + this works even if sizeof (long) < sizeof (time_t). */ + + bufp = buf + sizeof (buf) / sizeof (buf[0]); + negative_number = t < 0; + + do + { + int d = t % 10; + t /= 10; + *--bufp = (negative_number ? -d : d) + L_('0'); + } + while (t != 0); + + digits = 1; + always_output_a_sign = false; + goto do_number_sign_and_padding; + } + + case L_('X'): + if (modifier == L_('O')) + goto bad_format; +#ifdef _NL_CURRENT + if (! (modifier == L_('E') + && (*(subfmt = + (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ERA_T_FMT))) + != L_('\0')))) + subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(T_FMT)); + goto subformat; +#else + goto underlying_strftime; +#endif + case L_('T'): + subfmt = L_("%H:%M:%S"); + goto subformat; + + case L_('t'): + add1 (L_('\t')); + break; + + case L_('u'): + DO_NUMBER (1, (tp->tm_wday - 1 + 7) % 7 + 1); + + case L_('U'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (2, (tp->tm_yday - tp->tm_wday + 7) / 7); + + case L_('V'): + case L_('g'): + case L_('G'): + if (modifier == L_('E')) + goto bad_format; + { + /* YEAR is a leap year if and only if (tp->tm_year + TM_YEAR_BASE) + is a leap year, except that YEAR and YEAR - 1 both work + correctly even when (tp->tm_year + TM_YEAR_BASE) would + overflow. */ + int year = (tp->tm_year + + (tp->tm_year < 0 + ? TM_YEAR_BASE % 400 + : TM_YEAR_BASE % 400 - 400)); + int year_adjust = 0; + int days = iso_week_days (tp->tm_yday, tp->tm_wday); + + if (days < 0) + { + /* This ISO week belongs to the previous year. */ + year_adjust = -1; + days = iso_week_days (tp->tm_yday + (365 + __isleap (year - 1)), + tp->tm_wday); + } + else + { + int d = iso_week_days (tp->tm_yday - (365 + __isleap (year)), + tp->tm_wday); + if (0 <= d) + { + /* This ISO week belongs to the next year. */ + year_adjust = 1; + days = d; + } + } + + switch (*f) + { + case L_('g'): + { + int yy = (tp->tm_year % 100 + year_adjust) % 100; + DO_NUMBER (2, (0 <= yy + ? yy + : tp->tm_year < -TM_YEAR_BASE - year_adjust + ? -yy + : yy + 100)); + } + + case L_('G'): + DO_SIGNED_NUMBER (4, tp->tm_year < -TM_YEAR_BASE - year_adjust, + (tp->tm_year + (unsigned int) TM_YEAR_BASE + + year_adjust)); + + default: + DO_NUMBER (2, days / 7 + 1); + } + } + + case L_('W'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (2, (tp->tm_yday - (tp->tm_wday - 1 + 7) % 7 + 7) / 7); + + case L_('w'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (1, tp->tm_wday); + + case L_('Y'): + if (modifier == 'E') + { +#if HAVE_STRUCT_ERA_ENTRY + struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); + if (era) + { +# ifdef COMPILE_WIDE + subfmt = era->era_wformat; +# else + subfmt = era->era_format; +# endif + goto subformat; + } +#else + goto underlying_strftime; +#endif + } + if (modifier == L_('O')) + goto bad_format; + else + DO_SIGNED_NUMBER (4, tp->tm_year < -TM_YEAR_BASE, + tp->tm_year + (unsigned int) TM_YEAR_BASE); + + case L_('y'): + if (modifier == L_('E')) + { +#if HAVE_STRUCT_ERA_ENTRY + struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); + if (era) + { + int delta = tp->tm_year - era->start_date[0]; + DO_NUMBER (1, (era->offset + + delta * era->absolute_direction)); + } +#else + goto underlying_strftime; +#endif + } + + { + int yy = tp->tm_year % 100; + if (yy < 0) + yy = tp->tm_year < - TM_YEAR_BASE ? -yy : yy + 100; + DO_NUMBER (2, yy); + } + + case L_('Z'): + if (change_case) + { + to_uppcase = false; + to_lowcase = true; + } + +#if HAVE_TZNAME + /* The tzset() call might have changed the value. */ + if (!(zone && *zone) && tp->tm_isdst >= 0) + zone = tzname[tp->tm_isdst != 0]; +#endif + if (! zone) + zone = ""; + +#ifdef COMPILE_WIDE + { + /* The zone string is always given in multibyte form. We have + to transform it first. */ + wchar_t *wczone; + size_t len; + widen (zone, wczone, len); + cpy (len, wczone); + } +#else + cpy (strlen (zone), zone); +#endif + break; + + case L_(':'): + /* :, ::, and ::: are valid only just before 'z'. + :::: etc. are rejected later. */ + for (colons = 1; f[colons] == L_(':'); colons++) + continue; + if (f[colons] != L_('z')) + goto bad_format; + f += colons; + goto do_z_conversion; + + case L_('z'): + colons = 0; + + do_z_conversion: + if (tp->tm_isdst < 0) + break; + + { + int diff; + int hour_diff; + int min_diff; + int sec_diff; +#if HAVE_TM_GMTOFF + diff = tp->tm_gmtoff; +#else + if (ut) + diff = 0; + else + { + struct tm gtm; + struct tm ltm; + time_t lt; + + ltm = *tp; + lt = mktime (<m); + + if (lt == (time_t) -1) + { + /* mktime returns -1 for errors, but -1 is also a + valid time_t value. Check whether an error really + occurred. */ + struct tm tm; + + if (! __localtime_r (<, &tm) + || ((ltm.tm_sec ^ tm.tm_sec) + | (ltm.tm_min ^ tm.tm_min) + | (ltm.tm_hour ^ tm.tm_hour) + | (ltm.tm_mday ^ tm.tm_mday) + | (ltm.tm_mon ^ tm.tm_mon) + | (ltm.tm_year ^ tm.tm_year))) + break; + } + + if (! __gmtime_r (<, >m)) + break; + + diff = tm_diff (<m, >m); + } +#endif + + hour_diff = diff / 60 / 60; + min_diff = diff / 60 % 60; + sec_diff = diff % 60; + + switch (colons) + { + case 0: /* +hhmm */ + DO_TZ_OFFSET (5, diff < 0, 0, hour_diff * 100 + min_diff); + + case 1: tz_hh_mm: /* +hh:mm */ + DO_TZ_OFFSET (6, diff < 0, 04, hour_diff * 100 + min_diff); + + case 2: tz_hh_mm_ss: /* +hh:mm:ss */ + DO_TZ_OFFSET (9, diff < 0, 024, + hour_diff * 10000 + min_diff * 100 + sec_diff); + + case 3: /* +hh if possible, else +hh:mm, else +hh:mm:ss */ + if (sec_diff != 0) + goto tz_hh_mm_ss; + if (min_diff != 0) + goto tz_hh_mm; + DO_TZ_OFFSET (3, diff < 0, 0, hour_diff); + + default: + goto bad_format; + } + } + + case L_('\0'): /* GNU extension: % at end of format. */ + --f; + /* Fall through. */ + default: + /* Unknown format; output the format, including the '%', + since this is most likely the right thing to do if a + multibyte string has been misparsed. */ + bad_format: + { + int flen; + for (flen = 1; f[1 - flen] != L_('%'); flen++) + continue; + cpy (flen, &f[1 - flen]); + } + break; + } + } + +#if ! FPRINTFTIME + if (p && maxsize != 0) + *p = L_('\0'); +#endif + + return i; +} + +/* Write information from TP into S according to the format + string FORMAT, writing no more that MAXSIZE characters + (including the terminating '\0') and returning number of + characters written. If S is NULL, nothing will be written + anywhere, so to determine how many characters would be + written, use NULL for S and (size_t) -1 for MAXSIZE. */ +size_t +my_strftime (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) + const CHAR_T *format, + const struct tm *tp extra_args_spec LOCALE_PARAM_PROTO) +{ + return strftime_case_ (false, s, STRFTIME_ARG (maxsize) + format, tp extra_args LOCALE_ARG); +} + +#if defined _LIBC && ! FPRINTFTIME +libc_hidden_def (my_strftime) +#endif + + +#if defined emacs && ! FPRINTFTIME +/* For Emacs we have a separate interface which corresponds to the normal + strftime function plus the ut argument, but without the ns argument. */ +size_t +emacs_strftimeu (char *s, size_t maxsize, const char *format, + const struct tm *tp, int ut) +{ + return my_strftime (s, maxsize, format, tp, ut, 0); +} +#endif ------------------------------------------------------------ revno: 103051 committer: Sam Steingold branch nick: trunk timestamp: Mon 2011-01-31 11:49:44 -0500 message: * lisp/progmodes/compile.el (compilation-enable-debug-messages): Add a variable to make the parsing messages introduced in revno:103013 optional. (compilation-parse-errors, compilation--flush-parse): Use it. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-01-31 15:19:57 +0000 +++ lisp/ChangeLog 2011-01-31 16:49:44 +0000 @@ -1,3 +1,11 @@ +2011-01-31 Sam Steingold + + * progmodes/compile.el (compilation-enable-debug-messages): + Add a variable to make the parsing messages introduced in + revno:103013 optional. + (compilation-parse-errors, compilation--flush-parse): Use it. + + 2011-01-31 Deniz Dogan * net/rcirc.el: Clean log filenames (Bug#7933). === modified file 'lisp/progmodes/compile.el' --- lisp/progmodes/compile.el 2011-01-29 06:08:24 +0000 +++ lisp/progmodes/compile.el 2011-01-31 16:49:44 +0000 @@ -732,6 +732,9 @@ :group 'compilation :version "22.1") +(defvar compilation-enable-debug-messages nil + "Enable debug messages while parsing the compilation buffer.") + (defun compilation-set-skip-threshold (level) "Switch the `compilation-skip-threshold' level." (interactive @@ -1169,7 +1172,8 @@ "Parse errors between START and END. The errors recognized are the ones specified in RULES which default to `compilation-error-regexp-alist' if RULES is nil." - (message "compilation-parse-errors: %S %S" start end) + (when compilation-enable-debug-messages + (message "compilation-parse-errors: %S %S" start end)) (dolist (item (or rules compilation-error-regexp-alist)) (if (symbolp item) (setq item (cdr (assq item @@ -1225,7 +1229,6 @@ (goto-char start) (while (re-search-forward pat end t) - (when (setq props (compilation-error-properties file line end-line col end-col (or type 2) fmt)) @@ -1299,7 +1302,8 @@ (defun compilation--flush-parse (start end) "Mark the region between START and END for re-parsing." - (message "compilation--flush-parse: %S %S" start end) + (when compilation-enable-debug-messages + (message "compilation--flush-parse: %S %S" start end)) (if (markerp compilation--parsed) (move-marker compilation--parsed (min start compilation--parsed)))) ------------------------------------------------------------ revno: 103050 committer: Deniz Dogan branch nick: emacs-trunk timestamp: Mon 2011-01-31 16:19:57 +0100 message: * lisp/net/rcirc.el: Clean log filenames (Bug#7933). (rcirc-log-write): Use convert-standard-filename. (rcirc-log-filename-function): Documentation updates. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-01-30 18:59:58 +0000 +++ lisp/ChangeLog 2011-01-31 15:19:57 +0000 @@ -1,3 +1,9 @@ +2011-01-31 Deniz Dogan + + * net/rcirc.el: Clean log filenames (Bug#7933). + (rcirc-log-write): Use convert-standard-filename. + (rcirc-log-filename-function): Documentation updates. + 2011-01-30 Jan Djärv * mail/emacsbug.el (report-emacs-bug-insert-to-mailer): Check === modified file 'lisp/net/rcirc.el' --- lisp/net/rcirc.el 2011-01-26 08:36:39 +0000 +++ lisp/net/rcirc.el 2011-01-31 15:19:57 +0000 @@ -1565,8 +1565,11 @@ session. If the returned filename is absolute (`file-name-absolute-p' -returns true), then it is used as-is, otherwise the resulting -file is put into `rcirc-log-directory'." +returns t), then it is used as-is, otherwise the resulting file +is put into `rcirc-log-directory'. + +The filename is then cleaned using `convert-standard-filename' to +guarantee valid filenames for the current OS." :group 'rcirc :type 'function) @@ -1591,7 +1594,9 @@ Log data is written to `rcirc-log-directory', except for log-files with absolute names (see `rcirc-log-filename-function')." (dolist (cell rcirc-log-alist) - (let ((filename (expand-file-name (car cell) rcirc-log-directory)) + (let ((filename (convert-standard-filename + (expand-file-name (car cell) + rcirc-log-directory))) (coding-system-for-write 'utf-8)) (make-directory (file-name-directory filename) t) (with-temp-buffer ------------------------------------------------------------ revno: 103049 author: Lars Ingebrigtsen committer: Katsumi Yamaoka branch nick: trunk timestamp: Mon 2011-01-31 12:29:31 +0000 message: gnus-art.el (article-date-ut): Replace infinitely many Date headers with a single one when called interactively. diff: === modified file 'lisp/gnus/ChangeLog' --- lisp/gnus/ChangeLog 2011-01-31 10:49:39 +0000 +++ lisp/gnus/ChangeLog 2011-01-31 12:29:31 +0000 @@ -3,6 +3,8 @@ * gnus-art.el (article-transform-date): Rewrite to still work when there are several rfc2822 parts. (article-transform-date): Fix infinite recursion. + (article-date-ut): Replace infinitely many Date headers with a single + one when called interactively. * nnimap.el (nnimap-wait-for-response): Wait for results in a more secure manner. === modified file 'lisp/gnus/gnus-art.el' --- lisp/gnus/gnus-art.el 2011-01-31 10:49:39 +0000 +++ lisp/gnus/gnus-art.el 2011-01-31 12:29:31 +0000 @@ -1018,6 +1018,8 @@ (let ((types '(ut local english lapsed combined-lapsed iso8601 original user-defined)) default) + ;; Try to respect the legacy `gnus-treat-date-*' variables, if + ;; they're set. (dolist (type types) (let ((variable (intern (format "gnus-treat-date-%s" type)))) (when (and (boundp variable) @@ -1028,6 +1030,7 @@ (memq 'lapsed default)) (setq default (delq 'lapsed default))) (or default + ;; If they weren't set, we default to `combined-lapsed'. '(combined-lapsed))) "A list of Date header formats to display. Valid formats are `ut' (universal time), `local' (local time @@ -3439,8 +3442,8 @@ (setq date (get-text-property (match-beginning 0) 'original-date)) (delete-region (point-at-bol) (progn (gnus-article-forward-header) - (point))) - (article-transform-date date type bface eface))))))) + (point)))) + (article-transform-date date type bface eface)))))) (defun article-transform-date (date type bface eface) (dolist (this-type (cond ------------------------------------------------------------ revno: 103048 author: Lars Ingebrigtsen committer: Katsumi Yamaoka branch nick: trunk timestamp: Mon 2011-01-31 10:49:39 +0000 message: gnus-art.el (article-transform-date): Fix infinite recursion. diff: === modified file 'lisp/gnus/ChangeLog' --- lisp/gnus/ChangeLog 2011-01-31 07:27:07 +0000 +++ lisp/gnus/ChangeLog 2011-01-31 10:49:39 +0000 @@ -2,6 +2,7 @@ * gnus-art.el (article-transform-date): Rewrite to still work when there are several rfc2822 parts. + (article-transform-date): Fix infinite recursion. * nnimap.el (nnimap-wait-for-response): Wait for results in a more secure manner. === modified file 'lisp/gnus/gnus-art.el' --- lisp/gnus/gnus-art.el 2011-01-31 07:27:07 +0000 +++ lisp/gnus/gnus-art.el 2011-01-31 10:49:39 +0000 @@ -3440,8 +3440,7 @@ (delete-region (point-at-bol) (progn (gnus-article-forward-header) (point))) - (article-transform-date date type bface eface) - (forward-line 1))))))) + (article-transform-date date type bface eface))))))) (defun article-transform-date (date type bface eface) (dolist (this-type (cond @@ -3463,7 +3462,8 @@ (put-text-property (match-beginning 1) (1+ (match-end 1)) 'face bface) (put-text-property (match-beginning 2) (match-end 2) - 'face eface)))) + 'face eface)) + (forward-line 1))) (defun article-make-date-line (date type) "Return a DATE line of TYPE." ------------------------------------------------------------ revno: 103047 [merge] committer: Paul Eggert branch nick: trunk timestamp: Mon 2011-01-31 00:15:13 -0800 message: Merge: src/emacs.c now gets version number from configure.in diff: === modified file 'ChangeLog' --- ChangeLog 2011-01-30 23:34:18 +0000 +++ ChangeLog 2011-01-31 08:12:52 +0000 @@ -1,3 +1,11 @@ +2011-01-31 Paul Eggert + + src/emacs.c now gets version number from configure.in + * configure.in (version): Set this from $PACKAGE_VERSION, + which is set from AC_INIT, rather than scouting through src/emacs.c. + * configure: Regenerate. + * make-dist (version): Get it from configure.in, not src/emacs.c. + 2011-01-30 Paul Eggert strftime: import from gnulib === modified file 'admin/ChangeLog' --- admin/ChangeLog 2011-01-30 23:34:18 +0000 +++ admin/ChangeLog 2011-01-31 08:12:52 +0000 @@ -1,3 +1,10 @@ +2011-01-31 Paul Eggert + + src/emacs.c now gets version number from configure.in + * admin.el (set-version): Don't update src/emacs.c. + * quick-install-emacs (VERSION): Get it from configure.in, not from + src/emacs.c. + 2011-01-30 Paul Eggert strftime: import from gnulib === modified file 'admin/admin.el' --- admin/admin.el 2011-01-25 04:08:28 +0000 +++ admin/admin.el 2011-01-31 08:12:52 +0000 @@ -59,9 +59,6 @@ (interactive "DEmacs root directory: \nsVersion number: ") (unless (file-exists-p (expand-file-name "src/emacs.c" root)) (error "%s doesn't seem to be the root of an Emacs source tree" root)) - (set-version-in-file root "src/emacs.c" version - (rx (and "emacs_version" (0+ (not (in ?\"))) - ?\" (submatch (1+ (not (in ?\")))) ?\"))) (set-version-in-file root "README" version (rx (and "version" (1+ space) (submatch (1+ (in "0-9.")))))) === modified file 'admin/quick-install-emacs' --- admin/quick-install-emacs 2011-01-25 04:08:28 +0000 +++ admin/quick-install-emacs 2011-01-31 08:12:52 +0000 @@ -170,8 +170,10 @@ test x"$prefix" = x && { prefix="`get_config_var prefix`" || exit 4 ; } test x"$ARCH" = x && { ARCH="`get_config_var host`" || exit 4 ; } -VERSION=`grep 'char emacs_version' $SRC/src/emacs.c \ - | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'` +VERSION=` + sed -n 's/^AC_INIT(emacs,[ ]*\([^ )]*\).*/\1/p' <$SRC/configure.in +` || exit 4 +test -n "$VERSION" || { echo >&2 "$me: no version in configure.in"; exit 4; } DST_SHARE="$prefix/share/emacs/$VERSION" DST_BIN="$prefix/bin" === modified file 'configure' --- configure 2011-01-30 23:34:18 +0000 +++ configure 2011-01-31 08:12:52 +0000 @@ -16986,16 +16986,7 @@ as_fn_error $? "GCC 4.5.0 has problems compiling Emacs; see etc/PROBLEMS'." "$LINENO" 5 fi -#### Find out which version of Emacs this is. -version=`grep 'const char emacs_version' ${srcdir}/src/emacs.c \ - | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'` -if test x"${version}" = x; then - as_fn_error $? "can't find current emacs version in \`${srcdir}/src/emacs.c'." "$LINENO" 5 -fi -if test x"${version}" != x"$PACKAGE_VERSION"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: version mismatch between \`${srcdir}/configure.in' and \`${srcdir}/src/emacs.c'." >&5 -$as_echo "$as_me: WARNING: version mismatch between \`${srcdir}/configure.in' and \`${srcdir}/src/emacs.c'." >&2;} -fi +version=$PACKAGE_VERSION ### Specify what sort of things we'll be editing into Makefile and config.h. ### Use configuration here uncanonicalized to avoid exceeding size limits. === modified file 'configure.in' --- configure.in 2011-01-30 23:34:18 +0000 +++ configure.in 2011-01-31 08:12:52 +0000 @@ -3070,15 +3070,7 @@ AC_MSG_ERROR([GCC 4.5.0 has problems compiling Emacs; see etc/PROBLEMS'.]) fi -#### Find out which version of Emacs this is. -[version=`grep 'const char emacs_version' ${srcdir}/src/emacs.c \ - | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`] -if test x"${version}" = x; then - AC_MSG_ERROR([can't find current emacs version in `${srcdir}/src/emacs.c'.]) -fi -if test x"${version}" != x"$PACKAGE_VERSION"; then - AC_MSG_WARN([version mismatch between `${srcdir}/configure.in' and `${srcdir}/src/emacs.c'.]) -fi +version=$PACKAGE_VERSION ### Specify what sort of things we'll be editing into Makefile and config.h. ### Use configuration here uncanonicalized to avoid exceeding size limits. === modified file 'lib-src/ChangeLog' --- lib-src/ChangeLog 2011-01-30 09:17:36 +0000 +++ lib-src/ChangeLog 2011-01-31 08:12:52 +0000 @@ -1,3 +1,8 @@ +2011-01-31 Paul Eggert + + src/emacs.c now gets version number from configure.in + * ebrowse.c: Adjust comment to say that. + 2011-01-30 Jim Meyering make-docfile: don't corrupt heap for an invalid .elc file === modified file 'lib-src/ebrowse.c' --- lib-src/ebrowse.c 2011-01-25 04:08:28 +0000 +++ lib-src/ebrowse.c 2011-01-31 08:12:52 +0000 @@ -3565,7 +3565,7 @@ /* Display version and copyright info. The VERSION macro is set - from the Makefile and contains the Emacs version. */ + from config.h and contains the Emacs version. */ #ifndef VERSION # define VERSION "21" @@ -3812,7 +3812,7 @@ yyerror ("error getting size of file `%s'", out_filename); exit (EXIT_FAILURE); } - + else if (rc == 0) { yyerror ("file `%s' is empty", out_filename); === modified file 'make-dist' --- make-dist 2011-01-25 04:08:28 +0000 +++ make-dist 2011-01-31 08:12:52 +0000 @@ -146,7 +146,9 @@ fi ### Find out which version of Emacs this is. -version=`sed -n '/char emacs_version/ s/^[^"]*"\([^"]*\)".*$/\1/p' src/emacs.c` +version=` + sed -n 's/^AC_INIT(emacs,[ ]*\([^ )]*\).*/\1/p' &2 exit 1 === modified file 'src/ChangeLog' --- src/ChangeLog 2011-01-31 07:34:45 +0000 +++ src/ChangeLog 2011-01-31 08:15:13 +0000 @@ -1,3 +1,9 @@ +2011-01-31 Paul Eggert + + src/emacs.c now gets version number from configure.in + * emacs.c (emacs_version): Set to VERSION so that it + is determined automatically from ../configure.in. + 2011-01-31 Jim Meyering * charset.c (load_charset_map): Don't deref NULL on failed malloc. === modified file 'src/emacs.c' --- src/emacs.c 2011-01-30 22:17:44 +0000 +++ src/emacs.c 2011-01-31 08:12:52 +0000 @@ -88,9 +88,7 @@ #endif #endif -/* If you change the following line, remember to update - msdos/mainmake.v2 which gleans the Emacs version from it! */ -static const char emacs_version[] = "24.0.50"; +static const char emacs_version[] = VERSION; static const char emacs_copyright[] = "Copyright (C) 2011 Free Software Foundation, Inc."; /* Make these values available in GDB, which doesn't see macros. */ ------------------------------------------------------------ revno: 103046 committer: Jim Meyering branch nick: trunk timestamp: Mon 2011-01-31 08:34:45 +0100 message: charset.c (load_charset_map): Don't deref NULL on failed malloc. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-01-30 23:34:18 +0000 +++ src/ChangeLog 2011-01-31 07:34:45 +0000 @@ -1,3 +1,8 @@ +2011-01-31 Jim Meyering + + * charset.c (load_charset_map): Don't deref NULL on failed malloc. + Use xmalloc rather than malloc. + 2011-01-30 Paul Eggert strftime: import from gnulib === modified file 'src/charset.c' --- src/charset.c 2011-01-25 04:08:28 +0000 +++ src/charset.c 2011-01-31 07:34:45 +0000 @@ -292,7 +292,7 @@ else { if (! temp_charset_work) - temp_charset_work = malloc (sizeof (*temp_charset_work)); + temp_charset_work = xmalloc (sizeof (*temp_charset_work)); if (control_flag == 1) { memset (temp_charset_work->table.decoder, -1, ------------------------------------------------------------ Use --include-merges or -n0 to see merged revisions.