sxelibsrcdir = $(top_srcdir)/lib-src
bldlibsrcdir = $(top_builddir)/lib-src
-AM_CFLAGS =
+AM_CFLAGS =
AM_CPPFLAGS = -I$(sxesrcdir) $(c_switch_all)
AM_LDFLAGS = $(ld_switch_general) $(ld_libs_general)
if NEED_ALLOCA_C
ctags2_LDADD += $(ALLOCA_C)
endif
-ctags2_CPPFLAGS = $(AM_CPPFLAGS)
+ctags2_CPPFLAGS = $(AM_CPPFLAGS)
if WITH_BDWGC
ctags2_CPPFLAGS += $(BDWGC_CPPFLAGS)
ctags2_LDADD += $(BDWGC_LDFLAGS) $(BDWGC_LIBS)
ootags_SOURCES = $(REGEX_C) ootags.c
ootags_CFLAGS = $(REGEX_CF) -DOOTAGS
-ootags_CPPFLAGS = $(AM_CPPFLAGS)
+ootags_CPPFLAGS = $(AM_CPPFLAGS)
if WITH_BDWGC
ootags_CPPFLAGS += $(BDWGC_CPPFLAGS)
ootags_LDADD = $(BDWGC_LDFLAGS) $(BDWGC_LIBS)
cd $(DESTDIR)$(bindir) && \
$(RM) ctags
-#
+#
# Help the SXEmacs developers get nice post-processed source files
## Create preprocessor output (debugging purposes only)
Relative ones are stored relative to the output file's directory.\n");
puts ("-a, --append\n\
- Append tag entries to existing tags file.");
+ Append tag entries to existing tags file.");
puts ("--packages-only\n\
- For Ada files, only generate tags for packages.");
+ For Ada files, only generate tags for packages.");
if (CTAGS)
puts ("-B, --backward-search\n\
- Write the search commands for the tag entries using '?', the\n\
- backward-search command instead of '/', the forward-search command.");
+ Write the search commands for the tag entries using '?', the\n\
+ backward-search command instead of '/', the forward-search command.");
/* This option is mostly obsolete, because etags can now automatically
detect C++. Retained for backward compatibility and for debugging and
if (CTAGS)
puts ("-d, --defines\n\
- Create tag entries for C #define constants and enum constants, too.");
+ Create tag entries for C #define constants and enum constants, too.");
else
puts ("-D, --no-defines\n\
- Don't create tag entries for C #define constants and enum constants.\n\
+ Don't create tag entries for C #define constants and enum constants.\n\
This makes the tags file smaller.");
if (!CTAGS)
puts ("-i FILE, --include=FILE\n\
- Include a note in tag file indicating that, when searching for\n\
- a tag, one should also consult the tags file FILE after\n\
- checking the current file.");
+ Include a note in tag file indicating that, when searching for\n\
+ a tag, one should also consult the tags file FILE after\n\
+ checking the current file.");
puts ("-l LANG, --language=LANG\n\
- Force the following files to be considered as written in the\n\
+ Force the following files to be considered as written in the\n\
named language up to the next --language=LANG option.");
if (CTAGS)
if (PRINT_UNDOCUMENTED_OPTIONS_HELP)
puts ("--no-line-directive\n\
- Ignore #line preprocessor directives in C and derived languages.");
+ Ignore #line preprocessor directives in C and derived languages.");
if (CTAGS)
puts ("--members\n\
in some languages.");
puts ("-r REGEXP, --regex=REGEXP or --regex=@regexfile\n\
- Make a tag for each line matching a regular expression pattern\n\
+ Make a tag for each line matching a regular expression pattern\n\
in the following files. {LANGUAGE}REGEXP uses REGEXP for LANGUAGE\n\
files only. REGEXFILE is a file containing one REGEXP per line.\n\
REGEXP takes the form /TAGREGEXP/TAGNAME/MODS, where TAGNAME/ is\n\
causes dot to match any character, including newline.");
puts ("-R, --no-regex\n\
- Don't create tags from regexps for the following files.");
+ Don't create tags from regexps for the following files.");
puts ("-I, --ignore-indentation\n\
- In C and C++ do not assume that a closing brace in the first\n\
- column is the final brace of a function or structure definition.");
+ In C and C++ do not assume that a closing brace in the first\n\
+ column is the final brace of a function or structure definition.");
puts ("-o FILE, --output=FILE\n\
- Write the tags to FILE.");
+ Write the tags to FILE.");
puts ("--parse-stdin=NAME\n\
- Read from standard input and record tags as belonging to file NAME.");
+ Read from standard input and record tags as belonging to file NAME.");
if (CTAGS)
{
puts ("-t, --typedefs\n\
- Generate tag entries for C and Ada typedefs.");
+ Generate tag entries for C and Ada typedefs.");
puts ("-T, --typedefs-and-c++\n\
- Generate tag entries for C typedefs, C struct/enum/union tags,\n\
- and C++ member functions.");
+ Generate tag entries for C typedefs, C struct/enum/union tags,\n\
+ and C++ member functions.");
}
if (CTAGS)
puts ("-u, --update\n\
- Update the tag entries for the given files, leaving tag\n\
- entries for other files in place. Currently, this is\n\
- implemented by deleting the existing entries for the given\n\
- files and then rewriting the new entries at the end of the\n\
- tags file. It is often faster to simply rebuild the entire\n\
- tag file than to use this.");
+ Update the tag entries for the given files, leaving tag\n\
+ entries for other files in place. Currently, this is\n\
+ implemented by deleting the existing entries for the given\n\
+ files and then rewriting the new entries at the end of the\n\
+ tags file. It is often faster to simply rebuild the entire\n\
+ tag file than to use this.");
if (CTAGS)
{
puts ("-v, --vgrind\n\
- Print on the standard output an index of items intended for\n\
- human consumption, similar to the output of vgrind. The index\n\
- is sorted, and gives the page number of each item.");
+ Print on the standard output an index of items intended for\n\
+ human consumption, similar to the output of vgrind. The index\n\
+ is sorted, and gives the page number of each item.");
if (PRINT_UNDOCUMENTED_OPTIONS_HELP)
puts ("-w, --no-duplicates\n\
- Do not create duplicate tag entries, for compatibility with\n\
+ Do not create duplicate tag entries, for compatibility with\n\
traditional ctags.");
if (PRINT_UNDOCUMENTED_OPTIONS_HELP)
puts ("-w, --no-warn\n\
- Suppress warning messages about duplicate tag entries.");
+ Suppress warning messages about duplicate tag entries.");
puts ("-x, --cxref\n\
- Like --vgrind, but in the style of cxref, rather than vgrind.\n\
- The output uses line numbers instead of page numbers, but\n\
- beyond that the differences are cosmetic; try both to see\n\
- which you like.");
+ Like --vgrind, but in the style of cxref, rather than vgrind.\n\
+ The output uses line numbers instead of page numbers, but\n\
+ beyond that the differences are cosmetic; try both to see\n\
+ which you like.");
}
puts ("-V, --version\n\
- Print the version of the program.\n\
+ Print the version of the program.\n\
-h, --help\n\
- Print this help message.\n\
- Followed by one or more `--language' options prints detailed\n\
- help about tag generation for the specified languages.");
+ Print this help message.\n\
+ Followed by one or more `--language' options prints detailed\n\
+ help about tag generation for the specified languages.");
print_language_names ();
break;
case at_language:
case at_regexp:
- case at_end:
+ case at_end:
default:
continue; /* the for loop */
}
setenv ("LC_COLLATE", "C", 1);
setenv ("LC_ALL", "C", 1); */
int len = snprintf (cmd, sizeof(cmd),
- "sort -u -o %.*s %.*s",
- BUFSIZ, tagfile,
+ "sort -u -o %.*s %.*s",
+ BUFSIZ, tagfile,
BUFSIZ, tagfile);
if (len >= 0 && (size_t)len < sizeof(cmd))
- fatal("failed to build sort shell command line",
+ fatal("failed to build sort shell command line",
(char *)NULL);
exit (system (cmd));
}
/*
* add_node ()
* Adds a node to the tree of nodes. In etags mode, sort by file
- * name. In ctags mode, sort by tag name. Make no attempt at
- * balancing.
+ * name. In ctags mode, sort by tag name. Make no attempt at
+ * balancing.
*
* add_node is the only function allowed to add nodes, so it can
* maintain state.
* consider_token ()
* checks to see if the current token is at the start of a
* function or variable, or corresponds to a typedef, or
- * is a struct/union/enum tag, or #define, or an enum constant.
+ * is a struct/union/enum tag, or #define, or an enum constant.
*
* *IS_FUNC gets TRUE if the token is a function or #define macro
* with args. C_EXTP points to which language we are looking at.
/*
* C_entries ()
* This routine finds functions, variables, typedefs,
- * #define's, enum constants and struct/union/enum definitions in
- * C syntax and adds them to the list.
+ * #define's, enum constants and struct/union/enum definitions in
+ * C syntax and adds them to the list.
*/
static void
C_entries (c_ext, inf)
continue;
else if (cp[0] == '"') /* Sometimes, strings start in column one */
continue;
- else if (cp[0] == '-') /* attribute, e.g. "-define" */
+ else if (cp[0] == '-') /* attribute, e.g. "-define" */
{
erlang_attribute (cp);
if (last != NULL)
/* Force explicit tag name, if a name
is there. */
pfnote (name, TRUE, buffer + linecharno,
- charno - linecharno + 1, lineno,
+ charno - linecharno + 1, lineno,
linecharno);
else if(name == NULL)
abort();
- else
- make_tag (name, strlen (name), TRUE,
+ else
+ make_tag (name, strlen (name), TRUE,
buffer + linecharno,
- charno - linecharno + 1,
+ charno - linecharno + 1,
lineno, linecharno);
free(name);
name = NULL;
lbp->buffer, match, lineno, linecharno);
free(name);
name = NULL;
- } else
+ } else
make_tag (rp->name, strlen (rp->name), TRUE,
lbp->buffer, match, lineno, linecharno);
break;
along with this program. If not, see <http://www.gnu.org/licenses/>.
Author: Andy Norman (ange@hplb.hpl.hp.com), based on
- 'etc/emacsclient.c' from the GNU Emacs 18.52 distribution.
+ 'etc/emacsclient.c' from the GNU Emacs 18.52 distribution.
Please mail bugs and suggestions to the XEmacs maintainer.
*/
/*
filename_expand -- try to convert the given filename into a fully-qualified
- pathname.
+ pathname.
*/
static void
filename_expand(char *fullpath, char *filename, size_t fullsize)
if (filename[0] && filename[0] == '/') {
/* Absolute (unix-style) pathname. Do nothing */
- strncat(fullpath, filename, fullsize-1);
+ strncat(fullpath, filename, fullsize-1);
} else {
/* Assume relative Unix style path. Get the current directory
* and prepend it. FIXME: need to fix the case of DOS paths
* like "\foo", where we need to get the current drive. */
- strncat(fullpath, get_current_working_directory(), fullsize-1);
+ strncat(fullpath, get_current_working_directory(), fullsize-1);
len = strlen(fullpath);
/* trailing slash already? */
send_string(s, command);
free(path);
}
-
+
SNPRINTF(sz, command, sizeof(command), ")%s%s",
(quick || (nofiles && !suppress_windows_system))
? " 'quick"
Copyright (C) 1989 Free Software Foundation, Inc.
Author: Andy Norman (ange@hplb.hpl.hp.com), based on 'etc/server.c'
- from the 18.52 GNU Emacs distribution.
+ from the 18.52 GNU Emacs distribution.
Please mail bugs and suggestions to the author at the above address.
*/
Copyright (C) 1989 Free Software Foundation, Inc.
- Author: Andy Norman (ange@hplb.hpl.hp.com), based on
- 'etc/server.c' and 'etc/emacsclient.c' from the 18.52 GNU
- Emacs distribution.
+ Author: Andy Norman (ange@hplb.hpl.hp.com), based on
+ 'etc/server.c' and 'etc/emacsclient.c' from the 18.52 GNU
+ Emacs distribution.
Please mail bugs and suggestions to the author at the above address.
*/
-/* HISTORY
- * 11-Nov-1990 bristor@simba
+/* HISTORY
+ * 11-Nov-1990 bristor@simba
* Added EOT stuff.
*/
* since it limits the size of requests and responses. Don't make it bigger
* than your system's max message size though (usually a couple of k) or else
* msgsend will start failing. For sockets, using the system BUFSIZ is usually
- * what you want.
+ * what you want.
*/
# define GSERV_BUFSZ BUFSIZ
Copyright (C) 1989 Free Software Foundation, Inc.
- Author: Andy Norman (ange@hplb.hpl.hp.com), based on
- 'etc/server.c' and 'etc/emacsclient.c' from the 18.52 GNU
- Emacs distribution.
+ Author: Andy Norman (ange@hplb.hpl.hp.com), based on
+ 'etc/server.c' and 'etc/emacsclient.c' from the 18.52 GNU
+ Emacs distribution.
Please mail bugs and suggestions to the author at the above address.
*/
-/* HISTORY
- * 11-Nov-1990 bristor@simba
+/* HISTORY
+ * 11-Nov-1990 bristor@simba
* Added EOT stuff.
*/
#endif
if (hostarg != NULL) {
- /* hostname was given explicitly, via cmd line arg or GNU_HOST,
+ /* hostname was given explicitly, via cmd line arg or GNU_HOST,
* so obey it. */
#ifdef UNIX_DOMAIN_SOCKETS
if (!strcmp(hostarg, "unix")) {
#ifdef SYSV_IPC
/*
connect_to_ipc_server -- establish connection with server process via SYSV IPC
- Returns msqid for server if successful.
+ Returns msqid for server if successful.
*/
static int connect_to_ipc_server(void)
{
/*
disconnect_from_ipc_server -- inform the server that sending has finished,
- and wait for its reply.
+ and wait for its reply.
*/
void disconnect_from_ipc_server(int s, struct msgbuf *msgp, int echo)
{
#ifdef UNIX_DOMAIN_SOCKETS
/*
connect_to_unix_server -- establish connection with server process via a unix-
- domain socket. Returns socket descriptor for server
+ domain socket. Returns socket descriptor for server
if successful.
*/
static int connect_to_unix_server(void)
#ifdef INTERNET_DOMAIN_SOCKETS
/*
internet_addr -- return the internet addr of the hostname or
- internet address passed. Return -1 on error.
+ internet address passed. Return -1 on error.
*/
int internet_addr(char *host)
{
#endif
/*
- connect_to_internet_server -- establish connection with server process via
- an internet domain socket. Returns socket
+ connect_to_internet_server -- establish connection with server process via
+ an internet domain socket. Returns socket
descriptor for server if successful.
*/
static int connect_to_internet_server(char *serverhost, unsigned short port)
#if defined(INTERNET_DOMAIN_SOCKETS) || defined(UNIX_DOMAIN_SOCKETS)
/*
disconnect_from_server -- inform the server that sending has finished, and wait for
- its reply.
+ its reply.
*/
void disconnect_from_server(int s, int echo)
{
if (fread(buf, 1, 18, fp)!=18) /* skip 18 bytes */
if(feof(fp))
- break;
+ break;
}
}
} else {
for (i = 1; i < argc; i++) {
int j;
- if (argc > i + 1 && !strcmp (argv[i], "-d")) {
- /* XEmacs change; allow more than one chdir. The
- idea is that the second chdir is to source-lisp,
- and that any Lisp files not under there have the
- full path specified. */
- i += 1;
- if (chdir (argv[i]) < 0) {
+ if (argc > i + 1 && !strcmp (argv[i], "-d")) {
+ /* XEmacs change; allow more than one chdir. The
+ idea is that the second chdir is to source-lisp,
+ and that any Lisp files not under there have the
+ full path specified. */
+ i += 1;
+ if (chdir (argv[i]) < 0) {
fatal("Could not change to directory ", argv[i]);
}
- continue;
- } else if (argv[i][0] == '-') {
+ continue;
+ } else if (argv[i][0] == '-') {
i++;
continue;
}
put_filename (const char *filename)
{
/* XEmacs change; don't strip directory information. */
- /* <= because sizeof includes the nul byte at the end. Not quite
- right, because it should include the length of the symbol +
- "\037[VF]" instead of simply 10. */
- assert(sizeof("\037S\n") + strlen(filename) + 10
- <= DOC_MAX_FILENAME_LENGTH);
-
- putc (037, outfile);
- putc ('S', outfile);
- fprintf (outfile, "%s\n", filename);
+ /* <= because sizeof includes the nul byte at the end. Not quite
+ right, because it should include the length of the symbol +
+ "\037[VF]" instead of simply 10. */
+ assert(sizeof("\037S\n") + strlen(filename) + 10
+ <= DOC_MAX_FILENAME_LENGTH);
+
+ putc (037, outfile);
+ putc ('S', outfile);
+ fprintf (outfile, "%s\n", filename);
return;
}
c = getc(infile);
/*
* SXEmacs uses proper indentation so we need to
- * search for `\t' instead of ' ' here.
+ * search for `\t' instead of ' ' here.
*/
if (c == '\t') {
while (c == '\t') {
fprintf(outfile, "\tCDOC%s(\"%s\", \"\\\n",
defvarflag ? "SYM" : "SUBR", buf);
} else {
- put_filename (filename); /* XEmacs addition */
+ put_filename (filename); /* XEmacs addition */
putc(037, outfile);
putc(defvarflag ? 'V' : 'F', outfile);
fprintf(outfile, "%s\n", buf);
Adds the filename a symbol or function was found in before its docstring;
there's no need for this with the load-history available, but we do it for
- consistency with the C parsing code.
+ consistency with the C parsing code.
*/
static void
}
} else if (!strcmp(buffer, "custom-declare-variable")) {
- char c1 = 0, c2 = 0;
- type = 'V';
-
- c = getc (infile);
- if (c == '\'') {
- read_lisp_symbol (infile, buffer);
- } else {
- if (c != '(') {
- fprintf(stderr, "\
+ char c1 = 0, c2 = 0;
+ type = 'V';
+
+ c = getc (infile);
+ if (c == '\'') {
+ read_lisp_symbol (infile, buffer);
+ } else {
+ if (c != '(') {
+ fprintf(stderr, "\
## unparsable name in custom-declare-variable in %s\n",
filename);
- continue;
- }
- read_lisp_symbol (infile, buffer);
- if (strcmp (buffer, "quote")) {
- fprintf(stderr, "\
+ continue;
+ }
+ read_lisp_symbol (infile, buffer);
+ if (strcmp (buffer, "quote")) {
+ fprintf(stderr, "\
## unparsable name in custom-declare-variable in %s\n",
filename);
- continue;
- }
- read_lisp_symbol (infile, buffer);
- c = getc (infile);
- if (c != ')') {
- fprintf(stderr, "\
+ continue;
+ }
+ read_lisp_symbol (infile, buffer);
+ c = getc (infile);
+ if (c != ')') {
+ fprintf(stderr, "\
## unparsable quoted name in custom-declare-variable in %s\n",
filename);
- continue;
- }
- }
-
- if (saved_string == 0) {
- /* Skip to end of line; remember the two
- previous chars. */
- while (c != '\n' && c >= 0) {
- c2 = c1;
- c1 = c;
- /* SXEmacs: shame we can't do this. */
- /* c = getc_skipping_iso2022(infile); */
- (void)getc (infile);
- }
-
- /* If two previous characters were " and \,
- this is a doc string. Otherwise, there is
- none. */
- if (c2 != '"' || c1 != '\\') {
+ continue;
+ }
+ }
+
+ if (saved_string == 0) {
+ /* Skip to end of line; remember the two
+ previous chars. */
+ while (c != '\n' && c >= 0) {
+ c2 = c1;
+ c1 = c;
+ /* SXEmacs: shame we can't do this. */
+ /* c = getc_skipping_iso2022(infile); */
+ (void)getc (infile);
+ }
+
+ /* If two previous characters were " and \,
+ this is a doc string. Otherwise, there is
+ none. */
+ if (c2 != '"' || c1 != '\\') {
#ifdef DEBUG
- fprintf(stderr, "\
+ fprintf(stderr, "\
## non-docstring in %s (%s)\n",
buffer, filename);
#endif /* DEBUG */
- continue;
- }
- }
+ continue;
+ }
+ }
- } else if (!strcmp(buffer, "fset") ||
+ } else if (!strcmp(buffer, "fset") ||
!strcmp(buffer, "defalias")) {
char c1 = 0, c2 = 0;
type = 'F';
In the latter case, the opening quote (and leading
backslash-newline) have already been read. */
- put_filename (filename); /* XEmacs addition */
+ put_filename (filename); /* XEmacs addition */
putc(037, outfile);
putc(type, outfile);
fprintf(outfile, "%s\n", buffer);
13) Deal with parsing of menu specifications.
--ben
-
+
*/
/* Long comment from jwz:
(much of this comment is outdated, and a lot of it is actually
implemented)
-
-
+
+
PROPOSAL FOR HOW THIS ALL OUGHT TO WORK
this isn't implemented yet, but this is the plan-in-progress
-
+
In general, it's accepted that the best way to internationalize is for all
messages to be referred to by a symbolic name (or number) and come out of a
table or tables, which are easy to change.
something has gone wrong. (Except to do things like remove assumptions
about the order of words within a sentence, or how pluralization works.)
- There are two parts to the task of displaying translated strings to the
+ There are two parts to the task of displaying translated strings to the
user: the first is to extract the strings which need to be translated from
the sources; and the second is to make some call which will translate those
strings before they are presented to the user.
-
+
The old way was to use the same form to do both, that is, GETTEXT() was both
the tag that we searched for to build a catalog, and was the form which did
the translation. The new plan is to separate these two things more: the
already, and the translation will get done in some more centralized, lower
level place.
- This program (make-msgfile.c) addresses the first part, extracting the
+ This program (make-msgfile.c) addresses the first part, extracting the
strings.
-
+
For the emacs C code, we need to recognize the following patterns:
-
+
message ("string" ... )
error ("string")
report_file_error ("string" ... )
signal_simple_error ("string" ... )
signal_simple_error_2 ("string" ... )
-
+
build_translated_string ("string")
#### add this and use it instead of build_string() in some places.
-
+
yes_or_no_p ("string" ... )
#### add this instead of funcalling Qyes_or_no_p directly.
barf_or_query_if_file_exists #### restructure this
check all callers of Fsignal #### restructure these
signal_error (Qerror ... ) #### change all of these to error()
-
+
And we also parse out the `interactive' prompts from DEFUN() forms.
-
+
#### When we've got a string which is a candidate for translation, we
should ignore it if it contains only format directives, that is, if
there are no alphabetic characters in it that are not a part of a `%'
directive. (Careful not to translate either "%s%s" or "%s: ".)
For the emacs Lisp code, we need to recognize the following patterns:
-
+
(message "string" ... )
(error "string" ... )
(format "string" ... )
(read-file-name "string" ... )
(temp-minibuffer-message "string")
(query-replace-read-args "string" ... )
-
+
I expect there will be a lot like the above; basically, any function which
is a commonly used wrapper around an eventual call to `message' or
`read-from-minibuffer' needs to be recognized by this program.
(dgettext "domain-name" "string") #### do we still need this?
-
+
things that should probably be restructured:
`princ' in cmdloop.el
`insert' in debug.el
face-interactive
help.el, syntax.el all messed up
-
+
BPW: (format) is a tricky case. If I use format to create a string
that I then send to a file, I probably don't want the string translated.
On the other hand, If the string gets used as an argument to (y-or-n-p)
"string" ... ;###translate
- where the magic token ";###translate" on a line means that the string
+ where the magic token ";###translate" on a line means that the string
constant on this line should go into the message catalog. This is analogous
to the magic ";###autoload" comments, and to the magic comments used in the
EPSF structuring conventions.
translations, there are hooks in a small number of low level places in
emacs.
- Assume the existence of a C function gettext(str) which returns the
+ Assume the existence of a C function gettext(str) which returns the
translation of `str' if there is one, otherwise returns `str'.
- message() takes a char* as its argument, and always filters it through
Solving the "translating too much" problem:
The concern has been raised that in this situation:
- "Help" is a string for which we know a translation;
- - someone visits a file called Help, and someone does something
+ - someone visits a file called Help, and someone does something
contrived like (error buffer-file-name)
then we would display the translation of Help, which would not be correct.
We can solve this by adding a bit to Lisp_String objects which identifies
them as having been read as literal constants from a .el or .elc file (as
- opposed to having been constructed at run time as it would in the above
+ opposed to having been constructed at run time as it would in the above
case.) To solve this:
- Fmessage() takes a lisp string as its first argument.
if (paren_count > 0)
paren_count--;
else
- unput (')');
+ unput (')');
if (paren_count == 0)
{
in_paren_counting = 0;
else
process_Lisp_file ();
fputc ('\n', yyout);
-
+
fclose (yyin);
}
BEGIN DO_LISP;
yylex ();
}
-
/*
Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore)
-Permission to use, copy, modify, and distribute this material
-for any purpose and without fee is hereby granted, provided
-that the above copyright notice and this permission notice
-appear in all copies, and that the name of Bellcore not be
-used in advertising or publicity pertaining to this
-material without the specific, prior written permission
-of an authorized representative of Bellcore. BELLCORE
-MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY
-OF THIS MATERIAL FOR ANY PURPOSE. IT IS PROVIDED "AS IS",
+Permission to use, copy, modify, and distribute this material
+for any purpose and without fee is hereby granted, provided
+that the above copyright notice and this permission notice
+appear in all copies, and that the name of Bellcore not be
+used in advertising or publicity pertaining to this
+material without the specific, prior written permission
+of an authorized representative of Bellcore. BELLCORE
+MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY
+OF THIS MATERIAL FOR ANY PURPOSE. IT IS PROVIDED "AS IS",
WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
*/
return (0);
}
-/* If we're in portable newline mode, we have to convert CRLF to the
+/* If we're in portable newline mode, we have to convert CRLF to the
local newline convention on output */
static int CRpending = 0;
{
int c1, c2;
int sawnewline = 1, neednewline = 0;
- /* The neednewline hack is necessary because the newline leading into
+ /* The neednewline hack is necessary because the newline leading into
a multipart boundary is part of the boundary, not the data */
while ((c1 = getc(infile)) != EOF) {
/*
Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore)
-Permission to use, copy, modify, and distribute this material
-for any purpose and without fee is hereby granted, provided
-that the above copyright notice and this permission notice
-appear in all copies, and that the name of Bellcore not be
-used in advertising or publicity pertaining to this
-material without the specific, prior written permission
-of an authorized representative of Bellcore. BELLCORE
-MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY
-OF THIS MATERIAL FOR ANY PURPOSE. IT IS PROVIDED "AS IS",
+Permission to use, copy, modify, and distribute this material
+for any purpose and without fee is hereby granted, provided
+that the above copyright notice and this permission notice
+appear in all copies, and that the name of Bellcore not be
+used in advertising or publicity pertaining to this
+material without the specific, prior written permission
+of an authorized representative of Bellcore. BELLCORE
+MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY
+OF THIS MATERIAL FOR ANY PURPOSE. IT IS PROVIDED "AS IS",
WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
*/
#define BASE64 1
/* movemail foo bar -- move file foo to file bar,
locking file foo.
Copyright (C) 1986, 1992, 1993, 1994, 1996 Free Software Foundation, Inc.
-
+
Copyright (C) 2005 Johann "Myrkraverk" Oskarsson <johann@myrkraverk.com>
This file is part of SXEmacs.
* form "po:username". This will cause movemail to open a connection
* to a pop server running on $MAILHOST (environment variable).
* Movemail must be setuid to root in order to work with POP.
- *
+ *
* New module: popmail.c
* Modified routines:
* main - added code within #ifdef MAIL_USE_POP; added setuid
- * (getuid ()) after POP code.
+ * (getuid ()) after POP code.
* New routines in movemail.c:
* get_errmsg - return pointer to system error message
*
{"verbose", no_argument, NULL, 'v'},
{0}
};
-#endif
+#endif
#define DOTLOCKING 0
-#define FLOCKING 1
+#define FLOCKING 1
#define LOCKFING 2
-#define MMDF 3
+#define MMDF 3
#define LOCKING 4
#if defined(MAIL_LOCK_FLOCK) && defined(HAVE_FLOCK)
char buf[1024];
while (1) {
nread = read(indesc, buf, sizeof buf);
- if (nread < 0 ||
+ if (nread < 0 ||
nread != write(outdesc, buf, nread)) {
int saved_errno = errno;
unlink(outname);
#ifdef HAVE_MKSTEMP
/* Remove all group and other permissions.. */
- umask(S_IRWXG|S_IRWXO);
+ umask(S_IRWXG|S_IRWXO);
desc = mkstemp(tempname);
#else
desc = open(tempname, O_WRONLY | O_CREAT | O_EXCL, 0666);
#include <stdio.h>
#include "../src/syspwd.h"
-#define POP_ERROR (-1)
+#define POP_ERROR (-1)
#define POP_RETRIEVED (0)
#define POP_DONE (1)
puts("\n");
puts("-a, --append\n\
- Append tag entries to existing tags file.");
+ Append tag entries to existing tags file.");
if (CTAGS)
puts("-B, --backward-search\n\
- Write the search commands for the tag entries using '?', the\n\
- backward-search command instead of '/', the forward-search command.");
+ Write the search commands for the tag entries using '?', the\n\
+ backward-search command instead of '/', the forward-search command.");
puts("-C, --c++\n\
- Treat files whose name suffix defaults to C language as C++ files.");
+ Treat files whose name suffix defaults to C language as C++ files.");
if (CTAGS)
puts("-d, --defines\n\
- Create tag entries for C #define constants and enum constants, too.");
+ Create tag entries for C #define constants and enum constants, too.");
else
puts("-D, --no-defines\n\
- Don't create tag entries for C #define constants and enum constants.\n\
+ Don't create tag entries for C #define constants and enum constants.\n\
This makes the tags file smaller.");
if (!CTAGS) {
puts("-i FILE, --include=FILE\n\
- Include a note in tag file indicating that, when searching for\n\
- a tag, one should also consult the tags file FILE after\n\
- checking the current file.");
+ Include a note in tag file indicating that, when searching for\n\
+ a tag, one should also consult the tags file FILE after\n\
+ checking the current file.");
puts("-l LANG, --language=LANG\n\
- Force the following files to be considered as written in the\n\
+ Force the following files to be considered as written in the\n\
named language up to the next --language=LANG option.");
}
#ifdef ETAGS_REGEXPS
puts("-r /REGEXP/, --regex=/REGEXP/ or --regex=@regexfile\n\
- Make a tag for each line matching pattern REGEXP in the\n\
- following files. regexfile is a file containing one REGEXP\n\
+ Make a tag for each line matching pattern REGEXP in the\n\
+ following files. regexfile is a file containing one REGEXP\n\
per line. REGEXP is anchored (as if preceded by ^).\n\
The form /REGEXP/NAME/ creates a named tag. For example Tcl\n\
named tags can be created with:\n\
--regex=/proc[ \\t]+\\([^ \\t]+\\)/\\1/.");
puts("-R, --no-regex\n\
- Don't create tags from regexps for the following files.");
+ Don't create tags from regexps for the following files.");
#endif /* ETAGS_REGEXPS */
puts("-o FILE, --output=FILE\n\
- Write the tags to FILE.");
+ Write the tags to FILE.");
#ifdef OO_BROWSER
puts("-O, --oo-browser\n\
Generate a specialized tags format used only by the Altrasoft OO-Browser.");
#endif
puts("-I, --ignore-indentation\n\
- Don't rely on indentation quite as much as normal. Currently,\n\
- this means not to assume that a closing brace in the first\n\
- column is the final brace of a function or structure\n\
- definition in C and C++.");
+ Don't rely on indentation quite as much as normal. Currently,\n\
+ this means not to assume that a closing brace in the first\n\
+ column is the final brace of a function or structure\n\
+ definition in C and C++.");
if (CTAGS) {
puts("-t, --typedefs\n\
- Generate tag entries for C typedefs.");
+ Generate tag entries for C typedefs.");
puts("-T, --typedefs-and-c++\n\
- Generate tag entries for C typedefs, C struct/enum/union tags,\n\
- and C++ member functions.");
+ Generate tag entries for C typedefs, C struct/enum/union tags,\n\
+ and C++ member functions.");
puts("-u, --update\n\
- Update the tag entries for the given files, leaving tag\n\
- entries for other files in place. Currently, this is\n\
- implemented by deleting the existing entries for the given\n\
- files and then rewriting the new entries at the end of the\n\
- tags file. It is often faster to simply rebuild the entire\n\
- tag file than to use this.");
+ Update the tag entries for the given files, leaving tag\n\
+ entries for other files in place. Currently, this is\n\
+ implemented by deleting the existing entries for the given\n\
+ files and then rewriting the new entries at the end of the\n\
+ tags file. It is often faster to simply rebuild the entire\n\
+ tag file than to use this.");
puts("-v, --vgrind\n\
- Generates an index of items intended for human consumption,\n\
- similar to the output of vgrind. The index is sorted, and\n\
- gives the page number of each item.");
+ Generates an index of items intended for human consumption,\n\
+ similar to the output of vgrind. The index is sorted, and\n\
+ gives the page number of each item.");
puts("-w, --no-warn\n\
- Suppress warning messages about entries defined in multiple\n\
- files.");
+ Suppress warning messages about entries defined in multiple\n\
+ files.");
puts("-x, --cxref\n\
- Like --vgrind, but in the style of cxref, rather than vgrind.\n\
- The output uses line numbers instead of page numbers, but\n\
- beyond that the differences are cosmetic; try both to see\n\
- which you like.");
+ Like --vgrind, but in the style of cxref, rather than vgrind.\n\
+ The output uses line numbers instead of page numbers, but\n\
+ beyond that the differences are cosmetic; try both to see\n\
+ which you like.");
}
puts("-V, --version\n\
- Print the version of the program.\n\
+ Print the version of the program.\n\
-h, --help\n\
- Print this help message.");
+ Print this help message.");
print_language_names();
/*
* If etags, always find typedefs and structure tags. Why not?
* Also default is to find macro constants, enum constants and
- * global variables.
+ * global variables.
*/
if (!CTAGS) {
typedefs = typedefs_and_cplusplus = constantypedefs = TRUE;
import, C_JAVA, st_C_ignore
package, C_JAVA, st_C_ignore
friend, C_PLPL, st_C_ignore
-extends, C_JAVA, st_C_javastruct
-implements, C_JAVA, st_C_javastruct
+extends, C_JAVA, st_C_javastruct
+implements, C_JAVA, st_C_javastruct
interface, C_JAVA, st_C_struct
-class, C_PLPL, st_C_class
+class, C_PLPL, st_C_class
namespace, C_PLPL, st_C_struct
-domain, C_STAR, st_C_struct
-union, 0, st_C_union
-struct, 0, st_C_struct
-enum, 0, st_C_enum
-typedef, 0, st_C_typedef
-define, 0, st_C_define
+domain, C_STAR, st_C_struct
+union, 0, st_C_union
+struct, 0, st_C_struct
+enum, 0, st_C_enum
+typedef, 0, st_C_typedef
+define, 0, st_C_define
inline, 0, st_C_inline
bool, C_PLPL, st_C_typespec
-long, 0, st_C_typespec
-short, 0, st_C_typespec
-int, 0, st_C_typespec
-char, 0, st_C_typespec
-float, 0, st_C_typespec
-double, 0, st_C_typespec
-signed, 0, st_C_typespec
+long, 0, st_C_typespec
+short, 0, st_C_typespec
+int, 0, st_C_typespec
+char, 0, st_C_typespec
+float, 0, st_C_typespec
+double, 0, st_C_typespec
+signed, 0, st_C_typespec
unsigned, 0, st_C_typespec
-auto, 0, st_C_typespec
-void, 0, st_C_typespec
-extern, 0, st_C_extern
-static, 0, st_C_typespec
-const, 0, st_C_const
+auto, 0, st_C_typespec
+void, 0, st_C_typespec
+extern, 0, st_C_extern
+static, 0, st_C_typespec
+const, 0, st_C_const
volatile, 0, st_C_typespec
explicit, C_PLPL, st_C_typespec
mutable, C_PLPL, st_C_typespec
* consider_token ()
* checks to see if the current token is at the start of a
* function or variable, or corresponds to a typedef, or
- * is a struct/union/enum tag, or #define, or an enum constant.
+ * is a struct/union/enum tag, or #define, or an enum constant.
*
* *IS_FUNC gets TRUE iff the token is a function or #define macro
* with args. C_EXT is which language we are looking at.
/*
* C_entries ()
* This routine finds functions, variables, typedefs,
- * #define's, enum constants and struct/union/enum definitions in
- * #C syntax and adds them to the list.
+ * #define's, enum constants and struct/union/enum definitions in
+ * #C syntax and adds them to the list.
*/
#define current_lb_is_new (newndx == curndx)
#define switch_line_buffers() (curndx = 1 - curndx)
== tend
#ifdef OO_BROWSER
/* Also name #define constants,
- enumerations and enum_labels.
- Conditionalize `funorvar' reference
- here or #defines will appear without
- their #names.
- -- Bob Weiner, Altrasoft, 4/25/1998 */
+ enumerations and enum_labels.
+ Conditionalize `funorvar' reference
+ here or #defines will appear without
+ their #names.
+ -- Bob Weiner, Altrasoft, 4/25/1998 */
||
((oo_browser_format || funorvar)
&&
* Prolog support (rewritten) by Anders Lindgren, Mar. 96
*
* Assumes that the predicate starts at column 0.
- * Only the first clause of a predicate is added.
+ * Only the first clause of a predicate is added.
*/
int prolog_pred PP((char *s, char *last));
void prolog_skip_comment PP((linebuffer * plb, FILE * inf));
return -1;
}
\f
-/*
+/*
* Support for Erlang -- Anders Lindgren, Feb 1996.
*
* Generates tags for functions, defines, and records.
free(last);
last = NULL;
} else if ((len = erlang_func(cp, last)) > 0) {
- /*
+ /*
* Function. Store the function name so that we only
* generates a tag for the first clause.
*/
}
/*
- * Handle attributes. Currently, tags are generated for defines
+ * Handle attributes. Currently, tags are generated for defines
* and records.
*
* They are on the form:
/* pop.c: client routines for talking to a POP3-protocol post-office server
Copyright (C) 1991, 1993, 1996, 1997, 1999, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007 Free Software Foundation, Inc.
+ 2005, 2006, 2007 Free Software Foundation, Inc.
Written by Jonathan Kamens, jik@security.ov.com.
This file is part of SXEmacs.
/*
* Function: pop_open (char *host, char *username, char *password,
- * int flags)
+ * int flags)
*
* Purpose: Establishes a connection with a post-office server, and
- * completes the authorization portion of the session.
+ * completes the authorization portion of the session.
*
* Arguments:
- * host The server host with which the connection should be
- * established. Optional. If omitted, internal
- * heuristics will be used to determine the server host,
- * if possible.
- * username
- * The username of the mail-drop to access. Optional.
- * If omitted, internal heuristics will be used to
- * determine the username, if possible.
- * password
- * The password to use for authorization. If omitted,
- * internal heuristics will be used to determine the
- * password, if possible.
- * flags A bit mask containing flags controlling certain
- * functions of the routine. Valid flags are defined in
- * the file pop.h
+ * host The server host with which the connection should be
+ * established. Optional. If omitted, internal
+ * heuristics will be used to determine the server host,
+ * if possible.
+ * username
+ * The username of the mail-drop to access. Optional.
+ * If omitted, internal heuristics will be used to
+ * determine the username, if possible.
+ * password
+ * The password to use for authorization. If omitted,
+ * internal heuristics will be used to determine the
+ * password, if possible.
+ * flags A bit mask containing flags controlling certain
+ * functions of the routine. Valid flags are defined in
+ * the file pop.h
*
* Return value: Upon successful establishment of a connection, a
- * non-null popserver will be returned. Otherwise, null will be
- * returned, and the string variable pop_error will contain an
- * explanation of the error.
+ * non-null popserver will be returned. Otherwise, null will be
+ * returned, and the string variable pop_error will contain an
+ * explanation of the error.
*/
popserver
pop_open (host, username, password, flags)
* Function: pop_stat
*
* Purpose: Issue the STAT command to the server and return (in the
- * value parameters) the number of messages in the maildrop and
- * the total size of the maildrop.
+ * value parameters) the number of messages in the maildrop and
+ * the total size of the maildrop.
*
* Return value: 0 on success, or non-zero with an error in pop_error
- * in failure.
+ * in failure.
*
* Side effects: On failure, may make further operations on the
- * connection impossible.
+ * connection impossible.
*/
int
pop_stat (server, count, size)
* Function: pop_list
*
* Purpose: Performs the POP "list" command and returns (in value
- * parameters) two malloc'd zero-terminated arrays -- one of
- * message IDs, and a parallel one of sizes.
+ * parameters) two malloc'd zero-terminated arrays -- one of
+ * message IDs, and a parallel one of sizes.
*
* Arguments:
- * server The pop connection to talk to.
- * message The number of the one message about which to get
- * information, or 0 to get information about all
- * messages.
+ * server The pop connection to talk to.
+ * message The number of the one message about which to get
+ * information, or 0 to get information about all
+ * messages.
*
* Return value: 0 on success, non-zero with error in pop_error on
- * failure.
+ * failure.
*
* Side effects: On failure, may make further operations on the
- * connection impossible.
+ * connection impossible.
*/
int
pop_list (server, message, IDs, sizes)
* Purpose: Retrieve a specified message from the maildrop.
*
* Arguments:
- * server The server to retrieve from.
- * message The message number to retrieve.
+ * server The server to retrieve from.
+ * message The message number to retrieve.
* markfrom
- * If true, then mark the string "From " at the beginning
- * of lines with '>'.
+ * If true, then mark the string "From " at the beginning
+ * of lines with '>'.
* msg_buf Output parameter to which a buffer containing the
- * message is assigned.
+ * message is assigned.
*
* Return value: The number of bytes in msg_buf, which may contain
- * embedded nulls, not including its final null, or -1 on error
- * with pop_error set.
+ * embedded nulls, not including its final null, or -1 on error
+ * with pop_error set.
*
* Side effects: May kill connection on error.
*/
* Purpose: Delete a specified message.
*
* Arguments:
- * server Server from which to delete the message.
- * message Message to delete.
+ * server Server from which to delete the message.
+ * message Message to delete.
*
* Return value: 0 on success, non-zero with error in pop_error
- * otherwise.
+ * otherwise.
*/
int
pop_delete (server, message)
* Purpose: Send a noop command to the server.
*
* Argument:
- * server The server to send to.
+ * server The server to send to.
*
* Return value: 0 on success, non-zero with error in pop_error
- * otherwise.
+ * otherwise.
*
* Side effects: Closes connection on error.
*/
* Purpose: Find out the highest seen message from the server.
*
* Arguments:
- * server The server.
+ * server The server.
*
* Return value: If successful, the highest seen message, which is
- * greater than or equal to 0. Otherwise, a negative number with
- * the error explained in pop_error.
+ * greater than or equal to 0. Otherwise, a negative number with
+ * the error explained in pop_error.
*
* Side effects: Closes the connection on error.
*/
* Purpose: Reset the server to its initial connect state
*
* Arguments:
- * server The server.
+ * server The server.
*
* Return value: 0 for success, non-0 with error in pop_error
- * otherwise.
+ * otherwise.
*
* Side effects: Closes the connection on error.
*/
* Purpose: Quit the connection to the server,
*
* Arguments:
- * server The server to quit.
+ * server The server to quit.
*
* Return value: 0 for success, non-zero otherwise with error in
- * pop_error.
+ * pop_error.
*
* Side Effects: The popserver passed in is unusable after this
- * function is called, even if an error occurs.
+ * function is called, even if an error occurs.
*/
int
pop_quit (server)
* Function: socket_connection
*
* Purpose: Opens the network connection with the mail host, without
- * doing any sort of I/O with it or anything.
+ * doing any sort of I/O with it or anything.
*
* Arguments:
- * host The host to which to connect.
+ * host The host to which to connect.
* flags Option flags.
*
* Return value: A file descriptor indicating the connection, or -1
- * indicating failure, in which case an error has been copied
- * into pop_error.
+ * indicating failure, in which case an error has been copied
+ * into pop_error.
*/
static int
socket_connection (host, flags)
* Function: pop_getline
*
* Purpose: Get a line of text from the connection and return a
- * pointer to it. The carriage return and linefeed at the end of
- * the line are stripped, but periods at the beginnings of lines
- * are NOT dealt with in any special way.
+ * pointer to it. The carriage return and linefeed at the end of
+ * the line are stripped, but periods at the beginnings of lines
+ * are NOT dealt with in any special way.
*
* Arguments:
- * server The server from which to get the line of text.
+ * server The server from which to get the line of text.
*
* Returns: The number of characters in the line, which is returned in
- * LINE, not including the final null. A return value of 0
- * indicates a blank line. A negative return value indicates an
- * error (in which case the contents of LINE are undefined. In
- * case of error, an error message is copied into pop_error.
+ * LINE, not including the final null. A return value of 0
+ * indicates a blank line. A negative return value indicates an
+ * error (in which case the contents of LINE are undefined. In
+ * case of error, an error message is copied into pop_error.
*
* Notes: The line returned is overwritten with each call to pop_getline.
*
data_used = (cp + 2) - server->buffer - found;
/* terminate the string to be returned */
- *cp = '\0';
+ *cp = '\0';
server->data -= data_used;
server->buffer_index += data_used;
* Function: sendline
*
* Purpose: Sends a line of text to the POP server. The line of text
- * passed into this function should NOT have the carriage return
- * and linefeed on the end of it. Periods at beginnings of lines
- * will NOT be treated specially by this function.
+ * passed into this function should NOT have the carriage return
+ * and linefeed on the end of it. Periods at beginnings of lines
+ * will NOT be treated specially by this function.
*
* Arguments:
- * server The server to which to send the text.
- * line The line of text to send.
+ * server The server to which to send the text.
+ * line The line of text to send.
*
* Return value: Upon successful completion, a value of 0 will be
- * returned. Otherwise, a non-zero value will be returned, and
- * an error will be copied into pop_error.
+ * returned. Otherwise, a non-zero value will be returned, and
+ * an error will be copied into pop_error.
*
* Side effects: Closes the connection on error.
*/
* Procedure: fullwrite
*
* Purpose: Just like write, but keeps trying until the entire string
- * has been written.
+ * has been written.
*
* Return value: Same as write. Pop_error is not set.
*/
* Procedure getok
*
* Purpose: Reads a line from the server. If the return indicator is
- * positive, return with a zero exit status. If not, return with
- * a negative exit status.
+ * positive, return with a zero exit status. If not, return with
+ * a negative exit status.
*
* Arguments:
- * server The server to read from.
+ * server The server to read from.
*
* Returns: 0 for success, else for failure and puts error in pop_error.
*
* Function: gettermination
*
* Purpose: Gets the next line and verifies that it is a termination
- * line (nothing but a dot).
+ * line (nothing but a dot).
*
* Return value: 0 on success, non-zero with pop_error set on error.
*
* Function pop_close
*
* Purpose: Close a pop connection, sending a "RSET" command to try to
- * preserve any changes that were made and a "QUIT" command to
- * try to get the server to quit, but ignoring any responses that
- * are received.
+ * preserve any changes that were made and a "QUIT" command to
+ * try to get the server to quit, but ignoring any responses that
+ * are received.
*
* Side effects: The server is unusable after this function returns.
- * Changes made to the maildrop since the session was started (or
- * since the last pop_reset) may be lost.
+ * Changes made to the maildrop since the session was started (or
+ * since the last pop_reset) may be lost.
*/
void
pop_close (server)
* Function: pop_trash
*
* Purpose: Like pop_close or pop_quit, but doesn't deallocate the
- * memory associated with the server. It is legal to call
- * pop_close or pop_quit after this function has been called.
+ * memory associated with the server. It is legal to call
+ * pop_close or pop_quit after this function has been called.
*/
static void
pop_trash (server)
/* pop.h: Header file for the "pop.c" client POP3 protocol.
Copyright (C) 1991, 1993, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007 Free Software Foundation, Inc.
+ 2005, 2006, 2007 Free Software Foundation, Inc.
Written by Jonathan Kamens, jik@security.ov.com.
This file is part of SXEmacs.
#define POP_NO_KERBEROS (1<<0)
#define POP_NO_HESIOD (1<<1)
-#define POP_NO_GETPASS (1<<2)
+#define POP_NO_GETPASS (1<<2)
#ifdef __STDC__
#define _ARGS(a) a
extern void pop_close _ARGS((popserver));
#undef _ARGS
-
}
/* This call returns the time since the last reset_watch call. The time
- is returned as a string with the format <seconds>.<micro-seconds>
+ is returned as a string with the format <seconds>.<micro-seconds>
If reset_watch was not called yet, exit. */
static char *get_time(void)
/* Order size using quicksort. This implementation incorporates
four optimizations discussed in Sedgewick:
-
- 1. Non-recursive, using an explicit stack of pointer that store the
- next array partition to sort. To save time, this maximum amount
- of space required to store an array of MAX_INT is allocated on the
- stack. Assuming a 32-bit integer, this needs only 32 *
+
+ 1. Non-recursive, using an explicit stack of pointer that store the
+ next array partition to sort. To save time, this maximum amount
+ of space required to store an array of MAX_INT is allocated on the
+ stack. Assuming a 32-bit integer, this needs only 32 *
sizeof (stack_node) == 136 bits. Pretty cheap, actually.
2. Choose the pivot element using a median-of-three decision tree.
- This reduces the probability of selecting a bad pivot value and
+ This reduces the probability of selecting a bad pivot value and
eliminates certain extraneous comparisons.
3. Only quicksorts TOTAL_ELEMS / MAX_THRESH partitions, leaving
- insertion sort to order the MAX_THRESH items within each partition.
+ insertion sort to order the MAX_THRESH items within each partition.
This is a big win, since insertion sort is faster for small, mostly
sorted array segments.
-
+
4. The larger of the two sub-partitions is always pushed onto the
stack first, with the algorithm then concentrating on the
smaller partition. This *guarantees* no more than log (n)
int size;
int (*cmp) ();
{
- /* Allocating SIZE bytes for a pivot buffer facilitates a better
+ /* Allocating SIZE bytes for a pivot buffer facilitates a better
algorithm below since we can do comparisons directly on the pivot. */
char *pivot_buffer = (char *)alloca(size);
int max_thresh = MAX_THRESH * size;
char *pivot = pivot_buffer;
{
/* Select median value from among LO, MID, and HI. Rearrange
- LO and HI so the three values are sorted. This lowers the
- probability of picking a pathological pivot value and
+ LO and HI so the three values are sorted. This lowers the
+ probability of picking a pathological pivot value and
skips a comparison for both the LEFT_PTR and RIGHT_PTR. */
char *mid =
left_ptr = lo + size;
right_ptr = hi - size;
- /* Here's the famous ``collapse the walls'' section of quicksort.
- Gotta like those tight inner loops! They are the main reason
+ /* Here's the famous ``collapse the walls'' section of quicksort.
+ Gotta like those tight inner loops! They are the main reason
that this algorithm runs much faster than others. */
do {
while (CMP(left_ptr, pivot) < 0)
}
/* Set up pointers for next iteration. First determine whether
- left and right partitions are below the threshold size. If so,
+ left and right partitions are below the threshold size. If so,
ignore one or both. Otherwise, push the larger partition's
bounds on the stack and continue sorting the smaller one. */
}
/* Once the BASE_PTR array is partially sorted by quicksort the rest
- is completely sorted using insertion sort, since this is efficient
- for partitions below MAX_THRESH size. BASE_PTR points to the beginning
+ is completely sorted using insertion sort, since this is efficient
+ for partitions below MAX_THRESH size. BASE_PTR points to the beginning
of the array to sort, and END_PTR points at the very last element in
the array (*not* one beyond it!). */
if (tmp_ptr != base_ptr)
SWAP(tmp_ptr, base_ptr, size);
- /* Insertion sort, running from left-hand-side up to `right-hand-side.'
+ /* Insertion sort, running from left-hand-side up to `right-hand-side.'
Pretty much straight out of the original GNU qsort routine. */
for (run_ptr = base_ptr + size;
/* Give this program DOCSTR.mm.nn as standard input
and it outputs to standard output
a file of texinfo input containing the doc strings.
-
+
This version sorts the output by function name.
*/
/*
* yow.c
- *
+ *
* Print a quotation from Zippy the Pinhead.
* Qux <Kaufman-David@Yale> March 6, 1986
- *
+ *
* With dynamic memory allocation.
*/
#ifdef vms
int sz = snprintf(file, sizeof(file), "%s%s", PATH_DATA, YOW_FILE);
#else
- int sz = snprintf(file, sizeof(file), "%s/%s", PATH_DATA, YOW_FILE);
+ int sz = snprintf(file, sizeof(file), "%s/%s", PATH_DATA, YOW_FILE);
#endif
assert(sz>=0 && sz<sizeof(file));
#else /* !PATH_DATA */