Commit 54b8e3f7 authored by Paul Eggert's avatar Paul Eggert
Browse files

Merge from mainline.

parents 8f41de3a fc3b7291
2011-04-27 Niels Giesen <niels.giesen@gmail.com>
* calendar/icalendar.el (diary-lib): Add require statement.
(icalendar--create-uid): Read out a uid from a text-property on
the first character in the entry. This allows for code to add its
own uid to the entry.
(icalendar--convert-float-to-ical): Add export of
`diary-float'-entries save for those with the optional DAY
argument.
2011-04-27 Daniel Colascione <dan.colascione@gmail.com>
* subr.el (shell-quote-argument): Use alternate escaping strategy
......
......@@ -34,6 +34,8 @@
;; week of the year 2000 when they are exported.
;; - Yearly diary entries are assumed to occur the first time in the year
;; 1900 when they are exported.
;; - Float diary entries are assumed to occur the first time on the
;; day when they are exported.
;;; History:
......@@ -241,6 +243,7 @@ code for the event, and your personal domain name."
;; all the other libs we need
;; ======================================================================
(require 'calendar)
(require 'diary-lib)
;; ======================================================================
;; misc
......@@ -925,7 +928,10 @@ ENTRY-FULL is the full diary entry string. CONTENTS is the
current iCalendar object, as a string. Increase
`icalendar--uid-count'. Returns the UID string."
(let ((uid icalendar-uid-format))
(if
;; Allow other apps (such as org-mode) to create its own uid
(get-text-property 0 'uid entry-full)
(setq uid (get-text-property 0 'uid entry-full))
(setq uid (replace-regexp-in-string
"%c"
(format "%d" icalendar--uid-count)
......@@ -945,7 +951,7 @@ current iCalendar object, as a string. Increase
(let ((dtstart (if (string-match "^DTSTART[^:]*:\\([0-9]*\\)" contents)
(substring contents (match-beginning 1) (match-end 1))
"DTSTART")))
(setq uid (replace-regexp-in-string "%s" dtstart uid t t)))
(setq uid (replace-regexp-in-string "%s" dtstart uid t t))))
;; Return the UID string
uid))
......@@ -1545,18 +1551,65 @@ entries. ENTRY-MAIN is the first line of the diary entry."
nil))
(defun icalendar--convert-float-to-ical (nonmarker entry-main)
"Convert float diary entry to icalendar format -- unsupported!
"Convert float diary entry to icalendar format -- partially unsupported!
FIXME!
FIXME! DAY from diary-float yet unimplemented.
NONMARKER is a regular expression matching the start of non-marking
entries. ENTRY-MAIN is the first line of the diary entry."
(if (string-match (concat nonmarker
"%%(diary-float \\([^)]+\\))\\s-*\\(.*?\\) ?$")
entry-main)
NONMARKER is a regular expression matching the start of non-marking
entries. ENTRY-MAIN is the first line of the diary entry."
(if (string-match (concat nonmarker "%%\\((diary-float .+\\) ?$") entry-main)
(with-temp-buffer
(insert (match-string 1 entry-main))
(goto-char (point-min))
(let* ((sexp (read (current-buffer))) ;using `read' here
;easier than regexp
;matching, esp. with
;different forms of
;MONTH
(month (nth 1 sexp))
(dayname (nth 2 sexp))
(n (nth 3 sexp))
(day (nth 4 sexp))
(summary
(replace-regexp-in-string
"\\(^\s+\\|\s+$\\)" ""
(buffer-substring (point) (point-max)))))
(when day
(progn
(icalendar--dmsg "diary-float %s" entry-main)
(error "`diary-float' is not supported yet"))
(error "Don't know if or how to implement day in `diary-float'")))
(list (concat
;;Start today (yes this is an arbitrary choice):
"\nDTSTART;VALUE=DATE:"
(format-time-string "%Y%m%d" (current-time))
;;BUT remove today if `diary-float'
;;expression does not hold true for today:
(when
(null (let ((date (calendar-current-date))
(entry entry-main))
(diary-float month dayname n)))
(concat
"\nEXDATE;VALUE=DATE:"
(format-time-string "%Y%m%d" (current-time))))
"\nRRULE:"
(if (or (numberp month) (listp month))
"FREQ=YEARLY;BYMONTH="
"FREQ=MONTHLY")
(when
(listp month)
(mapconcat
(lambda (m)
(number-to-string m))
(cadr month) ","))
(when
(numberp month)
(number-to-string month))
";BYDAY="
(number-to-string n)
(aref icalendar--weekday-array dayname))
summary)))
;; no match
nil))
......
2011-04-27 Eli Zaretskii <eliz@gnu.org>
* inc/inttypes.h: New file.
* config.nt (HAVE_DECL_STRTOULL, HAVE_DECL_STRTOUMAX)
(HAVE_STRTOULL, HAVE_STRTOUMAX): New macros.
2011-04-27 Daniel Colascione <dan.colascione@gmail.com>
* cmdproxy.c (try_dequote_cmdline): Notice variable substitutions
......
......@@ -299,6 +299,20 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you have the `localtime_r' function. */
#undef HAVE_LOCALTIME_R
/* Define to 1 if you have the declaration of `strtoull', and to 0 if you
don't. */
#define HAVE_DECL_STRTOULL 1
/* Define to 1 if you have the declaration of `strtoumax', and to 0 if you
don't. */
#define HAVE_DECL_STRTOUMAX 1
/* Define to 1 if you have the `strtoull' function. */
#define HAVE_STRTOULL 1
/* Define to 1 if you have the `strtoumax' function. */
#define HAVE_STRTOUMAX 1
/* Define if you have the 'wchar_t' type. */
#define HAVE_WCHAR_T 1
......
/* Replacement inntypes.h file for building GNU Emacs on Windows with MSVC.
Copyright (C) 2011 Free Software Foundation, Inc.
This file is part of GNU Emacs.
GNU Emacs 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.
GNU Emacs 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 GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _REPL_INTTYPES_H
#define _REPL_INTTYPES_H
#ifdef __MINGW32__
#include_next <inttypes.h>
#else /* !__MINGW32__ */
#define uintmax_t unsigned __int64
#define strtoumax _strtoui64
#endif /* !__MINGW32__ */
#endif
......@@ -2,6 +2,19 @@
* doprnt.c (doprnt): Support "ll" length modifier, for long long.
2011-04-27 Eli Zaretskii <eliz@gnu.org>
Improve `doprnt' and its usage. (Bug#8545)
* doprnt.c (doprnt): Make sure `format' is never accessed beyond
`format_end'. Remove support for %l as a conversion specifier.
Don't use xrealloc. Improve diagnostics when the %l size modifier
is used. Update the commentary.
* eval.c (verror): Simplify calculation of size_t.
* coding.c (Ffind_operation_coding_system): Fix diagnostic error
messages.
2011-04-27 Yoshiaki Kasahara <kasahara@nc.kyushu-u.ac.jp> (tiny change)
* buffer.c (init_buffer) [USE_MMAP_FOR_BUFFERS]: Adjust to aliasing
......@@ -21,7 +34,7 @@
Remove unused local.
(emacs_gnutls_write): Don't use uninitialized rtnval if nbyte <= 0.
lisp.h: Fix a problem with aliasing and vector headers. (Bug#8546)
* lisp.h: Fix a problem with aliasing and vector headers. (Bug#8546)
GCC 4.6.0 optimizes based on type-based alias analysis. For
example, if b is of type struct buffer * and v of type struct
Lisp_Vector *, then gcc -O2 was incorrectly assuming that &b->size
......@@ -469,8 +482,8 @@
define if USE_GTK || USE_X_TOOLKIT.
(SET_SAVED_BUTTON_EVENT): Define only if USE_X_TOOLKIT || USE_GTK.
* xterm.h (x_dispatch_event): Extern only if USE_X_TOOLKIT.
* xterm.c, xterm.h (x_mouse_leave): Bring this function back, but only if
defined HAVE_MENUS && !defined USE_X_TOOLKIT && !defined USE_GTK.
* xterm.c, xterm.h (x_mouse_leave): Bring this function back, but only
if defined HAVE_MENUS && !defined USE_X_TOOLKIT && !defined USE_GTK.
* xmenu.c (menu_help_callback): Pointer type fixes.
Use const pointers when pointing at readonly data. Avoid pointer
......
......@@ -9282,14 +9282,15 @@ usage: (find-operation-coding-system OPERATION ARGUMENTS...) */)
|| !NATNUMP (target_idx = Fget (operation, Qtarget_idx)))
error ("Invalid first argument");
if (nargs < 1 + XFASTINT (target_idx))
error ("Too few arguments for operation: %s",
error ("Too few arguments for operation `%s'",
SDATA (SYMBOL_NAME (operation)));
target = args[XFASTINT (target_idx) + 1];
if (!(STRINGP (target)
|| (EQ (operation, Qinsert_file_contents) && CONSP (target)
&& STRINGP (XCAR (target)) && BUFFERP (XCDR (target)))
|| (EQ (operation, Qopen_network_stream) && INTEGERP (target))))
error ("Invalid %"pI"dth argument", XFASTINT (target_idx) + 1);
error ("Invalid argument %"pI"d of operation `%s'",
XFASTINT (target_idx) + 1, SDATA (SYMBOL_NAME (operation)));
if (CONSP (target))
target = XCAR (target);
......
......@@ -55,7 +55,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
%s means print a string argument.
%S is silently treated as %s, for loose compatibility with `Fformat'.
%d means print a `signed int' argument in decimal.
%l means print a `long int' argument in decimal.
%o means print an `unsigned int' argument in octal.
%x means print an `unsigned int' argument in hex.
%e means print a `double' argument in exponential notation.
......@@ -65,24 +64,28 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
%c means print a `signed int' argument as a single character.
%% means produce a literal % character.
A %-sequence may contain optional flag, width, and precision specifiers, as
follows:
A %-sequence may contain optional flag, width, and precision specifiers, and
a length modifier, as follows:
%<flags><width><precision>character
%<flags><width><precision><length>character
where flags is [+ -0l], width is [0-9]+, and precision is .[0-9]+
The + flag character inserts a + before any positive number, while a space
inserts a space before any positive number; these flags only affect %d, %l,
%o, %x, %e, %f, and %g sequences. The - and 0 flags affect the width
specifier, as described below.
The l (lower-case letter ell) flag is a `long' data type modifier: it is
supported for %d, %o, and %x conversions of integral arguments, and means
that the respective argument is to be treated as `long int' or `unsigned
long int'. ll means to use 'long long'. EMACS_INT arguments
should use the pI macro, which expands to whatever length modifier
is needed for the target host, e.g., "", "l", "ll".
inserts a space before any positive number; these flags only affect %d, %o,
%x, %e, %f, and %g sequences. The - and 0 flags affect the width specifier,
as described below. For signed numerical arguments only, the ` ' (space)
flag causes the result to be prefixed with a space character if it does not
start with a sign (+ or -).
The l (lower-case letter ell) length modifier is a `long' data type
modifier: it is supported for %d, %o, and %x conversions of integral
arguments, must immediately precede the conversion specifier, and means that
the respective argument is to be treated as `long int' or `unsigned long
int'. Similarly, ll (two letter ells) means to use `long long int' or
`unsigned long long int'. The empty length modifier means to use `int' or
`unsigned int'. EMACS_INT arguments should use the pI macro, which
expands to whatever length modifier is needed for the target host.
The width specifier supplies a lower limit for the length of the printed
representation. The padding, if any, normally goes on the left, but it goes
......@@ -168,7 +171,7 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
bufsize--;
/* Loop until end of format string or buffer full. */
while (fmt != format_end && bufsize > 0)
while (fmt < format_end && bufsize > 0)
{
if (*fmt == '%') /* Check for a '%' character */
{
......@@ -180,7 +183,7 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
/* Copy this one %-spec into fmtcpy. */
string = fmtcpy;
*string++ = '%';
while (1)
while (fmt < format_end)
{
*string++ = *fmt;
if ('0' <= *fmt && *fmt <= '9')
......@@ -190,7 +193,8 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
%1.1000f and %1000.1f both might need 1000+ bytes.
Parse the width or precision, checking for overflow. */
size_t n = *fmt - '0';
while ('0' <= fmt[1] && fmt[1] <= '9')
while (fmt < format_end
&& '0' <= fmt[1] && fmt[1] <= '9')
{
if (n >= SIZE_MAX / 10
|| n * 10 > SIZE_MAX - (fmt[1] - '0'))
......@@ -206,20 +210,16 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
;
else if (*fmt == 'l')
{
long_flag = 1;
if (fmt[1] == 'l')
{
long_flag = 2;
fmt++;
}
if (!strchr ("dox", fmt[1]))
/* %l as conversion specifier, not as modifier. */
long_flag = 1 + (fmt + 1 < fmt_end && fmt[1] == 'l');
fmt += long_flag;
break;
}
else
break;
fmt++;
}
if (fmt > format_end)
fmt = format_end;
*string = 0;
/* Make the size bound large enough to handle floating point formats
......@@ -232,8 +232,7 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
if (size_bound > size_allocated)
{
if (big_buffer)
big_buffer = (char *) xrealloc (big_buffer, size_bound);
else
xfree (big_buffer);
big_buffer = (char *) xmalloc (size_bound);
sprintf_buffer = big_buffer;
size_allocated = size_bound;
......@@ -242,7 +241,8 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
switch (*fmt++)
{
default:
error ("Invalid format operation %%%c", fmt[-1]);
error ("Invalid format operation %%%s%c",
long_flag ? "l" : "", fmt[-1]);
/* case 'b': */
case 'l':
......@@ -398,7 +398,7 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
char *save_bufptr = bufptr;
do { *bufptr++ = *fmt++; }
while (--bufsize > 0 && !CHAR_HEAD_P (*fmt));
while (fmt < format_end && --bufsize > 0 && !CHAR_HEAD_P (*fmt));
if (!CHAR_HEAD_P (*fmt))
{
bufptr = save_bufptr;
......
......@@ -1994,8 +1994,7 @@ verror (const char *m, va_list ap)
{
char buf[4000];
size_t size = sizeof buf;
size_t size_max =
min (MOST_POSITIVE_FIXNUM, min (INT_MAX, SIZE_MAX - 1)) + 1;
size_t size_max = min (MOST_POSITIVE_FIXNUM, SIZE_MAX);
size_t mlen = strlen (m);
char *buffer = buf;
size_t used;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment