mktime: add libc-config dependency
[gnulib.git] / doc / standards.texi
blob86c26bb9242a51e5c58966531895b09a44064492
1 \input texinfo @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename standards.info
4 @settitle GNU Coding Standards
5 @c This date is automagically updated when you save this file:
6 @set lastupdate August 3, 2018
7 @c %**end of header
9 @dircategory GNU organization
10 @direntry
11 * Standards: (standards).       GNU coding standards.
12 @end direntry
14 @c @setchapternewpage odd
15 @setchapternewpage off
17 @c Put everything in one index (arbitrarily chosen to be the concept index).
18 @syncodeindex fn cp
19 @syncodeindex ky cp
20 @syncodeindex pg cp
21 @syncodeindex vr cp
23 @c This is used by a cross ref in make-stds.texi
24 @set CODESTD  1
26 @copying
27 The GNU coding standards, last updated @value{lastupdate}.
29 Copyright @copyright{} 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
30 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
31 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Free Software Foundation, Inc.
33 Permission is granted to copy, distribute and/or modify this document
34 under the terms of the GNU Free Documentation License, Version 1.3 or
35 any later version published by the Free Software Foundation; with no
36 Invariant Sections, no Front-Cover Texts, and no Back-Cover
37 Texts.  A copy of the license is included in the section entitled
38 ``GNU Free Documentation License''.
39 @end copying
41 @titlepage
42 @title GNU Coding Standards
43 @author Richard Stallman, et al.
44 @author last updated @value{lastupdate}
45 @page
46 @vskip 0pt plus 1filll
47 @insertcopying
48 @end titlepage
50 @contents
52 @ifnottex
53 @node Top
54 @top GNU Coding Standards
56 @insertcopying
57 @end ifnottex
59 @menu
60 * Preface::                     About the GNU Coding Standards.
61 * Legal Issues::                Keeping free software free.
62 * Design Advice::               General program design.
63 * Program Behavior::            Program behavior for all programs
64 * Writing C::                   Making the best use of C.
65 * Documentation::               Documenting programs.
66 * Managing Releases::           The release process.
67 * References::                  Mentioning non-free software or documentation.
68 * GNU Free Documentation License::  Copying and sharing this manual.
69 * Index::
71 @end menu
73 @node Preface
74 @chapter About the GNU Coding Standards
76 The GNU Coding Standards were written by Richard Stallman and other GNU
77 Project volunteers.  Their purpose is to make the GNU system clean,
78 consistent, and easy to install.  This document can also be read as a
79 guide to writing portable, robust and reliable programs.  It focuses on
80 programs written in C, but many of the rules and principles are useful
81 even if you write in another programming language.  The rules often
82 state reasons for writing in a certain way.
84 @cindex where to obtain @code{standards.texi}
85 @cindex downloading this manual
86 If you did not obtain this file directly from the GNU project and
87 recently, please check for a newer version.  You can get the GNU
88 Coding Standards from the GNU web server in many
89 different formats, including the Texinfo source, PDF, HTML, DVI, plain
90 text, and more, at: @uref{https://www.gnu.org/prep/standards/}.
92 If you are maintaining an official GNU package, in addition to this
93 document, please read and follow the GNU maintainer information
94 (@pxref{Top, , Contents, maintain, Information for Maintainers of GNU
95 Software}).
97 @cindex @code{gnustandards-commit@@gnu.org} mailing list
98 If you want to receive diffs for every change to these GNU documents,
99 join the mailing list @code{gnustandards-commit@@gnu.org}, via the web
100 interface at
101 @url{https://lists.gnu.org/mailman/listinfo/gnustandards-commit}.
102 Archives are also available there.
104 @cindex @code{bug-standards@@gnu.org} email address
105 @cindex Savannah repository for gnustandards
106 @cindex gnustandards project repository
107 Please send corrections or suggestions for this document to
108 @email{bug-standards@@gnu.org}.  If you make a suggestion, please
109 include a suggested new wording for it, to help us consider the
110 suggestion efficiently.  We prefer a context diff to the Texinfo
111 source, but if that's difficult for you, you can make a context diff
112 for some other version of this document, or propose it in any way that
113 makes it clear.  The source repository for this document can be found
114 at @url{https://savannah.gnu.org/projects/gnustandards}.
116 These standards cover the minimum of what is important when writing a
117 GNU package.  Likely, the need for additional standards will come up.
118 Sometimes, you might suggest that such standards be added to this
119 document.  If you think your standards would be generally useful, please
120 do suggest them.
122 You should also set standards for your package on many questions not
123 addressed or not firmly specified here.  The most important point is to
124 be self-consistent---try to stick to the conventions you pick, and try
125 to document them as much as possible.  That way, your program will be
126 more maintainable by others.
128 The GNU Hello program serves as an example of how to follow the GNU
129 coding standards for a trivial program.
130 @uref{https://www.gnu.org/software/hello/hello.html}.
132 This release of the GNU Coding Standards was last updated
133 @value{lastupdate}.
136 @node Legal Issues
137 @chapter Keeping Free Software Free
138 @cindex legal aspects
140 This chapter discusses how you can make sure that GNU software
141 avoids legal difficulties, and other related issues.
143 @menu
144 * Reading Non-Free Code::       Referring to proprietary programs.
145 * Contributions::               Accepting contributions.
146 * Trademarks::                  How we deal with trademark issues.
147 @end menu
149 @node Reading Non-Free Code
150 @section Referring to Proprietary Programs
151 @cindex proprietary programs
152 @cindex avoiding proprietary code
154 Don't in any circumstances refer to Unix source code for or during
155 your work on GNU!  (Or to any other proprietary programs.)
157 If you have a vague recollection of the internals of a Unix program,
158 this does not absolutely mean you can't write an imitation of it, but
159 do try to organize the imitation internally along different lines,
160 because this is likely to make the details of the Unix version
161 irrelevant and dissimilar to your results.
163 For example, Unix utilities were generally optimized to minimize
164 memory use; if you go for speed instead, your program will be very
165 different.  You could keep the entire input file in memory and scan it
166 there instead of using stdio.  Use a smarter algorithm discovered more
167 recently than the Unix program.  Eliminate use of temporary files.  Do
168 it in one pass instead of two (we did this in the assembler).
170 Or, on the contrary, emphasize simplicity instead of speed.  For some
171 applications, the speed of today's computers makes simpler algorithms
172 adequate.
174 Or go for generality.  For example, Unix programs often have static
175 tables or fixed-size strings, which make for arbitrary limits; use
176 dynamic allocation instead.  Make sure your program handles NULs and
177 other funny characters in the input files.  Add a programming language
178 for extensibility and write part of the program in that language.
180 Or turn some parts of the program into independently usable libraries.
181 Or use a simple garbage collector instead of tracking precisely when
182 to free memory, or use a new GNU facility such as obstacks.
185 @node Contributions
186 @section Accepting Contributions
187 @cindex legal papers
188 @cindex accepting contributions
190 If the program you are working on is copyrighted by the Free Software
191 Foundation, then when someone else sends you a piece of code to add to
192 the program, we need legal papers to use it---just as we asked you to
193 sign papers initially.  @emph{Each} person who makes a nontrivial
194 contribution to a program must sign some sort of legal papers in order
195 for us to have clear title to the program; the main author alone is not
196 enough.
198 So, before adding in any contributions from other people, please tell
199 us, so we can arrange to get the papers.  Then wait until we tell you
200 that we have received the signed papers, before you actually use the
201 contribution.
203 This applies both before you release the program and afterward.  If
204 you receive diffs to fix a bug, and they make significant changes, we
205 need legal papers for that change.
207 This also applies to comments and documentation files.  For copyright
208 law, comments and code are just text.  Copyright applies to all kinds of
209 text, so we need legal papers for all kinds.
211 We know it is frustrating to ask for legal papers; it's frustrating for
212 us as well.  But if you don't wait, you are going out on a limb---for
213 example, what if the contributor's employer won't sign a disclaimer?
214 You might have to take that code out again!
216 You don't need papers for changes of a few lines here or there, since
217 they are not significant for copyright purposes.  Also, you don't need
218 papers if all you get from the suggestion is some ideas, not actual code
219 which you use.  For example, if someone sent you one implementation, but
220 you write a different implementation of the same idea, you don't need to
221 get papers.
223 The very worst thing is if you forget to tell us about the other
224 contributor.  We could be very embarrassed in court some day as a
225 result.
227 We have more detailed advice for maintainers of GNU packages.  If you
228 have reached the stage of maintaining a GNU program (whether released
229 or not), please take a look: @pxref{Legal Matters,,, maintain,
230 Information for GNU Maintainers}.
233 @node Trademarks
234 @section Trademarks
235 @cindex trademarks
237 Please do not include any trademark acknowledgements in GNU software
238 packages or documentation.
240 Trademark acknowledgements are the statements that such-and-such is a
241 trademark of so-and-so.  The GNU Project has no objection to the basic
242 idea of trademarks, but these acknowledgements feel like kowtowing,
243 and there is no legal requirement for them, so we don't use them.
245 What is legally required, as regards other people's trademarks, is to
246 avoid using them in ways which a reader might reasonably understand as
247 naming or labeling our own programs or activities.  For example, since
248 ``Objective C'' is (or at least was) a trademark, we made sure to say
249 that we provide a ``compiler for the Objective C language'' rather
250 than an ``Objective C compiler''.  The latter would have been meant as
251 a shorter way of saying the former, but it does not explicitly state
252 the relationship, so it could be misinterpreted as using ``Objective
253 C'' as a label for the compiler rather than for the language.
255 Please don't use ``win'' as an abbreviation for Microsoft Windows in
256 GNU software or documentation.  In hacker terminology, calling
257 something a ``win'' is a form of praise.  You're free to praise
258 Microsoft Windows on your own if you want, but please don't do so in
259 GNU packages.  Please write ``Windows'' in full, or abbreviate it to
260 ``w.''  @xref{System Portability}.
262 @node Design Advice
263 @chapter General Program Design
264 @cindex program design
266 This chapter discusses some of the issues you should take into
267 account when designing your program.
269 @c                         Standard or ANSI C
271 @c In 1989 the American National Standards Institute (ANSI) standardized
272 @c C   as  standard  X3.159-1989.    In  December   of  that   year  the
273 @c International Standards Organization ISO  adopted the ANSI C standard
274 @c making  minor changes.   In 1990  ANSI then  re-adopted  ISO standard
275 @c C. This version of C is known as either ANSI C or Standard C.
277 @c A major revision of the C Standard appeared in 1999.
279 @menu
280 * Source Language::             Which languages to use.
281 * Compatibility::               Compatibility with other implementations.
282 * Using Extensions::            Using non-standard features.
283 * Standard C::                  Using standard C features.
284 * Conditional Compilation::     Compiling code only if a conditional is true.
285 @end menu
287 @node Source Language
288 @section Which Languages to Use
289 @cindex programming languages
291 When you want to use a language that gets compiled and runs at high
292 speed, the best language to use is C.  C++ is ok too, but please don't
293 make heavy use of templates.  So is Java, if you compile it.
295 When highest efficiency is not required, other languages commonly used
296 in the free software community, such as Lisp, Scheme, Python, Ruby, and
297 Java, are OK too.  Scheme, as implemented by GNU@tie{}Guile, plays a
298 particular role in the GNU System: it is the preferred language to
299 extend programs written in C/C++, and also a fine language for a wide
300 range of applications.  The more GNU components use Guile and Scheme,
301 the more users are able to extend and combine them (@pxref{The Emacs
302 Thesis,,, guile, GNU Guile Reference Manual}).
304 Many programs are designed to be extensible: they include an interpreter
305 for a language that is higher level than C.  Often much of the program
306 is written in that language, too.  The Emacs editor pioneered this
307 technique.
309 @cindex Guile
310 @cindex GNOME and Guile
311 The standard extensibility interpreter for GNU software is Guile
312 (@uref{https://www.gnu.org/@/software/@/guile/}), which implements the
313 language Scheme (an especially clean and simple dialect of Lisp).
314 Guile also includes bindings for GTK+/GNOME, making it practical to
315 write modern GUI functionality within Guile.  We don't reject programs
316 written in other ``scripting languages'' such as Perl and Python, but
317 using Guile is the path that will lead to overall consistency of the
318 GNU system.
321 @node Compatibility
322 @section Compatibility with Other Implementations
323 @cindex compatibility with C and POSIX standards
324 @cindex C compatibility
325 @cindex POSIX compatibility
327 With occasional exceptions, utility programs and libraries for GNU
328 should be upward compatible with those in Berkeley Unix, and upward
329 compatible with Standard C if Standard C specifies their
330 behavior, and upward compatible with POSIX if POSIX specifies
331 their behavior.
333 When these standards conflict, it is useful to offer compatibility
334 modes for each of them.
336 @cindex options for compatibility
337 Standard C and POSIX prohibit many kinds of extensions.  Feel
338 free to make the extensions anyway, and include a @samp{--ansi},
339 @samp{--posix}, or @samp{--compatible} option to turn them off.
340 However, if the extension has a significant chance of breaking any real
341 programs or scripts, then it is not really upward compatible.  So you
342 should try to redesign its interface to make it upward compatible.
344 @cindex @code{POSIXLY_CORRECT}, environment variable
345 Many GNU programs suppress extensions that conflict with POSIX if the
346 environment variable @code{POSIXLY_CORRECT} is defined (even if it is
347 defined with a null value).  Please make your program recognize this
348 variable if appropriate.
350 When a feature is used only by users (not by programs or command
351 files), and it is done poorly in Unix, feel free to replace it
352 completely with something totally different and better.  (For example,
353 @code{vi} is replaced with Emacs.)  But it is nice to offer a compatible
354 feature as well.  (There is a free @code{vi} clone, so we offer it.)
356 Additional useful features are welcome regardless of whether
357 there is any precedent for them.
359 @node Using Extensions
360 @section Using Non-standard Features
361 @cindex non-standard extensions
363 Many GNU facilities that already exist support a number of convenient
364 extensions over the comparable Unix facilities.  Whether to use these
365 extensions in implementing your program is a difficult question.
367 On the one hand, using the extensions can make a cleaner program.
368 On the other hand, people will not be able to build the program
369 unless the other GNU tools are available.  This might cause the
370 program to work on fewer kinds of machines.
372 With some extensions, it might be easy to provide both alternatives.
373 For example, you can define functions with a ``keyword'' @code{INLINE}
374 and define that as a macro to expand into either @code{inline} or
375 nothing, depending on the compiler.
377 In general, perhaps it is best not to use the extensions if you can
378 straightforwardly do without them, but to use the extensions if they
379 are a big improvement.
381 An exception to this rule are the large, established programs (such as
382 Emacs) which run on a great variety of systems.  Using GNU extensions in
383 such programs would make many users unhappy, so we don't do that.
385 Another exception is for programs that are used as part of compilation:
386 anything that must be compiled with other compilers in order to
387 bootstrap the GNU compilation facilities.  If these require the GNU
388 compiler, then no one can compile them without having them installed
389 already.  That would be extremely troublesome in certain cases.
391 @node Standard C
392 @section Standard C and Pre-Standard C
393 @cindex ANSI C standard
395 1989 Standard C is widespread enough now that it is ok to use its
396 features in programs.  There is one exception: do not ever use the
397 ``trigraph'' feature of Standard C.
399 The 1999 and 2011 editions of Standard C are not fully supported
400 on all platforms.  If you aim to support compilation by
401 compilers other than GCC, you should not require these C
402 features in your programs.  It is ok to use these features
403 conditionally when the compiler supports them.
405 If your program is only meant to compile with GCC, then you can
406 use these features if GCC supports them, when they give substantial
407 benefit.
409 However, it is easy to support pre-standard compilers in most programs,
410 so if you know how to do that, feel free.
412 @cindex function prototypes
413 To support pre-standard C, instead of writing function definitions in
414 standard prototype form,
416 @example
418 foo (int x, int y)
419 @dots{}
420 @end example
422 @noindent
423 write the definition in pre-standard style like this,
425 @example
427 foo (x, y)
428      int x, y;
429 @dots{}
430 @end example
432 @noindent
433 and use a separate declaration to specify the argument prototype:
435 @example
436 int foo (int, int);
437 @end example
439 You need such a declaration anyway, in a header file, to get the benefit
440 of prototypes in all the files where the function is called.  And once
441 you have the declaration, you normally lose nothing by writing the
442 function definition in the pre-standard style.
444 This technique does not work for integer types narrower than @code{int}.
445 If you think of an argument as being of a type narrower than @code{int},
446 declare it as @code{int} instead.
448 There are a few special cases where this technique is hard to use.  For
449 example, if a function argument needs to hold the system type
450 @code{dev_t}, you run into trouble, because @code{dev_t} is shorter than
451 @code{int} on some machines; but you cannot use @code{int} instead,
452 because @code{dev_t} is wider than @code{int} on some machines.  There
453 is no type you can safely use on all machines in a non-standard
454 definition.  The only way to support non-standard C and pass such an
455 argument is to check the width of @code{dev_t} using Autoconf and choose
456 the argument type accordingly.  This may not be worth the trouble.
458 In order to support pre-standard compilers that do not recognize
459 prototypes, you may want to use a preprocessor macro like this:
461 @example
462 /* Declare the prototype for a general external function.  */
463 #if defined (__STDC__) || defined (WINDOWSNT)
464 #define P_(proto) proto
465 #else
466 #define P_(proto) ()
467 #endif
468 @end example
470 @node Conditional Compilation
471 @section Conditional Compilation
473 When supporting configuration options already known when building your
474 program we prefer using @code{if (... )} over conditional compilation,
475 as in the former case the compiler is able to perform more extensive
476 checking of all possible code paths.
478 For example, please write
480 @smallexample
481   if (HAS_FOO)
482     ...
483   else
484     ...
485 @end smallexample
487 @noindent
488 instead of:
490 @smallexample
491   #ifdef HAS_FOO
492     ...
493   #else
494     ...
495   #endif
496 @end smallexample
498 A modern compiler such as GCC will generate exactly the same code in
499 both cases, and we have been using similar techniques with good success
500 in several projects.  Of course, the former method assumes that
501 @code{HAS_FOO} is defined as either 0 or 1.
503 While this is not a silver bullet solving all portability problems,
504 and is not always appropriate, following this policy would have saved
505 GCC developers many hours, or even days, per year.
507 In the case of function-like macros like @code{REVERSIBLE_CC_MODE} in
508 GCC which cannot be simply used in @code{if (...)} statements, there is
509 an easy workaround.  Simply introduce another macro
510 @code{HAS_REVERSIBLE_CC_MODE} as in the following example:
512 @smallexample
513   #ifdef REVERSIBLE_CC_MODE
514   #define HAS_REVERSIBLE_CC_MODE 1
515   #else
516   #define HAS_REVERSIBLE_CC_MODE 0
517   #endif
518 @end smallexample
520 @node Program Behavior
521 @chapter Program Behavior for All Programs
523 This chapter describes conventions for writing robust
524 software.  It also describes general standards for error messages, the
525 command line interface, and how libraries should behave.
527 @menu
528 * Non-GNU Standards::           We consider standards such as POSIX;
529                                   we don't "obey" them.
530 * Semantics::                   Writing robust programs.
531 * Libraries::                   Library behavior.
532 * Errors::                      Formatting error messages.
533 * User Interfaces::             Standards about interfaces generally.
534 * Graphical Interfaces::        Standards for graphical interfaces.
535 * Command-Line Interfaces::     Standards for command line interfaces.
536 * Dynamic Plug-In Interfaces::  Standards for dynamic plug-in interfaces.
537 * Option Table::                Table of long options.
538 * OID Allocations::             Table of OID slots for GNU.
539 * Memory Usage::                When and how to care about memory needs.
540 * File Usage::                  Which files to use, and where.
541 @end menu
543 @node Non-GNU Standards
544 @section Non-GNU Standards
546 The GNU Project regards standards published by other organizations as
547 suggestions, not orders.  We consider those standards, but we do not
548 ``obey'' them.  In developing a GNU program, you should implement
549 an outside standard's specifications when that makes the GNU system
550 better overall in an objective sense.  When it doesn't, you shouldn't.
552 In most cases, following published standards is convenient for
553 users---it means that their programs or scripts will work more
554 portably.  For instance, GCC implements nearly all the features of
555 Standard C as specified by that standard.  C program developers would
556 be unhappy if it did not.  And GNU utilities mostly follow
557 specifications of POSIX.2; shell script writers and users would be
558 unhappy if our programs were incompatible.
560 But we do not follow either of these specifications rigidly, and there
561 are specific points on which we decided not to follow them, so as to
562 make the GNU system better for users.
564 For instance, Standard C says that nearly all extensions to C are
565 prohibited.  How silly!  GCC implements many extensions, some of which
566 were later adopted as part of the standard.  If you want these
567 constructs to give an error message as ``required'' by the standard,
568 you must specify @samp{--pedantic}, which was implemented only so that
569 we can say ``GCC is a 100% implementation of the standard'', not
570 because there is any reason to actually use it.
572 POSIX.2 specifies that @samp{df} and @samp{du} must output sizes by
573 default in units of 512 bytes.  What users want is units of 1k, so
574 that is what we do by default.  If you want the ridiculous behavior
575 ``required'' by POSIX, you must set the environment variable
576 @samp{POSIXLY_CORRECT} (which was originally going to be named
577 @samp{POSIX_ME_HARDER}).
579 GNU utilities also depart from the letter of the POSIX.2 specification
580 when they support long-named command-line options, and intermixing
581 options with ordinary arguments.  This minor incompatibility with
582 POSIX is never a problem in practice, and it is very useful.
584 In particular, don't reject a new feature, or remove an old one,
585 merely because a standard says it is ``forbidden'' or ``deprecated''.
588 @node Semantics
589 @section Writing Robust Programs
591 @cindex arbitrary limits on data
592 Avoid arbitrary limits on the length or number of @emph{any} data
593 structure, including file names, lines, files, and symbols, by allocating
594 all data structures dynamically.  In most Unix utilities, ``long lines
595 are silently truncated''.  This is not acceptable in a GNU utility.
597 @cindex @code{NUL} characters
598 @findex libiconv
599 Utilities reading files should not drop NUL characters, or any other
600 nonprinting characters.  Programs should work properly with multibyte
601 character encodings, such as UTF-8.  You can use libiconv to deal with
602 a range of encodings.
604 @cindex error messages
605 Check every system call for an error return, unless you know you wish
606 to ignore errors.  Include the system error text (from
607 @code{strerror}, or equivalent) in @emph{every} error message
608 resulting from a failing system call, as well as the name of the file
609 if any and the name of the utility.  Just ``cannot open foo.c'' or
610 ``stat failed'' is not sufficient.
612 @cindex @code{malloc} return value
613 @cindex memory allocation failure
614 Check every call to @code{malloc} or @code{realloc} to see if it
615 returned @code{NULL}.  Check @code{realloc} even if you are making the
616 block smaller; in a system that rounds block sizes to a power of 2,
617 @code{realloc} may get a different block if you ask for less space.
619 You must expect @code{free} to alter the contents of the block that was
620 freed.  Anything you want to fetch from the block, you must fetch before
621 calling @code{free}.
623 If @code{malloc} fails in a noninteractive program, make that a fatal
624 error.  In an interactive program (one that reads commands from the
625 user), it is better to abort the command and return to the command
626 reader loop.  This allows the user to kill other processes to free up
627 virtual memory, and then try the command again.
629 @cindex command-line arguments, decoding
630 Use @code{getopt_long} to decode arguments, unless the argument syntax
631 makes this unreasonable.
633 When static storage is to be written in during program execution, use
634 explicit C code to initialize it.  This way, restarting the program
635 (without reloading it), or part of it, will reinitialize those
636 variables.  Reserve C initialized declarations for data that will not
637 be changed.
638 @c ADR: why?
640 Try to avoid low-level interfaces to obscure Unix data structures (such
641 as file directories, utmp, or the layout of kernel memory), since these
642 are less likely to work compatibly.  If you need to find all the files
643 in a directory, use @code{readdir} or some other high-level interface.
644 These are supported compatibly by GNU.
646 @cindex signal handling
647 The preferred signal handling facilities are the BSD variant of
648 @code{signal}, and the POSIX @code{sigaction} function; the
649 alternative USG @code{signal} interface is an inferior design.
651 Nowadays, using the POSIX signal functions may be the easiest way
652 to make a program portable.  If you use @code{signal}, then on GNU/Linux
653 systems running GNU libc version 1, you should include
654 @file{bsd/signal.h} instead of @file{signal.h}, so as to get BSD
655 behavior.  It is up to you whether to support systems where
656 @code{signal} has only the USG behavior, or give up on them.
658 @cindex impossible conditions
659 In error checks that detect ``impossible'' conditions, just abort.
660 There is usually no point in printing any message.  These checks
661 indicate the existence of bugs.  Whoever wants to fix the bugs will have
662 to read the source code and run a debugger.  So explain the problem with
663 comments in the source.  The relevant data will be in variables, which
664 are easy to examine with the debugger, so there is no point moving them
665 elsewhere.
667 Do not use a count of errors as the exit status for a program.
668 @emph{That does not work}, because exit status values are limited to 8
669 bits (0 through 255).  A single run of the program might have 256
670 errors; if you try to return 256 as the exit status, the parent process
671 will see 0 as the status, and it will appear that the program succeeded.
673 @cindex temporary files
674 @cindex @code{TMPDIR} environment variable
675 If you make temporary files, check the @code{TMPDIR} environment
676 variable; if that variable is defined, use the specified directory
677 instead of @file{/tmp}.
679 In addition, be aware that there is a possible security problem when
680 creating temporary files in world-writable directories.  In C, you can
681 avoid this problem by creating temporary files in this manner:
683 @example
684 fd = open (filename, O_WRONLY | O_CREAT | O_EXCL, 0600);
685 @end example
687 @noindent
688 or by using the @code{mkstemps} function from Gnulib
689 (@pxref{mkstemps,,, gnulib, Gnulib}).
691 In bash, use @code{set -C} (long name @code{noclobber}) to avoid this
692 problem.  In addition, the @code{mktemp} utility is a more general
693 solution for creating temporary files from shell scripts
694 (@pxref{mktemp invocation,,, coreutils, GNU Coreutils}).
697 @node Libraries
698 @section Library Behavior
699 @cindex libraries
701 Try to make library functions reentrant.  If they need to do dynamic
702 storage allocation, at least try to avoid any nonreentrancy aside from
703 that of @code{malloc} itself.
705 Here are certain name conventions for libraries, to avoid name
706 conflicts.
708 Choose a name prefix for the library, more than two characters long.
709 All external function and variable names should start with this
710 prefix.  In addition, there should only be one of these in any given
711 library member.  This usually means putting each one in a separate
712 source file.
714 An exception can be made when two external symbols are always used
715 together, so that no reasonable program could use one without the
716 other; then they can both go in the same file.
718 External symbols that are not documented entry points for the user
719 should have names beginning with @samp{_}.  The @samp{_} should be
720 followed by the chosen name prefix for the library, to prevent
721 collisions with other libraries.  These can go in the same files with
722 user entry points if you like.
724 Static functions and variables can be used as you like and need not
725 fit any naming convention.
727 @node Errors
728 @section Formatting Error Messages
729 @cindex formatting error messages
730 @cindex error messages, formatting
732 Error messages from compilers should look like this:
734 @example
735 @var{sourcefile}:@var{lineno}: @var{message}
736 @end example
738 @noindent
739 If you want to mention the column number, use one of these formats:
741 @example
742 @var{sourcefile}:@var{lineno}:@var{column}: @var{message}
743 @var{sourcefile}:@var{lineno}.@var{column}: @var{message}
745 @end example
747 @noindent
748 Line numbers should start from 1 at the beginning of the file, and
749 column numbers should start from 1 at the beginning of the line.
750 (Both of these conventions are chosen for compatibility.)  Calculate
751 column numbers assuming that space and all ASCII printing characters
752 have equal width, and assuming tab stops every 8 columns.  For
753 non-ASCII characters, Unicode character widths should be used when in
754 a UTF-8 locale; GNU libc and GNU gnulib provide suitable
755 @code{wcwidth} functions.
757 The error message can also give both the starting and ending positions
758 of the erroneous text.  There are several formats so that you can
759 avoid redundant information such as a duplicate line number.
760 Here are the possible formats:
762 @example
763 @var{sourcefile}:@var{line1}.@var{column1}-@var{line2}.@var{column2}: @var{message}
764 @var{sourcefile}:@var{line1}.@var{column1}-@var{column2}: @var{message}
765 @var{sourcefile}:@var{line1}-@var{line2}: @var{message}
766 @end example
768 @noindent
769 When an error is spread over several files, you can use this format:
771 @example
772 @var{file1}:@var{line1}.@var{column1}-@var{file2}:@var{line2}.@var{column2}: @var{message}
773 @end example
775 Error messages from other noninteractive programs should look like this:
777 @example
778 @var{program}:@var{sourcefile}:@var{lineno}: @var{message}
779 @end example
781 @noindent
782 when there is an appropriate source file, or like this:
784 @example
785 @var{program}: @var{message}
786 @end example
788 @noindent
789 when there is no relevant source file.
791 If you want to mention the column number, use this format:
793 @example
794 @var{program}:@var{sourcefile}:@var{lineno}:@var{column}: @var{message}
795 @end example
797 In an interactive program (one that is reading commands from a
798 terminal), it is better not to include the program name in an error
799 message.  The place to indicate which program is running is in the
800 prompt or with the screen layout.  (When the same program runs with
801 input from a source other than a terminal, it is not interactive and
802 would do best to print error messages using the noninteractive style.)
804 The string @var{message} should not begin with a capital letter when
805 it follows a program name and/or file name, because that isn't the
806 beginning of a sentence.  (The sentence conceptually starts at the
807 beginning of the line.)  Also, it should not end with a period.
809 Error messages from interactive programs, and other messages such as
810 usage messages, should start with a capital letter.  But they should not
811 end with a period.
813 @node User Interfaces
814 @section Standards for Interfaces Generally
816 @cindex program name and its behavior
817 @cindex behavior, dependent on program's name
818 Please don't make the behavior of a utility depend on the name used
819 to invoke it.  It is useful sometimes to make a link to a utility
820 with a different name, and that should not change what it does.
822 Instead, use a run time option or a compilation switch or both to
823 select among the alternate behaviors.  You can also build two versions
824 of the program, with different names and different default behaviors.
826 @cindex output device and program's behavior
827 Likewise, please don't make the behavior of a command-line program
828 depend on the type of output device it gets as standard output or
829 standard input.  Device independence is an important principle of the
830 system's design; do not compromise it merely to save someone from
831 typing an option now and then.  (Variation in error message syntax
832 when using a terminal is ok, because that is a side issue that people
833 do not depend on.)
835 If you think one behavior is most useful when the output is to a
836 terminal, and another is most useful when the output is a file or a
837 pipe, then it is usually best to make the default behavior the one
838 that is useful with output to a terminal, and have an option for the
839 other behavior.  You can also build two different versions of the
840 program with different names.
842 There is an exception for programs whose output in certain cases is
843 binary data.  Sending such output to a terminal is useless and can
844 cause trouble.  If such a program normally sends its output to stdout,
845 it should detect, in these cases, when the output is a terminal and
846 give an error message instead.  The @code{-f} option should override
847 this exception, thus permitting the output to go to the terminal.
849 Compatibility requires certain programs to depend on the type of output
850 device.  It would be disastrous if @code{ls} or @code{sh} did not do so
851 in the way all users expect.  In some of these cases, we supplement the
852 program with a preferred alternate version that does not depend on the
853 output device type.  For example, we provide a @code{dir} program much
854 like @code{ls} except that its default output format is always
855 multi-column format.
857 @node Graphical Interfaces
858 @section Standards for Graphical Interfaces
859 @cindex graphical user interface
860 @cindex interface styles
861 @cindex user interface styles
863 @cindex GTK+
864 @cindex GNUstep
865 When you write a program that provides a graphical user interface,
866 please make it work with the X Window System, using the GTK+ toolkit
867 or the GNUstep toolkit, unless the functionality specifically requires
868 some alternative (for example, ``displaying jpeg images while in
869 console mode'').
871 In addition, please provide a command-line interface to control the
872 functionality.  (In many cases, the graphical user interface can be a
873 separate program which invokes the command-line program.)  This is
874 so that the same jobs can be done from scripts.
876 @cindex CORBA
877 @cindex GNOME
878 @cindex D-bus
879 @cindex keyboard interface
880 @cindex library interface
881 Please also consider providing a D-bus interface for use from other
882 running programs, such as within GNOME.  (GNOME used to use CORBA
883 for this, but that is being phased out.)  In addition, consider
884 providing a library interface (for use from C), and perhaps a
885 keyboard-driven console interface (for use by users from console
886 mode).  Once you are doing the work to provide the functionality and
887 the graphical interface, these won't be much extra work.
889 Please make your program interoperate with access technology such as
890 screen readers (see
891 @url{https://www.gnu.org/accessibility/accessibility.html}).  This should
892 be automatic if you use GTK+.
894 @node Command-Line Interfaces
895 @section Standards for Command Line Interfaces
896 @cindex command-line interface
898 @findex getopt
899 It is a good idea to follow the POSIX guidelines for the
900 command-line options of a program.  The easiest way to do this is to use
901 @code{getopt} to parse them.  Note that the GNU version of @code{getopt}
902 will normally permit options anywhere among the arguments unless the
903 special argument @samp{--} is used.  This is not what POSIX
904 specifies; it is a GNU extension.
906 @cindex long-named options
907 Please define long-named options that are equivalent to the
908 single-letter Unix-style options.  We hope to make GNU more user
909 friendly this way.  This is easy to do with the GNU function
910 @code{getopt_long}.
912 One of the advantages of long-named options is that they can be
913 consistent from program to program.  For example, users should be able
914 to expect the ``verbose'' option of any GNU program which has one, to be
915 spelled precisely @samp{--verbose}.  To achieve this uniformity, look at
916 the table of common long-option names when you choose the option names
917 for your program (@pxref{Option Table}).
919 It is usually a good idea for file names given as ordinary arguments to
920 be input files only; any output files would be specified using options
921 (preferably @samp{-o} or @samp{--output}).  Even if you allow an output
922 file name as an ordinary argument for compatibility, try to provide an
923 option as another way to specify it.  This will lead to more consistency
924 among GNU utilities, and fewer idiosyncrasies for users to remember.
926 @cindex standard command-line options
927 @cindex options, standard command-line
928 @cindex CGI programs, standard options for
929 @cindex PATH_INFO, specifying standard options as
930 All programs should support two standard options: @samp{--version}
931 and @samp{--help}.  CGI programs should accept these as command-line
932 options, and also if given as the @env{PATH_INFO}; for instance,
933 visiting @indicateurl{http://example.org/p.cgi/--help} in a browser should
934 output the same information as invoking @samp{p.cgi --help} from the
935 command line.
937 @menu
938 * --version::       The standard output for --version.
939 * --help::          The standard output for --help.
940 @end menu
942 @node --version
943 @subsection @option{--version}
945 @cindex @samp{--version} output
947 The standard @code{--version} option should direct the program to
948 print information about its name, version, origin and legal status,
949 all on standard output, and then exit successfully.  Other options and
950 arguments should be ignored once this is seen, and the program should
951 not perform its normal function.
953 @cindex canonical name of a program
954 @cindex program's canonical name
955 The first line is meant to be easy for a program to parse; the version
956 number proper starts after the last space.  In addition, it contains
957 the canonical name for this program, in this format:
959 @example
960 GNU Emacs 19.30
961 @end example
963 @noindent
964 The program's name should be a constant string; @emph{don't} compute it
965 from @code{argv[0]}.  The idea is to state the standard or canonical
966 name for the program, not its file name.  There are other ways to find
967 out the precise file name where a command is found in @code{PATH}.
969 If the program is a subsidiary part of a larger package, mention the
970 package name in parentheses, like this:
972 @example
973 emacsserver (GNU Emacs) 19.30
974 @end example
976 @noindent
977 If the package has a version number which is different from this
978 program's version number, you can mention the package version number
979 just before the close-parenthesis.
981 If you @emph{need} to mention the version numbers of libraries which
982 are distributed separately from the package which contains this program,
983 you can do so by printing an additional line of version info for each
984 library you want to mention.  Use the same format for these lines as for
985 the first line.
987 Please do not mention all of the libraries that the program uses ``just
988 for completeness''---that would produce a lot of unhelpful clutter.
989 Please mention library version numbers only if you find in practice that
990 they are very important to you in debugging.
992 The following line, after the version number line or lines, should be a
993 copyright notice.  If more than one copyright notice is called for, put
994 each on a separate line.
996 Next should follow a line stating the license, preferably using one of
997 abbreviations below, and a brief statement that the program is free
998 software, and that users are free to copy and change it.  Also mention
999 that there is no warranty, to the extent permitted by law.  See
1000 recommended wording below.
1002 It is ok to finish the output with a list of the major authors of the
1003 program, as a way of giving credit.
1005 Here's an example of output that follows these rules:
1007 @smallexample
1008 GNU hello 2.3
1009 Copyright (C) 2007 Free Software Foundation, Inc.
1010 License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
1011 This is free software: you are free to change and redistribute it.
1012 There is NO WARRANTY, to the extent permitted by law.
1013 @end smallexample
1015 You should adapt this to your program, of course, filling in the proper
1016 year, copyright holder, name of program, and the references to
1017 distribution terms, and changing the rest of the wording as necessary.
1019 This copyright notice only needs to mention the most recent year in
1020 which changes were made---there's no need to list the years for previous
1021 versions' changes.  You don't have to mention the name of the program in
1022 these notices, if that is inconvenient, since it appeared in the first
1023 line.  (The rules are different for copyright notices in source files;
1024 @pxref{Copyright Notices,,,maintain,Information for GNU Maintainers}.)
1026 Translations of the above lines must preserve the validity of the
1027 copyright notices (@pxref{Internationalization}).  If the translation's
1028 character set supports it, the @samp{(C)} should be replaced with the
1029 copyright symbol, as follows:
1031 @ifinfo
1032 (the official copyright symbol, which is the letter C in a circle);
1033 @end ifinfo
1034 @ifnotinfo
1035 @copyright{}
1036 @end ifnotinfo
1038 Write the word ``Copyright'' exactly like that, in English.  Do not
1039 translate it into another language.  International treaties recognize
1040 the English word ``Copyright''; translations into other languages do not
1041 have legal significance.
1043 Finally, here is the table of our suggested license abbreviations.
1044 Any abbreviation can be followed by @samp{v@var{version}[+]}, meaning
1045 that particular version, or later versions with the @samp{+}, as shown
1046 above.  In the case of a GNU license, @emph{always} indicate the permitted
1047 versions in this way.
1049 In the case of exceptions for extra permissions with the GPL, we use
1050 @samp{/} for a separator; the version number can follow the license
1051 abbreviation as usual, as in the examples below.
1053 @table @asis
1054 @item GPL
1055 GNU General Public License, @url{https://www.gnu.org/@/licenses/@/gpl.html}.
1057 @item LGPL
1058 GNU Lesser General Public License, @url{https://www.gnu.org/@/licenses/@/lgpl.html}.
1060 @item GPL/Ada
1061 GNU GPL with the exception for Ada.
1063 @item Apache
1064 The Apache Software Foundation license,
1065 @url{https://www.apache.org/@/licenses}.
1067 @item Artistic
1068 The Artistic license used for Perl, @url{https://dev.perl.org/licenses/artistic.html}.
1070 @item Expat
1071 The Expat license, @url{http://www.jclark.com/@/xml/@/copying.txt}.
1073 @item MPL
1074 The Mozilla Public License, @url{https://www.mozilla.org/@/MPL/}.
1076 @item OBSD
1077 The original (4-clause) BSD license, incompatible with the GNU GPL
1078 @url{https://www.xfree86.org/@/3.3.6/@/COPYRIGHT2.html#6}.
1080 @item PHP
1081 The license used for PHP, @url{http://www.php.net/@/license/}.
1083 @item public domain
1084 The non-license that is being in the public domain,
1085 @url{https://www.gnu.org/@/licenses/@/license-list.html#PublicDomain}.
1087 @item Python
1088 The license for Python,
1089 @url{https://directory.fsf.org/wiki?title=License:Python2.0.1}.
1091 @item RBSD
1092 The revised (3-clause) BSD, compatible with the GNU GPL,@*
1093 @url{https://www.xfree86.org/@/3.3.6/@/COPYRIGHT2.html#5}.
1095 @item X11
1096 The simple non-copyleft license used for most versions of the X Window
1097 System, @url{https://www.xfree86.org/@/3.3.6/@/COPYRIGHT2.html#3}.
1099 @item Zlib
1100 The license for Zlib, @url{http://www.gzip.org/@/zlib/@/zlib_license.html}.
1102 @end table
1104 More information about these licenses and many more are on the GNU
1105 licensing web pages,
1106 @url{https://www.gnu.org/@/licenses/@/license-list.html}.
1109 @node --help
1110 @subsection @option{--help}
1112 @cindex @samp{--help} output
1114 The standard @code{--help} option should output brief documentation
1115 for how to invoke the program, on standard output, then exit
1116 successfully.  Other options and arguments should be ignored once this
1117 is seen, and the program should not perform its normal function.
1119 @cindex address for bug reports
1120 @cindex bug reports
1121 Near the end of the @samp{--help} option's output, please place lines
1122 giving the email address for bug reports, the package's home page
1123 (normally @indicateurl{https://www.gnu.org/software/@var{pkg}}, and the
1124 general page for help using GNU programs.  The format should be like this:
1126 @example
1127 Report bugs to: @var{mailing-address}
1128 @var{pkg} home page: <https://www.gnu.org/software/@var{pkg}/>
1129 General help using GNU software: <https://www.gnu.org/gethelp/>
1130 @end example
1132 It is ok to mention other appropriate mailing lists and web pages.
1135 @node Dynamic Plug-In Interfaces
1136 @section Standards for Dynamic Plug-in Interfaces
1137 @cindex plug-ins
1138 @cindex dynamic plug-ins
1140 Another aspect of keeping free programs free is encouraging
1141 development of free plug-ins, and discouraging development of
1142 proprietary plug-ins.  Many GNU programs will not have anything like
1143 plug-ins at all, but those that do should follow these
1144 practices.
1146 First, the general plug-in architecture design should closely tie the
1147 plug-in to the original code, such that the plug-in and the base
1148 program are parts of one extended program.  For GCC, for example,
1149 plug-ins receive and modify GCC's internal data structures, and so
1150 clearly form an extended program with the base GCC.
1152 @vindex plugin_is_GPL_compatible
1153 Second, you should require plug-in developers to affirm that their
1154 plug-ins are released under an appropriate license.  This should be
1155 enforced with a simple programmatic check.  For GCC, again for
1156 example, a plug-in must define the global symbol
1157 @code{plugin_is_GPL_compatible}, thus asserting that the plug-in is
1158 released under a GPL-compatible license (@pxref{Plugins,, Plugins,
1159 gccint, GCC Internals}).
1161 By adding this check to your program you are not creating a new legal
1162 requirement.  The GPL itself requires plug-ins to be free software,
1163 licensed compatibly.  As long as you have followed the first rule above
1164 to keep plug-ins closely tied to your original program, the GPL and AGPL
1165 already require those plug-ins to be released under a compatible
1166 license.  The symbol definition in the plug-in---or whatever equivalent
1167 works best in your program---makes it harder for anyone who might
1168 distribute proprietary plug-ins to legally defend themselves.  If a case
1169 about this got to court, we can point to that symbol as evidence that
1170 the plug-in developer understood that the license had this requirement.
1173 @node Option Table
1174 @section Table of Long Options
1175 @cindex long option names
1176 @cindex table of long options
1178 Here is a table of long options used by GNU programs.  It is surely
1179 incomplete, but we aim to list all the options that a new program might
1180 want to be compatible with.  If you use names not already in the table,
1181 please send @email{bug-standards@@gnu.org} a list of them, with their
1182 meanings, so we can update the table.
1184 @c Please leave newlines between items in this table; it's much easier
1185 @c to update when it isn't completely squashed together and unreadable.
1186 @c When there is more than one short option for a long option name, put
1187 @c a semicolon between the lists of the programs that use them, not a
1188 @c period.   --friedman
1190 @table @samp
1191 @item after-date
1192 @samp{-N} in @code{tar}.
1194 @item all
1195 @samp{-a} in @code{du}, @code{ls}, @code{nm}, @code{stty}, @code{uname},
1196 and @code{unexpand}.
1198 @item all-text
1199 @samp{-a} in @code{diff}.
1201 @item almost-all
1202 @samp{-A} in @code{ls}.
1204 @item append
1205 @samp{-a} in @code{etags}, @code{tee}, @code{time};
1206 @samp{-r} in @code{tar}.
1208 @item archive
1209 @samp{-a} in @code{cp}.
1211 @item archive-name
1212 @samp{-n} in @code{shar}.
1214 @item arglength
1215 @samp{-l} in @code{m4}.
1217 @item ascii
1218 @samp{-a} in @code{diff}.
1220 @item assign
1221 @samp{-v} in @code{gawk}.
1223 @item assume-new
1224 @samp{-W} in @code{make}.
1226 @item assume-old
1227 @samp{-o} in @code{make}.
1229 @item auto-check
1230 @samp{-a} in @code{recode}.
1232 @item auto-pager
1233 @samp{-a} in @code{wdiff}.
1235 @item auto-reference
1236 @samp{-A} in @code{ptx}.
1238 @item avoid-wraps
1239 @samp{-n} in @code{wdiff}.
1241 @item background
1242 For server programs, run in the background.
1244 @item backward-search
1245 @samp{-B} in @code{ctags}.
1247 @item basename
1248 @samp{-f} in @code{shar}.
1250 @item batch
1251 Used in GDB.
1253 @item baud
1254 Used in GDB.
1256 @item before
1257 @samp{-b} in @code{tac}.
1259 @item binary
1260 @samp{-b} in @code{cpio} and @code{diff}.
1262 @item bits-per-code
1263 @samp{-b} in @code{shar}.
1265 @item block-size
1266 Used in @code{cpio} and @code{tar}.
1268 @item blocks
1269 @samp{-b} in @code{head} and @code{tail}.
1271 @item break-file
1272 @samp{-b} in @code{ptx}.
1274 @item brief
1275 Used in various programs to make output shorter.
1277 @item bytes
1278 @samp{-c} in @code{head}, @code{split}, and @code{tail}.
1280 @item c@t{++}
1281 @samp{-C} in @code{etags}.
1283 @item catenate
1284 @samp{-A} in @code{tar}.
1286 @item cd
1287 Used in various programs to specify the directory to use.
1289 @item changes
1290 @samp{-c} in @code{chgrp} and @code{chown}.
1292 @item classify
1293 @samp{-F} in @code{ls}.
1295 @item colons
1296 @samp{-c} in @code{recode}.
1298 @item command
1299 @samp{-c} in @code{su};
1300 @samp{-x} in GDB.
1302 @item compare
1303 @samp{-d} in @code{tar}.
1305 @item compat
1306 Used in @code{gawk}.
1308 @item compress
1309 @samp{-Z} in @code{tar} and @code{shar}.
1311 @item concatenate
1312 @samp{-A} in @code{tar}.
1314 @item confirmation
1315 @samp{-w} in @code{tar}.
1317 @item context
1318 Used in @code{diff}.
1320 @item copyleft
1321 @samp{-W copyleft} in @code{gawk}.
1323 @item copyright
1324 @samp{-C} in @code{ptx}, @code{recode}, and @code{wdiff};
1325 @samp{-W copyright} in @code{gawk}.
1327 @item core
1328 Used in GDB.
1330 @item count
1331 @samp{-q} in @code{who}.
1333 @item count-links
1334 @samp{-l} in @code{du}.
1336 @item create
1337 Used in @code{tar} and @code{cpio}.
1339 @item cut-mark
1340 @samp{-c} in @code{shar}.
1342 @item cxref
1343 @samp{-x} in @code{ctags}.
1345 @item date
1346 @samp{-d} in @code{touch}.
1348 @item debug
1349 @samp{-d} in @code{make} and @code{m4};
1350 @samp{-t} in Bison.
1352 @item define
1353 @samp{-D} in @code{m4}.
1355 @item defines
1356 @samp{-d} in Bison and @code{ctags}.
1358 @item delete
1359 @samp{-D} in @code{tar}.
1361 @item dereference
1362 @samp{-L} in @code{chgrp}, @code{chown}, @code{cpio}, @code{du},
1363 @code{ls}, and @code{tar}.
1365 @item dereference-args
1366 @samp{-D} in @code{du}.
1368 @item device
1369 Specify an I/O device (special file name).
1371 @item diacritics
1372 @samp{-d} in @code{recode}.
1374 @item dictionary-order
1375 @samp{-d} in @code{look}.
1377 @item diff
1378 @samp{-d} in @code{tar}.
1380 @item digits
1381 @samp{-n} in @code{csplit}.
1383 @item directory
1384 Specify the directory to use, in various programs.  In @code{ls}, it
1385 means to show directories themselves rather than their contents.  In
1386 @code{rm} and @code{ln}, it means to not treat links to directories
1387 specially.
1389 @item discard-all
1390 @samp{-x} in @code{strip}.
1392 @item discard-locals
1393 @samp{-X} in @code{strip}.
1395 @item dry-run
1396 @samp{-n} in @code{make}.
1398 @item ed
1399 @samp{-e} in @code{diff}.
1401 @item elide-empty-files
1402 @samp{-z} in @code{csplit}.
1404 @item end-delete
1405 @samp{-x} in @code{wdiff}.
1407 @item end-insert
1408 @samp{-z} in @code{wdiff}.
1410 @item entire-new-file
1411 @samp{-N} in @code{diff}.
1413 @item environment-overrides
1414 @samp{-e} in @code{make}.
1416 @item eof
1417 @samp{-e} in @code{xargs}.
1419 @item epoch
1420 Used in GDB.
1422 @item error-limit
1423 Used in @code{makeinfo}.
1425 @item error-output
1426 @samp{-o} in @code{m4}.
1428 @item escape
1429 @samp{-b} in @code{ls}.
1431 @item exclude-from
1432 @samp{-X} in @code{tar}.
1434 @item exec
1435 Used in GDB.
1437 @item exit
1438 @samp{-x} in @code{xargs}.
1440 @item exit-0
1441 @samp{-e} in @code{unshar}.
1443 @item expand-tabs
1444 @samp{-t} in @code{diff}.
1446 @item expression
1447 @samp{-e} in @code{sed}.
1449 @item extern-only
1450 @samp{-g} in @code{nm}.
1452 @item extract
1453 @samp{-i} in @code{cpio};
1454 @samp{-x} in @code{tar}.
1456 @item faces
1457 @samp{-f} in @code{finger}.
1459 @item fast
1460 @samp{-f} in @code{su}.
1462 @item fatal-warnings
1463 @samp{-E} in @code{m4}.
1465 @item file
1466 @samp{-f} in @code{gawk}, @code{info}, @code{make}, @code{mt},
1467 @code{sed}, and @code{tar}.
1469 @item field-separator
1470 @samp{-F} in @code{gawk}.
1472 @item file-prefix
1473 @samp{-b} in Bison.
1475 @item file-type
1476 @samp{-F} in @code{ls}.
1478 @item files-from
1479 @samp{-T} in @code{tar}.
1481 @item fill-column
1482 Used in @code{makeinfo}.
1484 @item flag-truncation
1485 @samp{-F} in @code{ptx}.
1487 @item fixed-output-files
1488 @samp{-y} in Bison.
1490 @item follow
1491 @samp{-f} in @code{tail}.
1493 @item footnote-style
1494 Used in @code{makeinfo}.
1496 @item force
1497 @samp{-f} in @code{cp}, @code{ln}, @code{mv}, and @code{rm}.
1499 @item force-prefix
1500 @samp{-F} in @code{shar}.
1502 @item foreground
1503 For server programs, run in the foreground;
1504 in other words, don't do anything special to run the server
1505 in the background.
1507 @item format
1508 Used in @code{ls}, @code{time}, and @code{ptx}.
1510 @item freeze-state
1511 @samp{-F} in @code{m4}.
1513 @item fullname
1514 Used in GDB.
1516 @item gap-size
1517 @samp{-g} in @code{ptx}.
1519 @item get
1520 @samp{-x} in @code{tar}.
1522 @item graphic
1523 @samp{-i} in @code{ul}.
1525 @item graphics
1526 @samp{-g} in @code{recode}.
1528 @item group
1529 @samp{-g} in @code{install}.
1531 @item gzip
1532 @samp{-z} in @code{tar} and @code{shar}.
1534 @item hashsize
1535 @samp{-H} in @code{m4}.
1537 @item header
1538 @samp{-h} in @code{objdump} and @code{recode}
1540 @item heading
1541 @samp{-H} in @code{who}.
1543 @item help
1544 Used to ask for brief usage information.
1546 @item here-delimiter
1547 @samp{-d} in @code{shar}.
1549 @item hide-control-chars
1550 @samp{-q} in @code{ls}.
1552 @item html
1553 In @code{makeinfo}, output HTML.
1555 @item idle
1556 @samp{-u} in @code{who}.
1558 @item ifdef
1559 @samp{-D} in @code{diff}.
1561 @item ignore
1562 @samp{-I} in @code{ls};
1563 @samp{-x} in @code{recode}.
1565 @item ignore-all-space
1566 @samp{-w} in @code{diff}.
1568 @item ignore-backups
1569 @samp{-B} in @code{ls}.
1571 @item ignore-blank-lines
1572 @samp{-B} in @code{diff}.
1574 @item ignore-case
1575 @samp{-f} in @code{look} and @code{ptx};
1576 @samp{-i} in @code{diff} and @code{wdiff}.
1578 @item ignore-errors
1579 @samp{-i} in @code{make}.
1581 @item ignore-file
1582 @samp{-i} in @code{ptx}.
1584 @item ignore-indentation
1585 @samp{-I} in @code{etags}.
1587 @item ignore-init-file
1588 @samp{-f} in Oleo.
1590 @item ignore-interrupts
1591 @samp{-i} in @code{tee}.
1593 @item ignore-matching-lines
1594 @samp{-I} in @code{diff}.
1596 @item ignore-space-change
1597 @samp{-b} in @code{diff}.
1599 @item ignore-zeros
1600 @samp{-i} in @code{tar}.
1602 @item include
1603 @samp{-i} in @code{etags};
1604 @samp{-I} in @code{m4}.
1606 @item include-dir
1607 @samp{-I} in @code{make}.
1609 @item incremental
1610 @samp{-G} in @code{tar}.
1612 @item info
1613 @samp{-i}, @samp{-l}, and @samp{-m} in Finger.
1615 @item init-file
1616 In some programs, specify the name of the file to read as the user's
1617 init file.
1619 @item initial
1620 @samp{-i} in @code{expand}.
1622 @item initial-tab
1623 @samp{-T} in @code{diff}.
1625 @item inode
1626 @samp{-i} in @code{ls}.
1628 @item interactive
1629 @samp{-i} in @code{cp}, @code{ln}, @code{mv}, @code{rm};
1630 @samp{-e} in @code{m4};
1631 @samp{-p} in @code{xargs};
1632 @samp{-w} in @code{tar}.
1634 @item intermix-type
1635 @samp{-p} in @code{shar}.
1637 @item iso-8601
1638 Used in @code{date}
1640 @item jobs
1641 @samp{-j} in @code{make}.
1643 @item just-print
1644 @samp{-n} in @code{make}.
1646 @item keep-going
1647 @samp{-k} in @code{make}.
1649 @item keep-files
1650 @samp{-k} in @code{csplit}.
1652 @item kilobytes
1653 @samp{-k} in @code{du} and @code{ls}.
1655 @item language
1656 @samp{-l} in @code{etags}.
1658 @item less-mode
1659 @samp{-l} in @code{wdiff}.
1661 @item level-for-gzip
1662 @samp{-g} in @code{shar}.
1664 @item line-bytes
1665 @samp{-C} in @code{split}.
1667 @item lines
1668 Used in @code{split}, @code{head}, and @code{tail}.
1670 @item link
1671 @samp{-l} in @code{cpio}.
1673 @item lint
1674 @itemx lint-old
1675 Used in @code{gawk}.
1677 @item list
1678 @samp{-t} in @code{cpio};
1679 @samp{-l} in @code{recode}.
1681 @item list
1682 @samp{-t} in @code{tar}.
1684 @item literal
1685 @samp{-N} in @code{ls}.
1687 @item load-average
1688 @samp{-l} in @code{make}.
1690 @item login
1691 Used in @code{su}.
1693 @item machine
1694 Used in @code{uname}.
1696 @item macro-name
1697 @samp{-M} in @code{ptx}.
1699 @item mail
1700 @samp{-m} in @code{hello} and @code{uname}.
1702 @item make-directories
1703 @samp{-d} in @code{cpio}.
1705 @item makefile
1706 @samp{-f} in @code{make}.
1708 @item mapped
1709 Used in GDB.
1711 @item max-args
1712 @samp{-n} in @code{xargs}.
1714 @item max-chars
1715 @samp{-n} in @code{xargs}.
1717 @item max-lines
1718 @samp{-l} in @code{xargs}.
1720 @item max-load
1721 @samp{-l} in @code{make}.
1723 @item max-procs
1724 @samp{-P} in @code{xargs}.
1726 @item mesg
1727 @samp{-T} in @code{who}.
1729 @item message
1730 @samp{-T} in @code{who}.
1732 @item minimal
1733 @samp{-d} in @code{diff}.
1735 @item mixed-uuencode
1736 @samp{-M} in @code{shar}.
1738 @item mode
1739 @samp{-m} in @code{install}, @code{mkdir}, and @code{mkfifo}.
1741 @item modification-time
1742 @samp{-m} in @code{tar}.
1744 @item multi-volume
1745 @samp{-M} in @code{tar}.
1747 @item name-prefix
1748 @samp{-a} in Bison.
1750 @item nesting-limit
1751 @samp{-L} in @code{m4}.
1753 @item net-headers
1754 @samp{-a} in @code{shar}.
1756 @item new-file
1757 @samp{-W} in @code{make}.
1759 @item no-builtin-rules
1760 @samp{-r} in @code{make}.
1762 @item no-character-count
1763 @samp{-w} in @code{shar}.
1765 @item no-check-existing
1766 @samp{-x} in @code{shar}.
1768 @item no-common
1769 @samp{-3} in @code{wdiff}.
1771 @item no-create
1772 @samp{-c} in @code{touch}.
1774 @item no-defines
1775 @samp{-D} in @code{etags}.
1777 @item no-deleted
1778 @samp{-1} in @code{wdiff}.
1780 @item no-dereference
1781 @samp{-d} in @code{cp}.
1783 @item no-inserted
1784 @samp{-2} in @code{wdiff}.
1786 @item no-keep-going
1787 @samp{-S} in @code{make}.
1789 @item no-lines
1790 @samp{-l} in Bison.
1792 @item no-piping
1793 @samp{-P} in @code{shar}.
1795 @item no-prof
1796 @samp{-e} in @code{gprof}.
1798 @item no-regex
1799 @samp{-R} in @code{etags}.
1801 @item no-sort
1802 @samp{-p} in @code{nm}.
1804 @item no-splash
1805 Don't print a startup splash screen.
1807 @item no-split
1808 Used in @code{makeinfo}.
1810 @item no-static
1811 @samp{-a} in @code{gprof}.
1813 @item no-time
1814 @samp{-E} in @code{gprof}.
1816 @item no-timestamp
1817 @samp{-m} in @code{shar}.
1819 @item no-validate
1820 Used in @code{makeinfo}.
1822 @item no-wait
1823 Used in @code{emacsclient}.
1825 @item no-warn
1826 Used in various programs to inhibit warnings.
1828 @item node
1829 @samp{-n} in @code{info}.
1831 @item nodename
1832 @samp{-n} in @code{uname}.
1834 @item nonmatching
1835 @samp{-f} in @code{cpio}.
1837 @item nstuff
1838 @samp{-n} in @code{objdump}.
1840 @item null
1841 @samp{-0} in @code{xargs}.
1843 @item number
1844 @samp{-n} in @code{cat}.
1846 @item number-nonblank
1847 @samp{-b} in @code{cat}.
1849 @item numeric-sort
1850 @samp{-n} in @code{nm}.
1852 @item numeric-uid-gid
1853 @samp{-n} in @code{cpio} and @code{ls}.
1855 @item nx
1856 Used in GDB.
1858 @item old-archive
1859 @samp{-o} in @code{tar}.
1861 @item old-file
1862 @samp{-o} in @code{make}.
1864 @item one-file-system
1865 @samp{-l} in @code{tar}, @code{cp}, and @code{du}.
1867 @item only-file
1868 @samp{-o} in @code{ptx}.
1870 @item only-prof
1871 @samp{-f} in @code{gprof}.
1873 @item only-time
1874 @samp{-F} in @code{gprof}.
1876 @item options
1877 @samp{-o} in @code{getopt}, @code{fdlist}, @code{fdmount},
1878 @code{fdmountd}, and @code{fdumount}.
1880 @item output
1881 In various programs, specify the output file name.
1883 @item output-prefix
1884 @samp{-o} in @code{shar}.
1886 @item override
1887 @samp{-o} in @code{rm}.
1889 @item overwrite
1890 @samp{-c} in @code{unshar}.
1892 @item owner
1893 @samp{-o} in @code{install}.
1895 @item paginate
1896 @samp{-l} in @code{diff}.
1898 @item paragraph-indent
1899 Used in @code{makeinfo}.
1901 @item parents
1902 @samp{-p} in @code{mkdir} and @code{rmdir}.
1904 @item pass-all
1905 @samp{-p} in @code{ul}.
1907 @item pass-through
1908 @samp{-p} in @code{cpio}.
1910 @item port
1911 @samp{-P} in @code{finger}.
1913 @item portability
1914 @samp{-c} in @code{cpio} and @code{tar}.
1916 @item posix
1917 Used in @code{gawk}.
1919 @item prefix-builtins
1920 @samp{-P} in @code{m4}.
1922 @item prefix
1923 @samp{-f} in @code{csplit}.
1925 @item preserve
1926 Used in @code{tar} and @code{cp}.
1928 @item preserve-environment
1929 @samp{-p} in @code{su}.
1931 @item preserve-modification-time
1932 @samp{-m} in @code{cpio}.
1934 @item preserve-order
1935 @samp{-s} in @code{tar}.
1937 @item preserve-permissions
1938 @samp{-p} in @code{tar}.
1940 @item print
1941 @samp{-l} in @code{diff}.
1943 @item print-chars
1944 @samp{-L} in @code{cmp}.
1946 @item print-data-base
1947 @samp{-p} in @code{make}.
1949 @item print-directory
1950 @samp{-w} in @code{make}.
1952 @item print-file-name
1953 @samp{-o} in @code{nm}.
1955 @item print-symdefs
1956 @samp{-s} in @code{nm}.
1958 @item printer
1959 @samp{-p} in @code{wdiff}.
1961 @item prompt
1962 @samp{-p} in @code{ed}.
1964 @item proxy
1965 Specify an HTTP proxy.
1967 @item query-user
1968 @samp{-X} in @code{shar}.
1970 @item question
1971 @samp{-q} in @code{make}.
1973 @item quiet
1974 Used in many programs to inhibit the usual output.  Every
1975 program accepting @samp{--quiet} should accept @samp{--silent} as a
1976 synonym.
1978 @item quiet-unshar
1979 @samp{-Q} in @code{shar}
1981 @item quote-name
1982 @samp{-Q} in @code{ls}.
1984 @item rcs
1985 @samp{-n} in @code{diff}.
1987 @item re-interval
1988 Used in @code{gawk}.
1990 @item read-full-blocks
1991 @samp{-B} in @code{tar}.
1993 @item readnow
1994 Used in GDB.
1996 @item recon
1997 @samp{-n} in @code{make}.
1999 @item record-number
2000 @samp{-R} in @code{tar}.
2002 @item recursive
2003 Used in @code{chgrp}, @code{chown}, @code{cp}, @code{ls}, @code{diff},
2004 and @code{rm}.
2006 @item reference
2007 @samp{-r} in @code{touch}.
2009 @item references
2010 @samp{-r} in @code{ptx}.
2012 @item regex
2013 @samp{-r} in @code{tac} and @code{etags}.
2015 @item release
2016 @samp{-r} in @code{uname}.
2018 @item reload-state
2019 @samp{-R} in @code{m4}.
2021 @item relocation
2022 @samp{-r} in @code{objdump}.
2024 @item rename
2025 @samp{-r} in @code{cpio}.
2027 @item replace
2028 @samp{-i} in @code{xargs}.
2030 @item report-identical-files
2031 @samp{-s} in @code{diff}.
2033 @item reset-access-time
2034 @samp{-a} in @code{cpio}.
2036 @item reverse
2037 @samp{-r} in @code{ls} and @code{nm}.
2039 @item reversed-ed
2040 @samp{-f} in @code{diff}.
2042 @item right-side-defs
2043 @samp{-R} in @code{ptx}.
2045 @item same-order
2046 @samp{-s} in @code{tar}.
2048 @item same-permissions
2049 @samp{-p} in @code{tar}.
2051 @item save
2052 @samp{-g} in @code{stty}.
2054 @item se
2055 Used in GDB.
2057 @item sentence-regexp
2058 @samp{-S} in @code{ptx}.
2060 @item separate-dirs
2061 @samp{-S} in @code{du}.
2063 @item separator
2064 @samp{-s} in @code{tac}.
2066 @item sequence
2067 Used by @code{recode} to chose files or pipes for sequencing passes.
2069 @item shell
2070 @samp{-s} in @code{su}.
2072 @item show-all
2073 @samp{-A} in @code{cat}.
2075 @item show-c-function
2076 @samp{-p} in @code{diff}.
2078 @item show-ends
2079 @samp{-E} in @code{cat}.
2081 @item show-function-line
2082 @samp{-F} in @code{diff}.
2084 @item show-tabs
2085 @samp{-T} in @code{cat}.
2087 @item silent
2088 Used in many programs to inhibit the usual output.
2089 Every program accepting
2090 @samp{--silent} should accept @samp{--quiet} as a synonym.
2092 @item size
2093 @samp{-s} in @code{ls}.
2095 @item socket
2096 Specify a file descriptor for a network server to use for its socket,
2097 instead of opening and binding a new socket.  This provides a way to
2098 run, in a non-privileged process, a server that normally needs a
2099 reserved port number.
2101 @item sort
2102 Used in @code{ls}.
2104 @item source
2105 @samp{-W source} in @code{gawk}.
2107 @item sparse
2108 @samp{-S} in @code{tar}.
2110 @item speed-large-files
2111 @samp{-H} in @code{diff}.
2113 @item split-at
2114 @samp{-E} in @code{unshar}.
2116 @item split-size-limit
2117 @samp{-L} in @code{shar}.
2119 @item squeeze-blank
2120 @samp{-s} in @code{cat}.
2122 @item start-delete
2123 @samp{-w} in @code{wdiff}.
2125 @item start-insert
2126 @samp{-y} in @code{wdiff}.
2128 @item starting-file
2129 Used in @code{tar} and @code{diff} to specify which file within
2130 a directory to start processing with.
2132 @item statistics
2133 @samp{-s} in @code{wdiff}.
2135 @item stdin-file-list
2136 @samp{-S} in @code{shar}.
2138 @item stop
2139 @samp{-S} in @code{make}.
2141 @item strict
2142 @samp{-s} in @code{recode}.
2144 @item strip
2145 @samp{-s} in @code{install}.
2147 @item strip-all
2148 @samp{-s} in @code{strip}.
2150 @item strip-debug
2151 @samp{-S} in @code{strip}.
2153 @item submitter
2154 @samp{-s} in @code{shar}.
2156 @item suffix
2157 @samp{-S} in @code{cp}, @code{ln}, @code{mv}.
2159 @item suffix-format
2160 @samp{-b} in @code{csplit}.
2162 @item sum
2163 @samp{-s} in @code{gprof}.
2165 @item summarize
2166 @samp{-s} in @code{du}.
2168 @item symbolic
2169 @samp{-s} in @code{ln}.
2171 @item symbols
2172 Used in GDB and @code{objdump}.
2174 @item synclines
2175 @samp{-s} in @code{m4}.
2177 @item sysname
2178 @samp{-s} in @code{uname}.
2180 @item tabs
2181 @samp{-t} in @code{expand} and @code{unexpand}.
2183 @item tabsize
2184 @samp{-T} in @code{ls}.
2186 @item terminal
2187 @samp{-T} in @code{tput} and @code{ul}.
2188 @samp{-t} in @code{wdiff}.
2190 @item text
2191 @samp{-a} in @code{diff}.
2193 @item text-files
2194 @samp{-T} in @code{shar}.
2196 @item time
2197 Used in @code{ls} and @code{touch}.
2199 @item timeout
2200 Specify how long to wait before giving up on some operation.
2202 @item to-stdout
2203 @samp{-O} in @code{tar}.
2205 @item total
2206 @samp{-c} in @code{du}.
2208 @item touch
2209 @samp{-t} in @code{make}, @code{ranlib}, and @code{recode}.
2211 @item trace
2212 @samp{-t} in @code{m4}.
2214 @item traditional
2215 @samp{-t} in @code{hello};
2216 @samp{-W traditional} in @code{gawk};
2217 @samp{-G} in @code{ed}, @code{m4}, and @code{ptx}.
2219 @item tty
2220 Used in GDB.
2222 @item typedefs
2223 @samp{-t} in @code{ctags}.
2225 @item typedefs-and-c++
2226 @samp{-T} in @code{ctags}.
2228 @item typeset-mode
2229 @samp{-t} in @code{ptx}.
2231 @item uncompress
2232 @samp{-z} in @code{tar}.
2234 @item unconditional
2235 @samp{-u} in @code{cpio}.
2237 @item undefine
2238 @samp{-U} in @code{m4}.
2240 @item undefined-only
2241 @samp{-u} in @code{nm}.
2243 @item update
2244 @samp{-u} in @code{cp}, @code{ctags}, @code{mv}, @code{tar}.
2246 @item usage
2247 Used in @code{gawk}; same as @samp{--help}.
2249 @item uuencode
2250 @samp{-B} in @code{shar}.
2252 @item vanilla-operation
2253 @samp{-V} in @code{shar}.
2255 @item verbose
2256 Print more information about progress.  Many programs support this.
2258 @item verify
2259 @samp{-W} in @code{tar}.
2261 @item version
2262 Print the version number.
2264 @item version-control
2265 @samp{-V} in @code{cp}, @code{ln}, @code{mv}.
2267 @item vgrind
2268 @samp{-v} in @code{ctags}.
2270 @item volume
2271 @samp{-V} in @code{tar}.
2273 @item what-if
2274 @samp{-W} in @code{make}.
2276 @item whole-size-limit
2277 @samp{-l} in @code{shar}.
2279 @item width
2280 @samp{-w} in @code{ls} and @code{ptx}.
2282 @item word-regexp
2283 @samp{-W} in @code{ptx}.
2285 @item writable
2286 @samp{-T} in @code{who}.
2288 @item zeros
2289 @samp{-z} in @code{gprof}.
2290 @end table
2292 @node OID Allocations
2293 @section OID Allocations
2294 @cindex OID allocations for GNU
2295 @cindex SNMP
2296 @cindex LDAP
2297 @cindex X.509
2299 The OID (object identifier) 1.3.6.1.4.1.11591 has been assigned to the
2300 GNU Project (thanks to Sergey Poznyakoff).  These are used for SNMP,
2301 LDAP, X.509 certificates, and so on.  The web site
2302 @url{https://www.alvestrand.no/objectid} has a (voluntary) listing of
2303 many OID assignments.
2305 If you need a new slot for your GNU package, write
2306 @email{maintainers@@gnu.org}.  Here is a list of arcs currently
2307 assigned:
2309 @example
2310 @include gnu-oids.texi
2311 @end example
2314 @node Memory Usage
2315 @section Memory Usage
2316 @cindex memory usage
2318 If a program typically uses just a few meg of memory, don't bother making any
2319 effort to reduce memory usage.  For example, if it is impractical for
2320 other reasons to operate on files more than a few meg long, it is
2321 reasonable to read entire input files into memory to operate on them.
2323 However, for programs such as @code{cat} or @code{tail}, that can
2324 usefully operate on very large files, it is important to avoid using a
2325 technique that would artificially limit the size of files it can handle.
2326 If a program works by lines and could be applied to arbitrary
2327 user-supplied input files, it should keep only a line in memory, because
2328 this is not very hard and users will want to be able to operate on input
2329 files that are bigger than will fit in memory all at once.
2331 If your program creates complicated data structures, just make them in
2332 memory and give a fatal error if @code{malloc} returns @code{NULL}.
2334 @pindex valgrind
2335 @cindex memory leak
2336 Memory analysis tools such as @command{valgrind} can be useful, but
2337 don't complicate a program merely to avoid their false alarms.  For
2338 example, if memory is used until just before a process exits, don't
2339 free it simply to silence such a tool.
2342 @node File Usage
2343 @section File Usage
2344 @cindex file usage
2346 Programs should be prepared to operate when @file{/usr} and @file{/etc}
2347 are read-only file systems.  Thus, if the program manages log files,
2348 lock files, backup files, score files, or any other files which are
2349 modified for internal purposes, these files should not be stored in
2350 @file{/usr} or @file{/etc}.
2352 There are two exceptions.  @file{/etc} is used to store system
2353 configuration information; it is reasonable for a program to modify
2354 files in @file{/etc} when its job is to update the system configuration.
2355 Also, if the user explicitly asks to modify one file in a directory, it
2356 is reasonable for the program to store other files in the same
2357 directory.
2359 @node Writing C
2360 @chapter Making The Best Use of C
2362 This chapter provides advice on how best to use the C language
2363 when writing GNU software.
2365 @menu
2366 * Formatting::                  Formatting your source code.
2367 * Comments::                    Commenting your work.
2368 * Syntactic Conventions::       Clean use of C constructs.
2369 * Names::                       Naming variables, functions, and files.
2370 * System Portability::          Portability among different operating systems.
2371 * CPU Portability::             Supporting the range of CPU types.
2372 * System Functions::            Portability and ``standard'' library functions.
2373 * Internationalization::        Techniques for internationalization.
2374 * Character Set::               Use ASCII by default.
2375 * Quote Characters::            Use "..." or '...' in the C locale.
2376 * Mmap::                        How you can safely use @code{mmap}.
2377 @end menu
2379 @node Formatting
2380 @section Formatting Your Source Code
2381 @cindex formatting source code
2383 @cindex line length
2384 @cindex length of source lines
2385 Please keep the length of source lines to 79 characters or less, for
2386 maximum readability in the widest range of environments.
2388 @cindex open brace
2389 @cindex braces, in C source
2390 @cindex function definitions, formatting
2391 It is important to put the open-brace that starts the body of a C
2392 function in column one, so that they will start a defun.  Several
2393 tools look for open-braces in column one to find the beginnings of C
2394 functions.  These tools will not work on code not formatted that way.
2396 Avoid putting open-brace, open-parenthesis or open-bracket in column
2397 one when they are inside a function, so that they won't start a defun.
2398 The open-brace that starts a @code{struct} body can go in column one
2399 if you find it useful to treat that definition as a defun.
2401 It is also important for function definitions to start the name of the
2402 function in column one.  This helps people to search for function
2403 definitions, and may also help certain tools recognize them.  Thus,
2404 using Standard C syntax, the format is this:
2406 @example
2407 static char *
2408 concat (char *s1, char *s2)
2410   @dots{}
2412 @end example
2414 @noindent
2415 or, if you want to use traditional C syntax, format the definition like
2416 this:
2418 @example
2419 static char *
2420 concat (s1, s2)        /* Name starts in column one here */
2421      char *s1, *s2;
2422 @{                     /* Open brace in column one here */
2423   @dots{}
2425 @end example
2427 In Standard C, if the arguments don't fit nicely on one line,
2428 split it like this:
2430 @example
2432 lots_of_args (int an_integer, long a_long, short a_short,
2433               double a_double, float a_float)
2434 @dots{}
2435 @end example
2437 @cindex @code{struct} types, formatting
2438 @cindex @code{enum} types, formatting
2439 For @code{struct} and @code{enum} types, likewise put the braces in
2440 column one, unless the whole contents fits on one line:
2442 @example
2443 struct foo
2445   int a, b;
2447 @exdent @r{or}
2448 struct foo @{ int a, b; @}
2449 @end example
2451 The rest of this section gives our recommendations for other aspects of
2452 C formatting style, which is also the default style of the @code{indent}
2453 program in version 1.2 and newer.  It corresponds to the options
2455 @smallexample
2456 -nbad -bap -nbc -bbo -bl -bli2 -bls -ncdb -nce -cp1 -cs -di2
2457 -ndj -nfc1 -nfca -hnl -i2 -ip5 -lp -pcs -psl -nsc -nsob
2458 @end smallexample
2460 We don't think of these recommendations as requirements, because it
2461 causes no problems for users if two different programs have different
2462 formatting styles.
2464 But whatever style you use, please use it consistently, since a mixture
2465 of styles within one program tends to look ugly.  If you are
2466 contributing changes to an existing program, please follow the style of
2467 that program.
2469 For the body of the function, our recommended style looks like this:
2471 @example
2472 if (x < foo (y, z))
2473   haha = bar[4] + 5;
2474 else
2475   @{
2476     while (z)
2477       @{
2478         haha += foo (z, z);
2479         z--;
2480       @}
2481     return ++x + bar ();
2482   @}
2483 @end example
2485 @cindex spaces before open-paren
2486 We find it easier to read a program when it has spaces before the
2487 open-parentheses and after the commas.  Especially after the commas.
2489 When you split an expression into multiple lines, split it
2490 before an operator, not after one.  Here is the right way:
2492 @cindex expressions, splitting
2493 @example
2494 if (foo_this_is_long && bar > win (x, y, z)
2495     && remaining_condition)
2496 @end example
2498 Try to avoid having two operators of different precedence at the same
2499 level of indentation.  For example, don't write this:
2501 @example
2502 mode = (inmode[j] == VOIDmode
2503         || GET_MODE_SIZE (outmode[j]) > GET_MODE_SIZE (inmode[j])
2504         ? outmode[j] : inmode[j]);
2505 @end example
2507 Instead, use extra parentheses so that the indentation shows the nesting:
2509 @example
2510 mode = ((inmode[j] == VOIDmode
2511          || (GET_MODE_SIZE (outmode[j]) > GET_MODE_SIZE (inmode[j])))
2512         ? outmode[j] : inmode[j]);
2513 @end example
2515 Insert extra parentheses so that Emacs will indent the code properly.
2516 For example, the following indentation looks nice if you do it by hand,
2518 @example
2519 v = rup->ru_utime.tv_sec*1000 + rup->ru_utime.tv_usec/1000
2520     + rup->ru_stime.tv_sec*1000 + rup->ru_stime.tv_usec/1000;
2521 @end example
2523 @noindent
2524 but Emacs would alter it.  Adding a set of parentheses produces
2525 something that looks equally nice, and which Emacs will preserve:
2527 @example
2528 v = (rup->ru_utime.tv_sec*1000 + rup->ru_utime.tv_usec/1000
2529      + rup->ru_stime.tv_sec*1000 + rup->ru_stime.tv_usec/1000);
2530 @end example
2532 Format do-while statements like this:
2534 @example
2536   @{
2537     a = foo (a);
2538   @}
2539 while (a > 0);
2540 @end example
2542 @cindex formfeed
2543 @cindex control-L
2544 Please use formfeed characters (control-L) to divide the program into
2545 pages at logical places (but not within a function).  It does not matter
2546 just how long the pages are, since they do not have to fit on a printed
2547 page.  The formfeeds should appear alone on lines by themselves.
2549 @node Comments
2550 @section Commenting Your Work
2551 @cindex commenting
2553 Every program should start with a comment saying briefly what it is for.
2554 Example: @samp{fmt - filter for simple filling of text}.  This comment
2555 should be at the top of the source file containing the @samp{main}
2556 function of the program.
2558 Also, please write a brief comment at the start of each source file,
2559 with the file name and a line or two about the overall purpose of the
2560 file.
2562 Please write the comments in a GNU program in English, because English
2563 is the one language that nearly all programmers in all countries can
2564 read.  If you do not write English well, please write comments in
2565 English as well as you can, then ask other people to help rewrite them.
2566 If you can't write comments in English, please find someone to work with
2567 you and translate your comments into English.
2569 Please put a comment on each function saying what the function does,
2570 what sorts of arguments it gets, and what the possible values of
2571 arguments mean and are used for.  It is not necessary to duplicate in
2572 words the meaning of the C argument declarations, if a C type is being
2573 used in its customary fashion.  If there is anything nonstandard about
2574 its use (such as an argument of type @code{char *} which is really the
2575 address of the second character of a string, not the first), or any
2576 possible values that would not work the way one would expect (such as,
2577 that strings containing newlines are not guaranteed to work), be sure
2578 to say so.
2580 Also explain the significance of the return value, if there is one.
2582 Please put two spaces after the end of a sentence in your comments, so
2583 that the Emacs sentence commands will work.  Also, please write
2584 complete sentences and capitalize the first word.  If a lower-case
2585 identifier comes at the beginning of a sentence, don't capitalize it!
2586 Changing the spelling makes it a different identifier.  If you don't
2587 like starting a sentence with a lower case letter, write the sentence
2588 differently (e.g., ``The identifier lower-case is @dots{}'').
2590 The comment on a function is much clearer if you use the argument
2591 names to speak about the argument values.  The variable name itself
2592 should be lower case, but write it in upper case when you are speaking
2593 about the value rather than the variable itself.  Thus, ``the inode
2594 number NODE_NUM'' rather than ``an inode''.
2596 There is usually no purpose in restating the name of the function in
2597 the comment before it, because readers can see that for themselves.
2598 There might be an exception when the comment is so long that the function
2599 itself would be off the bottom of the screen.
2601 There should be a comment on each static variable as well, like this:
2603 @example
2604 /* Nonzero means truncate lines in the display;
2605    zero means continue them.  */
2606 int truncate_lines;
2607 @end example
2609 @cindex conditionals, comments for
2610 @cindex @code{#endif}, commenting
2611 Every @samp{#endif} should have a comment, except in the case of short
2612 conditionals (just a few lines) that are not nested.  The comment should
2613 state the condition of the conditional that is ending, @emph{including
2614 its sense}.  @samp{#else} should have a comment describing the condition
2615 @emph{and sense} of the code that follows.  For example:
2617 @example
2618 @group
2619 #ifdef foo
2620   @dots{}
2621 #else /* not foo */
2622   @dots{}
2623 #endif /* not foo */
2624 @end group
2625 @group
2626 #ifdef foo
2627   @dots{}
2628 #endif /* foo */
2629 @end group
2630 @end example
2632 @noindent
2633 but, by contrast, write the comments this way for a @samp{#ifndef}:
2635 @example
2636 @group
2637 #ifndef foo
2638   @dots{}
2639 #else /* foo */
2640   @dots{}
2641 #endif /* foo */
2642 @end group
2643 @group
2644 #ifndef foo
2645   @dots{}
2646 #endif /* not foo */
2647 @end group
2648 @end example
2650 @node Syntactic Conventions
2651 @section Clean Use of C Constructs
2652 @cindex syntactic conventions
2654 @cindex implicit @code{int}
2655 @cindex function argument, declaring
2656 Please explicitly declare the types of all objects.  For example, you
2657 should explicitly declare all arguments to functions, and you should
2658 declare functions to return @code{int} rather than omitting the
2659 @code{int}.
2661 @cindex compiler warnings
2662 @cindex @samp{-Wall} compiler option
2663 Some programmers like to use the GCC @samp{-Wall} option, and change the
2664 code whenever it issues a warning.  If you want to do this, then do.
2665 Other programmers prefer not to use @samp{-Wall}, because it gives
2666 warnings for valid and legitimate code which they do not want to change.
2667 If you want to do this, then do.  The compiler should be your servant,
2668 not your master.
2670 @pindex clang
2671 @pindex lint
2672 Don't make the program ugly just to placate static analysis tools such
2673 as @command{lint}, @command{clang}, and GCC with extra warnings
2674 options such as @option{-Wconversion} and @option{-Wundef}.  These
2675 tools can help find bugs and unclear code, but they can also generate
2676 so many false alarms that it hurts readability to silence them with
2677 unnecessary casts, wrappers, and other complications.  For example,
2678 please don't insert casts to @code{void} or calls to do-nothing
2679 functions merely to pacify a lint checker.
2681 Declarations of external functions and functions to appear later in the
2682 source file should all go in one place near the beginning of the file
2683 (somewhere before the first function definition in the file), or else
2684 should go in a header file.  Don't put @code{extern} declarations inside
2685 functions.
2687 @cindex temporary variables
2688 It used to be common practice to use the same local variables (with
2689 names like @code{tem}) over and over for different values within one
2690 function.  Instead of doing this, it is better to declare a separate local
2691 variable for each distinct purpose, and give it a name which is
2692 meaningful.  This not only makes programs easier to understand, it also
2693 facilitates optimization by good compilers.  You can also move the
2694 declaration of each local variable into the smallest scope that includes
2695 all its uses.  This makes the program even cleaner.
2697 Don't use local variables or parameters that shadow global identifiers.
2698 GCC's @samp{-Wshadow} option can detect this problem.
2700 @cindex multiple variables in a line
2701 Don't declare multiple variables in one declaration that spans lines.
2702 Start a new declaration on each line, instead.  For example, instead
2703 of this:
2705 @example
2706 @group
2707 int    foo,
2708        bar;
2709 @end group
2710 @end example
2712 @noindent
2713 write either this:
2715 @example
2716 int foo, bar;
2717 @end example
2719 @noindent
2720 or this:
2722 @example
2723 int foo;
2724 int bar;
2725 @end example
2727 @noindent
2728 (If they are global variables, each should have a comment preceding it
2729 anyway.)
2731 When you have an @code{if}-@code{else} statement nested in another
2732 @code{if} statement, always put braces around the @code{if}-@code{else}.
2733 Thus, never write like this:
2735 @example
2736 if (foo)
2737   if (bar)
2738     win ();
2739   else
2740     lose ();
2741 @end example
2743 @noindent
2744 always like this:
2746 @example
2747 if (foo)
2748   @{
2749     if (bar)
2750       win ();
2751     else
2752       lose ();
2753   @}
2754 @end example
2756 If you have an @code{if} statement nested inside of an @code{else}
2757 statement, either write @code{else if} on one line, like this,
2759 @example
2760 if (foo)
2761   @dots{}
2762 else if (bar)
2763   @dots{}
2764 @end example
2766 @noindent
2767 with its @code{then}-part indented like the preceding @code{then}-part,
2768 or write the nested @code{if} within braces like this:
2770 @example
2771 if (foo)
2772   @dots{}
2773 else
2774   @{
2775     if (bar)
2776       @dots{}
2777   @}
2778 @end example
2780 Don't declare both a structure tag and variables or typedefs in the
2781 same declaration.  Instead, declare the structure tag separately
2782 and then use it to declare the variables or typedefs.
2784 Try to avoid assignments inside @code{if}-conditions (assignments
2785 inside @code{while}-conditions are ok).  For example, don't write
2786 this:
2788 @example
2789 if ((foo = (char *) malloc (sizeof *foo)) == NULL)
2790   fatal ("virtual memory exhausted");
2791 @end example
2793 @noindent
2794 instead, write this:
2796 @example
2797 foo = (char *) malloc (sizeof *foo);
2798 if (foo == NULL)
2799   fatal ("virtual memory exhausted");
2800 @end example
2802 @node Names
2803 @section Naming Variables, Functions, and Files
2805 @cindex names of variables, functions, and files
2806 The names of global variables and functions in a program serve as
2807 comments of a sort.  So don't choose terse names---instead, look for
2808 names that give useful information about the meaning of the variable or
2809 function.  In a GNU program, names should be English, like other
2810 comments.
2812 Local variable names can be shorter, because they are used only within
2813 one context, where (presumably) comments explain their purpose.
2815 Try to limit your use of abbreviations in symbol names.  It is ok to
2816 make a few abbreviations, explain what they mean, and then use them
2817 frequently, but don't use lots of obscure abbreviations.
2819 Please use underscores to separate words in a name, so that the Emacs
2820 word commands can be useful within them.  Stick to lower case; reserve
2821 upper case for macros and @code{enum} constants, and for name-prefixes
2822 that follow a uniform convention.
2824 For example, you should use names like @code{ignore_space_change_flag};
2825 don't use names like @code{iCantReadThis}.
2827 Variables that indicate whether command-line options have been
2828 specified should be named after the meaning of the option, not after
2829 the option-letter.  A comment should state both the exact meaning of
2830 the option and its letter.  For example,
2832 @example
2833 @group
2834 /* Ignore changes in horizontal whitespace (-b).  */
2835 int ignore_space_change_flag;
2836 @end group
2837 @end example
2839 When you want to define names with constant integer values, use
2840 @code{enum} rather than @samp{#define}.  GDB knows about enumeration
2841 constants.
2843 @cindex file-name limitations
2844 @pindex doschk
2845 You might want to make sure that none of the file names would conflict
2846 if the files were loaded onto an MS-DOS file system which shortens the
2847 names.  You can use the program @code{doschk} to test for this.
2849 Some GNU programs were designed to limit themselves to file names of 14
2850 characters or less, to avoid file name conflicts if they are read into
2851 older System V systems.  Please preserve this feature in the existing
2852 GNU programs that have it, but there is no need to do this in new GNU
2853 programs.  @code{doschk} also reports file names longer than 14
2854 characters.
2857 @node System Portability
2858 @section Portability between System Types
2859 @cindex portability, between system types
2861 In the Unix world, ``portability'' refers to porting to different Unix
2862 versions.  For a GNU program, this kind of portability is desirable, but
2863 not paramount.
2865 The primary purpose of GNU software is to run on top of the GNU kernel,
2866 compiled with the GNU C compiler, on various types of CPU.  So the
2867 kinds of portability that are absolutely necessary are quite limited.
2868 But it is important to support Linux-based GNU systems, since they
2869 are the form of GNU that is popular.
2871 Beyond that, it is good to support the other free operating systems
2872 (*BSD), and it is nice to support other Unix-like systems if you want
2873 to.  Supporting a variety of Unix-like systems is desirable, although
2874 not paramount.  It is usually not too hard, so you may as well do it.
2875 But you don't have to consider it an obligation, if it does turn out to
2876 be hard.
2878 @pindex autoconf
2879 The easiest way to achieve portability to most Unix-like systems is to
2880 use Autoconf.  It's unlikely that your program needs to know more
2881 information about the host platform than Autoconf can provide, simply
2882 because most of the programs that need such knowledge have already been
2883 written.
2885 Avoid using the format of semi-internal data bases (e.g., directories)
2886 when there is a higher-level alternative (@code{readdir}).
2888 @cindex non-POSIX systems, and portability
2889 As for systems that are not like Unix, such as MSDOS, Windows, VMS, MVS,
2890 and older Macintosh systems, supporting them is often a lot of work.
2891 When that is the case, it is better to spend your time adding features
2892 that will be useful on GNU and GNU/Linux, rather than on supporting
2893 other incompatible systems.
2895 If you do support Windows, please do not abbreviate it as ``win''.
2896 @xref{Trademarks}.
2898 Usually we write the name ``Windows'' in full, but when brevity is
2899 very important (as in file names and some symbol names), we abbreviate
2900 it to ``w''.  In GNU Emacs, for instance, we use @samp{w32} in file
2901 names of Windows-specific files, but the macro for Windows
2902 conditionals is called @code{WINDOWSNT}.  In principle there could
2903 also be @samp{w64}.
2905 It is a good idea to define the ``feature test macro''
2906 @code{_GNU_SOURCE} when compiling your C files.  When you compile on GNU
2907 or GNU/Linux, this will enable the declarations of GNU library extension
2908 functions, and that will usually give you a compiler error message if
2909 you define the same function names in some other way in your program.
2910 (You don't have to actually @emph{use} these functions, if you prefer
2911 to make the program more portable to other systems.)
2913 But whether or not you use these GNU extensions, you should avoid
2914 using their names for any other meanings.  Doing so would make it hard
2915 to move your code into other GNU programs.
2917 @node CPU Portability
2918 @section Portability between CPUs
2920 @cindex data types, and portability
2921 @cindex portability, and data types
2922 Even GNU systems will differ because of differences among CPU
2923 types---for example, difference in byte ordering and alignment
2924 requirements.  It is absolutely essential to handle these differences.
2925 However, don't make any effort to cater to the possibility that an
2926 @code{int} will be less than 32 bits.  We don't support 16-bit machines
2927 in GNU.
2929 You need not cater to the possibility that @code{long} will be smaller
2930 than pointers and @code{size_t}.  We know of one such platform: 64-bit
2931 programs on Microsoft Windows.  If you care about making your package
2932 run on Windows using Mingw64, you would need to deal with 8-byte
2933 pointers and 4-byte @code{long}, which would break this code:
2935 @example
2936 printf ("size = %lu\n", (unsigned long) sizeof array);
2937 printf ("diff = %ld\n", (long) (pointer2 - pointer1));
2938 @end example
2940 Whether to support Mingw64, and Windows in general, in your package is
2941 your choice.  The GNU Project doesn't say you have any responsibility to
2942 do so.  Our goal is to replace proprietary systems, including Windows,
2943 not to enhance them.  If people pressure you to make your program run
2944 on Windows, and you are not interested, you can respond with, ``Switch
2945 to GNU/Linux --- your freedom depends on it.''
2947 Predefined file-size types like @code{off_t} are an exception: they are
2948 longer than @code{long} on many platforms, so code like the above won't
2949 work with them.  One way to print an @code{off_t} value portably is to
2950 print its digits yourself, one by one.
2952 Don't assume that the address of an @code{int} object is also the
2953 address of its least-significant byte.  This is false on big-endian
2954 machines.  Thus, don't make the following mistake:
2956 @example
2957 int c;
2958 @dots{}
2959 while ((c = getchar ()) != EOF)
2960   write (file_descriptor, &c, 1);
2961 @end example
2963 @noindent Instead, use @code{unsigned char} as follows.  (The @code{unsigned}
2964 is for portability to unusual systems where @code{char} is signed and
2965 where there is integer overflow checking.)
2967 @example
2968 int c;
2969 while ((c = getchar ()) != EOF)
2970   @{
2971     unsigned char u = c;
2972     write (file_descriptor, &u, 1);
2973   @}
2974 @end example
2976 @cindex casting pointers to integers
2977 Avoid casting pointers to integers if you can.  Such casts greatly
2978 reduce portability, and in most programs they are easy to avoid.  In the
2979 cases where casting pointers to integers is essential---such as, a Lisp
2980 interpreter which stores type information as well as an address in one
2981 word---you'll have to make explicit provisions to handle different word
2982 sizes.  You will also need to make provision for systems in which the
2983 normal range of addresses you can get from @code{malloc} starts far away
2984 from zero.
2987 @node System Functions
2988 @section Calling System Functions
2990 @cindex C library functions, and portability
2991 @cindex POSIX functions, and portability
2992 @cindex library functions, and portability
2993 @cindex portability, and library functions
2995 Historically, C implementations differed substantially, and many
2996 systems lacked a full implementation of ANSI/ISO C89.  Nowadays,
2997 however, all practical systems have a C89 compiler and GNU C supports
2998 almost all of C99 and some of C11.  Similarly, most systems implement
2999 POSIX.1-2001 libraries and tools, and many have POSIX.1-2008.
3001 Hence, there is little reason to support old C or non-POSIX systems,
3002 and you may want to take advantage of standard C and POSIX to write
3003 clearer, more portable, or faster code.  You should use standard
3004 interfaces where possible; but if GNU extensions make your program
3005 more maintainable, powerful, or otherwise better, don't hesitate to
3006 use them.  In any case, don't make your own declaration of system
3007 functions; that's a recipe for conflict.
3009 Despite the standards, nearly every library function has some sort of
3010 portability issue on some system or another.  Here are some examples:
3012 @table @code
3013 @item open
3014 Names with trailing @code{/}'s are mishandled on many platforms.
3016 @item printf
3017 @code{long double} may be unimplemented; floating values Infinity and
3018 NaN are often mishandled; output for large precisions may be
3019 incorrect.
3021 @item readlink
3022 May return @code{int} instead of @code{ssize_t}.
3024 @item scanf
3025 On Windows, @code{errno} is not set on failure.
3026 @end table
3028 @cindex Gnulib
3029 @uref{https://www.gnu.org/software/gnulib/, Gnulib} is a big help in
3030 this regard.  Gnulib provides implementations of standard interfaces
3031 on many of the systems that lack them, including portable
3032 implementations of enhanced GNU interfaces, thereby making their use
3033 portable, and of POSIX-1.2008 interfaces, some of which are missing
3034 even on up-to-date GNU systems.
3036 @findex xmalloc, in Gnulib
3037 @findex error messages, in Gnulib
3038 @findex data structures, in Gnulib
3039 Gnulib also provides many useful non-standard interfaces; for example,
3040 C implementations of standard data structures (hash tables, binary
3041 trees), error-checking type-safe wrappers for memory allocation
3042 functions (@code{xmalloc}, @code{xrealloc}), and output of error
3043 messages.
3045 Gnulib integrates with GNU Autoconf and Automake to remove much of the
3046 burden of writing portable code from the programmer: Gnulib makes your
3047 configure script automatically determine what features are missing and
3048 use the Gnulib code to supply the missing pieces.
3050 The Gnulib and Autoconf manuals have extensive sections on
3051 portability: @ref{Top,, Introduction, gnulib, Gnulib} and
3052 @pxref{Portable C and C++,,, autoconf, Autoconf}.  Please consult them
3053 for many more details.
3056 @node Internationalization
3057 @section Internationalization
3058 @cindex internationalization
3060 @pindex gettext
3061 GNU has a library called GNU gettext that makes it easy to translate the
3062 messages in a program into various languages.  You should use this
3063 library in every program.  Use English for the messages as they appear
3064 in the program, and let gettext provide the way to translate them into
3065 other languages.
3067 Using GNU gettext involves putting a call to the @code{gettext} macro
3068 around each string that might need translation---like this:
3070 @example
3071 printf (gettext ("Processing file '%s'..."), file);
3072 @end example
3074 @noindent
3075 This permits GNU gettext to replace the string @code{"Processing file
3076 '%s'..."} with a translated version.
3078 Once a program uses gettext, please make a point of writing calls to
3079 @code{gettext} when you add new strings that call for translation.
3081 Using GNU gettext in a package involves specifying a @dfn{text domain
3082 name} for the package.  The text domain name is used to separate the
3083 translations for this package from the translations for other packages.
3084 Normally, the text domain name should be the same as the name of the
3085 package---for example, @samp{coreutils} for the GNU core utilities.
3087 @cindex message text, and internationalization
3088 To enable gettext to work well, avoid writing code that makes
3089 assumptions about the structure of words or sentences.  When you want
3090 the precise text of a sentence to vary depending on the data, use two or
3091 more alternative string constants each containing a complete sentences,
3092 rather than inserting conditionalized words or phrases into a single
3093 sentence framework.
3095 Here is an example of what not to do:
3097 @smallexample
3098 printf ("%s is full", capacity > 5000000 ? "disk" : "floppy disk");
3099 @end smallexample
3101 If you apply gettext to all strings, like this,
3103 @smallexample
3104 printf (gettext ("%s is full"),
3105         capacity > 5000000 ? gettext ("disk") : gettext ("floppy disk"));
3106 @end smallexample
3108 @noindent
3109 the translator will hardly know that "disk" and "floppy disk" are meant to
3110 be substituted in the other string.  Worse, in some languages (like French)
3111 the construction will not work: the translation of the word "full" depends
3112 on the gender of the first part of the sentence; it happens to be not the
3113 same for "disk" as for "floppy disk".
3115 Complete sentences can be translated without problems:
3117 @example
3118 printf (capacity > 5000000 ? gettext ("disk is full")
3119         : gettext ("floppy disk is full"));
3120 @end example
3122 A similar problem appears at the level of sentence structure with this
3123 code:
3125 @example
3126 printf ("#  Implicit rule search has%s been done.\n",
3127         f->tried_implicit ? "" : " not");
3128 @end example
3130 @noindent
3131 Adding @code{gettext} calls to this code cannot give correct results for
3132 all languages, because negation in some languages requires adding words
3133 at more than one place in the sentence.  By contrast, adding
3134 @code{gettext} calls does the job straightforwardly if the code starts
3135 out like this:
3137 @example
3138 printf (f->tried_implicit
3139         ? "#  Implicit rule search has been done.\n",
3140         : "#  Implicit rule search has not been done.\n");
3141 @end example
3143 Another example is this one:
3145 @example
3146 printf ("%d file%s processed", nfiles,
3147         nfiles != 1 ? "s" : "");
3148 @end example
3150 @noindent
3151 The problem with this example is that it assumes that plurals are made
3152 by adding `s'.  If you apply gettext to the format string, like this,
3154 @example
3155 printf (gettext ("%d file%s processed"), nfiles,
3156         nfiles != 1 ? "s" : "");
3157 @end example
3159 @noindent
3160 the message can use different words, but it will still be forced to use
3161 `s' for the plural.  Here is a better way, with gettext being applied to
3162 the two strings independently:
3164 @example
3165 printf ((nfiles != 1 ? gettext ("%d files processed")
3166          : gettext ("%d file processed")),
3167         nfiles);
3168 @end example
3170 @noindent
3171 But this still doesn't work for languages like Polish, which has three
3172 plural forms: one for nfiles == 1, one for nfiles == 2, 3, 4, 22, 23, 24, ...
3173 and one for the rest.  The GNU @code{ngettext} function solves this problem:
3175 @example
3176 printf (ngettext ("%d files processed", "%d file processed", nfiles),
3177         nfiles);
3178 @end example
3181 @node Character Set
3182 @section Character Set
3183 @cindex character set
3184 @cindex encodings
3185 @cindex ASCII characters
3186 @cindex non-ASCII characters
3188 Sticking to the ASCII character set (plain text, 7-bit characters) is
3189 preferred in GNU source code comments, text documents, and other
3190 contexts, unless there is good reason to do something else because of
3191 the application domain.  For example, if source code deals with the
3192 French Revolutionary calendar, it is OK if its literal strings contain
3193 accented characters in month names like ``Flor@'eal''.  Also, it is OK
3194 (but not required) to use non-ASCII characters to represent proper
3195 names of contributors in change logs (@pxref{Change Logs}).
3197 If you need to use non-ASCII characters, you should normally stick
3198 with one encoding, certainly within a single file.  UTF-8 is likely to
3199 be the best choice.
3202 @node Quote Characters
3203 @section Quote Characters
3204 @cindex quote characters
3205 @cindex locale-specific quote characters
3206 @cindex left quote
3207 @cindex right quote
3208 @cindex opening quote
3209 @cindex single quote
3210 @cindex double quote
3211 @cindex grave accent
3212 @set txicodequoteundirected
3213 @set txicodequotebacktick
3215 In the C locale, the output of GNU programs should stick to plain
3216 ASCII for quotation characters in messages to users: preferably 0x22
3217 (@samp{"}) or 0x27 (@samp{'}) for both opening and closing quotes.
3218 Although GNU programs traditionally used 0x60 (@samp{`}) for opening
3219 and 0x27 (@samp{'}) for closing quotes, nowadays quotes @samp{`like
3220 this'} are typically rendered asymmetrically, so quoting @samp{"like
3221 this"} or @samp{'like this'} typically looks better.
3223 It is ok, but not required, for GNU programs to generate
3224 locale-specific quotes in non-C locales.  For example:
3226 @example
3227 printf (gettext ("Processing file '%s'..."), file);
3228 @end example
3230 @noindent
3231 Here, a French translation might cause @code{gettext} to return the
3232 string @code{"Traitement de fichier
3233 @guilsinglleft{}@tie{}%s@tie{}@guilsinglright{}..."}, yielding quotes
3234 more appropriate for a French locale.
3236 Sometimes a program may need to use opening and closing quotes
3237 directly.  By convention, @code{gettext} translates the string
3238 @samp{"`"} to the opening quote and the string @samp{"'"} to the
3239 closing quote, and a program can use these translations.  Generally,
3240 though, it is better to translate quote characters in the context of
3241 longer strings.
3243 If the output of your program is ever likely to be parsed by another
3244 program, it is good to provide an option that makes this parsing
3245 reliable.  For example, you could escape special characters using
3246 conventions from the C language or the Bourne shell.  See for example
3247 the option @option{--quoting-style} of GNU @code{ls}.
3249 @clear txicodequoteundirected
3250 @clear txicodequotebacktick
3253 @node Mmap
3254 @section Mmap
3255 @findex mmap
3257 If you use @code{mmap} to read or write files, don't assume it either
3258 works on all files or fails for all files.  It may work on some files
3259 and fail on others.
3261 The proper way to use @code{mmap} is to try it on the specific file for
3262 which you want to use it---and if @code{mmap} doesn't work, fall back on
3263 doing the job in another way using @code{read} and @code{write}.
3265 The reason this precaution is needed is that the GNU kernel (the HURD)
3266 provides a user-extensible file system, in which there can be many
3267 different kinds of ``ordinary files''.  Many of them support
3268 @code{mmap}, but some do not.  It is important to make programs handle
3269 all these kinds of files.
3272 @node Documentation
3273 @chapter Documenting Programs
3274 @cindex documentation
3276 A GNU program should ideally come with full free documentation, adequate
3277 for both reference and tutorial purposes.  If the package can be
3278 programmed or extended, the documentation should cover programming or
3279 extending it, as well as just using it.
3281 @menu
3282 * GNU Manuals::                 Writing proper manuals.
3283 * Doc Strings and Manuals::     Compiling doc strings doesn't make a manual.
3284 * Manual Structure Details::    Specific structure conventions.
3285 * License for Manuals::         Writing the distribution terms for a manual.
3286 * Manual Credits::              Giving credit to documentation contributors.
3287 * Printed Manuals::             Mentioning the printed manual.
3288 * NEWS File::                   NEWS files supplement manuals.
3289 * Change Logs::                 Recording changes.
3290 * Man Pages::                   Man pages are secondary.
3291 * Reading other Manuals::       How far you can go in learning
3292                                 from other manuals.
3293 @end menu
3295 @node GNU Manuals
3296 @section GNU Manuals
3298 The preferred document format for the GNU system is the Texinfo
3299 formatting language.  Every GNU package should (ideally) have
3300 documentation in Texinfo both for reference and for learners.  Texinfo
3301 makes it possible to produce a good quality formatted book, using
3302 @TeX{}, and to generate an Info file.  It is also possible to generate
3303 HTML output from Texinfo source.  See the Texinfo manual, either the
3304 hardcopy, or the on-line version available through @code{info} or the
3305 Emacs Info subsystem (@kbd{C-h i}).
3307 Nowadays some other formats such as Docbook and Sgmltexi can be
3308 converted automatically into Texinfo.  It is ok to produce the Texinfo
3309 documentation by conversion this way, as long as it gives good results.
3311 Make sure your manual is clear to a reader who knows nothing about the
3312 topic and reads it straight through.  This means covering basic topics
3313 at the beginning, and advanced topics only later.  This also means
3314 defining every specialized term when it is first used.
3316 Programmers tend to carry over the structure of the program as the
3317 structure for its documentation.  But this structure is not
3318 necessarily good for explaining how to use the program; it may be
3319 irrelevant and confusing for a user.
3321 Instead, the right way to structure documentation is according to the
3322 concepts and questions that a user will have in mind when reading it.
3323 This principle applies at every level, from the lowest (ordering
3324 sentences in a paragraph) to the highest (ordering of chapter topics
3325 within the manual).  Sometimes this structure of ideas matches the
3326 structure of the implementation of the software being documented---but
3327 often they are different.  An important part of learning to write good
3328 documentation is to learn to notice when you have unthinkingly
3329 structured the documentation like the implementation, stop yourself,
3330 and look for better alternatives.
3332 For example, each program in the GNU system probably ought to be
3333 documented in one manual; but this does not mean each program should
3334 have its own manual.  That would be following the structure of the
3335 implementation, rather than the structure that helps the user
3336 understand.
3338 Instead, each manual should cover a coherent @emph{topic}.  For example,
3339 instead of a manual for @code{diff} and a manual for @code{diff3}, we
3340 have one manual for ``comparison of files'' which covers both of those
3341 programs, as well as @code{cmp}.  By documenting these programs
3342 together, we can make the whole subject clearer.
3344 The manual which discusses a program should certainly document all of
3345 the program's command-line options and all of its commands.  It should
3346 give examples of their use.  But don't organize the manual as a list
3347 of features.  Instead, organize it logically, by subtopics.  Address
3348 the questions that a user will ask when thinking about the job that
3349 the program does.  Don't just tell the reader what each feature can
3350 do---say what jobs it is good for, and show how to use it for those
3351 jobs.  Explain what is recommended usage, and what kinds of usage
3352 users should avoid.
3354 In general, a GNU manual should serve both as tutorial and reference.
3355 It should be set up for convenient access to each topic through Info,
3356 and for reading straight through (appendixes aside).  A GNU manual
3357 should give a good introduction to a beginner reading through from the
3358 start, and should also provide all the details that hackers want.
3359 The Bison manual is a good example of this---please take a look at it
3360 to see what we mean.
3362 That is not as hard as it first sounds.  Arrange each chapter as a
3363 logical breakdown of its topic, but order the sections, and write their
3364 text, so that reading the chapter straight through makes sense.  Do
3365 likewise when structuring the book into chapters, and when structuring a
3366 section into paragraphs.  The watchword is, @emph{at each point, address
3367 the most fundamental and important issue raised by the preceding text.}
3369 If necessary, add extra chapters at the beginning of the manual which
3370 are purely tutorial and cover the basics of the subject.  These provide
3371 the framework for a beginner to understand the rest of the manual.  The
3372 Bison manual provides a good example of how to do this.
3374 To serve as a reference, a manual should have an Index that lists all
3375 the functions, variables, options, and important concepts that are
3376 part of the program.  One combined Index should do for a short manual,
3377 but sometimes for a complex package it is better to use multiple
3378 indices.  The Texinfo manual includes advice on preparing good index
3379 entries, see @ref{Index Entries, , Making Index Entries, texinfo, GNU
3380 Texinfo}, and see @ref{Indexing Commands, , Defining the Entries of an
3381 Index, texinfo, GNU Texinfo}.
3383 Don't use Unix man pages as a model for how to write GNU documentation;
3384 most of them are terse, badly structured, and give inadequate
3385 explanation of the underlying concepts.  (There are, of course, some
3386 exceptions.)  Also, Unix man pages use a particular format which is
3387 different from what we use in GNU manuals.
3389 Please include an email address in the manual for where to report
3390 bugs @emph{in the text of the manual}.
3392 Please do not use the term ``pathname'' that is used in Unix
3393 documentation; use ``file name'' (two words) instead.  We use the term
3394 ``path'' only for search paths, which are lists of directory names.
3396 Please do not use the term ``illegal'' to refer to erroneous input to
3397 a computer program.  Please use ``invalid'' for this, and reserve the
3398 term ``illegal'' for activities prohibited by law.
3400 Please do not write @samp{()} after a function name just to indicate
3401 it is a function.  @code{foo ()} is not a function, it is a function
3402 call with no arguments.
3404 Whenever possible, please stick to the active voice, avoiding the
3405 passive, and use the present tense, not the future tense.  For
3406 instance, write ``The function @code{foo} returns a list containing
3407 @var{a} and @var{b}'' rather than ``A list containing @var{a} and
3408 @var{b} will be returned.''  One advantage of the active voice is it
3409 requires you to state the subject of the sentence; with the passive
3410 voice, you might omit the subject, which leads to vagueness.
3412 It is proper to use the future tense when grammar demands it, as in,
3413 ``If you type @kbd{x}, the computer will self-destruct in 10
3414 seconds.''
3416 @node Doc Strings and Manuals
3417 @section Doc Strings and Manuals
3419 Some programming systems, such as Emacs, provide a documentation string
3420 for each function, command or variable.  You may be tempted to write a
3421 reference manual by compiling the documentation strings and writing a
3422 little additional text to go around them---but you must not do it.  That
3423 approach is a fundamental mistake.  The text of well-written
3424 documentation strings will be entirely wrong for a manual.
3426 A documentation string needs to stand alone---when it appears on the
3427 screen, there will be no other text to introduce or explain it.
3428 Meanwhile, it can be rather informal in style.
3430 The text describing a function or variable in a manual must not stand
3431 alone; it appears in the context of a section or subsection.  Other text
3432 at the beginning of the section should explain some of the concepts, and
3433 should often make some general points that apply to several functions or
3434 variables.  The previous descriptions of functions and variables in the
3435 section will also have given information about the topic.  A description
3436 written to stand alone would repeat some of that information; this
3437 redundancy looks bad.  Meanwhile, the informality that is acceptable in
3438 a documentation string is totally unacceptable in a manual.
3440 The only good way to use documentation strings in writing a good manual
3441 is to use them as a source of information for writing good text.
3443 @node Manual Structure Details
3444 @section Manual Structure Details
3445 @cindex manual structure
3447 The title page of the manual should state the version of the programs or
3448 packages documented in the manual.  The Top node of the manual should
3449 also contain this information.  If the manual is changing more
3450 frequently than or independent of the program, also state a version
3451 number for the manual in both of these places.
3453 Each program documented in the manual should have a node named
3454 @samp{@var{program} Invocation} or @samp{Invoking @var{program}}.  This
3455 node (together with its subnodes, if any) should describe the program's
3456 command line arguments and how to run it (the sort of information people
3457 would look for in a man page).  Start with an @samp{@@example}
3458 containing a template for all the options and arguments that the program
3459 uses.
3461 Alternatively, put a menu item in some menu whose item name fits one of
3462 the above patterns.  This identifies the node which that item points to
3463 as the node for this purpose, regardless of the node's actual name.
3465 The @samp{--usage} feature of the Info reader looks for such a node
3466 or menu item in order to find the relevant text, so it is essential
3467 for every Texinfo file to have one.
3469 If one manual describes several programs, it should have such a node for
3470 each program described in the manual.
3472 @node License for Manuals
3473 @section License for Manuals
3474 @cindex license for manuals
3476 Please use the GNU Free Documentation License for all GNU manuals that
3477 are more than a few pages long.  Likewise for a collection of short
3478 documents---you only need one copy of the GNU FDL for the whole
3479 collection.  For a single short document, you can use a very permissive
3480 non-copyleft license, to avoid taking up space with a long license.
3482 See @uref{https://www.gnu.org/copyleft/fdl-howto.html} for more explanation
3483 of how to employ the GFDL.
3485 Note that it is not obligatory to include a copy of the GNU GPL or GNU
3486 LGPL in a manual whose license is neither the GPL nor the LGPL.  It can
3487 be a good idea to include the program's license in a large manual; in a
3488 short manual, whose size would be increased considerably by including
3489 the program's license, it is probably better not to include it.
3491 @node Manual Credits
3492 @section Manual Credits
3493 @cindex credits for manuals
3495 Please credit the principal human writers of the manual as the authors,
3496 on the title page of the manual.  If a company sponsored the work, thank
3497 the company in a suitable place in the manual, but do not cite the
3498 company as an author.
3500 @node Printed Manuals
3501 @section Printed Manuals
3503 The FSF publishes some GNU manuals in printed form.  To encourage sales
3504 of these manuals, the on-line versions of the manual should mention at
3505 the very start that the printed manual is available and should point at
3506 information for getting it---for instance, with a link to the page
3507 @url{https://www.gnu.org/order/order.html}.  This should not be included
3508 in the printed manual, though, because there it is redundant.
3510 It is also useful to explain in the on-line forms of the manual how the
3511 user can print out the manual from the sources.
3513 @node NEWS File
3514 @section The NEWS File
3515 @cindex @file{NEWS} file
3517 In addition to its manual, the package should have a file named
3518 @file{NEWS} which contains a list of user-visible changes worth
3519 mentioning.  In each new release, add items to the front of the file and
3520 identify the version they pertain to.  Don't discard old items; leave
3521 them in the file after the newer items.  This way, a user upgrading from
3522 any previous version can see what is new.
3524 If the @file{NEWS} file gets very long, move some of the older items
3525 into a file named @file{ONEWS} and put a note at the end referring the
3526 user to that file.
3528 @node Change Logs
3529 @section Change Logs
3530 @cindex change logs
3532 Keep a change log to describe all the changes made to program source
3533 files.  The purpose of this is so that people investigating bugs in the
3534 future will know about the changes that might have introduced the bug.
3535 Often a new bug can be found by looking at what was recently changed.
3536 More importantly, change logs can help you eliminate conceptual
3537 inconsistencies between different parts of a program, by giving you a
3538 history of how the conflicting concepts arose and who they came from.
3540 @menu
3541 * Change Log Concepts::
3542 * Style of Change Logs::
3543 * Simple Changes::
3544 * Conditional Changes::
3545 * Indicating the Part Changed::
3546 @end menu
3548 @node Change Log Concepts
3549 @subsection Change Log Concepts
3551 @cindex change set
3552 @cindex batch of changes
3553 You can think of the change log as a conceptual ``undo list'' which
3554 states how earlier versions were different from the current version.
3555 People can see the current version; they don't need the change log to
3556 tell them what is in it.  What they want from a change log is a clear
3557 explanation of how the earlier version differed.  Each @dfn{entry} in
3558 a change log describes either an individual change or the smallest
3559 batch of changes that belong together, also known as a @dfn{change
3560 set}.
3562 @cindex title, change log entry
3563 @cindex description, change log entry
3564 It is a good idea to start the change log entry with a description
3565 of the overall change.  This should be as long as needed to give
3566 a clear description.
3568 Then give a list of names of the entities or definitions that you
3569 changed, according to the files they are in, and what was changed
3570 in each one.  @xref{Style of Change Logs}.
3572 The change log file is normally called @file{ChangeLog} and covers an
3573 entire directory.  Each directory can have its own change log, or a
3574 directory can use the change log of its parent directory---it's up to
3575 you.
3577 Instead of using a file named @file{ChangeLog}, you can record the
3578 change log information as log entries in a version control system such
3579 as RCS or CVS.  This can be converted automatically to a
3580 @file{ChangeLog} file using @code{rcs2log}; in Emacs, the command
3581 @kbd{C-x v a} (@code{vc-update-change-log}) does the job.
3583 The best place to explain how parts of the new code work with other code
3584 is in comments in the code, not in the change log.
3586 If you think that a change calls for explanation of @emph{why} the
3587 change was needed---that is, what problem the old code had such that
3588 it required this change---you're probably right.  Please put the
3589 explanation in comments in the code, where people will see it whenever
3590 they see the code.  An example of such an explanation is, ``This
3591 function used to be iterative, but that failed when MUMBLE was a
3592 tree.''  (Though such a simple reason would not need this kind of
3593 explanation.)
3595 The best place for other kinds of explanation of the change is in the
3596 change log entry.
3598 The easiest way to add an entry to @file{ChangeLog} is with the Emacs
3599 command @kbd{M-x add-change-log-entry}.  An individual change should
3600 have an asterisk, the name of the changed file, and then in
3601 parentheses the name of the changed functions, variables or whatever,
3602 followed by a colon.  Then describe the changes you made to that
3603 function or variable.
3605 @node Style of Change Logs
3606 @subsection Style of Change Logs
3607 @cindex change logs, style
3609 Here are some simple examples of change log entries, starting with the
3610 header line that says who made the change and when it was installed,
3611 followed by descriptions of specific changes.  (These examples are
3612 drawn from Emacs and GCC.)
3614 @example
3615 1998-08-17  Richard Stallman  <rms@@gnu.org>
3617 * register.el (insert-register): Return nil.
3618 (jump-to-register): Likewise.
3620 * sort.el (sort-subr): Return nil.
3622 * tex-mode.el (tex-bibtex-file, tex-file, tex-region):
3623 Restart the tex shell if process is gone or stopped.
3624 (tex-shell-running): New function.
3626 * expr.c (store_one_arg): Round size up for move_block_to_reg.
3627 (expand_call): Round up when emitting USE insns.
3628 * stmt.c (assign_parms): Round size up for move_block_from_reg.
3629 @end example
3631 It's important to name the changed function or variable in full.  Don't
3632 abbreviate function or variable names, and don't combine them.
3633 Subsequent maintainers will often search for a function name to find all
3634 the change log entries that pertain to it; if you abbreviate the name,
3635 they won't find it when they search.
3637 For example, some people are tempted to abbreviate groups of function
3638 names by writing @samp{* register.el (@{insert,jump-to@}-register)};
3639 this is not a good idea, since searching for @code{jump-to-register} or
3640 @code{insert-register} would not find that entry.
3642 Separate unrelated change log entries with blank lines.  Don't put
3643 blank lines between individual changes of an entry.  You can omit the
3644 file name and the asterisk when successive individual changes are in
3645 the same file.
3647 Break long lists of function names by closing continued lines with
3648 @samp{)}, rather than @samp{,}, and opening the continuation with
3649 @samp{(} as in this example:
3651 @example
3652 * keyboard.c (menu_bar_items, tool_bar_items)
3653 (Fexecute_extended_command): Deal with 'keymap' property.
3654 @end example
3656 When you install someone else's changes, put the contributor's name in
3657 the change log entry rather than in the text of the entry.  In other
3658 words, write this:
3660 @example
3661 2002-07-14  John Doe  <jdoe@@gnu.org>
3663         * sewing.c: Make it sew.
3664 @end example
3666 @noindent
3667 rather than this:
3669 @example
3670 2002-07-14  Usual Maintainer  <usual@@gnu.org>
3672         * sewing.c: Make it sew.  Patch by jdoe@@gnu.org.
3673 @end example
3675 As for the date, that should be the date you applied the change.
3677 @node Simple Changes
3678 @subsection Simple Changes
3680 Certain simple kinds of changes don't need much detail in the change
3681 log.
3683 When you change the calling sequence of a function in a simple fashion,
3684 and you change all the callers of the function to use the new calling
3685 sequence, there is no need to make individual entries for all the
3686 callers that you changed.  Just write in the entry for the function
3687 being called, ``All callers changed''---like this:
3689 @example
3690 * keyboard.c (Fcommand_execute): New arg SPECIAL.
3691 All callers changed.
3692 @end example
3694 When you change just comments or doc strings, it is enough to write an
3695 entry for the file, without mentioning the functions.  Just ``Doc
3696 fixes'' is enough for the change log.
3698 There's no technical need to make change log entries for non-software
3699 files (manuals, help files, media files, etc.).  This is because they
3700 are not susceptible to bugs that are hard to understand.  To correct
3701 an error, you need not know the history of the erroneous passage; it
3702 is enough to compare what the file says with the actual facts.
3704 However, you should keep change logs for non-software files when the
3705 project gets copyright assignments from its contributors, so as to
3706 make the records of authorship more accurate.
3708 @node Conditional Changes
3709 @subsection Conditional Changes
3710 @cindex conditional changes, and change logs
3711 @cindex change logs, conditional changes
3713 Source files can often contain code that is conditional to build-time
3714 or static conditions.  For example, C programs can contain
3715 compile-time @code{#if} conditionals; programs implemented in
3716 interpreted languages can contain module imports of function
3717 definitions that are only performed for certain versions of the
3718 interpreter; and Automake @file{Makefile.am} files can contain
3719 variable definitions or target declarations that are only to be
3720 considered if a configure-time Automake conditional is true.
3722 Many changes are conditional as well: sometimes you add a new variable,
3723 or function, or even a new program or library, which is entirely
3724 dependent on a build-time condition.  It is useful to indicate
3725 in the change log the conditions for which a change applies.
3727 Our convention for indicating conditional changes is to use
3728 @emph{square brackets around the name of the condition}.
3730 Conditional changes can happen in numerous scenarios and with many
3731 variations, so here are some examples to help clarify.  This first
3732 example describes changes in C, Perl, and Python files which are
3733 conditional but do not have an associated function or entity name:
3735 @example
3736 * xterm.c [SOLARIS2]: Include <string.h>.
3737 * FilePath.pm [$^O eq 'VMS']: Import the VMS::Feature module.
3738 * framework.py [sys.version_info < (2, 6)]: Make "with" statement
3739   available by importing it from __future__,
3740   to support also python 2.5.
3741 @end example
3743 Our other examples will for simplicity be limited to C, as the minor
3744 changes necessary to adapt them to other languages should be
3745 self-evident.
3747 Next, here is an entry describing a new definition which is entirely
3748 conditional: the C macro @code{FRAME_WINDOW_P} is defined (and used)
3749 only when the macro @code{HAVE_X_WINDOWS} is defined:
3751 @example
3752 * frame.h [HAVE_X_WINDOWS] (FRAME_WINDOW_P): Macro defined.
3753 @end example
3755 Next, an entry for a change within the function @code{init_display},
3756 whose definition as a whole is unconditional, but the changes
3757 themselves are contained in a @samp{#ifdef HAVE_LIBNCURSES}
3758 conditional:
3760 @example
3761 * dispnew.c (init_display) [HAVE_LIBNCURSES]: If X, call tgetent.
3762 @end example
3764 Finally, here is an entry for a change that takes effect only when
3765 a certain macro is @emph{not} defined:
3767 @example
3768 * host.c (gethostname) [!HAVE_SOCKETS]: Replace with winsock version.
3769 @end example
3772 @node Indicating the Part Changed
3773 @subsection Indicating the Part Changed
3775 Indicate the part of a function which changed by using angle brackets
3776 enclosing an indication of what the changed part does.  Here is an entry
3777 for a change in the part of the function @code{sh-while-getopts} that
3778 deals with @code{sh} commands:
3780 @example
3781 * progmodes/sh-script.el (sh-while-getopts) <sh>: Handle case that
3782 user-specified option string is empty.
3783 @end example
3786 @node Man Pages
3787 @section Man Pages
3788 @cindex man pages
3790 In the GNU project, man pages are secondary.  It is not necessary or
3791 expected for every GNU program to have a man page, but some of them do.
3792 It's your choice whether to include a man page in your program.
3794 When you make this decision, consider that supporting a man page
3795 requires continual effort each time the program is changed.  The time
3796 you spend on the man page is time taken away from more useful work.
3798 For a simple program which changes little, updating the man page may be
3799 a small job.  Then there is little reason not to include a man page, if
3800 you have one.
3802 For a large program that changes a great deal, updating a man page may
3803 be a substantial burden.  If a user offers to donate a man page, you may
3804 find this gift costly to accept.  It may be better to refuse the man
3805 page unless the same person agrees to take full responsibility for
3806 maintaining it---so that you can wash your hands of it entirely.  If
3807 this volunteer later ceases to do the job, then don't feel obliged to
3808 pick it up yourself; it may be better to withdraw the man page from the
3809 distribution until someone else agrees to update it.
3811 When a program changes only a little, you may feel that the
3812 discrepancies are small enough that the man page remains useful without
3813 updating.  If so, put a prominent note near the beginning of the man
3814 page stating that you don't maintain it and that the Texinfo manual
3815 is more authoritative.  The note should say how to access the Texinfo
3816 documentation.
3818 Be sure that man pages include a copyright statement and free license.
3819 The simple all-permissive license is appropriate for simple man pages
3820 (@pxref{License Notices for Other Files,,,maintain,Information for GNU
3821 Maintainers}).
3823 For long man pages, with enough explanation and documentation that
3824 they can be considered true manuals, use the GFDL (@pxref{License for
3825 Manuals}).
3827 Finally, the GNU help2man program
3828 (@uref{https://www.gnu.org/software/help2man/}) is one way to automate
3829 generation of a man page, in this case from @option{--help} output.
3830 This is sufficient in many cases.
3832 @node Reading other Manuals
3833 @section Reading other Manuals
3835 There may be non-free books or documentation files that describe the
3836 program you are documenting.
3838 It is ok to use these documents for reference, just as the author of a
3839 new algebra textbook can read other books on algebra.  A large portion
3840 of any non-fiction book consists of facts, in this case facts about how
3841 a certain program works, and these facts are necessarily the same for
3842 everyone who writes about the subject.  But be careful not to copy your
3843 outline structure, wording, tables or examples from preexisting non-free
3844 documentation.  Copying from free documentation may be ok; please check
3845 with the FSF about the individual case.
3847 @node Managing Releases
3848 @chapter The Release Process
3849 @cindex releasing
3851 Making a release is more than just bundling up your source files in a
3852 tar file and putting it up for FTP.  You should set up your software so
3853 that it can be configured to run on a variety of systems.  Your Makefile
3854 should conform to the GNU standards described below, and your directory
3855 layout should also conform to the standards discussed below.  Doing so
3856 makes it easy to include your package into the larger framework of
3857 all GNU software.
3859 @menu
3860 * Configuration::               How configuration of GNU packages should work.
3861 * Makefile Conventions::        Makefile conventions.
3862 * Releases::                    Making releases
3863 @end menu
3865 @node Configuration
3866 @section How Configuration Should Work
3867 @cindex program configuration
3869 @pindex configure
3870 Each GNU distribution should come with a shell script named
3871 @code{configure}.  This script is given arguments which describe the
3872 kind of machine and system you want to compile the program for.
3873 The @code{configure} script must record the configuration options so
3874 that they affect compilation.
3876 The description here is the specification of the interface for the
3877 @code{configure} script in GNU packages.  Many packages implement it
3878 using GNU Autoconf (@pxref{Top,, Introduction, autoconf, Autoconf})
3879 and/or GNU Automake (@pxref{Top,, Introduction, automake, Automake}),
3880 but you do not have to use these tools.  You can implement it any way
3881 you like; for instance, by making @code{configure} be a wrapper around
3882 a completely different configuration system.
3884 Another way for the @code{configure} script to operate is to make a
3885 link from a standard name such as @file{config.h} to the proper
3886 configuration file for the chosen system.  If you use this technique,
3887 the distribution should @emph{not} contain a file named
3888 @file{config.h}.  This is so that people won't be able to build the
3889 program without configuring it first.
3891 Another thing that @code{configure} can do is to edit the Makefile.  If
3892 you do this, the distribution should @emph{not} contain a file named
3893 @file{Makefile}.  Instead, it should include a file @file{Makefile.in} which
3894 contains the input used for editing.  Once again, this is so that people
3895 won't be able to build the program without configuring it first.
3897 If @code{configure} does write the @file{Makefile}, then @file{Makefile}
3898 should have a target named @file{Makefile} which causes @code{configure}
3899 to be rerun, setting up the same configuration that was set up last
3900 time.  The files that @code{configure} reads should be listed as
3901 dependencies of @file{Makefile}.
3903 All the files which are output from the @code{configure} script should
3904 have comments at the beginning stating that they were generated
3905 automatically using @code{configure}.  This is so that users won't think
3906 of trying to edit them by hand.
3908 The @code{configure} script should write a file named @file{config.status}
3909 which describes which configuration options were specified when the
3910 program was last configured.  This file should be a shell script which,
3911 if run, will recreate the same configuration.
3913 The @code{configure} script should accept an option of the form
3914 @samp{--srcdir=@var{dirname}} to specify the directory where sources are found
3915 (if it is not the current directory).  This makes it possible to build
3916 the program in a separate directory, so that the actual source directory
3917 is not modified.
3919 If the user does not specify @samp{--srcdir}, then @code{configure} should
3920 check both @file{.} and @file{..} to see if it can find the sources.  If
3921 it finds the sources in one of these places, it should use them from
3922 there.  Otherwise, it should report that it cannot find the sources, and
3923 should exit with nonzero status.
3925 Usually the easy way to support @samp{--srcdir} is by editing a
3926 definition of @code{VPATH} into the Makefile.  Some rules may need to
3927 refer explicitly to the specified source directory.  To make this
3928 possible, @code{configure} can add to the Makefile a variable named
3929 @code{srcdir} whose value is precisely the specified directory.
3931 In addition, the @samp{configure} script should take options
3932 corresponding to most of the standard directory variables
3933 (@pxref{Directory Variables}).  Here is the list:
3935 @example
3936 --prefix --exec-prefix --bindir --sbindir --libexecdir --sysconfdir
3937 --sharedstatedir --localstatedir --runstatedir
3938 --libdir --includedir --oldincludedir
3939 --datarootdir --datadir --infodir --localedir --mandir --docdir
3940 --htmldir --dvidir --pdfdir --psdir
3941 @end example
3943 The @code{configure} script should also take an argument which specifies the
3944 type of system to build the program for.  This argument should look like
3945 this:
3947 @example
3948 @var{cpu}-@var{company}-@var{system}
3949 @end example
3951 For example, an Athlon-based GNU/Linux system might be
3952 @samp{i686-pc-linux-gnu}.
3954 The @code{configure} script needs to be able to decode all plausible
3955 alternatives for how to describe a machine.  Thus,
3956 @samp{athlon-pc-gnu/linux} would be a valid alias.  There is a shell
3957 script called
3958 @uref{https://git.savannah.gnu.org/@/gitweb/@/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD,
3959 @file{config.sub}} that you can use as a subroutine to validate system
3960 types and canonicalize aliases.
3962 The @code{configure} script should also take the option
3963 @option{--build=@var{buildtype}}, which should be equivalent to a
3964 plain @var{buildtype} argument.  For example, @samp{configure
3965 --build=i686-pc-linux-gnu} is equivalent to @samp{configure
3966 i686-pc-linux-gnu}.  When the build type is not specified by an option
3967 or argument, the @code{configure} script should normally guess it using
3968 the shell script
3969 @uref{https://git.savannah.gnu.org/@/gitweb/@/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD,
3970 @file{config.guess}}.
3972 @cindex optional features, configure-time
3973 Other options are permitted to specify in more detail the software
3974 or hardware present on the machine, to include or exclude optional parts
3975 of the package, or to adjust the name of some tools or arguments to them:
3977 @table @samp
3978 @item --enable-@var{feature}@r{[}=@var{parameter}@r{]}
3979 Configure the package to build and install an optional user-level
3980 facility called @var{feature}.  This allows users to choose which
3981 optional features to include.  Giving an optional @var{parameter} of
3982 @samp{no} should omit @var{feature}, if it is built by default.
3984 No @samp{--enable} option should @strong{ever} cause one feature to
3985 replace another.  No @samp{--enable} option should ever substitute one
3986 useful behavior for another useful behavior.  The only proper use for
3987 @samp{--enable} is for questions of whether to build part of the program
3988 or exclude it.
3990 @item --with-@var{package}
3991 @c @r{[}=@var{parameter}@r{]}
3992 The package @var{package} will be installed, so configure this package
3993 to work with @var{package}.
3995 @c  Giving an optional @var{parameter} of
3996 @c @samp{no} should omit @var{package}, if it is used by default.
3998 Possible values of @var{package} include
3999 @samp{gnu-as} (or @samp{gas}), @samp{gnu-ld}, @samp{gnu-libc},
4000 @samp{gdb},
4001 @samp{x},
4003 @samp{x-toolkit}.
4005 Do not use a @samp{--with} option to specify the file name to use to
4006 find certain files.  That is outside the scope of what @samp{--with}
4007 options are for.
4009 @item @var{variable}=@var{value}
4010 Set the value of the variable @var{variable} to @var{value}.  This is
4011 used to override the default values of commands or arguments in the
4012 build process.  For example, the user could issue @samp{configure
4013 CFLAGS=-g CXXFLAGS=-g} to build with debugging information and without
4014 the default optimization.
4016 Specifying variables as arguments to @code{configure}, like this:
4017 @example
4018 ./configure CC=gcc
4019 @end example
4020 is preferable to setting them in environment variables:
4021 @example
4022 CC=gcc ./configure
4023 @end example
4024 as it helps to recreate the same configuration later with
4025 @file{config.status}.  However, both methods should be supported.
4026 @end table
4028 All @code{configure} scripts should accept all of the ``detail''
4029 options and the variable settings, whether or not they make any
4030 difference to the particular package at hand.  In particular, they
4031 should accept any option that starts with @samp{--with-} or
4032 @samp{--enable-}.  This is so users will be able to configure an
4033 entire GNU source tree at once with a single set of options.
4035 You will note that the categories @samp{--with-} and @samp{--enable-}
4036 are narrow: they @strong{do not} provide a place for any sort of option
4037 you might think of.  That is deliberate.  We want to limit the possible
4038 configuration options in GNU software.  We do not want GNU programs to
4039 have idiosyncratic configuration options.
4041 Packages that perform part of the compilation process may support
4042 cross-compilation.  In such a case, the host and target machines for the
4043 program may be different.
4045 The @code{configure} script should normally treat the specified type of
4046 system as both the host and the target, thus producing a program which
4047 works for the same type of machine that it runs on.
4049 To compile a program to run on a host type that differs from the build
4050 type, use the configure option @option{--host=@var{hosttype}}, where
4051 @var{hosttype} uses the same syntax as @var{buildtype}.  The host type
4052 normally defaults to the build type.
4054 To configure a cross-compiler, cross-assembler, or what have you, you
4055 should specify a target different from the host, using the configure
4056 option @samp{--target=@var{targettype}}.  The syntax for
4057 @var{targettype} is the same as for the host type.  So the command would
4058 look like this:
4060 @example
4061 ./configure --host=@var{hosttype} --target=@var{targettype}
4062 @end example
4064 The target type normally defaults to the host type.
4065 Programs for which cross-operation is not meaningful need not accept the
4066 @samp{--target} option, because configuring an entire operating system for
4067 cross-operation is not a meaningful operation.
4069 Some programs have ways of configuring themselves automatically.  If
4070 your program is set up to do this, your @code{configure} script can simply
4071 ignore most of its arguments.
4073 @comment The makefile standards are in a separate file that is also
4074 @comment included by make.texinfo.  Done by roland@gnu.ai.mit.edu on 1/6/93.
4075 @comment For this document, turn chapters into sections, etc.
4076 @lowersections
4077 @include make-stds.texi
4078 @raisesections
4080 @node Releases
4081 @section Making Releases
4082 @cindex packaging
4084 @cindex version numbers, for releases
4085 You should identify each release with a pair of version numbers, a
4086 major version and a minor.  We have no objection to using more than
4087 two numbers, but it is very unlikely that you really need them.
4089 Package the distribution of @code{Foo version 69.96} up in a gzipped tar
4090 file with the name @file{foo-69.96.tar.gz}.  It should unpack into a
4091 subdirectory named @file{foo-69.96}.
4093 Building and installing the program should never modify any of the files
4094 contained in the distribution.  This means that all the files that form
4095 part of the program in any way must be classified into @dfn{source
4096 files} and @dfn{non-source files}.  Source files are written by humans
4097 and never changed automatically; non-source files are produced from
4098 source files by programs under the control of the Makefile.
4100 @cindex @file{README} file
4101 The distribution should contain a file named @file{README} with a
4102 general overview of the package:
4104 @itemize
4105 @item the name of the package;
4107 @item the version number of the package, or refer to where in the
4108 package the version can be found;
4110 @item a general description of what the package does;
4112 @item a reference to the file @file{INSTALL}, which
4113 should in turn contain an explanation of the installation procedure;
4115 @item a brief explanation of any unusual top-level directories or
4116 files, or other hints for readers to find their way around the source;
4118 @item a reference to the file which contains the copying conditions.
4119 The GNU GPL, if used, should be in a file called @file{COPYING}.  If
4120 the GNU LGPL is used, it should be in a file called
4121 @file{COPYING.LESSER}.
4122 @end itemize
4124 Naturally, all the source files must be in the distribution.  It is
4125 okay to include non-source files in the distribution along with the
4126 source files they are generated from, provided they are up-to-date
4127 with the source they are made from, and machine-independent, so that
4128 normal building of the distribution will never modify them.  We
4129 commonly include non-source files produced by Autoconf, Automake,
4130 Bison, @code{flex}, @TeX{}, and @code{makeinfo}; this helps avoid
4131 unnecessary dependencies between our distributions, so that users can
4132 install whichever versions of whichever packages they like.  Do not
4133 induce new dependencies on other software lightly.
4135 Non-source files that might actually be modified by building and
4136 installing the program should @strong{never} be included in the
4137 distribution.  So if you do distribute non-source files, always make
4138 sure they are up to date when you make a new distribution.
4140 Make sure that all the files in the distribution are world-readable, and
4141 that directories are world-readable and world-searchable (octal mode 755).
4142 We used to recommend that all directories in the distribution also be
4143 world-writable (octal mode 777), because ancient versions of @code{tar}
4144 would otherwise not cope when extracting the archive as an unprivileged
4145 user.  That can easily lead to security issues when creating the archive,
4146 however, so now we recommend against that.
4148 Don't include any symbolic links in the distribution itself.  If the tar
4149 file contains symbolic links, then people cannot even unpack it on
4150 systems that don't support symbolic links.  Also, don't use multiple
4151 names for one file in different directories, because certain file
4152 systems cannot handle this and that prevents unpacking the
4153 distribution.
4155 Try to make sure that all the file names will be unique on MS-DOS.  A
4156 name on MS-DOS consists of up to 8 characters, optionally followed by a
4157 period and up to three characters.  MS-DOS will truncate extra
4158 characters both before and after the period.  Thus,
4159 @file{foobarhacker.c} and @file{foobarhacker.o} are not ambiguous; they
4160 are truncated to @file{foobarha.c} and @file{foobarha.o}, which are
4161 distinct.
4163 @cindex @file{texinfo.tex}, in a distribution
4164 Include in your distribution a copy of the @file{texinfo.tex} you used
4165 to test print any @file{*.texinfo} or @file{*.texi} files.
4167 Likewise, if your program uses small GNU software packages like regex,
4168 getopt, obstack, or termcap, include them in the distribution file.
4169 Leaving them out would make the distribution file a little smaller at
4170 the expense of possible inconvenience to a user who doesn't know what
4171 other files to get.
4173 @node References
4174 @chapter References to Non-Free Software and Documentation
4175 @cindex references to non-free material
4177 A GNU program should not recommend, promote, or grant legitimacy to
4178 the use of any non-free program.  Proprietary software is a social and
4179 ethical problem, and our aim is to put an end to that problem.  We
4180 can't stop some people from writing proprietary programs, or stop
4181 other people from using them, but we can and should refuse to
4182 advertise them to new potential customers, or to give the public the
4183 idea that their existence is ethical.
4185 The GNU definition of free software is found on the GNU web site at
4186 @url{https://www.gnu.org/@/philosophy/@/free-sw.html}, and the definition
4187 of free documentation is found at
4188 @url{https://www.gnu.org/@/philosophy/@/free-doc.html}.  The terms ``free''
4189 and ``non-free'', used in this document, refer to those definitions.
4191 A list of important licenses and whether they qualify as free is in
4192 @url{https://www.gnu.org/@/licenses/@/license-list.html}.  If it is not
4193 clear whether a license qualifies as free, please ask the GNU Project
4194 by writing to @email{licensing@@gnu.org}.  We will answer, and if the
4195 license is an important one, we will add it to the list.
4197 When a non-free program or system is well known, you can mention it in
4198 passing---that is harmless, since users who might want to use it
4199 probably already know about it.  For instance, it is fine to explain
4200 how to build your package on top of some widely used non-free
4201 operating system, or how to use it together with some widely used
4202 non-free program.
4204 However, you should give only the necessary information to help those
4205 who already use the non-free program to use your program with
4206 it---don't give, or refer to, any further information about the
4207 proprietary program, and don't imply that the proprietary program
4208 enhances your program, or that its existence is in any way a good
4209 thing.  The goal should be that people already using the proprietary
4210 program will get the advice they need about how to use your free
4211 program with it, while people who don't already use the proprietary
4212 program will not see anything likely to lead them to take an interest
4213 in it.
4215 If a non-free program or system is obscure in your program's domain,
4216 your program should not mention or support it at all, since doing so
4217 would tend to popularize the non-free program more than it popularizes
4218 your program.  (You cannot hope to find many additional users for your
4219 program among the users of Foobar, if the existence of Foobar is not
4220 generally known among people who might want to use your program.)
4222 Sometimes a program is free software in itself but depends on a
4223 non-free platform in order to run.  For instance, many Java programs
4224 depend on some non-free Java libraries.  To recommend or promote such
4225 a program is to promote the other programs it needs.  This is why we
4226 are careful about listing Java programs in the Free Software
4227 Directory: we don't want to promote the non-free Java libraries.
4229 We hope this particular problem with Java will be gone by and by, as
4230 we replace the remaining non-free standard Java libraries with free
4231 software, but the general principle will remain the same: don't
4232 recommend, promote or legitimize programs that depend on non-free
4233 software to run.
4235 Some free programs strongly encourage the use of non-free software.  A
4236 typical example is @command{mplayer}.  It is free software in itself,
4237 and the free code can handle some kinds of files.  However,
4238 @command{mplayer} recommends use of non-free codecs for other kinds of
4239 files, and users that install @command{mplayer} are very likely to
4240 install those codecs along with it.  To recommend @command{mplayer}
4241 is, in effect, to promote use of the non-free codecs.
4243 Thus, you should not recommend programs that strongly encourage the
4244 use of non-free software.  This is why we do not list
4245 @command{mplayer} in the Free Software Directory.
4247 A GNU package should not refer the user to any non-free documentation
4248 for free software.  Free documentation that can be included in free
4249 operating systems is essential for completing the GNU system, or any
4250 free operating system, so encouraging it is a priority; to recommend
4251 use of documentation that we are not allowed to include undermines the
4252 impetus for the community to produce documentation that we can
4253 include.  So GNU packages should never recommend non-free
4254 documentation.
4256 By contrast, it is ok to refer to journal articles and textbooks in
4257 the comments of a program for explanation of how it functions, even
4258 though they are non-free.  This is because we don't include such
4259 things in the GNU system even if they are free---they are outside the
4260 scope of what a software distribution needs to include.
4262 Referring to a web site that describes or recommends a non-free
4263 program is promoting that program, so please do not make links to (or
4264 mention by name) web sites that contain such material.  This policy is
4265 relevant particularly for the web pages for a GNU package.
4267 Following links from nearly any web site can lead eventually to
4268 non-free software; this is inherent in the nature of the web.  So it
4269 makes no sense to criticize a site for having such links.  As long as
4270 the site does not itself recommend a non-free program, there is no
4271 need to consider the question of the sites that it links to for other
4272 reasons.
4274 Thus, for example, you should not refer to AT&T's web site if that
4275 recommends AT&T's non-free software packages; you should not refer to
4276 a page @var{p} that links to AT&T's site presenting it as a place to get
4277 some non-free program, because that part of the page @var{p} itself
4278 recommends and legitimizes the non-free program.  However, that @var{p}
4279 contains a link to AT&T's web site for some other purpose (such as
4280 long-distance telephone service) is not an objection against it.
4282 A web page recommends a program in a particularly strong way if it
4283 requires users to run that program in order to use the page.  Many
4284 pages contain Javascript code which they recommend in this way.  This
4285 Javascript code may be free or nonfree, but nonfree is the usual case.
4287 If the purpose for which you would refer to the page cannot be carried
4288 out without running nonfree Javascript code, then you should not refer
4289 to it.  Thus, if the purpose of referring to the page is for people to
4290 view a video, or subscribing to a mailing list, and the viewing or
4291 subscribing fail to work if the user's browser blocks the nonfree
4292 Javascript code, then don't refer to that page.
4294 The extreme case is that of web sites which depend on nonfree
4295 Javascript code even to @emph{see} the contents of the pages.  Any
4296 site hosted on @indicateurl{wix.com} has this problem, and so do some
4297 other sites.  Referring people to such pages to read their contents
4298 is, in effect, urging them to run those nonfree programs---so please
4299 don't refer to those pages.  (Such pages also break the Web, so they
4300 deserve condemnation for two reasons.)
4302 Instead, please quote excerpts from the page to make your point,
4303 or find another place to refer to that information.
4305 @node GNU Free Documentation License
4306 @appendix GNU Free Documentation License
4308 @cindex FDL, GNU Free Documentation License
4309 @include fdl.texi
4311 @node Index
4312 @unnumbered Index
4313 @printindex cp
4315 @bye
4317 Local variables:
4318 eval: (add-hook 'before-save-hook 'time-stamp)
4319 time-stamp-start: "@set lastupdate "
4320 time-stamp-end: "$"
4321 time-stamp-format: "%:b %:d, %:y"
4322 compile-command: "cd work.s && make"
4323 End: