diff --git a/build/jam/HaikuImage b/build/jam/HaikuImage index 9a8436e83d..9e157b4953 100644 --- a/build/jam/HaikuImage +++ b/build/jam/HaikuImage @@ -44,7 +44,7 @@ SYSTEM_BIN = "[" addattr alert arp base64 basename bash bc beep bootman bzip2 listport listres listsem listusb ln locate logger login logname ls lsindex mail2mbox makebootable mbox2mail md5sum merge message mimeset mkdos mkdir mkfifo mkfs mkindex modifiers mount mount_nfs mountvolume mv - netcat netstat nl nohup + netcat netstat nl nohup nproc od open passwd paste patch pathchk pc ping play playfile playsound playwav pr prio printenv printf profile ps ptx pwd diff --git a/src/bin/coreutils/ABOUT-NLS b/src/bin/coreutils/ABOUT-NLS index 3575535a82..83bc72ec26 100644 --- a/src/bin/coreutils/ABOUT-NLS +++ b/src/bin/coreutils/ABOUT-NLS @@ -101,8 +101,11 @@ codes, stating which languages are allowed. As a user, if your language has been installed for this package, you only have to set the `LANG' environment variable to the appropriate -`LL_CC' combination. Here `LL' is an ISO 639 two-letter language code, -and `CC' is an ISO 3166 two-letter country code. For example, let's +`LL_CC' combination. If you happen to have the `LC_ALL' or some other +`LC_xxx' environment variables set, you should unset them before +setting `LANG', otherwise the setting of `LANG' will not have the +desired effect. Here `LL' is an ISO 639 two-letter language code, and +`CC' is an ISO 3166 two-letter country code. For example, let's suppose that you speak German and live in Germany. At the shell prompt, merely execute `setenv LANG de_DE' (in `csh'), `export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash'). @@ -153,8 +156,7 @@ people who like their own language and write it well, and who are also able to synergize with other translators speaking the same language. Each translation team has its own mailing list. The up-to-date list of teams can be found at the Free Translation Project's homepage, -`http://www.iro.umontreal.ca/contrib/po/HTML/', in the "National teams" -area. +`http://translationproject.org/', in the "Teams" area. If you'd like to volunteer to _work_ at translating messages, you should become a member of the translating team for your own language. @@ -168,81 +170,76 @@ message to `sv-request@li.org', having this message body: _actively_ in translations, or at solving translational difficulties, rather than merely lurking around. If your team does not exist yet and you want to start one, or if you are unsure about what to do or how to -get started, please write to `translation@iro.umontreal.ca' to reach the -coordinator for all translator teams. +get started, please write to `coordinator@translationproject.org' to +reach the coordinator for all translator teams. The English team is special. It works at improving and uniformizing -the terminology in use. Proven linguistic skill are praised more than -programming skill, here. +the terminology in use. Proven linguistic skills are praised more than +programming skills, here. 1.5 Available Packages ====================== Languages are not equally supported in all packages. The following -matrix shows the current state of internationalization, as of July -2006. The matrix shows, in regard of each package, for which languages +matrix shows the current state of internationalization, as of November +2007. The matrix shows, in regard of each package, for which languages PO files have been submitted to translation coordination, with a translation percentage of at least 50%. Ready PO files af am ar az be bg bs ca cs cy da de el en en_GB eo +----------------------------------------------------+ - GNUnet | [] | + Compendium | [] [] [] [] | a2ps | [] [] [] [] [] | aegis | () | ant-phone | () | anubis | [] | ap-utils | | - aspell | [] [] [] [] | - bash | [] [] [] | - batchelor | [] | + aspell | [] [] [] [] [] | + bash | [] | bfd | | bibshelf | [] | - binutils | [] | + binutils | | bison | [] [] | bison-runtime | [] | bluez-pin | [] [] [] [] [] | cflow | [] | - clisp | [] [] | + clisp | [] [] [] | console-tools | [] [] | - coreutils | [] [] [] [] | + coreutils | [] [] [] [] | cpio | | cpplib | [] [] [] | cryptonit | [] | - darkstat | [] () [] | - dialog | [] [] [] [] [] [] | + dialog | | diffutils | [] [] [] [] [] [] | doodle | [] | e2fsprogs | [] [] | enscript | [] [] [] [] | - error | [] [] [] [] | - fetchmail | [] [] () [] | - fileutils | [] [] | - findutils | [] [] [] | + fetchmail | [] [] () [] [] | + findutils | [] | + findutils_stable | [] [] [] | flex | [] [] [] | - fslint | [] | + fslint | | gas | | gawk | [] [] [] | - gbiff | [] | gcal | [] | gcc | [] | gettext-examples | [] [] [] [] [] | gettext-runtime | [] [] [] [] [] | gettext-tools | [] [] | - gimp-print | [] [] [] [] | gip | [] | - gliv | [] | + gliv | [] [] | glunarclock | [] | gmult | [] [] | gnubiff | () | - gnucash | () () [] | - gnucash-glossary | [] () | + gnucash | [] [] () () [] | gnuedu | | - gnulib | [] [] [] [] [] [] | + gnulib | [] | + gnunet | | gnunet-gtk | | - gnutls | | + gnutls | [] | gpe-aerial | [] [] | gpe-beam | [] [] | - gpe-calendar | [] [] | + gpe-calendar | | gpe-clock | [] [] | gpe-conf | [] [] | gpe-contacts | | @@ -260,42 +257,43 @@ translation percentage of at least 50%. gpe-todo | | gphoto2 | [] [] [] [] | gprof | [] [] | - gpsdrive | () () | + gpsdrive | | gramadoir | [] [] | - grep | [] [] [] [] [] [] | - gretl | | + grep | [] [] | + gretl | () | gsasl | | gss | | - gst-plugins | [] [] [] [] | - gst-plugins-base | [] [] [] | - gst-plugins-good | [] [] [] [] [] [] [] | + gst-plugins-bad | [] [] | + gst-plugins-base | [] [] | + gst-plugins-good | [] [] [] | + gst-plugins-ugly | [] [] | gstreamer | [] [] [] [] [] [] [] | - gtick | [] () | - gtkam | [] [] [] | + gtick | () | + gtkam | [] [] [] [] | gtkorphan | [] [] | gtkspell | [] [] [] [] | gutenprint | [] | - hello | [] [] [] [] [] | - id-utils | [] [] | - impost | | - indent | [] [] [] | - iso_3166 | [] [] | - iso_3166_1 | [] [] [] [] [] | + hello | [] [] [] [] [] | + herrie | [] | + hylafax | | + idutils | [] [] | + indent | [] [] [] [] | + iso_15924 | | + iso_3166 | [] [] [] [] [] [] [] [] [] [] [] | iso_3166_2 | | - iso_3166_3 | [] | - iso_4217 | [] | - iso_639 | [] [] | + iso_4217 | [] [] [] | + iso_639 | [] [] [] [] | jpilot | [] | jtag | | jwhois | | kbd | [] [] [] [] | - keytouch | | - keytouch-editor | | - keytouch-keyboa... | | + keytouch | [] [] | + keytouch-editor | [] | + keytouch-keyboa... | [] | latrine | () | ld | [] | leafpad | [] [] [] [] [] | - libc | [] [] [] [] [] | + libc | [] [] [] [] | libexif | [] | libextractor | [] | libgpewidget | [] [] [] | @@ -304,123 +302,113 @@ translation percentage of at least 50%. libgphoto2_port | [] [] | libgsasl | | libiconv | [] [] | - libidn | [] [] | + libidn | [] [] [] | lifelines | [] () | lilypond | [] | lingoteach | | + lprng | | lynx | [] [] [] [] | m4 | [] [] [] [] | + mailfromd | | mailutils | [] | make | [] [] | - man-db | [] () [] [] | + man-db | [] [] [] | minicom | [] [] [] | - mysecretdiary | [] [] | - nano | [] [] () [] | - nano_1_0 | [] () [] [] | + nano | [] [] [] | opcodes | [] | - parted | | - pilot-qof | [] | + parted | [] [] | + pilot-qof | | + popt | [] [] [] | psmisc | [] | pwdutils | | - python | | qof | | radius | [] | recode | [] [] [] [] [] [] | - rpm | [] [] | + rpm | [] | screem | | scrollkeeper | [] [] [] [] [] [] [] [] | sed | [] [] [] | - sh-utils | [] [] | - shared-mime-info | [] [] [] | + shared-mime-info | [] [] [] [] () [] [] [] | sharutils | [] [] [] [] [] [] | shishi | | - silky | | skencil | [] () | - sketch | [] () | solfege | | soundtracker | [] [] | sp | [] | - stardict | [] | system-tools-ba... | [] [] [] [] [] [] [] [] [] | - tar | [] | + tar | [] [] | texinfo | [] [] [] | - textutils | [] [] [] | tin | () () | - tp-robot | [] | - tuxpaint | [] [] [] [] [] | + tuxpaint | [] [] [] [] [] [] | unicode-han-tra... | | unicode-transla... | | util-linux | [] [] [] [] | - vorbis-tools | [] [] [] [] | + util-linux-ng | [] [] [] [] | + vorbis-tools | [] | wastesedge | () | wdiff | [] [] [] [] | - wget | [] [] | - xchat | [] [] [] [] [] | - xkeyboard-config | | - xpad | [] [] | + wget | [] [] [] | + xchat | [] [] [] [] [] [] [] | + xkeyboard-config | [] | + xpad | [] [] [] | +----------------------------------------------------+ af am ar az be bg bs ca cs cy da de el en en_GB eo - 11 0 1 2 8 21 1 42 43 2 62 99 18 1 16 16 + 6 0 2 1 8 26 2 40 48 2 56 88 15 1 15 18 es et eu fa fi fr ga gl gu he hi hr hu id is it +--------------------------------------------------+ - GNUnet | | + Compendium | [] [] [] [] [] | a2ps | [] [] [] () | aegis | | ant-phone | [] | anubis | [] | ap-utils | [] [] | aspell | [] [] [] | - bash | [] [] [] | - batchelor | [] [] | - bfd | [] | + bash | [] | + bfd | [] [] | bibshelf | [] [] [] | binutils | [] [] [] | bison | [] [] [] [] [] [] | bison-runtime | [] [] [] [] [] | bluez-pin | [] [] [] [] [] | - cflow | | + cflow | [] | clisp | [] [] | console-tools | | coreutils | [] [] [] [] [] [] | cpio | [] [] [] | cpplib | [] [] | cryptonit | [] | - darkstat | [] () [] [] [] | - dialog | [] [] [] [] [] [] [] [] | + dialog | [] [] [] | diffutils | [] [] [] [] [] [] [] [] [] | doodle | [] [] | e2fsprogs | [] [] [] | enscript | [] [] [] | - error | [] [] [] [] [] | fetchmail | [] | - fileutils | [] [] [] [] [] [] | - findutils | [] [] [] [] | + findutils | [] [] [] | + findutils_stable | [] [] [] [] | flex | [] [] [] | - fslint | [] | + fslint | | gas | [] [] | - gawk | [] [] [] [] | - gbiff | [] | + gawk | [] [] [] [] () | gcal | [] [] | gcc | [] | - gettext-examples | [] [] [] [] [] | + gettext-examples | [] [] [] [] [] [] [] | gettext-runtime | [] [] [] [] [] [] | - gettext-tools | [] [] [] | - gimp-print | [] [] | - gip | [] [] [] | + gettext-tools | [] [] [] [] | + gip | [] [] [] [] | gliv | () | glunarclock | [] [] [] | gmult | [] [] [] | gnubiff | () () | gnucash | () () () | - gnucash-glossary | [] [] | gnuedu | [] | - gnulib | [] [] [] [] [] [] [] [] | + gnulib | [] [] [] | + gnunet | | gnunet-gtk | | gnutls | | gpe-aerial | [] [] | gpe-beam | [] [] | - gpe-calendar | [] [] [] [] | + gpe-calendar | | gpe-clock | [] [] [] [] | gpe-conf | [] | gpe-contacts | [] [] | @@ -437,642 +425,611 @@ translation percentage of at least 50%. gpe-today | [] [] [] [] | gpe-todo | [] | gphoto2 | [] [] [] [] [] | - gprof | [] [] [] [] | - gpsdrive | () () [] () | + gprof | [] [] [] [] [] | + gpsdrive | [] | gramadoir | [] [] | - grep | [] [] [] [] [] [] [] [] [] [] [] [] | - gretl | [] [] [] | - gsasl | [] | - gss | [] | - gst-plugins | [] [] [] | - gst-plugins-base | [] [] | - gst-plugins-good | [] [] [] | + grep | [] [] [] | + gretl | [] [] [] () | + gsasl | [] [] | + gss | [] [] | + gst-plugins-bad | [] [] [] [] | + gst-plugins-base | [] [] [] [] | + gst-plugins-good | [] [] [] [] [] | + gst-plugins-ugly | [] [] [] [] | gstreamer | [] [] [] | - gtick | [] [] [] [] [] | + gtick | [] [] [] | gtkam | [] [] [] [] | gtkorphan | [] [] | - gtkspell | [] [] [] [] [] [] | + gtkspell | [] [] [] [] [] [] [] | gutenprint | [] | hello | [] [] [] [] [] [] [] [] [] [] [] [] [] | - id-utils | [] [] [] [] [] | - impost | [] [] | + herrie | [] | + hylafax | | + idutils | [] [] [] [] [] | indent | [] [] [] [] [] [] [] [] [] [] | - iso_3166 | [] [] [] | - iso_3166_1 | [] [] [] [] [] [] [] | + iso_15924 | [] | + iso_3166 | [] [] [] [] [] [] [] [] [] [] [] [] [] | iso_3166_2 | [] | - iso_3166_3 | [] | - iso_4217 | [] [] [] [] | - iso_639 | [] [] [] [] [] | + iso_4217 | [] [] [] [] [] [] | + iso_639 | [] [] [] [] [] [] | jpilot | [] [] | jtag | [] | jwhois | [] [] [] [] [] | kbd | [] [] | - keytouch | [] | + keytouch | [] [] [] | keytouch-editor | [] | - keytouch-keyboa... | [] | - latrine | [] [] [] | - ld | [] [] | + keytouch-keyboa... | [] [] | + latrine | [] [] | + ld | [] [] [] [] | leafpad | [] [] [] [] [] [] | libc | [] [] [] [] [] | libexif | [] | libextractor | [] | libgpewidget | [] [] [] [] [] | - libgpg-error | | + libgpg-error | [] | libgphoto2 | [] [] [] | libgphoto2_port | [] [] | libgsasl | [] [] | - libiconv | [] | + libiconv | [] [] [] | libidn | [] [] | lifelines | () | - lilypond | [] | + lilypond | [] [] [] | lingoteach | [] [] [] | + lprng | | lynx | [] [] [] | m4 | [] [] [] [] | + mailfromd | | mailutils | [] [] | make | [] [] [] [] [] [] [] [] | - man-db | () | + man-db | [] | minicom | [] [] [] [] | - mysecretdiary | [] [] [] | - nano | [] () [] [] [] [] | - nano_1_0 | [] [] [] [] [] | + nano | [] [] [] [] [] [] [] | opcodes | [] [] [] [] | - parted | [] [] [] [] | + parted | [] [] [] | pilot-qof | | - psmisc | [] [] [] | + popt | [] [] [] [] | + psmisc | [] [] | pwdutils | | - python | | - qof | | + qof | [] | radius | [] [] | recode | [] [] [] [] [] [] [] [] | rpm | [] [] | screem | | scrollkeeper | [] [] [] | sed | [] [] [] [] [] | - sh-utils | [] [] [] [] [] [] [] | shared-mime-info | [] [] [] [] [] [] | sharutils | [] [] [] [] [] [] [] [] | - shishi | | - silky | [] | + shishi | [] | skencil | [] [] | - sketch | [] [] | solfege | [] | soundtracker | [] [] [] | sp | [] | - stardict | [] | - system-tools-ba... | [] [] [] [] [] [] [] [] | - tar | [] [] [] [] [] [] | - texinfo | [] [] | - textutils | [] [] [] [] [] | + system-tools-ba... | [] [] [] [] [] [] [] [] [] | + tar | [] [] [] [] [] | + texinfo | [] [] [] | tin | [] () | - tp-robot | [] [] [] [] | tuxpaint | [] [] | unicode-han-tra... | | unicode-transla... | [] [] | util-linux | [] [] [] [] [] [] [] | - vorbis-tools | [] [] | + util-linux-ng | [] [] [] [] [] [] [] | + vorbis-tools | | wastesedge | () | wdiff | [] [] [] [] [] [] [] [] | wget | [] [] [] [] [] [] [] [] | - xchat | [] [] [] [] [] [] [] [] | - xkeyboard-config | [] [] [] [] | + xchat | [] [] [] [] [] [] [] | + xkeyboard-config | [] [] [] [] | xpad | [] [] [] | +--------------------------------------------------+ es et eu fa fi fr ga gl gu he hi hr hu id is it - 89 21 16 2 41 119 61 14 1 8 1 6 61 30 0 53 + 85 22 14 2 48 101 61 12 2 8 2 6 53 29 1 52 - ja ko ku ky lg lt lv mk mn ms mt nb ne nl nn no + ja ka ko ku ky lg lt lv mk mn ms mt nb ne nl nn +--------------------------------------------------+ - GNUnet | | - a2ps | () [] [] () | - aegis | () | - ant-phone | [] | - anubis | [] [] [] | - ap-utils | [] | - aspell | [] [] | - bash | [] | - batchelor | [] [] | + Compendium | [] | + a2ps | () [] [] | + aegis | () | + ant-phone | [] | + anubis | [] [] [] | + ap-utils | [] | + aspell | [] [] | + bash | [] | bfd | | - bibshelf | [] | + bibshelf | [] | binutils | | - bison | [] [] [] | - bison-runtime | [] [] [] | - bluez-pin | [] [] [] | + bison | [] [] [] | + bison-runtime | [] [] [] | + bluez-pin | [] [] [] | cflow | | - clisp | [] | + clisp | [] | console-tools | | - coreutils | [] | - cpio | | - cpplib | [] | - cryptonit | [] | - darkstat | [] [] | - dialog | [] [] | - diffutils | [] [] [] | + coreutils | [] | + cpio | [] | + cpplib | [] | + cryptonit | [] | + dialog | [] [] | + diffutils | [] [] [] | doodle | | - e2fsprogs | [] | - enscript | [] | - error | [] | - fetchmail | [] [] | - fileutils | [] [] | - findutils | [] | - flex | [] [] | - fslint | [] [] | + e2fsprogs | [] | + enscript | [] | + fetchmail | [] [] | + findutils | [] | + findutils_stable | [] | + flex | [] [] | + fslint | | gas | | - gawk | [] [] | - gbiff | [] | + gawk | [] [] | gcal | | gcc | | - gettext-examples | [] [] | - gettext-runtime | [] [] [] | - gettext-tools | [] [] | - gimp-print | [] [] | - gip | [] [] | - gliv | [] | - glunarclock | [] [] | - gmult | [] [] | + gettext-examples | [] [] [] | + gettext-runtime | [] [] [] | + gettext-tools | [] [] | + gip | [] [] | + gliv | [] | + glunarclock | [] [] | + gmult | [] [] [] | gnubiff | | - gnucash | () () | - gnucash-glossary | [] | + gnucash | () () () | gnuedu | | - gnulib | [] [] [] [] | + gnulib | [] [] | + gnunet | | gnunet-gtk | | - gnutls | | - gpe-aerial | [] | - gpe-beam | [] | - gpe-calendar | [] | - gpe-clock | [] [] | - gpe-conf | [] [] | - gpe-contacts | [] | - gpe-edit | [] [] | - gpe-filemanager | [] | - gpe-go | [] [] | - gpe-login | [] [] | - gpe-ownerinfo | [] | - gpe-package | [] | - gpe-sketchbook | [] [] | - gpe-su | [] [] | - gpe-taskmanager | [] [] [] | - gpe-timesheet | [] | - gpe-today | [] | - gpe-todo | | - gphoto2 | [] [] | - gprof | | - gpsdrive | () () () | - gramadoir | () | - grep | [] [] [] | + gnutls | [] | + gpe-aerial | [] | + gpe-beam | [] | + gpe-calendar | [] | + gpe-clock | [] [] [] | + gpe-conf | [] [] [] | + gpe-contacts | [] | + gpe-edit | [] [] [] | + gpe-filemanager | [] [] | + gpe-go | [] [] [] | + gpe-login | [] [] [] | + gpe-ownerinfo | [] [] | + gpe-package | [] [] | + gpe-sketchbook | [] [] | + gpe-su | [] [] [] | + gpe-taskmanager | [] [] [] [] | + gpe-timesheet | [] | + gpe-today | [] [] | + gpe-todo | [] | + gphoto2 | [] [] | + gprof | [] | + gpsdrive | [] | + gramadoir | () | + grep | [] [] | gretl | | - gsasl | [] | + gsasl | [] | gss | | - gst-plugins | [] | - gst-plugins-base | | - gst-plugins-good | [] | - gstreamer | [] | - gtick | [] | - gtkam | [] | - gtkorphan | [] | - gtkspell | [] [] | - gutenprint | | - hello | [] [] [] [] [] [] [] [] | - id-utils | [] | - impost | | - indent | [] [] | - iso_3166 | [] | - iso_3166_1 | [] [] | - iso_3166_2 | [] | - iso_3166_3 | [] | - iso_4217 | [] [] [] | - iso_639 | [] [] | - jpilot | () () () | + gst-plugins-bad | [] | + gst-plugins-base | [] | + gst-plugins-good | [] | + gst-plugins-ugly | [] | + gstreamer | [] | + gtick | [] | + gtkam | [] [] | + gtkorphan | [] | + gtkspell | [] [] | + gutenprint | [] | + hello | [] [] [] [] [] [] [] | + herrie | [] | + hylafax | | + idutils | [] | + indent | [] [] | + iso_15924 | [] | + iso_3166 | [] [] [] [] [] [] [] [] | + iso_3166_2 | [] | + iso_4217 | [] [] [] | + iso_639 | [] [] [] [] | + jpilot | () () | jtag | | - jwhois | [] | - kbd | [] | - keytouch | [] | - keytouch-editor | | + jwhois | [] | + kbd | [] | + keytouch | [] | + keytouch-editor | [] | keytouch-keyboa... | | - latrine | [] | + latrine | [] | ld | | - leafpad | [] [] | - libc | [] [] [] [] [] | + leafpad | [] [] | + libc | [] [] [] | libexif | | libextractor | | - libgpewidget | [] | + libgpewidget | [] | libgpg-error | | libgphoto2 | [] | libgphoto2_port | [] | - libgsasl | [] | - libiconv | | - libidn | [] [] | - lifelines | [] | - lilypond | | - lingoteach | [] | - lynx | [] [] | - m4 | [] [] | + libgsasl | [] | + libiconv | [] | + libidn | [] [] | + lifelines | [] | + lilypond | [] | + lingoteach | [] | + lprng | | + lynx | [] [] | + m4 | [] [] | + mailfromd | | mailutils | | - make | [] [] [] | - man-db | () | + make | [] [] [] | + man-db | | minicom | [] | - mysecretdiary | [] | - nano | [] [] [] | - nano_1_0 | [] [] [] | - opcodes | [] | - parted | [] [] | + nano | [] [] [] | + opcodes | [] | + parted | [] [] | pilot-qof | | - psmisc | [] [] [] | + popt | [] [] [] | + psmisc | [] [] [] | pwdutils | | - python | | qof | | radius | | - recode | [] | - rpm | [] [] | + recode | [] | + rpm | [] [] | screem | [] | - scrollkeeper | [] [] [] [] | - sed | [] [] | - sh-utils | [] [] | - shared-mime-info | [] [] [] [] [] | - sharutils | [] [] | + scrollkeeper | [] [] [] [] | + sed | [] [] | + shared-mime-info | [] [] [] [] [] [] [] | + sharutils | [] [] | shishi | | - silky | [] | skencil | | - sketch | | - solfege | | + solfege | () () | soundtracker | | sp | () | - stardict | [] [] | - system-tools-ba... | [] [] [] [] | - tar | [] [] [] | - texinfo | [] [] [] | - textutils | [] [] [] | + system-tools-ba... | [] [] [] [] | + tar | [] [] [] | + texinfo | [] [] | tin | | - tp-robot | [] | - tuxpaint | [] | + tuxpaint | () [] [] | unicode-han-tra... | | unicode-transla... | | - util-linux | [] [] | - vorbis-tools | [] | - wastesedge | [] | - wdiff | [] [] | - wget | [] [] | - xchat | [] [] [] [] | - xkeyboard-config | [] | - xpad | [] [] [] | + util-linux | [] [] | + util-linux-ng | [] [] | + vorbis-tools | | + wastesedge | [] | + wdiff | [] [] | + wget | [] [] | + xchat | [] [] [] [] | + xkeyboard-config | [] [] [] | + xpad | [] [] [] | +--------------------------------------------------+ - ja ko ku ky lg lt lv mk mn ms mt nb ne nl nn no - 40 24 2 1 1 3 1 2 3 21 0 15 1 101 5 3 + ja ka ko ku ky lg lt lv mk mn ms mt nb ne nl nn + 51 2 25 3 2 0 6 0 2 2 20 0 11 1 103 6 - nso or pa pl pt pt_BR rm ro ru rw sk sl sq sr sv ta - +------------------------------------------------------+ - GNUnet | | - a2ps | () [] [] [] [] [] [] | - aegis | () () | - ant-phone | [] [] | - anubis | [] [] [] | - ap-utils | () | - aspell | [] [] | - bash | [] [] [] | - batchelor | [] [] | - bfd | | - bibshelf | [] | - binutils | [] [] | - bison | [] [] [] [] [] | - bison-runtime | [] [] [] [] | - bluez-pin | [] [] [] [] [] [] [] [] [] | - cflow | [] | - clisp | [] | - console-tools | [] | - coreutils | [] [] [] [] | - cpio | [] [] [] | - cpplib | [] | - cryptonit | [] [] | - darkstat | [] [] [] [] [] [] | - dialog | [] [] [] [] [] [] [] [] [] | - diffutils | [] [] [] [] [] [] | - doodle | [] [] | - e2fsprogs | [] [] | - enscript | [] [] [] [] [] | - error | [] [] [] [] | - fetchmail | [] [] [] | - fileutils | [] [] [] [] [] | - findutils | [] [] [] [] [] [] | - flex | [] [] [] [] [] | - fslint | [] [] [] [] | - gas | | - gawk | [] [] [] [] | - gbiff | [] | - gcal | [] | - gcc | [] | - gettext-examples | [] [] [] [] [] [] [] [] | - gettext-runtime | [] [] [] [] [] [] [] [] | - gettext-tools | [] [] [] [] [] [] [] | - gimp-print | [] [] | - gip | [] [] [] [] | - gliv | [] [] [] [] | - glunarclock | [] [] [] [] [] [] | - gmult | [] [] [] [] | - gnubiff | () | - gnucash | () [] | - gnucash-glossary | [] [] [] | - gnuedu | | - gnulib | [] [] [] [] [] | - gnunet-gtk | [] | - gnutls | [] [] | - gpe-aerial | [] [] [] [] [] [] [] | - gpe-beam | [] [] [] [] [] [] [] | - gpe-calendar | [] [] [] [] [] [] [] [] | - gpe-clock | [] [] [] [] [] [] [] [] | - gpe-conf | [] [] [] [] [] [] [] | - gpe-contacts | [] [] [] [] [] | - gpe-edit | [] [] [] [] [] [] [] [] | - gpe-filemanager | [] [] | - gpe-go | [] [] [] [] [] [] | - gpe-login | [] [] [] [] [] [] [] [] | - gpe-ownerinfo | [] [] [] [] [] [] [] [] | - gpe-package | [] [] | - gpe-sketchbook | [] [] [] [] [] [] [] [] | - gpe-su | [] [] [] [] [] [] [] [] | - gpe-taskmanager | [] [] [] [] [] [] [] [] | - gpe-timesheet | [] [] [] [] [] [] [] [] | - gpe-today | [] [] [] [] [] [] [] [] | - gpe-todo | [] [] [] [] | - gphoto2 | [] [] [] [] [] | - gprof | [] [] [] | - gpsdrive | [] [] [] | - gramadoir | [] [] | - grep | [] [] [] [] [] [] [] [] | - gretl | [] | - gsasl | [] [] | - gss | [] [] [] | - gst-plugins | [] [] [] [] | - gst-plugins-base | [] | - gst-plugins-good | [] [] [] [] | - gstreamer | [] [] [] | - gtick | [] [] [] | - gtkam | [] [] [] [] | - gtkorphan | [] | - gtkspell | [] [] [] [] [] [] [] [] | - gutenprint | [] | - hello | [] [] [] [] [] [] [] [] | - id-utils | [] [] [] [] | - impost | [] | - indent | [] [] [] [] [] [] | - iso_3166 | [] [] [] [] [] [] | - iso_3166_1 | [] [] [] [] | - iso_3166_2 | | - iso_3166_3 | [] [] [] [] | - iso_4217 | [] [] [] [] | - iso_639 | [] [] [] [] | - jpilot | | - jtag | [] | - jwhois | [] [] [] [] | - kbd | [] [] [] | - keytouch | [] | - keytouch-editor | [] | - keytouch-keyboa... | [] | - latrine | [] [] | - ld | [] | - leafpad | [] [] [] [] [] [] | - libc | [] [] [] [] [] | - libexif | [] | - libextractor | [] [] | - libgpewidget | [] [] [] [] [] [] [] | - libgpg-error | [] [] | - libgphoto2 | [] | - libgphoto2_port | [] [] [] | - libgsasl | [] [] [] [] | - libiconv | | - libidn | [] [] () | - lifelines | [] [] | - lilypond | | - lingoteach | [] | - lynx | [] [] [] | - m4 | [] [] [] [] [] | - mailutils | [] [] [] [] | - make | [] [] [] [] | - man-db | [] [] | - minicom | [] [] [] [] [] | - mysecretdiary | [] [] [] [] | - nano | [] [] | - nano_1_0 | [] [] [] [] | - opcodes | [] [] | - parted | [] | - pilot-qof | [] | - psmisc | [] [] | - pwdutils | [] [] | - python | | - qof | [] | - radius | [] [] | - recode | [] [] [] [] [] [] [] | - rpm | [] [] [] [] | - screem | | - scrollkeeper | [] [] [] [] [] [] [] | - sed | [] [] [] [] [] [] [] [] [] | - sh-utils | [] [] [] | - shared-mime-info | [] [] [] [] [] | - sharutils | [] [] [] [] | - shishi | [] | - silky | [] | - skencil | [] [] [] | - sketch | [] [] [] | - solfege | [] | - soundtracker | [] [] | - sp | | - stardict | [] [] [] | - system-tools-ba... | [] [] [] [] [] [] [] [] [] | - tar | [] [] [] [] [] | - texinfo | [] [] [] [] | - textutils | [] [] [] | - tin | () | - tp-robot | [] | - tuxpaint | [] [] [] [] [] | - unicode-han-tra... | | - unicode-transla... | | - util-linux | [] [] [] [] | - vorbis-tools | [] [] | - wastesedge | | - wdiff | [] [] [] [] [] [] | - wget | [] [] [] [] | - xchat | [] [] [] [] [] [] [] | - xkeyboard-config | [] [] | - xpad | [] [] [] | - +------------------------------------------------------+ - nso or pa pl pt pt_BR rm ro ru rw sk sl sq sr sv ta - 0 2 3 58 31 53 5 76 72 5 42 48 12 51 130 2 + or pa pl pt pt_BR rm ro ru rw sk sl sq sr sv ta + +--------------------------------------------------+ + Compendium | [] [] [] [] [] | + a2ps | () [] [] [] [] [] [] | + aegis | () () | + ant-phone | [] [] | + anubis | [] [] [] | + ap-utils | () | + aspell | [] [] [] | + bash | [] [] | + bfd | | + bibshelf | [] | + binutils | [] [] | + bison | [] [] [] [] [] | + bison-runtime | [] [] [] [] [] | + bluez-pin | [] [] [] [] [] [] [] [] [] | + cflow | [] | + clisp | [] | + console-tools | [] | + coreutils | [] [] [] [] | + cpio | [] [] [] | + cpplib | [] | + cryptonit | [] [] | + dialog | [] | + diffutils | [] [] [] [] [] [] | + doodle | [] [] | + e2fsprogs | [] [] | + enscript | [] [] [] [] [] | + fetchmail | [] [] [] | + findutils | [] [] [] | + findutils_stable | [] [] [] [] [] [] | + flex | [] [] [] [] [] | + fslint | [] | + gas | | + gawk | [] [] [] [] | + gcal | [] | + gcc | [] [] | + gettext-examples | [] [] [] [] [] [] [] [] | + gettext-runtime | [] [] [] [] [] [] [] [] | + gettext-tools | [] [] [] [] [] [] [] | + gip | [] [] [] [] | + gliv | [] [] [] [] [] [] | + glunarclock | [] [] [] [] [] [] | + gmult | [] [] [] [] | + gnubiff | () [] | + gnucash | () [] | + gnuedu | | + gnulib | [] [] [] | + gnunet | | + gnunet-gtk | [] | + gnutls | [] [] | + gpe-aerial | [] [] [] [] [] [] [] | + gpe-beam | [] [] [] [] [] [] [] | + gpe-calendar | [] [] [] [] | + gpe-clock | [] [] [] [] [] [] [] [] | + gpe-conf | [] [] [] [] [] [] [] | + gpe-contacts | [] [] [] [] [] | + gpe-edit | [] [] [] [] [] [] [] [] [] | + gpe-filemanager | [] [] | + gpe-go | [] [] [] [] [] [] [] [] | + gpe-login | [] [] [] [] [] [] [] [] | + gpe-ownerinfo | [] [] [] [] [] [] [] [] | + gpe-package | [] [] | + gpe-sketchbook | [] [] [] [] [] [] [] [] | + gpe-su | [] [] [] [] [] [] [] [] | + gpe-taskmanager | [] [] [] [] [] [] [] [] | + gpe-timesheet | [] [] [] [] [] [] [] [] | + gpe-today | [] [] [] [] [] [] [] [] | + gpe-todo | [] [] [] [] | + gphoto2 | [] [] [] [] [] [] | + gprof | [] [] [] | + gpsdrive | [] [] | + gramadoir | [] [] | + grep | [] [] [] [] | + gretl | [] [] [] | + gsasl | [] [] [] | + gss | [] [] [] [] | + gst-plugins-bad | [] [] [] | + gst-plugins-base | [] [] | + gst-plugins-good | [] [] | + gst-plugins-ugly | [] [] [] | + gstreamer | [] [] [] [] | + gtick | [] | + gtkam | [] [] [] [] [] | + gtkorphan | [] | + gtkspell | [] [] [] [] [] [] [] [] | + gutenprint | [] | + hello | [] [] [] [] [] [] [] [] | + herrie | [] [] [] | + hylafax | | + idutils | [] [] [] [] [] | + indent | [] [] [] [] [] [] [] | + iso_15924 | | + iso_3166 | [] [] [] [] [] [] [] [] [] [] [] [] [] | + iso_3166_2 | | + iso_4217 | [] [] [] [] [] [] [] | + iso_639 | [] [] [] [] [] [] [] | + jpilot | | + jtag | [] | + jwhois | [] [] [] [] | + kbd | [] [] [] | + keytouch | [] | + keytouch-editor | [] | + keytouch-keyboa... | [] | + latrine | | + ld | [] | + leafpad | [] [] [] [] [] [] | + libc | [] [] [] [] | + libexif | [] [] | + libextractor | [] [] | + libgpewidget | [] [] [] [] [] [] [] [] | + libgpg-error | [] [] [] | + libgphoto2 | [] | + libgphoto2_port | [] [] [] | + libgsasl | [] [] [] [] | + libiconv | [] [] [] | + libidn | [] [] () | + lifelines | [] [] | + lilypond | | + lingoteach | [] | + lprng | [] | + lynx | [] [] [] | + m4 | [] [] [] [] [] | + mailfromd | [] | + mailutils | [] [] [] | + make | [] [] [] [] | + man-db | [] [] [] [] | + minicom | [] [] [] [] [] | + nano | [] [] [] [] | + opcodes | [] [] | + parted | [] | + pilot-qof | | + popt | [] [] [] [] | + psmisc | [] [] | + pwdutils | [] [] | + qof | [] [] | + radius | [] [] | + recode | [] [] [] [] [] [] [] | + rpm | [] [] [] [] | + screem | | + scrollkeeper | [] [] [] [] [] [] [] | + sed | [] [] [] [] [] [] [] [] [] | + shared-mime-info | [] [] [] [] [] [] | + sharutils | [] [] [] [] | + shishi | [] | + skencil | [] [] [] | + solfege | [] | + soundtracker | [] [] | + sp | | + system-tools-ba... | [] [] [] [] [] [] [] [] [] | + tar | [] [] [] [] | + texinfo | [] [] [] [] | + tin | () | + tuxpaint | [] [] [] [] [] [] | + unicode-han-tra... | | + unicode-transla... | | + util-linux | [] [] [] [] | + util-linux-ng | [] [] [] [] | + vorbis-tools | [] | + wastesedge | | + wdiff | [] [] [] [] [] [] [] | + wget | [] [] [] [] | + xchat | [] [] [] [] [] [] [] | + xkeyboard-config | [] [] [] | + xpad | [] [] [] | + +--------------------------------------------------+ + or pa pl pt pt_BR rm ro ru rw sk sl sq sr sv ta + 0 5 77 31 53 4 58 72 3 45 46 9 45 122 3 tg th tk tr uk ven vi wa xh zh_CN zh_HK zh_TW zu +---------------------------------------------------+ - GNUnet | [] | 2 + Compendium | [] [] [] [] | 19 a2ps | [] [] [] | 19 - aegis | | 0 + aegis | [] | 1 ant-phone | [] [] | 6 anubis | [] [] [] | 11 ap-utils | () [] | 4 - aspell | [] [] [] | 14 - bash | [] | 11 - batchelor | [] [] | 9 - bfd | | 1 + aspell | [] [] [] | 16 + bash | [] | 6 + bfd | | 2 bibshelf | [] | 7 - binutils | [] [] [] | 9 - bison | [] [] [] | 19 - bison-runtime | [] [] [] | 16 + binutils | [] [] [] [] | 9 + bison | [] [] [] [] | 20 + bison-runtime | [] [] [] [] | 18 bluez-pin | [] [] [] [] [] [] | 28 - cflow | [] [] | 4 - clisp | | 6 + cflow | [] [] | 5 + clisp | | 9 console-tools | [] [] | 5 - coreutils | [] [] | 17 - cpio | [] [] [] | 9 - cpplib | [] [] [] [] | 11 - cryptonit | | 5 - darkstat | [] () () | 15 - dialog | [] [] [] [] [] | 30 - diffutils | [] [] [] [] | 28 + coreutils | [] [] [] | 18 + cpio | [] [] [] [] | 11 + cpplib | [] [] [] [] [] | 12 + cryptonit | [] | 6 + dialog | [] [] [] | 9 + diffutils | [] [] [] [] [] | 29 doodle | [] | 6 e2fsprogs | [] [] | 10 enscript | [] [] [] | 16 - error | [] [] [] [] | 18 fetchmail | [] [] | 12 - fileutils | [] [] [] | 18 - findutils | [] [] [] | 17 + findutils | [] [] [] | 11 + findutils_stable | [] [] [] [] | 18 flex | [] [] | 15 - fslint | [] | 9 + fslint | [] | 2 gas | [] | 3 - gawk | [] [] | 15 - gbiff | [] | 5 + gawk | [] [] [] | 16 gcal | [] | 5 - gcc | [] [] [] | 6 - gettext-examples | [] [] [] [] [] [] | 26 + gcc | [] [] [] | 7 + gettext-examples | [] [] [] [] [] [] | 29 gettext-runtime | [] [] [] [] [] [] | 28 - gettext-tools | [] [] [] [] [] | 19 - gimp-print | [] [] | 12 - gip | [] [] | 12 - gliv | [] [] | 8 + gettext-tools | [] [] [] [] [] | 20 + gip | [] [] | 13 + gliv | [] [] | 11 glunarclock | [] [] [] | 15 - gmult | [] [] [] [] | 15 - gnubiff | [] | 1 - gnucash | () | 2 - gnucash-glossary | [] [] | 9 + gmult | [] [] [] [] | 16 + gnubiff | [] | 2 + gnucash | () [] | 5 gnuedu | [] | 2 - gnulib | [] [] [] [] [] | 28 - gnunet-gtk | | 1 - gnutls | | 2 + gnulib | [] | 10 + gnunet | | 0 + gnunet-gtk | [] [] | 3 + gnutls | | 4 gpe-aerial | [] [] | 14 gpe-beam | [] [] | 14 - gpe-calendar | [] [] [] [] | 19 - gpe-clock | [] [] [] [] | 20 - gpe-conf | [] [] | 14 + gpe-calendar | [] [] | 7 + gpe-clock | [] [] [] [] | 21 + gpe-conf | [] [] [] | 16 gpe-contacts | [] [] | 10 - gpe-edit | [] [] [] [] | 19 - gpe-filemanager | [] | 5 - gpe-go | [] [] | 14 - gpe-login | [] [] [] [] [] | 20 - gpe-ownerinfo | [] [] [] [] | 20 - gpe-package | [] | 5 + gpe-edit | [] [] [] [] [] | 22 + gpe-filemanager | [] [] | 7 + gpe-go | [] [] [] [] | 19 + gpe-login | [] [] [] [] [] | 21 + gpe-ownerinfo | [] [] [] [] | 21 + gpe-package | [] | 6 gpe-sketchbook | [] [] | 16 - gpe-su | [] [] [] | 19 - gpe-taskmanager | [] [] [] | 19 + gpe-su | [] [] [] [] | 21 + gpe-taskmanager | [] [] [] [] | 21 gpe-timesheet | [] [] [] [] | 18 - gpe-today | [] [] [] [] [] | 20 - gpe-todo | [] | 6 - gphoto2 | [] [] [] [] | 20 - gprof | [] [] | 11 - gpsdrive | | 4 + gpe-today | [] [] [] [] [] | 21 + gpe-todo | [] [] | 8 + gphoto2 | [] [] [] [] | 21 + gprof | [] [] | 13 + gpsdrive | [] | 5 gramadoir | [] | 7 - grep | [] [] [] [] | 33 - gretl | | 4 - gsasl | [] [] | 6 - gss | [] | 5 - gst-plugins | [] [] [] | 15 - gst-plugins-base | [] [] [] | 9 - gst-plugins-good | [] [] [] | 18 - gstreamer | [] [] [] | 17 - gtick | [] | 11 - gtkam | [] | 13 + grep | [] | 12 + gretl | | 6 + gsasl | [] [] [] | 9 + gss | [] | 7 + gst-plugins-bad | [] [] [] | 13 + gst-plugins-base | [] [] | 11 + gst-plugins-good | [] [] [] [] [] | 16 + gst-plugins-ugly | [] [] [] | 13 + gstreamer | [] [] [] | 18 + gtick | [] [] | 7 + gtkam | [] | 16 gtkorphan | [] | 7 - gtkspell | [] [] [] [] [] [] | 26 - gutenprint | | 3 - hello | [] [] [] [] [] | 39 - id-utils | [] [] | 14 - impost | [] | 4 - indent | [] [] [] [] | 25 - iso_3166 | [] [] [] | 15 - iso_3166_1 | [] [] | 20 - iso_3166_2 | | 2 - iso_3166_3 | [] [] | 9 - iso_4217 | [] [] | 14 - iso_639 | [] | 14 + gtkspell | [] [] [] [] [] [] | 27 + gutenprint | | 4 + hello | [] [] [] [] [] | 38 + herrie | [] [] | 8 + hylafax | | 0 + idutils | [] [] | 15 + indent | [] [] [] [] [] | 28 + iso_15924 | [] [] | 4 + iso_3166 | [] [] [] [] [] [] [] [] [] | 54 + iso_3166_2 | [] [] | 4 + iso_4217 | [] [] [] [] [] | 24 + iso_639 | [] [] [] [] [] | 26 jpilot | [] [] [] [] | 7 jtag | [] | 3 jwhois | [] [] [] | 13 - kbd | [] [] | 12 - keytouch | [] | 4 - keytouch-editor | | 2 - keytouch-keyboa... | | 2 - latrine | [] [] | 8 - ld | [] [] [] [] | 8 - leafpad | [] [] [] [] | 23 - libc | [] [] [] | 23 - libexif | [] | 4 + kbd | [] [] [] | 13 + keytouch | [] | 8 + keytouch-editor | [] | 5 + keytouch-keyboa... | [] | 5 + latrine | [] [] | 5 + ld | [] [] [] [] | 10 + leafpad | [] [] [] [] [] | 24 + libc | [] [] [] | 19 + libexif | [] | 5 libextractor | [] | 5 - libgpewidget | [] [] [] | 19 - libgpg-error | [] | 4 - libgphoto2 | [] | 8 + libgpewidget | [] [] [] | 20 + libgpg-error | [] | 6 + libgphoto2 | [] [] | 9 libgphoto2_port | [] [] [] | 11 libgsasl | [] | 8 - libiconv | [] | 4 - libidn | [] [] | 10 + libiconv | [] [] | 11 + libidn | [] [] | 11 lifelines | | 4 - lilypond | | 2 + lilypond | [] | 6 lingoteach | [] | 6 + lprng | [] | 2 lynx | [] [] [] | 15 m4 | [] [] [] | 18 - mailutils | [] | 8 + mailfromd | [] [] | 3 + mailutils | [] [] | 8 make | [] [] [] | 20 - man-db | [] | 6 + man-db | [] | 9 minicom | [] | 14 - mysecretdiary | [] [] | 12 - nano | [] [] | 15 - nano_1_0 | [] [] [] | 18 + nano | [] [] [] | 20 opcodes | [] [] | 10 - parted | [] [] [] | 10 - pilot-qof | [] | 3 - psmisc | [] | 10 + parted | [] [] [] | 11 + pilot-qof | [] | 1 + popt | [] [] [] [] | 18 + psmisc | [] [] | 10 pwdutils | [] | 3 - python | | 0 - qof | [] | 2 - radius | [] | 6 + qof | [] | 4 + radius | [] [] | 7 recode | [] [] [] | 25 - rpm | [] [] [] [] | 14 + rpm | [] [] [] [] | 13 screem | [] | 2 scrollkeeper | [] [] [] [] | 26 - sed | [] [] [] | 22 - sh-utils | [] | 15 - shared-mime-info | [] [] [] [] | 23 + sed | [] [] [] [] | 23 + shared-mime-info | [] [] [] | 29 sharutils | [] [] [] | 23 - shishi | | 1 - silky | [] | 4 + shishi | [] | 3 skencil | [] | 7 - sketch | | 6 - solfege | | 2 + solfege | [] | 3 soundtracker | [] [] | 9 sp | [] | 3 - stardict | [] [] [] [] | 11 - system-tools-ba... | [] [] [] [] [] [] [] | 37 - tar | [] [] [] [] | 19 + system-tools-ba... | [] [] [] [] [] [] [] | 38 + tar | [] [] [] | 17 texinfo | [] [] [] | 15 - textutils | [] [] [] | 17 tin | | 1 - tp-robot | [] [] [] | 10 - tuxpaint | [] [] [] | 16 + tuxpaint | [] [] [] | 19 unicode-han-tra... | | 0 unicode-transla... | | 2 util-linux | [] [] [] | 20 - vorbis-tools | [] [] | 11 + util-linux-ng | [] [] [] | 20 + vorbis-tools | [] [] | 4 wastesedge | | 1 - wdiff | [] [] | 22 - wget | [] [] [] | 19 - xchat | [] [] [] [] | 28 - xkeyboard-config | [] [] [] [] | 11 - xpad | [] [] [] | 14 + wdiff | [] [] | 23 + wget | [] [] [] | 20 + xchat | [] [] [] [] | 29 + xkeyboard-config | [] [] [] | 14 + xpad | [] [] [] | 15 +---------------------------------------------------+ - 77 teams tg th tk tr uk ven vi wa xh zh_CN zh_HK zh_TW zu - 172 domains 0 1 1 78 39 0 135 13 1 50 3 54 0 2054 + 76 teams tg th tk tr uk ven vi wa xh zh_CN zh_HK zh_TW zu + 163 domains 0 3 1 74 51 0 143 21 1 57 7 45 0 2036 Some counters in the preceding matrix are higher than the number of visible blocks let us expect. This is because a few extra PO files are @@ -1085,10 +1042,10 @@ distributed as such by its maintainer. There might be an observable lag between the mere existence a PO file and its wide availability in a distribution. - If July 2006 seems to be old, you may fetch a more recent copy of -this `ABOUT-NLS' file on most GNU archive sites. The most up-to-date -matrix with full percentage details can be found at -`http://www.iro.umontreal.ca/contrib/po/HTML/matrix.html'. + If November 2007 seems to be old, you may fetch a more recent copy +of this `ABOUT-NLS' file on most GNU archive sites. The most +up-to-date matrix with full percentage details can be found at +`http://translationproject.org/extra/matrix.html'. 1.6 Using `gettext' in new packages =================================== @@ -1106,6 +1063,6 @@ the use of `gettext' the only thing missing are the translations. The Free Translation Project is also available for packages which are not developed inside the GNU project. Therefore the information given above applies also for every other Free Software Project. Contact -`translation@iro.umontreal.ca' to make the `.pot' files available to -the translation teams. +`coordinator@translationproject.org' to make the `.pot' files available +to the translation teams. diff --git a/src/bin/coreutils/AUTHORS b/src/bin/coreutils/AUTHORS index 7095db09a5..0c15472fad 100644 --- a/src/bin/coreutils/AUTHORS +++ b/src/bin/coreutils/AUTHORS @@ -46,11 +46,12 @@ md5sum: Ulrich Drepper, Scott Miller, David Madore mkdir: David MacKenzie mkfifo: David MacKenzie mknod: David MacKenzie -mktemp: Jim Meyering +mktemp: Jim Meyering, Eric Blake mv: Mike Parker, David MacKenzie, Jim Meyering nice: David MacKenzie nl: Scott Bartram, David MacKenzie nohup: Jim Meyering +nproc: Giuseppe Scrivano od: Jim Meyering paste: David M. Ihnat, David MacKenzie pathchk: Paul Eggert, David MacKenzie, Jim Meyering diff --git a/src/bin/coreutils/ChangeLog b/src/bin/coreutils/ChangeLog index 1dba0b319a..741f54a4bd 100644 --- a/src/bin/coreutils/ChangeLog +++ b/src/bin/coreutils/ChangeLog @@ -1,5 +1,2212 @@ +2010-01-13 Jim Meyering + + version 8.4 + * NEWS: Record release date. + +2010-01-13 Pádraig Brady + + tests: avoid spurious failures on older shells + * tests/tail-2/inotify-hash-abuse: Use kill rather than wait + to determine if the tail process is still running. + * tests/tail-2/inotify-hash-abuse2: Ditto. + +2010-01-13 Jim Meyering + + tests: work around spurious test failure with OpenBSD4.5's /bin/sh + * tests/ls/infloop: OpenBSD4.5's /bin/sh would mistakenly include + "set -x"-output in an application's stderr stream when stderr is + redirected before stdout. This was causing one spurious test failure. + The work-around: redirect stdout first. + Reported by Nelson Beebe. + + tests: don't silently skip the sort-version tests + * tests/misc/sort-version: Don't use <<- and indented here-doc contents. + s/<<-/<[4]: here document `x' unclosed + [Exit 1] + by contrast, bash warns but still exits successfully: + $ printf 'cat<<-x\n foo\n x\n'|bash && echo you lose + bash: line 3: warning: here-document at line 1 delimited by \ + end-of-file (wanted `x') + foo + x + you lose + +2010-01-12 Eric Blake + + tests: avoid spurious failure on old kernel + * tests/touch/no-dereference: Skip test if utimensat doesn't + support symlinks. + Reported by Bernhard Voelker. + +2010-01-12 Pádraig Brady + + maint: update info about getting the prerequisite automake + * README-prereq: Now that we require automake-1.11.1 + update the instructions from getting it from the git repo + + maint: remove an already handled item from TODO + * TODO: The question regarding printf octal escapes is answered in + commit 4bcefa62, 2003-04-21, "Fix printf POSIX compatibility bug ..." + + maint: fix tests on solaris by using /usr/xpg4/bin + * tests/check.mk: Prepend /usr/xpg4/bin to the $PATH if present. + Using the more standard utilities allows tests such as misc/printenv, + which uses the -E option to grep, to complete. + +2010-01-12 Jim Meyering + + build: update gnulib, to get fixed getlogin-related tests + + build: fix build failure due to missing libxattr + Configure is supposed to detect insufficient XATTR support. + However, if a system has the required headers, but no library, + the configure script would mistakenly enable USE_XATTR. + * m4/xattr.m4 (gl_FUNC_XATTR): If the attr_copy_file function + is not found, don't set USE_XATTR. + Nelson Beebe reported a link failure on RHEL 5.3. + Also, do not let the combination of --disable-xattr and + a stray LIB_XATTR environment setting perturb the build. + * NEWS (Build-related): Mention it. + + doc: mention the wchar.h vs. glibc build problem + * NEWS (Build-related): Mention the wchar.h issue. + +2010-01-12 Pádraig Brady + + nproc: return a possibly more accurate total CPU count + * gnulib: Update, for num_processors() improvement. + * NEWS: Mention the fix. + +2010-01-12 Kamil Dudka + + ls: reorder includes to work around broken + * src/ls.c: Include later, to avoid build + failure with a header from libcap-2.16-1 or earlier. + See http://bugzilla.redhat.com/483548 for details. + +2010-01-08 Eric Blake + + maint: move coreutils specific rule into cfg.mk + * gnulib: Update, for maint.mk improvement. + * cfg.mk (_makefile_at_at_check_excpetions): New rule, needed + for latest change to maint.mk. + +2010-01-07 Jim Meyering + + post-release administrivia + * NEWS: Add header line for next release. + * .prev-version: Record previous version. + * cfg.mk (old_NEWS_hash): Auto-update. + + version 8.3 + * NEWS: Record release date. + + maint: change an email address in THANKS + * THANKS: Adjust Denis' address. + +2010-01-07 Eric Blake + + pr: ensure the page header line is of the required format + Before this change, with too long a file name, the name would + abut the date field on the left and possibly also the "Page N" + field on the right, rather than leaving a one-space separator + in each case. Fixes a regression introduced on Mar 6 2009, + by commit a4053c5291d5797734b3e4f042f9e1adf3944fd6 + + * src/pr.c (print_header): Ensure that there is at least one + space before and after the file name part of the header line. + * NEWS: Mention it. + * tests/pr/W20l24f-ll: s/xPage/ x Page/. + * THANKS: Update. + Reported by Denis McKeon, in https://savannah.gnu.org/bugs/?28492. + + maint: apply correct license to auxiliary files + * gnulib: Update, for maint.mk improvements. + * HACKING: Use GFDL 1.3, not 1.2. + * NEWS: Likewise. + * README: Likewise. + * cfg.mk (old_NEWS_hash): Update accordingly. + * .gitignore: Ignore file created by 'make update-NEWS-hash'. + +2010-01-06 Jim Meyering + + build: require newer versions of automake and autoconf + * configure.ac: Require autoconf-2.62 and automake-1.11.1 or newer. + * bootstrap.conf (buildreq): Require automake-1.11.1 or newer, + to ensure people use a version with the fix for CVE-2009-4029. + Note that the coreutils-8.2 tarball included a fixed Makefile.in. + Require autoconf-2.62, per automake. + +2010-01-06 Eric Blake + + cp, touch: avoid problem with new glibc + * gnulib: Update, for utimens fix. + * NEWS: Mention the fix. + Reported by Guillaume Ayoub in http://bugs.debian.org/563726. + See also http://bugzilla.redhat.com/552320. + +2010-01-05 Philip Rowlands + + doc: fix typo in NEWS + * NEWS: Fix typo: s/repeated/repeatedly/ + +2010-01-05 Jim Meyering + + build: update gnulib submodule to latest + + maint: always free a buffer, to avoid even semblance of a leak + * src/tac.c (main): Free the input buffer in most cases. + +2010-01-04 Jim Meyering + + maint: use more readable operator: "||" rather than "|" + * src/cp.c (make_dir_parents_private): Use "||" rather than "|", + so that clang understands there is no undefined pointer dereference. + +2010-01-03 Jim Meyering + + maint: record update-copyright options for this package + * cfg.mk: Next time, just run "make update-copyright". + +2010-01-01 Eric Blake + + ls: fix color of broken symlinks colored as target + * src/ls.c (print_color_indicator): When using 'LINK target' in + dircolors, treat broken symlink as C_ORPHAN. + * tests/misc/ls-misc (sl-dangle2, sl-dangle3, sl-dangle4) + (sl-dangle5): Test for it, and add more coverage. + * NEWS: Document it. + * THANKS: Update. + Reported by Chris Jones. + +2010-01-01 Jim Meyering + + df: use fputs in place of printf in a few more places + * src/df.c (print_header): Use fputs rather than printf in more places. + Suggested by Eric Blake. + + build: update gnulib submodule to latest + + maint: add a few copyrights; remove obsolete README file + * tests/README: Remove long-obsolete file. + * tests/Makefile.am (EXTRA_DIST): Remove README. + * tests/misc/truncate-dir-fail: Add copyright comment. + * tests/misc/selinux: Likewise. + * tests/misc/chcon: Likewise. + * tests/misc/chcon-fail: Likewise. + * tests/sample-test: Use only 2010 in this list. + + maint: update all FSF copyright year lists to include 2010 + Use this command: + git ls-files | grep -v COPYING \ + | xargs env UPDATE_COPYRIGHT_USE_INTERVALS=1 \ + build-aux/update-copyright + +2010-01-01 Stéphane Raimbault + + pr --help: add missing space between short and long options usage message + * src/pr.c (usage): Add missing space. + + pr --help: improve a line-break + * src/pr.c (usage): Move the newline character a bit farther. + + df: add comments to help translators align column headers + * src/df.c (print_header): Add a comment telling translators to + retain the message length, and another to align header translations. + +2009-12-31 Jim Meyering + + maint: newer gnulib; don't hard-code my GPG key ID + * cfg.mk (gpg_key_ID): Remove definition, now that maint.mk automates it. + * gnulib: Update to latest. + + doc: update tail's documentation to allow for new -F semantics + * src/tail.c (usage): Reword tail -F description, so that it no + longer mentions details specific to the non-inotify implementation. + Also, join diagnostic strings (while staying under the 509-byte limit) + to ease formatting of translations. The latter was prompted by + a report from Stéphane Raimbault. + * doc/coreutils.texi (tail invocation): Update description here, too. + +2009-12-31 Eric Blake + + touch: work around ntfs-3g bug + * gnulib: Update, for utimensat fix. + * NEWS: Improve wording about touch fixes. + * THANKS: Update. + Reported by Stuart Citrin. + +2009-12-30 Jim Meyering + + build: update gnulib submodule to latest + + doc: mention two tail -F bug fixes in NEWS + * NEWS (Bug fixes): Two tail -F fixes. + + tail: test for a bug in inotify-enabled tail -F + tail -F a b would stop tracking additions to b after "mv a b". + * tests/tail-2/F-vs-rename: New file. + * tests/Makefile.am (TESTS): Add it. + +2009-12-30 Giuseppe Scrivano + + tail -F: don't stop following the target of a rename + This fixes a bug whereby tail -F would fail to track changes + to a file that was a target of a rename, and when the source of + the rename was another tailed file. + + * src/tail.c (tail_forever_inotify): Ensure the wd is not already + present in the hash table before trying to add it. When a new watch + descriptor is added to the `wd_to_name' hash table, check that it is + not already present. If it is present then remove the previous element. + +2009-12-30 Pádraig Brady + + maint: improve the info about $PATH in README-prereq + * README-prereq: It wasn't obvious that the $PATH should + be set before building any of the prerequisite packages, + so move that information up. + +2009-12-29 Jim Meyering + + tail: add another test to exercise abort-inducing flaw in tail -F + * tests/tail-2/inotify-hash-abuse2: New test, based on a reproducer + by Rob Wortman. + * tests/Makefile.am (TESTS): Add it. + + tail: add a test to exercise abort-inducing flaw in tail -F + * tests/tail-2/inotify-hash-abuse: New file, derived from + a report by Rob Wortman. + * tests/Makefile.am (TESTS): Add it. + Improved by: Pádraig Brady. + +2009-12-29 Giuseppe Scrivano + + tail: remove `fdspec' from the hash table before changing its key + * src/tail.c (tail_forever_inotify): Avoid modifying fdspec->wd while + it is in the wd_to_name hash table. Once it is removed, it can be + added using the new `wd' as key for the hash table. This fixes the + abort-inducing bug reported by Rob Wortman in + http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/19372 + +2009-12-29 Jim Meyering + + maint: quiet "make" in doc/ + * doc/Makefile.am (constants.texi): Add a use of AM_V_GEN. + + tail: rename an internal variable + * src/tail.c (tail_forever_inotify): s/wd_table/wd_to_name/ + + tail: avoid read-beyond-end-of-buffer error + * src/tail.c (tail_forever_inotify): Do not use f[i] in a context + where i may be larger than the largest valid index. In the final + "if" clause in which we'd remove an inotify watch, we might have + used f[n_files]. Use fspec instead, since it is guaranteed to + be defined. + +2009-12-26 Eric Blake + + maint: ignore more built files + Recent gnulib changes added new built files. + + * .gitignore: Add arg-nonnull.h, link-warning.h, + unused-parameter.h. + + tac: supply link dependency + * src/Makefile.am (tac_LDADD): Add LIB_GETHRXTIME. + * THANKS: Update. + Reported by Robert Schwebel. + +2009-12-26 Jim Meyering + + build: update gnulib submodule to latest + + tail: shrink internal struct by 8 bytes + * tail.c (struct File_spec): Rearrange struct members to decrease + size by 8 bytes to 76,96 on i686,x86_64 respectively. + +2009-12-25 Jim Meyering + + maint: tail: avoid in-function #if directives + * src/tail.c (fremote): Add a comment. + Move definition "up" to precede first use, so we can + remove its prototype and the #if..#endif around each use. + (any_remote_file): Rename from any_remote_files. + +2009-12-25 Pádraig Brady + + tail: fix --follow to not use inotify on remote files + * src/tail.c (struct File_spec): Add a flag to record if file is remote. + (recheck): If we're using inotify then check if the file has gone remote + and if so, drop it with a warning. + (any_remote_files): A new function to check for any open remote files. + (tailable_stdin): A new function to refactor the check for whether + a tailable file was specified through stdin. + (fremote): A new function to check if a file descriptor + refers to a remote file. + (tail_forever_inotify): Add some comments. + (tail_file): Record if a file is remote when initially opened. + (main): Disable inotify if any remote files specified. + Also document the caveat about remounted files not + being noticed by inotify. + * NEWS: Mention the fix. + +2009-12-23 Pádraig Brady + + wc: line-buffer the printed counts + * src/wc.c (main): Set stdout to line buffered mode + to ensure parallel running instances don't intersperse + their output. This adds 6.5% to the run time in the worst case + of many zero length files, but has neglible impact for + standard sized files. + * tests/misc/wc-parallel: New test for atomic output. + * tests/Makefile.am: Reference it. + * NEWS: Mention the fix + This is similar to commit 710fe413, 20-10-2009, + "md5sum, sha*sum, sum: line-buffer the printed checksums" + +2009-12-22 Pádraig Brady + + stat: Recognize k-afs, gfs, ocfs2 file system types + * src/stat.c (human_fstype): Add k-afs, gfs/gfs2 and ocfs2. + * NEWS: Update the stat -f entry. + + stat: add support for more file system types + * src/stat.c (human_fstype): Add the following FS types: + fuseblk, rpc_pipefs. Also fix a typo of minux3 to minix3, + and mention the fs-magic-compare make target to help update the list. + * NEWS: Mention the fix. + +2009-12-20 Jim Meyering + + build: correct coreutils-specific distcheck rules + * dist-check.mk (built_programs): Use $(bin_PROGRAMS), not $(PROGRAMS). + Otherwise, my-instcheck would fail due to non-installation of e.g., + the noinst_PROGRAMS, setuidgid and getlimits. + (taint-distcheck): Correct the grep command that checks for libtool + traces in configure. + +2009-12-20 Eric Blake + + touch: fix ctime regression in 'touch -a' + Regression introduced in coreutils 8.1 due to a bug in the Linux + kernel implementation of utimensat with mtime of UTIME_OMIT. + + * gnulib: Update to latest, to pick up utimensat fix. + * NEWS: Mention the change. + * THANKS: Update. + Reported by John Stanley. + +2009-12-19 Pádraig Brady + + maint: don't include the strverscmp gnulib module + * bootstrap.conf (gnulib_modules): Remove the strverscmp module + which is not used since commit e505736f, on 03-10-2008, + "ls and sort: use filevercmp instead of strverscmp" + + doc: enhance and reference info about version comparison + * doc/coreutils.texi (sort invocation): Reference the additional + info about filevercmp rather than the unused strverscmp. + (Details about version sort): Add some examples that are not + handled well by fileversmp. + * src/ls.c: Change a comment referencing the now unused strverscmp. + + rm: fix --one-file-system regression due to fts conversion + * src/remove.c (rm_fts): Fix incorrect comparison of + device and inode numbers. + * tests/rm/one-file-system2: Add a separate test so + that it can be run as a normal user (It doesn't need to mount). + * tests/Makefile.am: Reference it. + * NEWS: Mention the fix. + Reported by Jan Larres. + +2009-12-14 Jim Meyering + + maint: improve dist-check.mk rules + * dist-check.mk (null_AM_MAKEFLAGS): Remove LIBTOOL. Adding it was + erroneous, since it is required when building from a distribution + tarball of a libtool-using project. Reported by Ralf Wildenhues. + (my-distcheck): Reorganize to use a subshell and set -e, so that + failures propagate "out". Without this change, setting LIBTOOL=false + would cause a failure that would then be ignored, probably due to a + problem in $(install-transform-check). + +2009-12-14 Thiago Farina + + base64: use *_OPTION_DESCRIPTION macros instead of hard-coded strings + * src/base64 (usage): Use HELP_OPTION_DESCRIPTION and + VERSION_OPTION_DESCRIPTION macros, not literal strings. + +2009-12-13 Jim Meyering + + tests: unpack xz-compressed tarballs when possible, not always *.gz + * dist-check.mk: Unpack compressed tarball using xz when possible, + since that's faster. + + maint: make dist-check.mk more easily shared + * dist-check.mk (built_programs): More generic, but still assumes src/. + Don't set GZIP in environment when untarring. + (my-distcheck): Use $(DIST_ARCHIVES), rather than assuming that + there is always a .tar.gz file. + + nohup: if fd_repoen fails (redirecting stdin), report it + * src/nohup.c (main): Don't ignore fd_reopen failure. + + tests: make the taint-distcheck rule easier to share with other projects + * dist-check.mk (taint-distcheck): Skip this test in a project + that uses libtool. + + stat: recognize "sockfs" file system type, ... + ... now that its magic number appears in . + * src/stat.c (human_fstype) [S_MAGIC_SOCKFS]: Add case. + + maint: move definitions from maint.mk to dist-check.mk + * dist-check.mk (null_AM_MAKEFLAGS): Define here, not in maint.mk. + (built_programs): Likewise. + (my-distcheck): Move comments to... + (coreutils-path-check): ...the code they refer to. + Remove obsolete comments. + (null_AM_MAKEFLAGS): Add gperf, even though it's not used here. + * gnulib: Update to latest, for fixed maint.mk. + +2009-12-12 Jim Meyering + + tests: tail-without-inotify: avoid spurious test failure + * tests/tail-2/wait: Account for the possibility that the kernel + lacks inotify support. Reported by Chris Clayton. + + factor: add a missing va_end + * src/factor.c (debug): Add missing va_end. + +2009-12-11 Jim Meyering + + build: update gnulib submodule to latest; adapt a patch + * gl/lib/tempname.c.diff: Adjust patch to apply to gnulib, now that + most TABs in indentation have been converted to spaces by running + this command: f=tempname.c.diff; patch-xform $f > k && mv k $f + + post-release administrivia + * NEWS: Add header line for next release. + * .prev-version: Record previous version. + * cfg.mk (old_NEWS_hash): Auto-update. + + version 8.2 + * NEWS: Record release date. + + tests: use a slightly better CU_TEST_NAME setting + * tests/check.mk (CU_TEST_NAME): Better test names. + + tail: don't call fstat on an uninitialized FD + This bug showed up via valgrind as a "Conditional jump or move + depends on uninitialized value(s)" error. + * src/tail.c (ignore_fifo_and_pipe): New function. + (main): Use it only when tailing forever. + The code to compute n_viable and mark some F[i] as ignored would call + isapipe on an uninitialized file descriptor. But n_viable and those + .ignored marks are useful/used only when tailing forever. This bug + was introduced via commit f0ff8c73 (7.6), "tail: make the new + piped-stdin test as portable as the old one". + * NEWS (Bug fixes): Mention it. + + doc: NEWS: mention that gnulib's mgetgroups fix affects id + * NEWS (Bug fixes): Mention the "id" bug fix inherited via this gnulib + change: "mgetgroups: do not write bytes beyond end of malloc'd buffer" + http://git.sv.gnu.org/cgit/gnulib.git/commit/?id=51d5e813e9ee6cf23 + +2009-12-10 Jim Meyering + + build: update gnulib submodule to latest + + tests: avoid spurious failure when run via valgrind + * tests/misc/printenv: Ignore LD_PRELOAD differences. + +2009-12-09 Jim Meyering + + doc: NEWS: the "make distcheck" vulnerability dates back to 5.0 + * NEWS (Bug fixes): Correct the introduced-in version number. + This was introduced on 2003-04-02 by commit 722a49ea. + + doc: NEWS: mention the "make distcheck" vulnerability + * NEWS (Bug fixes): Mention implications of the "make distcheck" change. + This was introduced on 2008-07-22 by commit 9bb0d576, "tests: ensure + "make check" w/tainted build dir no longer impacts $HOME". + + tests: don't let "umask 077" cause root-only cp/preserve-gid failure + * tests/cp/preserve-gid: Use working_umask_or_skip_ to set umask to 022. + +2009-12-08 Jim Meyering + + build: update gnulib submodule to latest + +2009-12-08 Pádraig Brady + + maint: remove an erroneous comment + * tests/misc/timeout: Remove an erroneous comment + introduced through copy and paste. + + sort: fix failure if sort's parent has ignored SIGCHLD + * src/sort.c (main): Reset the SIGCHLD handler to the default + as otherwise wait() could return an error. + * tests/misc/sort-compress: Set the CHLD handler in a subshell + to SIG_IGN to ensure the sort command resets it to SIG_DFL. + * NEWS: Mention the fix. + + timeout: fix failure if timeout's parent has ignored SIGCHLD + * src/timeout.c (main): Reset the SIGCHLD handler to the default + as otherwise wait() could return -1 and set errno to ECHILD. + This condition was ignored until commit 0b1dcf33, on 31-08-2009, + "timeout: defensive handling of all wait() errors" + but subsequently timeout would run the command correctly + but then fail with an error message. + * tests/misc/timeout: In a subshell set the CHLD handler to + SIG_IGN to ensure the timeout command resets it to SIG_DFL. + * NEWS: Mention the fix. + + tests: fix stty-row-col failure on small fixed terminals + * tests/misc/stty-row-col: Linux virtual consoles at least, + issue an error if you try to increase their size, so skip the + test if we can't increase the dimensions of the tty by 1 cell. + Reported by Matthew Burgess. + + tests: fix stty failure with serial control settings + * tests/misc/stty: Don't check the serial control settings as + these are ignored by various Linux kernels. + Reported by Matthew Burgess. + +2009-12-07 Jim Meyering + + build: update gnulib submodule to latest + + build: distcheck: do not leave a $TMPDIR/coreutils directory behind + * dist-check.mk (tmpdir): Rename from TMPDIR. Use ./tests/torture + unconditionally, rather than $TMPDIR-with-default-to-/tmp. + Otherwise, running "make distcheck" could leave an empty /tmp/coreutils + directory behind. + (tp): Simplify, now that it's always in the build-dir. + (taint-distcheck): Set HOME earlier, in case $(MAKE) misbehaves. + (my-instcheck, coreutils-path-check): Add diagnostics, so it's easier + to diagnose when each runs. + (coreutils-path-check): Run configure with --quiet, to reduce output. + Inspired by Ralf Wildenhues' report of /tmp/coreutils being left behind. + +2009-12-06 Jim Meyering + + tests: readdir-mountpoint-inode avoid false-positive w/virtualbox + * tests/ls/readdir-mountpoint-inode: With some systems, stat can + succeed on a mount point and report that the inode number is 0. + Since ls displays "?" for those, that would otherwise show up as a + difference. Skip such mount points. Reported by Sergei Steshenko + in http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/19142 + +2009-12-06 Pádraig Brady + + tests: don't run tail-2/inotify-race by default + * tests/tail-2/inotify-race: Note the caveats of the test. + I.E. the intermittent skips and the gdb hang reported + by Alan Curry. Add extra info to the log on why the test + is skipped as it may be due to multiple reasons. Mark + the test as very expensive so that it's not normally run. + +2009-12-05 Eric Blake + + id: handle systems without getgroups support + If getgroups failed with ENOSYS, mgetgroups would unnecessarily + fail, and that provoked id into freeing an uninitialized pointer. + Meanwhile, we were not using xalloc_die properly. Both issues + are better solved in gnulib, by introducing xgetgroups; this + patch uses the new interface. + + Regression introduced by commit 6a31fd8d7. + + * gnulib: Update, for mgetgroups improvments. + * src/id.c (print_full_info): Adjust caller to die on allocation + failure, and no longer worry about ENOSYS. + * src/group-list.c (print_group_list): Likewise. + * src/setuidgid.c (main): Likewise. + * NEWS: Mention the fix. + * THANKS: Update. + Reported by Scott Harrison. + +2009-12-03 Jim Meyering + + tests: fix a bug in sanitize_path_ that inhibited verbose output + * tests/test-lib.sh (sanitize_path_): Use "set -- ...", not "set - ...", + since the latter turns off the -x setting we rely on for VERBOSE=yes + output. + +2009-12-01 Eric Blake + + sort: fix link failure on Solaris + Commit f9d0bb8481 made sort depend on xnanosleep. + + * src/Makefile.am (sort_LDADD): Add LIB_NANOSLEEP. + +2009-12-01 Jim Meyering + + rm: fix empty-name bug introduced with conversion to use fts + While "rm ''" would properly fail, "rm F1 '' F2" would fail + to remove F1 and F2, due to the empty string argument. + This bug was introduced on 2009-07-12, via commit 4f73ecaf, + "rm: rewrite to use fts". + * gnulib: Update to latest, for fixed fts.c. + * NEWS (Bug fixes): Describe it. + * tests/rm/empty-name: Adjust for changed diagnostic. + (mk_file): Define, copied from misc/ls-misc. + (empty-name-2): New test, for today's fix. + * lib/xfts.c (xfts_open): Reflect the change in fts_open, now that + it no longer fails immediately when one argument is the empty string. + Assert that the bit flags were not the cause of failure. + * po/POTFILES.in: Remove xfts.c. + * THANKS: Update. + Reported by Ladislav Hagara. + +2009-11-30 Pádraig Brady + + bootstrap: fix handling of various perl --version formats + * bootstrap (get_version): Don't use perl's $] special + variable, as that requires updating all bootstrap.conf files to + use perl's x.yyyzzz version format. Instead make the regular + expression more general to support version formats from older + perl-5.005_002 (5.5.2) and perl-5.11 which has other numbers + in the version line. + +2009-11-29 Jim Meyering + + bootstrap: update from gnulib, for perl-5.11.x support + * bootstrap (get_version): Handle perl separately, + since perl-5.11's --version output is different. + + build: update gnulib submodule to latest + +2009-11-28 Jim Meyering + + maint: chown.c: remove a comment + * src/chown.c: Remove old spec-like comment. + +2009-11-24 Eric Blake + + tests: fix link failure on cygwin + Counterpart to commit 8fe40b84bd8, since test-link.c uses rename, + and we override gnulib with a rename() replacement that can xalloc_die. + + * gl/modules/link-tests.diff: New file. + + build: fix link failure on cygwin + Cygwin 1.5 has a broken sleep, and the gnulib tests dragged in + rpl_sleep which then caused a link failure because it wasn't in + libcoreutils.a. We could solve it by using the gnulib sleep module. + However, sleep and usleep may interact poorly with SIGALRM, and they + have less granularity; so it is better to adopt a policy that if we + must sleep, prefer xnanosleep. + + * src/sort.c (pipe_fork): Use xnanosleep, to avoid the need for + rpl_sleep on cygwin, and to reduce granularity. + (MAX_FORK_TRIES_COMPRESS, MAX_FORK_TRIES_DECOMPRESS): Increase, + to account for reduction in granularity. + * src/tail.c (tail_file): Use xnanosleep in debug code. + * cfg.mk (sc_prohibit_sleep): New rule. + +2009-11-23 Jim Meyering + + tests: avoid test failures when PATH contains an unsearchable directory + * tests/test-lib.sh (sanitize_path_): New function. + Always call it. + +2009-11-22 Dmitry V. Levin + + tests: do not fail on read-only root file system + * tests/touch/not-owner: Handle the case when the root file system is + mounted read-only. + Reported by Solar Designer. + +2009-11-20 Jim Meyering + + maint: cfg.mk: remove factored-out ftp host/dir definitions + * cfg.mk (gnu_ftp_host-alpha, gnu_ftp_host-beta gnu_ftp_host-stable): + (gnu_rel_host, url_dir_list): Remove definitions. The defaults, + now provided by maint.mk, are the same. + * gnulib: Update for latest, including those maint.mk additions. + + maint: correct comments in test scripts + * tests/misc/pwd-long: Fix spelling of cygwin1.dll in comment. + * tests/rm/fail-eperm: Likewise. + Reported by Eric Blake. + + maint: don't list "warnings" module explicitly + * bootstrap.conf (gnulib_modules): Remove "warnings", now that + it's pulled in automatically via "manywarnings". + + maint: move xfreopen module to gnulib + * gl/lib/xfreopen.c: Remove file. + * gl/lib/xfreopen.h: Likewise. + * gl/modules/xfreopen: Likewise. + + build: update gnulib submodule to latest + +2009-11-19 Jim Meyering + + tests: avoid spurious failures due to insecure directory in PATH + These tests perform no PATH search, and used to simply delete PATH from + the environment. However, that is not portable, as seen on Cygwin, + where cygwin.dll must be resolvable via PATH when starting a sub-shell. + With commit 0cc04241, we took the alternate approach of untainting the + incoming $ENV{PATH}, but that fails when it contains an other-writable + directory. Instead, now we hard code it to '/bin:/usr/bin'. + + * tests/misc/pwd-long: Hard code $ENV{PATH} to a safe value. + * tests/rm/fail-eperm: Likewise. + Reported by Gilles Espinasse, Andreas Schwab, and Bauke Jan Douma. + +2009-11-18 Jim Meyering + + build: "make stable" emitted an invalid gnupload command + * cfg.mk (gnu_ftp_host-stable): Rename from gnu_ftp_host-major. + * README-release: Change another s/major/stable/. + + post-release administrivia + * NEWS: Add header line for next release. + * .prev-version: Record previous version. + * cfg.mk (old_NEWS_hash): Auto-update. + + version 8.1 + * NEWS: Record release date. + + build: update gnulib for Solaris utimens workaround + + build: update gnulib submodule to latest + +2009-11-17 Jim Meyering + + maint: remove local gnulib-related patches + * gl/lib/printf-args.c.diff: Remove file. No longer needed. + * gl/lib/vasnprintf.c.diff: Likewise. + + build: update gnulib for Solaris 10 unsetenv work-around + + doc: mention the du/fts vs. NFSv4 mount-point work-around + * NEWS (Changes in behavior): Mention it. + + build: update from gnulib for (un)setenv fixes + +2009-11-16 Jim Meyering + + build: update gnulib submodule to latest + + true, false: perform initialization only when argc == 2 + * src/true.c (main): There is no reason to examine argv[0], + call atexit, etc., in the usual case in which we're about to exit. + This has the side effect of making it so that these programs + no longer segfault when subjected to execve abuse. + Before this change, these commands would make "true" segfault: + printf '%s\n' '#include ' 'int main(int c, char**v)' \ + '{ execve (v[1], 0, 0); }' > k.c && gcc k.c && ./a.out $PWD/true + Now it succeeds. Reported by Tetsuo Handa and Bart Van Assche + via OndÅ™ej Vašík in http://bugzilla.redhat.com/537684. + + tail -F can fail to track a file after it's been rotated + Tailing forever and by-name (--follow=name, -F), tail would + sometimes fail to follow a file that had been removed via rename. + If you can't apply this patch and have tail 7.6 or newer, you can + work around the bug via the undocumented --disable-inotify option. + * src/tail.c (tail_forever_inotify): When tailing by name (-F), + do not un-watch a file upon receipt of the IN_MOVE_SELF event. + Reported by Arjan Opmeer in http://bugs.debian.org/548439. + * NEWS (Bug fixes): Mention it. + Also see http://marc.info/?l=coreutils-bug&m=125829031916515 + * tests/Makefile.am (TESTS): Add tail-2/inotify-rotate. + * tests/tail-2/inotify-rotate: New test. + +2009-11-14 Jim Meyering + + tests: help-version: exit nonzero when $built_programs is empty + * tests/misc/help-version: Use "Exit 1", rather than "Exit $fail" + with fail defined to 0 when $built_programs is empty. + + build: do use AM_GNU_GETTEXT's "need-formatstring-macros" option + * configure.ac: Revert commit 49741b61 and add a comment. + Reported by Eric Blake. + +2009-11-14 Pádraig Brady + + tests: avoid a spurious failure on a loaded system + * tests/misc/timeout-parameters: This test could fail due to + the 1-second timeout expiring before a command of "no_such" + could be exec'd and fail. Increase to 10 seconds. + +2009-11-13 Jim Meyering + + build: require gettext-0.17 + * configure.ac: Require gettext-0.17; it was released two years ago. + + build: correct gettext configure-time support + * configure.ac: Use AM_GNU_GETTEXT([external], [need-ngettext]), + rather than AM_GNU_GETTEXT([external], [need-formatstring-macros]). + Reported by Martin Jacobs in + http://thread.gmane.org/gmane.comp.parsers.bison.bugs/3181 + * THANKS: Add his name. + + build: update gnulib to latest, for fixed test-getgroups.c + + tests: avoid a spurious timeout on a heavily-loaded system + * tests/misc/timeout-parameters: This test would fail due to + the 1-second timeout expiring before a command of "." could + be exec'd and fail. Increase to 10 seconds. + +2009-11-13 Eric Blake + + build: update gnulib, for getgroups improvements + A replacement getgroups is now guaranteed to exist, but it may + fail with ENOSYS. mgetgroups is moved to gnulib, and now takes + gid_t instead of GETGROUPS_T (but setgroups still needs GETGROUPS_T). + + * gnulib: Update to latest. + * gl/modules/mgetgroups: Delete, moved to gnulib. + * gl/m4/mgetgroups.m4: Likewise. + * gl/lib/mgetgroups.h: Likewise. + * gl/lib/mgetgroups.c: Likewise. + * src/group-list.c (print_group_list): Adjust callers. + * src/id.c (print_full_info): Likewise. + +2009-11-12 Jim Meyering + + build: bootstrap: add a comment; generalize autoheader check + * bootstrap: Sync from gnulib and diff. + + build: update gnulib to latest; more *BSD and Solaris work-arounds + +2009-11-11 Jim Meyering + + bootstrap: use git_modules_config in one more place + * bootstrap: Make bootstrap's --gnulib-srcdir more useful (for testing). + +2009-11-10 Eric Blake + + doc: fix typo + * doc/coreutils.texi (mktemp invocation): Quote shell variable. + +2009-11-09 Jim Meyering + + build: update gnulib submodule to latest for its FreeBSD fixes + +2009-11-09 Pádraig Brady + + ls: fix capability coloring + Capability checking was incorrectly done on just the base name + rather than on the whole path. Consequently there could be both + false positives and negatives when coloring files with capabilities. + Also capability checking was not done at all in certain cases for + non executable files. Note passing absolute rather than relative + names to cap_get_file() reduces the has_capability() overhead + from around 33% to 30%. I.E. ls --color is now around 3% faster. + + * src/ls.c (struct fileinfo): Add a has_capability member. + (print_color_indicator): Refactor to pass just a fileinfo pointer + and a flag to say if we're dealing with a symlink target. + (print_name_with_quoting): Likewise. + (gobble_file): Set has_capability in the fileinfo struct. Also do + a capability check even if executable coloring is disabled. + Ditto for SETUID and SETUID coloring. + Comment on how expensive has_capability() is. + (print_long_format): Adjust to refactored print_name_with_quoting. + (quote_name): Likewise. + (print_file_name_and_frills): Likewise. + * tests/ls/capability: Test the various false positive and negatives. + * THANKS: Add reporter (Ivan Labath). + * NEWS: Mention the fix. + +2009-11-07 Eric Blake + + build: consistently use freopen-safer + cat, head, ptx, shuf, tac, tail, tee, tr, and uniq used freopen + on stdout, and were potentially vulnerable. dircolors, du, and + tsort only used it on stdin, which is unaffected by freopen_safer, + but this covers all uses for consistency. + + * cfg.mk (sc_require_stdio_safer): New rule. + * gl/modules/xfreopen (Depends-on): Add freopen-safer. + * gl/lib/xfreopen.c (includes): Use stdio--.h. + * src/ptx.c (includes): Likewise. + * src/shuf.c (includes): Likewise. + * src/uniq.c (includes): Likewise. + * src/dircolors.c (includes): Likewise. + * src/du.c (includes): Likewise. + * src/tsort.c (includes): Likewise. + + mktemp: fix bug with -q and closed stdout + If stdin or stdout is closed, then freopen(,stderr) can violate + the premise that STDERR_FILENO==fileno(stderr), which in turn + breaks mktemp -q. + + * bootstrap.conf (gnulib_modules): Add freopen-safer. + * src/mktemp.c (includes): Use stdio--.h. + * tests/misc/close-stdout: Enhance test to catch bug. + +2009-11-07 Jim Meyering + + maint: make du's cycle-detection code consistent + * src/du.c (process_file): Revert the du.c-changing part of + commit 8ba5d1a7. Use cycle_warning_required instead. + + chcon, chgrp, chmod and chown now diagnose a directory cycle + * lib/xfts.c (cycle_warning_required): New function. + * lib/xfts.h: Declare it. + * src/chown-core.c (change_file_owner): Diagnose a cycle. + * src/chmod.c (process_file): Likewise. + * src/chcon.c (process_file): Likewise. + * NEWS (Bug fixes): Mention this. + +2009-11-06 Giuseppe Scrivano + + nproc: A new program to count the available processors + * AUTHORS: Add my name. + * NEWS: Mention it. + * README: Likewise. + * bootstrap.conf (gnulib_modules): Add nproc. + * doc/coreutils.texi (nproc invocation): Add nproc info. + * man/Makefile.am (nproc.1): Add dependency. + * man/nproc.x: New template. + * man/.gitignore: Ignore generated man page. + * po/POTFILES.in: Add src/nproc.c. + * src/.gitignore: Exclude nproc. + * src/Makefile.am (EXTRA_PROGRAMS): Add nproc. + * src/nproc.c: New file. + * tests/Makefile.am (TESTS): Add misc/nproc-{avail,positive}. + * tests/misc/nproc-avail: New file. + * tests/misc/nproc-positive: New file. + +2009-11-06 Jim Meyering + + build: move do-release-commit-and-tag to gnulib + * bootstrap.conf (gnulib_modules): Add do-release-commit-and-tag. + * build-aux/do-release-commit-and-tag: Remove file. Now it's in gnulib. + * gnulib: Update submodule to the latest, to get the just-moved script. + +2009-11-05 Eric Blake + + mktemp: use more robust means to avoid double-close of stdout + Reverts earlier patch - fflush() can succeed but fclose() fail for + some cases of write failures, and we want to catch those. + + * src/mktemp.c (stdout_closed): New variable. + (maybe_close_stdout): New function, borrowed from dd.c. + (main): Track whether stdout has been closed. + + mktemp: enhance test to catch just-fixed typo behavior + Penance for botching the conflict resolution while rebasing my series. + + * tests/misc/mktemp (check_tmp): Test for the bug when wrong parameter + is used. + +2009-11-05 Jim Meyering + + mktemp: don't try to close stdout twice + * src/mktemp.c (main): Rather than calling close_stream (which would + make atexit-called close_stdout try to close it a second time), + check for write failure via ferror and fflush. + + mktemp: don't use suff_len in place of #-of-`X's variable + * src/mktemp.c (mkstemp_len, mkdtemp_len): Pass x_len as final + argument, and not suff_len. + +2009-11-05 Eric Blake + + mktemp: add suffix handling + Now that mkstemps is supported, we might as well use it. + + * src/mktemp.c (TMPDIR_OPTION): New enum value. + (longopts): Add new option. + (usage): Document it. + (count_trailing_X_s): Rename... + (count_consecutive_X_s): ...to this, and add parameter. + (mkstemp_len, mkdtemp_len): Add parameter. + (main): Implement new option. + (AUTHORS): Add myself. + * AUTHORS (mktemp): Likewise. + * tests/misc/mktemp: Test new option. + * doc/coreutils.texi (mktemp invocation): Document it. + * NEWS: Likewise. + Fixes http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=548316. + + build: reflect gnulib changes to tempname + In glibc 2.11 and gnulib, gen_tempname added a parameter + suffixlen (unfortunately, it is typed as int rather than + size_t, for historical compatibility to a poor choice by BSD). + + * gnulib: Import latest changes. + * gl/lib/tempname.h.diff: Accommodate new suffixlen parameter. + * gl/lib/tempname.c.diff (check_x_suffix): Allow for X in suffix + beyond x_suffix_len. + (gen_tempname_len): Add suffixlen parameter. + (__gen_tempname): Update caller. + * src/mktemp.c (mkstemp_len, mkdtemp_len): Update callers. + + build: override gnulib tempname via diff + Diffs are more robust than wholesale replacement, because bootstrap + will inform us of any incompatible changes made in upstream gnulib. + + * gl/lib/tempname.h: Change... + * gl/lib/tempname.h.diff: ...to diff. + * gl/lib/tempname.c: Change... + * gl/lib/tempname.c.diff: ...to diff. + + mktemp: rearrange --help output + * src/mktemp.c (usage): Align indentation and sort by long + options. Describe valid templates. + Suggested by http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=548316. + + tests: enhance mktemp test + * tests/misc/mktemp: Add more coverage. + + doc: document mktemp + * doc/coreutils.texi (mktemp invocation): New node. + * TODO: Delete completed task. + + mktemp: don't leave file behind on write failure + * src/mktemp.c (main): Remove just-created file if stdout had + problems. + * bootstrap.conf (gnulib_modules): Add remove. + * tests/misc/close-stdout: Test it. + * NEWS: Document it. + +2009-11-05 Jim Meyering + + du: cleanup: remove dead-code vestige of already-removed option + * src/du.c (MEGABYTES_LONG_OPTION, main): Remove vestiges + of already-removed long option, --megabytes. + + du now diagnoses cycles, rather than ignoring them + * src/du.c (symlink_deref_bits): New global, decl moved from ... + (main): ...here. + (process_file): When fts detects a directory cycle that can't + be due to symlinks, report it and arrange to exit nonzero. + * NEWS (Bug fixes): Mention it. + + maint: factor out cycle warning, now that du will use it, too + * src/system.h (emit_cycle_warning): Define. Factored out of... + * src/remove.c (rm_fts): ...here. Use the new macro. + +2009-11-03 Jim Meyering + + tests: rm: add test for today's change in behavior + * tests/Makefile.am (root_tests): Add rm/read-only to the list. + * tests/rm/read-only: New file. + + rm -f: ignore EROFS when it's really ENOENT + rm -f must not print a diagnostic for a nonexistent file. However, + most linux-based kernel unlinkat functions set errno to EROFS when + the named file (regardless of whether it exists) would lie on a + read-only file system. remove.c now performs an extra fstatat call + in that case, to determine whether the file exists. + * src/remove.c (excise): Map EROFS to ENOENT, if a file is nonexistent. + Reported by Steven Drake in . + * NEWS (Changes in behavior): Mention it. + + tests: inotify-race: don't let malfunctioning gdb hang the test + * tests/tail-2/inotify-race: Apply timeout to each gdb invocation. + +2009-11-02 Eric Blake + + build: avoid some warnings + * gl/lib/mbsalign.c (mbsalign): Mark unused parameter. + * bootstrap.conf (gnulib_modules): Remove obsolete + rename-dest-slash. + * gnulib-tests/Makefile.am (AM_CFLAGS): Reduce set of warnings for + gnulib tests. + * gl/modules/rename-tests.diff (Makefile.am): New file, to add + LIBINTL to LDADD, since we avoid canonicalize-lgpl module. + * gl/lib/regcomp.c.diff (regerror, calc_next) + (build_collating_symbol, parse_bracket_element, build_equiv_class) + (free_tree): Mark unused parameters. + * gl/lib/regex_internal.h.diff (re_string_elem_size_at): New file, + to mark unused parameters. + * gl/lib/printf-args.c.diff (PRINTF_FETCHARGS): New file, to avoid + type mismatch. + * gl/lib/vasnprintf.c (VASNPRINTF): New file, to avoid shadowing + local variable name. + * .gitignore: Ignore temporary build artifacts. + + build: update gnulib submodule to latest, for fewer compiler warnings + +2009-10-31 Jim Meyering + + admin: automate one more part of the release process + This script automates the process of updating NEWS, performs + the resulting final commit (thus with a consistent log message), + and applies a signed tag (v$VERSION) to the result. + * build-aux/do-release-commit-and-tag: New script. + * README-release: Document it. + + admin: fix typo in release procedure + * README-release: s/gzip/coreutils/ + +2009-10-30 Jim Meyering + + tests: prohibit fail=0 initialization + * cfg.mk (sc_prohibit_fail_0): New rule. + * .x-sc_prohibit_fail_0: New file. + * Makefile.am (syntax_check_exceptions): Distribute the new file. + + tests: factor 350 fail=0 initializations into test-lib.sh + Run this command to remove the factored-out "fail=0" lines. + perl -ni -e '/^fail=0$/ or print' $(g grep -l '^fail=0$') + * tests/test-lib.sh: Initialize fail=0 here, not in 300+ scripts. + * tests/...: nearly all bourne shell scripts + Suggested by Eric Blake. + + tests: remove the less-regular fail=0 assignments manually + * tests/tail-2/assert-2: + * tests/tail-2/assert: + * tests/cp/file-perm-race: + * tests/misc/df: + * tests/misc/truncate-dir-fail: + +2009-10-29 Jim Meyering + + tests: don't let a fail=1 env. setting induce unwarranted test failure + * cfg.mk (sc_fail_is_initialized): New rule. + Fix the offenders: + * tests/cp/acl: Set fail=0 + * tests/cp/backup-is-src: Likewise. + * tests/cp/file-perm-race: Likewise. + * tests/cp/reflink-auto: Likewise. + * tests/cp/same-file: Likewise. + * tests/ln/backup-1: Likewise. + * tests/misc/su-fail: Likewise. + * tests/misc/truncate-owned-by-other: Likewise. + * tests/mkdir/p-3: Likewise. + * tests/mkdir/selinux: Likewise. + * tests/mkdir/special-1: Likewise. + * tests/mv/acl: Likewise. + * tests/mv/backup-is-src: Likewise. + * tests/mv/diag: Likewise. + * tests/mv/force: Likewise. + * tests/mv/hard-link-1: Likewise. + * tests/mv/into-self-3: Likewise. + * tests/mv/sticky-to-xpart: Likewise. + * tests/touch/now-owned-by-other: Likewise. + + remove stray closing comment delimiter, "*/", in previous change + * gl/lib/regexec.c.diff: Fix a typo. + +2009-10-29 Eric Blake + + maint: avoid exiting with magic number + Cope with gnulib's new sc_prohibit_magic_number_exit rule. + + * .x-sc_prohibit_magic_number_exit: New file, to add exemptions. + * Makefile.am (syntax_check_exceptions): Distribute it. + * lib/euidaccess-stat.c (main): Fix culprits. + * src/chcon.c (main): Likewise. + * src/runcon.c (main): Likewise. + * src/setuidgid.c (main): Likewise. + +2009-10-29 Jim Meyering + + build (--enable-gcc-warnings): enable gcc's -Werror also in lib/ + * configure.ac (GNULIB_WARN_CFLAGS): Define. + * lib/Makefile.am (AM_CFLAGS): Use $(GNULIB_WARN_CFLAGS) + rather than $(WARN_CFLAGS) and add $(WERROR_CFLAGS). + * gl/lib/regcomp.c.diff: New file. + * gl/lib/regex_internal.c.diff: New file. + * gl/lib/regexec.c.diff: New file. + + build: update gnulib submodule to latest + + build: allow whitespace violations in gl/lib/*.diff files + * .gitattributes: Exempt gl/lib/*.diff. + * .x-sc_prohibit_tab_based_indentation: Likewise. + * .x-sc_space_tab:Likewise. + +2009-10-29 Eric Blake + + nice, nohup, su: detect write failure to stderr + These programs can print non-fatal diagnostics to stderr prior to + exec'ing a subsidiary program. However, if we thought the situation + warranted a diagnostic, we insist that the diagnostic be printed + without error, rather than blindly exec, as it may be a security risk. + + For an example, try 'nice -n -1 nice 2>/dev/full'. Failure to raise + priority (by lowering niceness) is not fatal, but failure to inform + the user about failure to change priority is dangerous. + + * src/nice.c (main): Declare failure if writing advisory message + to stderr fails. + * src/nohup.c (main): Likewise. + * src/su.c (main): Likewise. + * tests/misc/nice: Test this. + * tests/misc/nohup: Likewise. + * NEWS: Document this. + +2009-10-28 Jim Meyering + + doc: tell --enable-gcc-warnings users where to report problems + * README-hacking: Add a caveat for --enable-gcc-warnings. + + build: make doc checks more user-friendly + * doc/Makefile.am (check-texinfo): Begin moving each individual test + into its own rules. + (sc-avoid-builtin, sc-avoid-path): New rules. + Extracted from check-texinfo. + (syntax_checks): Add them. + + doc: avoid failing "make check" + * doc/coreutils.texi (env invocation): s/builtin/built-in/ + +2009-10-28 Pádraig Brady + + doc: improve the echo and printf help on escapes + * src/printf.c (usage): Merge strings with echo.c to + aid translators. Move the description for \NNN beside + the other numeric escape codes. Don't mention + "character" as that suggests character conversion. + * src/echo.c (usage): Likewise. + Also mention the \xHH escape sequence. + + echo, printf: interpret \e as the Escape character + Match gcc, perl, bash, ksh, tcsh, ... in supporting \e. + * src/printf.c (print_escape_char): Output \x1B when \e encountered. + * src/echo.c (main): Likewise. + * src/stat.c (print_escape_char): Likewise. + * doc/coreutils.texi (echo invocation): Add \e to the list. + * tests/misc/printf: Verify that \e outputs \x1B. + * NEWS: Mention the change in behaviour. + +2009-10-28 Eric Blake + + printenv: ignore bogus variable names + Exposed by env a=b=c printenv a=b. + + * src/printenv.c (main): Silently reject = in names. + * tests/misc/printenv: Test for it. + * NEWS: Document this. + +2009-10-28 Pádraig Brady + + maint: avoid "make syntax-check" failure + * src/printenv.c: Remove unused "long-options.h" + +2009-10-28 Eric Blake + + doc: turn env comments into documentation + * src/env.c: Convert introductory comments... + * doc/coreutils.texi (env invocation): ...into documentation. + Suggested by Jim Meyering. + + env, printenv: add -0/--null option + Allows for unambiguous processing when environment values (or even + non-portable names!) contain newline. + + * src/env.c (longopts): Add new option. + (usage): Document it. + (main): Implement it. + * src/printenv.c (longopts): New variable. + (usage): Document new option. + (main): Implement it. + * doc/coreutils.texi (Common options): New macro optNull. + (du invocation, env invocation, printenv invocation): Use it. + * NEWS: Mention this. + * tests/misc/env-null: New test. + * tests/Makefile.am (TESTS): Run it. + + tests: add printenv coverage + * tests/misc/printenv: New test. + * tests/Makefile.am (TESTS): Run it. + * .gitignore: Ignore more cruft. + + tests: fix PATH problems on cygwin + * tests/misc/sort-compress: Remove non-portable over-restriction + of PATH; besides, commit 3ea177e changed sort to no longer default + to gzip. + * tests/rm/fail-eperm: Untaint, rather than clear, PATH. + * tests/misc/pwd-long: Likewise. Also skip test if long path + cannot be created. + (normalize_to_cwd_relative): Use eq rather than ==, since cygwin + perl doesn't properly handle 64-bit ino_t numerically. + +2009-10-27 Eric Blake + + tests: clean up tests of env -- handling + The comment in env.c about -- handling has not matched the behavior + in the code since the initial commit back in 1992. + + * src/env.c: Fix bogus comment. + * tests/misc/env: Further tweaks, avoiding PATH problems inherent + in testing -i, and testing program name containing =. + * doc/coreutils.texi (env invocation): Mention that intermediate + program is needed to invoke program with name containing =. + + doc: document PATH interactions with env + * doc/coreutils.texi (env invocation): Mention that PATH is + modified prior to exec. + * tests/misc/env: Test this. + + env: reject bogus -u arguments + * src/env.c (main): Use unsetenv rather than putenv to remove + items from environ, and check for failure. + * bootstrap.conf (gnulib_modules): Add unsetenv. + * tests/misc/env: Test this. + * NEWS: Document it. + + maint: let gnulib provide environ + * bootstrap.conf (gnulib_modules): Add environ. + * src/env.c (environ): Delete declaration. + * src/printenv.c (environ): Likewise. + * src/stdbuf.c (environ): Likewise. + * src/su.c (environ): Likewise. + +2009-10-26 Eric Blake + + tests: avoid file name not portable to cygwin + * tests/misc/chroot-fail: Use 'no_such', not '...', since cygwin + 1.5 silently strips trailing dots. + * tests/misc/nice-fail: Likewise. + * tests/misc/stdbuf: Likewise. + * tests/misc/timeout-parameters: Likewise. + +2009-10-26 Jim Meyering + + tests: rm/one-file-system: work around umount failure + * tests/rm/one-file-system (cleanup_): Unmount a/b, rather than + "$other_partition_tmpdir", to accommodate those who link /etc/mtab + to /proc/mounts. Reported by Gilles Espinasse in + http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/18508 + + tests: adjust new env test not to fail + * tests/misc/env: Create ./-i as a link to our "echo" binary, + rather than as a bourne shell script, so that env can exec it. + Set PATH to ".". + + tests: nice: adjust new tests to work more portably + * tests/misc/nice (tests): Accommodate a nice program for which + "nice -n -1 nice" prints nothing. It should print -1 or (usually) 0. + Otherwise, we'd get syntax errors. + + nice: execute program even when setpriority fails due to EACCES + * src/nice.c (perm_related_errno): New function. + (main): Use it, rather than testing only errno == EPERM. + * NEWS (Bug fixes): Mention it. + +2009-10-26 Pádraig Brady + + timeout: don't orphan monitored programs if they ignore specified signals + * src/timeout.c (install_signal_handlers): Handle any user + specified signal, so that if it does not cause the child + to exit then we don't exit and orphan the child. Previously this + for example, would leave an orphan dd process running: + timeout -sUSR1 1s dd if=/dev/zero of=/dev/null + * NEWS: Mention the fix. + +2009-10-24 Eric Blake + + tests: test recent status changes + * tests/misc/nice: Enhance test. + * tests/misc/chroot-fail: New test. + * tests/misc/env: Likewise. + * tests/misc/nice-fail: Likewise. + * tests/misc/su-fail: Likewise. + * tests/Makefile.am (TESTS): Run new tests. + + maint: move chroot test + * tests/chroot/credentials: Move... + * tests/misc/chroot-credentials: ...here, to reduce number of + directories. + * tests/Makefile.am (root_tests): Reflect rename. + + tests: enhance stdbuf and timeout tests + * tests/misc/timeout-parameters: Validate exact exit status. + * tests/misc/stdbuf: Likewise. + * tests/misc/timeout: Likewise. Use require_built_. + * tests/misc/arch: Likewise. + + nohup: use EXIT_CANCELED if not POSIXLY_CORRECT + * src/nohup.c (NOHUP_FAILURE): Rename... + (POSIX_NOHUP_FAILURE): ...to this. + (main): Pay attention to POSIXLY_CORRECT, to determine whether to + use status 125 or 127. + * doc/coreutils.texi (nohup invocation): Document this. + * NEWS: Likewise. + * tests/misc/invalid-opt (exit_status): Adjust expected results. + * tests/misc/help-version (expected_failure_status): Likewise. + * tests/misc/nohup: Likewise. + + chroot, env, nice, su: use EXIT_CANCELED for internal failure + * src/chroot.c (main): Use EXIT_CANCELED, not EXIT_FAILURE. + * src/env.c (main): Likewise. + * src/nice.c (main): Likewise. + * src/su.c (change_identity, main): Likewise. + * doc/coreutils.texi (chroot invocation, env invocation) + (nice invocation, su invocation): Document this. + * NEWS: Likewise. + * tests/misc/invalid-opt (exit_status): Adjust expected results. + * tests/misc/help-version (expected_failure_status): Likewise. + + tests: accommodate BSD getopt + * tests/misc/invalid-opt (err_subst): Support alternate spelling. + +2009-10-23 Eric Blake + + build: prohibit improper use of stat and lstat + * cfg.mk (sc_prohibit_stat_macro_address): New rule. + * src/ln.c (do_link): Adjust comment to avoid false positive. + * src/stat.c (do_stat): Likewise. + * src/touch.c (main): Likewise. + + build: update gnulib submodule to latest, for test cleanups + +2009-10-22 Eric Blake + + maint: turn on compiler warnings for gnulib tests + * gnulib-tests/Makefile.am (AM_CFLAGS): Add WARN_CFLAGS. + * configure.ac (enable-gcc-warnings): Also use -funit-at-a-time, + to silence gcc 4.3.4 -Wdisabled-optimization. + * .gitignore: Ignore some more files. + +2009-10-22 Jim Meyering + + build: prohibit direct use of readlink or readlinkat + * cfg.mk (sc_prohibit_readlink): New rule. + Suggested by Eric Blake. + +2009-10-22 Giuseppe Scrivano + + tests: add a test for the `tail -f' race condition bug + If new data becomes available between the initial read and when tail + registers the inotify watch descriptors, ensure that it is read + before a new event happens on the file. + * tests/Makefile.am (TESTS): Add tail-2/inotify-race. + * tests/tail-2/inotify-race: New file. + + tail -f: avoid a race condition + * NEWS (Bug fixes): Mention it. + * src/tail.c (check_fspec): New function. + (tail_forever_inotify): Ensure there is no new data before entering the + inotify events wait loop. + +2009-10-22 Eric Blake + + build: update gnulib submodule to latest, for utimens enhancements + + tests: ensure touch honors trailing slash + * tests/touch/trailing-slash: New test. + * tests/Makefile.am (TESTS): Run it. + +2009-10-21 Pádraig Brady + + md5sum, sha*sum, sum: line-buffer the printed checksums + * src/md5sum.c (main): Set stdout to line buffered mode + to ensure parallel running instances don't intersperse + their output. This adds 5% to the run time in the worst case + of many zero length files, or 2% with standard file sizes. + * src/sum.c (main): Likewise. + * tests/misc/md5sum-parallel: New test for atomic output. + * tests/Makefile.am: Reference it. + * NEWS: Mention the fix + +2009-10-20 Pádraig Brady + + maint: issue warnings for more missing optional libraries + * README-hacking: Suggest to use ./configure --quiet so that + any warnings are easily noticed. + * m4/gmp.m4 (cu_GMP): Warn if libgmp is not available. + * m4/jm-macros.m4 (coreutils_MACROS): Normalize the libcap warning. + * m4/xattr.m4 (gl_FUNC_XATTR): Warn if libattr is not available. + +2009-10-19 Jim Meyering + + build: use gnulib's isblank module + * bootstrap.conf (gnulib_modules): Add isblank. + * src/system.h (isblank): Don't define. + * m4/check-decl.m4: Don't check for isblank declaration. + * gnulib: Update submodule to latest. + +2009-10-18 Jim Meyering + + maint: factor out duplication in currently unused rules + * src/Makefile.am (fs_normalize_perl_subst): Define. + (fs-magic, fs-kernel-magic): Use it. + +2009-10-17 Eric Blake + + touch: add -h to change symlink timestamps, where supported + * src/touch.c (no_dereference): New flag variable. + (longopts): Add -h/--no-dereference. + (touch): Add symlink handling. + (usage): Document new option. + (main): Accept new option. + * NEWS: Document it. + * doc/coreutils.texi (touch invocation): Likewise. Also mention + birthtime. + * tests/touch/no-dereference: New test. + * tests/Makefile.am (TESTS): Run it. + +2009-10-17 Jim Meyering + + tests: abmon-align: avoid test failure + * tests/ls/abmon-align: Don't remove (1d;) the first line of output. + That was making the test consider only 11 of 12 month names. + Rewrite not to use \(.*\), as that provoked a malfunction in GNU sed + on powerpc Mac OS X (though we don't know yet whether this is due to a + sed bug, or to miscompilation). Nelson Beebe reported the test failure. + + build: update gnulib submodule to latest + +2009-10-15 Jim Meyering + + build: don't let environment settings perturb build + Setting the envvars, LIB_FDATASYNC, LIB_XATTR or LIB_CRYPT + could cause a configure-time and/or build-time malfunction. + Typically, a configure-time function-in-library test is performed + via code like this: + + LIB_VAR= + AC_SUBST([LIB_VAR]) + prefix_saved_LIBS=$LIBS + AC_SEARCH_LIBS([FUNC], [LIB_NAME], + [test "$ac_cv_search_FUNC" = "none required" || + LIB_VAR=$ac_cv_search_FUNC]) + LIBS=$prefix_saved_LIBS + + However, in each of the files affected by this change, the LIB_VAR= + initialization was omitted. Thus, when set in the environment, its + value would propagate into generated Makefiles when FUNC is not found + in LIB_NAME. + * m4/jm-macros.m4 (coreutils_MACROS): Initialize AC_SUBST'd var + * m4/lib-check.m4 (cu_LIB_CHECK): Likewise. + * m4/xattr.m4 (gl_FUNC_XATTR): Likewise. + +2009-10-13 C de-Avillez + + tail: add add missing backslash at the end of a line in usage + * src/tail.c (usage): Add missing backslash at the end of a line. + +2009-10-12 Eric Blake + + tail: tweak usage for more clarity + * src/tail.c (usage): Spell out -n +K. + * THANKS: Update. + Reported by Jan-Pawel Wrozstinski. + +2009-10-10 Eric Blake + + touch: optimize use of utimens + * src/touch.c (main): Use UTIME_NOW rather than calling gettime. + (touch): Use UTIME_OMIT rather than stat. + + copy: allow symlink timestamp preservation on more systems + * src/copy.c (utimens_symlink): Simplify by using lutimens. + * m4/jm-macros.m4 (coreutils_MACROS): Drop utimensat; gnulib does + this for us. + * tests/cp/preserve-slink-time: Recognize lutimes support. + + build: update gnulib submodule to latest, for utimens improvements + +2009-10-10 Jim Meyering + + tests: adjust tail-2/pid to work around FreeBSD 6.1 failure + * tests/tail-2/pid: Run tail -f --pid=... on an actual file, not on + /dev/null, to avoid this failure on FreeBSD 6.1: tail: /dev/null: + cannot change nonblocking mode: Inappropriate ioctl for device + +2009-10-10 Eric Blake + + maint: touch up previous LDADD patch + * src/Makefile.am (dir_LDADD): Delete; the ls_LDADD line covers this. + +2009-10-10 Jim Meyering + + build: build uname(1) unconditionally + Before, on a system without the uname function, the build + system would detect that and not build/install a uname program. + Now that gnulib guarantees a uname function, ... + * configure.ac: Don't check for the uname function. + * src/Makefile.am (build_if_possible__progs): Move uname... + (EXTRA_PROGRAMS): ...to this list. + + maint: list program names one per line + * src/Makefile.am (EXTRA_PROGRAMS): List them one per line. + (build_if_possible__progs): Likewise. + + build: ls: fix link failure due to missing -lacl + * src/Makefile.am (ls_LDADD): Re-add $(LIB_ACL). + Inadvertently-removed by commit 78c93601. + +2009-10-10 Eric Blake + + maint: touch up previous LDADD patch + * src/Makefile.am (stdbuf_LDADD): Add missing primer. + (hostname_LDADD, uname_LDADD): Add GETHOSTNAME_LIB. + * bootstrap.conf (gnulib_modules): Add uname. + + maint: improve additional library tracking + * src/Makefile.am (LDADD): Refactor, to make per-library additions + to individual programs easier to maintain. + +2009-10-09 Jim Meyering + + chcon: don't disable just because SELinux is disabled + * src/chcon.c (main): Now that gnulib provides getfilecon wrappers, + we can revert most of the 2009-10-05 commit 3a97d664, "chcon: exit + immediately if SELinux is disabled", since chcon is still useful as + long as the file system provides handlers for the security.* + name space. gnulib's getfilecon wrappers ensure that an offending + context now evokes a return value of -1. + Prompted by comments from Stephen Smalley in + http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/18378/focus=18394 + * NEWS (Bug fixes): Mention it. + + ls: remove explicit getfilecon work-around + * src/ls.c (gobble_file): Remove l?getfilecon work-around, + now that the gnulib wrappers handle it for us. + + build: update gnulib submodule to latest, for getfilecon wrappers + +2009-10-09 Eric Blake + + maint: use X2NREALLOC in more places + * src/chroot.c (set_additional_groups): Use X2NREALLOC rather than + x2nrealloc. + * src/factor.c (emit_factor): Likewise. + * src/setuidgid.c (main): Likewise. + + maint: remove unused macros and declarations + * src/system.h (EDQUOT, EISDIR, ENOSYS, EOVERFLOW, F_OK, X_OK) + (W_OK, R_OK): Delete; macros provided by gnulib. + (includes): Gnulib guarantees both and , in + either order. + (free, malloc, memchr, realloc, getenv, lseek): Delete, gnulib + guarantees these declarations. + * m4/check-decl.m4 (gl_CHECK_DECLS): Delete checks now done by + gnulib. + + maint: move timeout exit statuses + * src/timeout.c (EXIT_TIMEDOUT, EXIT_CANCELED): Remove as + macros... + * src/system.h (EXIT_TIMEDOUT, EXIT_CANCELED): ...and provide as + enum values instead. + * src/stdbuf.c (EXIT_CANCELED): Delete. + + stat: test recent patch + * tests/misc/stat-slash: New test. + * tests/Makefile.am (TESTS): Run it. + +2009-10-08 Eric Blake + + stdbuf: improve path search + * src/stdbuf.c (set_program_path): Use gnulib methods for better + file name handling. + * bootstrap.conf (gnulib_modules): Add xreadlink. + + stat: work with recent gnulib changes + * src/stat.c (do_stat): Don't mask function-like stat macro. + +2009-10-08 Jim Meyering + + stat: add support for many more file system types + * src/stat.c (human_fstype): Add the following FS types, + from : afs, anon-inode FS, btrfs, cgroupfs, + cramfs-wend, debugfs, futexfs, inotifyfs, minux3, securityfs, + selinux, xenfs. + Also add "nilfs". + * src/Makefile.am (fs-kernel-magic): New rule. + * NEWS (Bug fixes): Mention this. + + stat: recognize CIFS and HFS file system types + * src/stat.c (human_fstype) [CIFS, HFS]: Add new file system types. + Prompted by a report from Stuart Kemp. + Normalize the form of a few hexadecimal magic numbers. + Alphabetize on S_MAGIC_ case names. + * src/Makefile.am (fs-magic-compare, fs-def, fs-magic): New rules, to + automate comparison of our list with that in the Linux statfs man page. + * NEWS (Bug fixes): Mention it. + +2009-10-07 Guenter Knauf + + md5sum, sha*sum: also accept openssl checksum syntax + * src/md5sum.c (split_3): Accept openssl checksum syntax, which + differs only by two spaces from that of the bsd checksum tools: + openssl: MD5(f)= d41d8cd98f00b204e9800998ecf8427e + bsd: MD5 (f) = d41d8cd98f00b204e9800998ecf8427e + +2009-10-06 Jim Meyering + + maint: make release-making instructions more generic + * README-release: Make instructions more generic. + + post-release administrivia + * NEWS: Add header line for next release. + * .prev-version: Record previous version. + * cfg.mk (old_NEWS_hash): Auto-update. + + version 8.0 + * NEWS: Record release date. + + build: update gnulib submodule to latest + +2009-10-06 OndÅ™ej Vašík + + chcon: exit immediately if SELinux is disabled + This change happens to avoid an abort in chcon when SELinux is + disabled while operating on a file with an "unlabeled" context from + back in 2006. However, that same abort can still be triggered by the + same file when running chcon with SELinux enabled. This bug in chcon + will be fixed in a subsequent commit via a getfilecon wrapper. See + http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/18378/focus=18384 + for how to correct your disk attributes to avoid triggering this bug. + * src/chcon.c (main): Exit immediately if SELinux is disabled. + Reported in http://bugzilla.redhat.com/527142 by Yanko Kaneti. + * src/runcon.c (main): Do not hardcode program name in error message. + * THANKS: Update. + +2009-10-03 Jim Meyering + + build: update gnulib submodule to latest + +2009-10-02 James R. Van Zandt + + dircolors: highlight .cgm and .emf as images + * src/dircolors.hin: Add .cgm, .emf. + * THANKS: Update. + +2009-10-02 Jim Meyering + + maint: remove obsolete syntax-check exclusion + * cfg.mk (local-checks-to-skip): Remove strftime-check. + +2009-10-02 Pádraig Brady + + tail: avoid a race where we could miss new data with --pid + * src/tail.c (tail_forever, tail_forever_inotify): Close a race in + tail_forever_inotify where new data written after the file check by + a now dead process, but before the pid check, is not output. We use + the POSIX guarantee that read() and write() are serialized wrt each + other even in separate processes, to assume full file consistency + after exit() and so poll for new data _after_ the writer has exited. + This also allows us to not redundantly _wait_ for new data if the + process is dead. + * tests/tail-2/pid: Remove the now partially invalid sub second sleep + check as we now don't unconditionally wait, and replace it with a check + for the redundant sleep. Also clarify some of the existing comments. + * NEWS: Mention the fix. + +2009-10-02 Jim Meyering + + maint: move gnu-web-doc-update script to gnulib + * bootstrap.conf (gnulib_modules): Add gnu-web-doc-update. + Remove gendocs, since gnu-web-doc-update depends on it. + * gnu-web-doc-update: Remove file, now that we get it from gnulib. + + build: update gnulib submodule to latest + +2009-09-30 Jim Meyering + + tests: tail-2/pid: use a 3-second timeout, not 1 + * tests/tail-2/pid: When using the timeout program to ensuring that + tail -s.1 --pid=$PID_T_MAX does not wait forever, use a timeout longer + than 1 second. A 1-second timeout could be too short on a very busy + system, and result in a timeout, and hence false-positive failure. + + 2009-09-30 Jim Meyering + + build: update gnulib submodule to latest + + build: translate diagnostics from two new files + * po/POTFILES.in: Add two new files: lib/siglist.h, lib/strsignal.c + + build: now that we use the lock module, don't exclude lock.m4 + * bootstrap.conf: Don't exclude lock.m4. + +2009-09-30 Pádraig Brady + + ls: always print "?" for allocated size of a dereferenced dangling symlink + Previously for `ls -Ls` (but not `ls -Lsl`), we referenced + the st_blocks returned from the previous failed stat() call. + This undefined value was seen to be 0 for dangling symlinks at least. + * src/ls.c (print_file_name_and_frills, length_of_file_name_and_frills): + Don't use st_blocks if the previous stat() failed + * tests/ls/dangle: Add a test case + * NEWS: Mention the fix, and roll up related items into a single entry. + +2009-09-30 Jim Meyering + + build: use gnulib's freopen module + * bootstrap.conf (gnulib_modules): Add freopen, strsignal, fsync. + Exposed via make CFLAGS=-DGNULIB_POSIXCHECK 2>&1 \ + |perl -lne '/.* use gnulib module (\S+).*/ and print $1' \ + |sort |uniq -c|sort -nr + (avoided_gnulib_modules): Don't avoid the "lock" module. + Now it's required, as a dependency of the strsignal module. + +2009-09-29 Jim Meyering + + stat: interpret "-" as standard input + * src/stat.c (do_stat): Interpret a command line argument of "-" + to mean "standard input", like many other tools do. + (do_statfs): Fail upon any attempt to use "-". + * NEWS (Changes in behavior): Mention it. + * tests/misc/stat-hyphen: New test, to exercise the above. + * tests/Makefile.am (TESTS): Add misc/stat-hyphen. + + ls: don't use an undefined struct stat after failed stat/lstat + * src/ls.c (format_inode): Access f->stat only if f->stat_ok is set. + * NEWS (Bug fixes): Mention it. + Improved-by: Pádraig Brady + + ls: print "?", not "0" as inode of dereferenced dangling symlink + ls prints inode numbers two ways: for long (-l) listings, + and for short ones, e.g., ls -li and ls -i. The code to print + long listings properly printed "?" when the inode was unknown, + but the code for handling short listings would print 0 instead. + Factor out the formatting code into a new function so ls prints + the right string ("?") from both places: + * NEWS (Bug fixes): Mention it. + * src/ls.c (format_inode): New function. + (print_long_format): Use it here. + (print_file_name_and_frills): Use it here, too. + * tests/ls/dangle: Exercise this fix. + Reported by Yang Ren in http://bugzilla.redhat.com/525400 + + ls: with -LR, exit with status 2 upon detecting a cycle + * src/ls.c (print_dir): Diagnosing the cycle is not enough. + Also set exit status to 2. This is what Solaris' /bin/ls does, too. + * tests/ls/infloop: Rework test: match both expected stdout and stderr. + Require an exit status of 2 in this case. + * doc/coreutils.texi (ls invocation): Mention that a loop provokes + in an exit status of 2. + * NEWS (Bug fixes): Mention it. + Reported by Yang Ren in http://bugzilla.redhat.com/525402. + * THANKS: Correct ordering of Yang Ren's names. + +2009-09-26 Jim Meyering + + maint: factor coreutils-specific code out of bootstrap + * bootstrap (bootstrap_epilogue): Define a default, empty function. + Remove coreutils-specific code, and instead, + invoke this new function at the end of this script. + * bootstrap.conf (bootstrap_epilogue): Define, to override the default. + +2009-09-25 Eric Blake + + cp, mv: use linkat to guarantee semantics + * src/copy.c (copy_internal): Use linkat, not link. + + ln: add -L/-P options + * src/ln.c (STAT_LIKE_LINK): Delete. + (logical): New flag. + (long_options): Add -L, -P. + (usage): Mention them. + (main): Choose between them. + (do_link): Perform correct action. + * tests/ln/misc: Move hard-to-sym portion of test... + * tests/ln/hard-to-sym: ...into new test, and add more. + * tests/Makefile.am (TESTS): Run new test. + * NEWS: Document this. + * doc/coreutils.texi (link invocation, ln invocation): Likewise. + * bootstrap.conf (gnulib_modules): Add linkat. + + build: update gnulib submodule to latest + +2009-09-23 Pádraig Brady + + maint: Use logical rather than bitwise operators on bools + This is because bitwise operators are: + - confusing and inconsistent in a boolean context + - non short circuiting + - brittle in C89 where bool can be an int (so > 1) + + maint: expr: avoid compiler warnings without GMP + * src/expr.c (mpz_clear, mpz_get_str, mpz_out_str) + [!HAVE_GMP]: Reference unused arguments. + +2009-09-23 Eric Blake + + build: update gnulib submodule to latest + + maint: summarize gnulib changes + * NEWS: Provide a blurb about recent gnulib improvements. Fix typo + in readlink blurb. + +2009-09-23 Jim Meyering + + doc: ls: further improve --help message re --color + * src/ls.c (usage): Correct grammar, change voice, shorten. + Inspired by a report from Bruno Schulenberg. + +2009-09-23 Eric Blake + + readlink: pick up gnulib changes to readlink -f + * bootstrap.conf (obsolete_gnulib_modules): Move rename... + (gnulib_modules): ...here. Add symlink. + * NEWS: Document the change in readlink. + * doc/coreutils.texi (readlink invocation): Likewise. + * tests/readlink/can-f: Update test to new semantics, and add test + of loop. + +2009-09-23 Jim Meyering + + maint: df.c: adapt to newer gnulib + * src/df.c: Don't include "canonicalize.h". No longer needed, + since canonicalize_file_name is now guaranteed to be declared + in , thanks to gnulib. + + build: update gnulib submodule to latest + +2009-09-22 Pádraig Brady + + doc: stdbuf: mention it can have a non standard exit status + * doc/coreutils.texi (Exit status): Add stdbuf to the list + + maint: uptime: fix a theoretical compile warning + * src/uptime.c (print_uptime) [!HAVE_UTMPX_H && !HAVE_UTMP_H]: + Reference possibly unused arguments. + + ls: fix a performance regression + * src/ls.c (print_color_indicator): This reinstates commit f3f1ccfd, + 21-10-2008, "ls: make it possible to disable file capabilities checking" + which was inadvertently reverted with commit 3a169f4c, 14-09-2009, + "ls: handle disabling of colors consistently ...". + +2009-09-22 Eric Blake + + build: avoid compiler warnings on cygwin 1.5 + * src/copy.c (utimens_symlink): Avoid unused variables. + * src/su.c (getusershell): Rely on gnulib for prototype. + +2009-09-21 Jim Meyering + + doc: ls: add an article, "the" + * src/ls.c (usage): Tweak wording. + +2009-09-21 Pádraig Brady + + ls: handle disabling of colors consistently for all tile types + * src/ls.c (print_color_indicator): Use consistent syntax for + all file and directory subtypes, and fall back to the color + of the base type if there is no enabled color for the subtype. + This allows turning off specific colors for o+w dirs for example. + * tests/ls/color-dtype-dir: Add a case to test that turning off + coloring for o+w directories, falls back to standard dir color. + * NEWS: Mention the fix + Introduced by commit ac467814, 2005-09-05, + "Colorize set-user-ID ... files and sticky ... directories." + + doc: ls: make help for --color more concise and accurate + * src/ls.c (usage): Shorten the --color ancillary info by + two lines, while replacing --color=none with --color=never. + Mention "always" is the default parameter of the --color option, + along with the primary help for that option. + Mention the ancillary --color info in the --color primary help. + + doc: normalize and add missing entries to texinfo menu + * doc/coreutils.texi: Add the missing arch, base64, link, readlink, + and unlink entries. Also remove extraneous '.' from some entries + and try to align all entries on the same column. + * THANKS: Add Benno Schulenberg. + + doc: mention the texinfo documentation in --help + * src/system.h: Rename emit_bug_reporting_address() to + emit_ancillary_info() and update it to not print the translation + project address in en_* locales, and _do_ print it in the 'C' + (and other) locales so that it's included in the default man page. + Also mention how to invoke the texinfo documentation for each command. + Also move the "hard-locale.h" include to the 8 files that now use it. + * man/help2man: Strip the newly added texinfo reference from the + --help output as a more verbose version is already added by help2man. + Suggestion from C de-Avillez + +2009-09-21 Jim Meyering + + maint: automate the web-doc updating procedure + * gnu-web-doc-update: New script, destined for gnulib. + * README-release: Refer to the new script. + +2009-09-19 Jim Meyering + + dircolors: arrange to highlight names with the .lz suffix + * src/dircolors.hin: Add .lz, for GNU lzip. + Suggested by Matias A. Fonzo. + + mktemp: adapt to new, 3-argument gen_tempname_len + * src/mktemp.c (mkstemp_len, mkdtemp_len): Update callers of + gen_tempname_len. + * gl/lib/tempname.c, gl/lib/tempname.h: Rebase against recently + API-modified copy of tempname module in gnulib. + Reported by Lluís Batlle. + +2009-09-17 Jim Meyering + + build: merge bootstrap changes from gnulib + * bootstrap: Update from gnulib. + +2009-09-17 Eric Blake + + rm, rmdir: improve cross-compilation support + * bootstrap.conf (gnulib_modules): Drop rmdir-errno. + * src/rmdir.c (errno_rmdir_non_empty): Check both cases allowed by + POSIX, rather than relying on configure-time check that might + fail during cross-compilation. Reverts commit 9b6eb98d41. + +2009-09-15 OndÅ™ej Vašík + + cp: fix a probably redundant chmod when setting xattrs + * src/copy.c (copy_reg): Fix initial value of access_changed variable. + This was introduced by Pádraig Brady in commit cca83faf, 2009-09-14, + "cp,mv: preserve extended attributes even for read-only files" + +2009-09-14 Jim Meyering + + doc: NEWS: mention origin of touch -t ....60 bug + * NEWS: It is an old bug. + + doc: touch, document that it accepts .60 + * doc/coreutils.texi (touch invocation): Document that SS may be 60. + + touch: don't reject "60" as number of seconds in a legacy time stamp + A valid command like "touch -t 197101010000.60 F" would fail due + to the suffix of ".60". This bug is fixed via the latest change + to gnulib's posixtm module. + * tests/touch/60-seconds: New test. + * tests/Makefile.am (TESTS): Add it. + * NEWS (Bug fixes): Mention it. + + build: update gnulib submodule to latest, for fixed posixtm module + + maint: use #!/bin/sh consistently in shell-based test scripts + * tests/misc/sort-continue: Change first line to standard #!/bin/sh, + not #!/bin/bash (though it doesn't matter, since each is invoked + via $(SHELL) dir/test-name. + +2009-09-14 Pádraig Brady + + tests: fix dd/skip-seek-past-file to work on ecryptfs + * tests/dd/skip-seek-past-file: Require sparse support + to ensure that when we're checking if we can create an + $OFF_T_MAX length file, that we don't actually allocate + any space. This was an issue on ecryptfs and was reported + by Bert Wesarg. + +2009-09-14 OndÅ™ej Vašík + + cp,mv: preserve extended attributes even for read-only files + * src/copy.c (copy_reg): Temporarily set u+rw on the destination file + to allow GNU/Linux to set xattrs. + * tests/misc/xattr: Test that change. + * NEWS (Bug fixes): Mention it. + Reported by Ernest N. Mamikonyan. + +2009-09-14 Jim Meyering + + doc: improve timeout's --help message + * src/timeout.c (usage): Improve --help description. + +2009-09-13 Jim Meyering + + maint: use consistent cpp indentation in all .c files + * src/stty.c: Make cpp indentation reflect nesting. + * src/factor.c: Likewise. + + doc: NEWS: say quadratic and linear, rather than O(N^2) and O(N) + * NEWS: Use a slightly less technical description. + Suggested by Andreas Schwab. + + doc: improve NEWS + * NEWS (rm -r, without -f): Mention that the N in "O(N)" represents + hierarchy depth. Suggested by Ralf Wildenhues. + (rm -r, standards conformance): Make wording more accurate. + 2009-09-11 Jim Meyering + id: don't print context=... when POSIXLY_CORRECT is set + * src/id.c (print_full_info) [POSIXLY_CORRECT]: Don't print context. + Reported by Ulrich Drepper. + * NEWS (Changes in behavior): Mention it. + * doc/coreutils.texi (id invocation): Document that id also prints the + security context, when possible, and when POSIXLY_CORRECT is not set. + * tests/id/no-context: New file. Test for this. + * tests/Makefile.am (TESTS): Add it. + +2009-09-11 Eric Blake + + rm: avoid compiler warning + * src/remove.c (rm_fts): Don't allow fall-through when assertions + are disabled. + + euidaccess-stat: remove unnecessary macros + * lib/euidaccess-stat.c (F_OK, R_OK, W_OK, X_OK): Delete; now + guaranteed by gnulib. + + rm: use gnulib faccessat + * bootstrap.conf (gnulib_modules): Add faccessat. Replace strdup + with strdup-posix. + * m4/jm-macros.m4 (coreutils_MACROS): Revert previous change, now + that gnulib does it for us. + * src/remove.c (write_protected_non_symlink): Use faccessat in + more situations. + +2009-09-11 Jim Meyering + + rm: improve efficiency of rm -r (without -f) from O(N^2) to O(N) + where N is the depth of the deepest hierarchy rm is processing. + * src/remove.c (write_protected_non_symlink): Use faccessat to + avoid O(N)-per-entry cost of calling euidaccess. + * m4/jm-macros.m4 (coreutils_MACROS): Check for faccessat. + * NEWS (Improvements): Mention it. + + build: placate gcc's new -Wskip-jump-init + * remove.c (rm_fts): Put braces around each of the two offending blocks. + * configure.ac: Don't turn off -Wjump-misses-init. + With the rewrite of remove.c, it is no longer needed. + + rm: rewrite to use fts + * remove.c: Don't include "unlinkdir.h"; no longer used. + Do not include or "cycle-check.h". Likewise. + Include "xfts.h". + (dir_name, dir_len): Remove definitions. + (CONSECUTIVE_READDIR_UNLINK_THRESHOLD): Likewise. + (INODE_SORT_DIR_ENTRIES_THRESHOLD, NEED_REWIND, D_TYPE): Likewise. + (struct dirstack_state, Dirstack_state): Likewise. + (g_buf, g_n_allocated): Remove declarations. + (hash_freer, hash_compare_strings, rm_malloc): Remove functions. + (rm_free, push_dir, top_dir, pop_dir, right_justify): Likewise. + (full_filename0, xfull_filename, full_filename_): Likewise. + (AD_stack_height, AD_stack_top, AD_stack_pop, AD_stack_clear): Likewise. + (obstack_init_minimal, ds_init, ds_clear, ds_free): Likewise. + (AD_pop_and_chdir, AD_ensure_initialized, AD_mark_helper): Likewise. + (AD_mark_as_unremovable, AD_mark_current_as_unremovable): Likewise. + (AD_push_initial, AD_push, AD_push, AD_is_removable): Likewise. + (write_protected_non_symlink): Change 3rd parameter from + dirstack_state "ds" to full_name. + (prompt): Adjust parameters. Now, state comes from FTS/FTSENT pair. + Those replace fd_cwd and "ds". Remove "filename". Remove pdirent_type + in favor of new "is_dir" parameter. Rename is_empty to is_empty_p. + (DO_RMDIR, DO_UNLINK): Remove definitions. + (remove_entry, fd_to_subdirp, compare_ino): Remove functions. + (dirent_count, dirent_inode_sort_may_be_useful): Likewise. + (preprocess_dir): Likewise. + (fts_skip_tree, mark_ancestor_dirs, excise, rm_fts): New functions. + (remove_cwd_entries, remove_dir, rm_1): Remove functions. + (rm): Rewrite as a simple loop calling fts_read and dispatching + each entry via rm_fts. + * src/rm.c (main): Adapt to new signature of rm(). + * bootstrap.conf (gnulib_modules): Remove unlinkdir, no longer used. + * src/Makefile.am (sc_tight_scope): Also recognize an extern "enum" + declaration. + * tests/rm/empty-name: Adjust expected output to match new diagnostic. + * NEWS (Improvements): Mention it. + + maint: doc: adjust README-release + * README-release: Remove mention of bootstrap's old + --gnulib-srcdir=/gnulib option. No longer needed, and its + use can lead to subtle problems. + + post-release administrivia + * NEWS: Add header line for next release. + * .prev-version: Record previous version. + * cfg.mk (old_NEWS_hash): Auto-update. + version 7.6 * NEWS: Record release date. diff --git a/src/bin/coreutils/ChangeLog-2005 b/src/bin/coreutils/ChangeLog-2005 index 88023aa79d..f3727288cb 100644 --- a/src/bin/coreutils/ChangeLog-2005 +++ b/src/bin/coreutils/ChangeLog-2005 @@ -11609,7 +11609,7 @@ ----- - Copyright (C) 2002, 2003, 2004, 2005, 2009 Free Software Foundation, Inc. + Copyright (C) 2002-2005, 2009-2010 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted provided the copyright notice diff --git a/src/bin/coreutils/ChangeLog-2006 b/src/bin/coreutils/ChangeLog-2006 index db5b3279b3..3d136119ef 100644 --- a/src/bin/coreutils/ChangeLog-2006 +++ b/src/bin/coreutils/ChangeLog-2006 @@ -4033,7 +4033,7 @@ ----- - Copyright (C) 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted provided the copyright notice diff --git a/src/bin/coreutils/ChangeLog-2007 b/src/bin/coreutils/ChangeLog-2007 index ef6bbe8f10..b7a5d2f31f 100644 --- a/src/bin/coreutils/ChangeLog-2007 +++ b/src/bin/coreutils/ChangeLog-2007 @@ -4015,7 +4015,7 @@ ----- - Copyright (C) 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted provided the copyright notice diff --git a/src/bin/coreutils/ChangeLog-2008 b/src/bin/coreutils/ChangeLog-2008 index c296b61e3c..601c18beed 100644 --- a/src/bin/coreutils/ChangeLog-2008 +++ b/src/bin/coreutils/ChangeLog-2008 @@ -372,7 +372,7 @@ ----- - Copyright (C) 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted provided the copyright notice diff --git a/src/bin/coreutils/GNUmakefile b/src/bin/coreutils/GNUmakefile index 33eb3aa4d5..40ccc061d0 100644 --- a/src/bin/coreutils/GNUmakefile +++ b/src/bin/coreutils/GNUmakefile @@ -5,7 +5,7 @@ # It is necessary if you want to build targets usually of interest # only to the maintainer. -# Copyright (C) 2001, 2003, 2006-2009 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2006-2010 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/INSTALL b/src/bin/coreutils/INSTALL index 35602c21d9..81fd332cef 100644 --- a/src/bin/coreutils/INSTALL +++ b/src/bin/coreutils/INSTALL @@ -2,7 +2,7 @@ Installation Instructions ************************* Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, -2006, 2007, 2008, 2009 Free Software Foundation, Inc. +2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright @@ -69,6 +69,10 @@ of `autoconf'. 5. Optionally, type `make installcheck' to repeat any self-tests, but this time using the binaries in their final installed location. + This target does not install anything. Running this target as a + regular user, particularly if the prior `make install' required + root privileges, verifies that the installation completed + correctly. 6. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the @@ -141,7 +145,7 @@ Installation Names `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PREFIX', where PREFIX must be an -absolute path. +absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you @@ -155,7 +159,7 @@ kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. In general, the default for these options is expressed in terms of `${prefix}', so that specifying just `--prefix' will affect all of the other directory -specifications. +specifications that were not explicitly provided. The most portable way to affect installation locations is to pass the correct locations to `configure'; however, many packages provide one or @@ -165,28 +169,25 @@ having to reconfigure or recompile. The first method involves providing an override variable for each affected directory. For example, `make install -prefix=/path/to/alternate' will choose an alternate location, as well as -influencing all other directory configuration variables that were -expressed in terms of `${prefix}' (or, put another way, all directories -specified during `configure' but not in terms of the common prefix must -each be overridden at install time for the entire installation to be -relocated). The approach of makefile variable overrides for each -directory variable is required by the GNU Coding Standards, and ideally -causes no recompilation. However, some platforms have known -limitations with the semantics of shared libraries that end up -requiring recompilation when using this method, particularly noticeable -in packages that use GNU Libtool. +prefix=/alternate/directory' will choose an alternate location for all +directory configuration variables that were expressed in terms of +`${prefix}'. Any directories that were specified during `configure', +but not in terms of `${prefix}', must each be overridden at install +time for the entire installation to be relocated. The approach of +makefile variable overrides for each directory variable is required by +the GNU Coding Standards, and ideally causes no recompilation. +However, some platforms have known limitations with the semantics of +shared libraries that end up requiring recompilation when using this +method, particularly noticeable in packages that use GNU Libtool. The second method involves providing the `DESTDIR' variable. For -example, `make install DESTDIR=/path/to/alternate' will prepend -`/path/to/alternate' before all installation paths. The approach of +example, `make install DESTDIR=/alternate/directory' will prepend +`/alternate/directory' before all installation names. The approach of `DESTDIR' overrides is not required by the GNU Coding Standards, and does not work on platforms that have drive letters. On the other hand, it does better at avoiding recompilation issues, and works well even when some directory options were not specified in terms of `${prefix}' -at `configure' time. For packages which support `DESTDIR', the -variable should remain undefined during `configure' and `make all', and -only be specified during `make install'. +at `configure' time. Optional Features ================= diff --git a/src/bin/coreutils/Makefile.am b/src/bin/coreutils/Makefile.am index 6175a8eef0..1eb9c12c90 100644 --- a/src/bin/coreutils/Makefile.am +++ b/src/bin/coreutils/Makefile.am @@ -1,6 +1,6 @@ # Make coreutils. -*-Makefile-*- -# Copyright (C) 1990, 1993-2009 Free Software Foundation, Inc. +# Copyright (C) 1990, 1993-2010 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -47,6 +47,8 @@ syntax_check_exceptions = \ .x-sc_po_check \ .x-sc_program_name \ .x-sc_prohibit_atoi_atof \ + .x-sc_prohibit_fail_0 \ + .x-sc_prohibit_magic_number_exit \ .x-sc_prohibit_stat_st_blocks \ .x-sc_prohibit_strcmp \ .x-sc_prohibit_tab_based_indentation \ diff --git a/src/bin/coreutils/Makefile.in b/src/bin/coreutils/Makefile.in index f1993eeaed..a3baf38768 100644 --- a/src/bin/coreutils/Makefile.in +++ b/src/bin/coreutils/Makefile.in @@ -17,7 +17,7 @@ # Make coreutils. -*-Makefile-*- -# Copyright (C) 1990, 1993-2009 Free Software Foundation, Inc. +# Copyright (C) 1990, 1993-2010 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -74,35 +74,40 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/cloexec.m4 $(top_srcdir)/m4/close-stream.m4 \ $(top_srcdir)/m4/close.m4 $(top_srcdir)/m4/closein.m4 \ $(top_srcdir)/m4/closeout.m4 $(top_srcdir)/m4/codeset.m4 \ - $(top_srcdir)/m4/config-h.m4 $(top_srcdir)/m4/cycle-check.m4 \ - $(top_srcdir)/m4/d-ino.m4 $(top_srcdir)/m4/d-type.m4 \ - $(top_srcdir)/m4/dirent-safer.m4 $(top_srcdir)/m4/dirent_h.m4 \ - $(top_srcdir)/m4/dirfd.m4 $(top_srcdir)/m4/dirname.m4 \ - $(top_srcdir)/m4/dos.m4 $(top_srcdir)/m4/double-slash-root.m4 \ - $(top_srcdir)/m4/dup2.m4 $(top_srcdir)/m4/eealloc.m4 \ - $(top_srcdir)/m4/environ.m4 $(top_srcdir)/m4/errno_h.m4 \ - $(top_srcdir)/m4/error.m4 $(top_srcdir)/m4/euidaccess-stat.m4 \ + $(top_srcdir)/m4/config-h.m4 $(top_srcdir)/m4/ctype.m4 \ + $(top_srcdir)/m4/cycle-check.m4 $(top_srcdir)/m4/d-ino.m4 \ + $(top_srcdir)/m4/d-type.m4 $(top_srcdir)/m4/dirent-safer.m4 \ + $(top_srcdir)/m4/dirent_h.m4 $(top_srcdir)/m4/dirfd.m4 \ + $(top_srcdir)/m4/dirname.m4 $(top_srcdir)/m4/dos.m4 \ + $(top_srcdir)/m4/double-slash-root.m4 $(top_srcdir)/m4/dup2.m4 \ + $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/environ.m4 \ + $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/error.m4 \ + $(top_srcdir)/m4/euidaccess-stat.m4 \ $(top_srcdir)/m4/euidaccess.m4 $(top_srcdir)/m4/exclude.m4 \ $(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/exponentd.m4 \ $(top_srcdir)/m4/exponentf.m4 $(top_srcdir)/m4/exponentl.m4 \ - $(top_srcdir)/m4/extensions.m4 $(top_srcdir)/m4/fchdir.m4 \ - $(top_srcdir)/m4/fclose.m4 $(top_srcdir)/m4/fcntl-safer.m4 \ - $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/fd-reopen.m4 \ - $(top_srcdir)/m4/fdopendir.m4 $(top_srcdir)/m4/fflush.m4 \ - $(top_srcdir)/m4/file-type.m4 $(top_srcdir)/m4/fileblocks.m4 \ - $(top_srcdir)/m4/filemode.m4 $(top_srcdir)/m4/filenamecat.m4 \ - $(top_srcdir)/m4/flexmember.m4 $(top_srcdir)/m4/float_h.m4 \ - $(top_srcdir)/m4/fnmatch.m4 $(top_srcdir)/m4/fopen.m4 \ - $(top_srcdir)/m4/fpending.m4 $(top_srcdir)/m4/fpieee.m4 \ - $(top_srcdir)/m4/fprintftime.m4 $(top_srcdir)/m4/fpurge.m4 \ - $(top_srcdir)/m4/freading.m4 $(top_srcdir)/m4/frexp.m4 \ + $(top_srcdir)/m4/extensions.m4 $(top_srcdir)/m4/faccessat.m4 \ + $(top_srcdir)/m4/fchdir.m4 $(top_srcdir)/m4/fclose.m4 \ + $(top_srcdir)/m4/fcntl-o.m4 $(top_srcdir)/m4/fcntl-safer.m4 \ + $(top_srcdir)/m4/fcntl.m4 $(top_srcdir)/m4/fcntl_h.m4 \ + $(top_srcdir)/m4/fd-reopen.m4 $(top_srcdir)/m4/fdopendir.m4 \ + $(top_srcdir)/m4/fflush.m4 $(top_srcdir)/m4/file-type.m4 \ + $(top_srcdir)/m4/fileblocks.m4 $(top_srcdir)/m4/filemode.m4 \ + $(top_srcdir)/m4/filenamecat.m4 $(top_srcdir)/m4/flexmember.m4 \ + $(top_srcdir)/m4/float_h.m4 $(top_srcdir)/m4/fnmatch.m4 \ + $(top_srcdir)/m4/fopen.m4 $(top_srcdir)/m4/fpending.m4 \ + $(top_srcdir)/m4/fpieee.m4 $(top_srcdir)/m4/fprintftime.m4 \ + $(top_srcdir)/m4/fpurge.m4 $(top_srcdir)/m4/freading.m4 \ + $(top_srcdir)/m4/freopen.m4 $(top_srcdir)/m4/frexp.m4 \ $(top_srcdir)/m4/frexpl.m4 $(top_srcdir)/m4/fseeko.m4 \ $(top_srcdir)/m4/fstypename.m4 $(top_srcdir)/m4/fsusage.m4 \ - $(top_srcdir)/m4/ftello.m4 $(top_srcdir)/m4/ftruncate.m4 \ - $(top_srcdir)/m4/fts.m4 $(top_srcdir)/m4/getaddrinfo.m4 \ + $(top_srcdir)/m4/fsync.m4 $(top_srcdir)/m4/ftello.m4 \ + $(top_srcdir)/m4/ftruncate.m4 $(top_srcdir)/m4/fts.m4 \ + $(top_srcdir)/m4/getaddrinfo.m4 \ $(top_srcdir)/m4/getcwd-abort-bug.m4 \ $(top_srcdir)/m4/getcwd-path-max.m4 $(top_srcdir)/m4/getcwd.m4 \ $(top_srcdir)/m4/getdate.m4 $(top_srcdir)/m4/getdelim.m4 \ + $(top_srcdir)/m4/getdtablesize.m4 \ $(top_srcdir)/m4/getgroups.m4 $(top_srcdir)/m4/gethostname.m4 \ $(top_srcdir)/m4/gethrxtime.m4 $(top_srcdir)/m4/getline.m4 \ $(top_srcdir)/m4/getloadavg.m4 $(top_srcdir)/m4/getndelim2.m4 \ @@ -126,24 +131,27 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intmax_t.m4 \ $(top_srcdir)/m4/inttostr.m4 $(top_srcdir)/m4/inttypes-pri.m4 \ $(top_srcdir)/m4/inttypes.m4 $(top_srcdir)/m4/inttypes_h.m4 \ - $(top_srcdir)/m4/isapipe.m4 $(top_srcdir)/m4/isnand.m4 \ - $(top_srcdir)/m4/isnanf.m4 $(top_srcdir)/m4/isnanl.m4 \ - $(top_srcdir)/m4/jm-macros.m4 $(top_srcdir)/m4/jm-winsz1.m4 \ - $(top_srcdir)/m4/jm-winsz2.m4 $(top_srcdir)/m4/lchmod.m4 \ + $(top_srcdir)/m4/isapipe.m4 $(top_srcdir)/m4/isblank.m4 \ + $(top_srcdir)/m4/isnand.m4 $(top_srcdir)/m4/isnanf.m4 \ + $(top_srcdir)/m4/isnanl.m4 $(top_srcdir)/m4/jm-macros.m4 \ + $(top_srcdir)/m4/jm-winsz1.m4 $(top_srcdir)/m4/jm-winsz2.m4 \ + $(top_srcdir)/m4/langinfo_h.m4 $(top_srcdir)/m4/lchmod.m4 \ $(top_srcdir)/m4/lchown.m4 $(top_srcdir)/m4/ldexpl.m4 \ $(top_srcdir)/m4/lib-check.m4 $(top_srcdir)/m4/lib-ignore.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/link-follow.m4 \ - $(top_srcdir)/m4/link.m4 $(top_srcdir)/m4/localcharset.m4 \ - $(top_srcdir)/m4/locale-fr.m4 $(top_srcdir)/m4/locale-ja.m4 \ - $(top_srcdir)/m4/locale-tr.m4 $(top_srcdir)/m4/locale-zh.m4 \ - $(top_srcdir)/m4/long-options.m4 $(top_srcdir)/m4/longlong.m4 \ - $(top_srcdir)/m4/ls-mntd-fs.m4 $(top_srcdir)/m4/lseek.m4 \ - $(top_srcdir)/m4/lstat.m4 $(top_srcdir)/m4/malloc.m4 \ - $(top_srcdir)/m4/malloca.m4 $(top_srcdir)/m4/manywarnings.m4 \ - $(top_srcdir)/m4/math_h.m4 $(top_srcdir)/m4/mbchar.m4 \ - $(top_srcdir)/m4/mbiter.m4 $(top_srcdir)/m4/mbrlen.m4 \ - $(top_srcdir)/m4/mbrtowc.m4 $(top_srcdir)/m4/mbsinit.m4 \ + $(top_srcdir)/m4/link.m4 $(top_srcdir)/m4/linkat.m4 \ + $(top_srcdir)/m4/localcharset.m4 $(top_srcdir)/m4/locale-fr.m4 \ + $(top_srcdir)/m4/locale-ja.m4 $(top_srcdir)/m4/locale-tr.m4 \ + $(top_srcdir)/m4/locale-zh.m4 $(top_srcdir)/m4/locale_h.m4 \ + $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/long-options.m4 \ + $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ls-mntd-fs.m4 \ + $(top_srcdir)/m4/lseek.m4 $(top_srcdir)/m4/lstat.m4 \ + $(top_srcdir)/m4/malloc.m4 $(top_srcdir)/m4/malloca.m4 \ + $(top_srcdir)/m4/manywarnings.m4 $(top_srcdir)/m4/math_h.m4 \ + $(top_srcdir)/m4/mbchar.m4 $(top_srcdir)/m4/mbiter.m4 \ + $(top_srcdir)/m4/mbrlen.m4 $(top_srcdir)/m4/mbrtowc.m4 \ + $(top_srcdir)/m4/mbsinit.m4 $(top_srcdir)/m4/mbslen.m4 \ $(top_srcdir)/m4/mbsrtowcs.m4 $(top_srcdir)/m4/mbstate_t.m4 \ $(top_srcdir)/m4/mbswidth.m4 $(top_srcdir)/m4/md5.m4 \ $(top_srcdir)/m4/memcasecmp.m4 $(top_srcdir)/m4/memchr.m4 \ @@ -152,34 +160,34 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/mempcpy.m4 $(top_srcdir)/m4/memrchr.m4 \ $(top_srcdir)/m4/memset.m4 $(top_srcdir)/m4/memxfrm.m4 \ $(top_srcdir)/m4/mgetgroups.m4 $(top_srcdir)/m4/mkancesdirs.m4 \ - $(top_srcdir)/m4/mkdir-p.m4 $(top_srcdir)/m4/mkdir-slash.m4 \ + $(top_srcdir)/m4/mkdir-p.m4 $(top_srcdir)/m4/mkdir.m4 \ $(top_srcdir)/m4/mkstemp.m4 $(top_srcdir)/m4/mktime.m4 \ $(top_srcdir)/m4/mmap-anon.m4 $(top_srcdir)/m4/mode_t.m4 \ $(top_srcdir)/m4/modechange.m4 $(top_srcdir)/m4/mountlist.m4 \ $(top_srcdir)/m4/mpsort.m4 $(top_srcdir)/m4/multiarch.m4 \ $(top_srcdir)/m4/nanosleep.m4 $(top_srcdir)/m4/netdb_h.m4 \ - $(top_srcdir)/m4/netinet_in_h.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/open.m4 \ - $(top_srcdir)/m4/openat.m4 $(top_srcdir)/m4/pathmax.m4 \ - $(top_srcdir)/m4/perl.m4 $(top_srcdir)/m4/perror.m4 \ - $(top_srcdir)/m4/physmem.m4 $(top_srcdir)/m4/po.m4 \ - $(top_srcdir)/m4/posix-shell.m4 $(top_srcdir)/m4/posixtm.m4 \ - $(top_srcdir)/m4/posixver.m4 $(top_srcdir)/m4/prereq.m4 \ - $(top_srcdir)/m4/printf-frexp.m4 \ + $(top_srcdir)/m4/netinet_in_h.m4 \ + $(top_srcdir)/m4/nl_langinfo.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/nproc.m4 \ + $(top_srcdir)/m4/open.m4 $(top_srcdir)/m4/openat.m4 \ + $(top_srcdir)/m4/pathmax.m4 $(top_srcdir)/m4/perl.m4 \ + $(top_srcdir)/m4/perror.m4 $(top_srcdir)/m4/physmem.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/posix-shell.m4 \ + $(top_srcdir)/m4/posixtm.m4 $(top_srcdir)/m4/posixver.m4 \ + $(top_srcdir)/m4/prereq.m4 $(top_srcdir)/m4/printf-frexp.m4 \ $(top_srcdir)/m4/printf-frexpl.m4 $(top_srcdir)/m4/printf.m4 \ $(top_srcdir)/m4/priv-set.m4 $(top_srcdir)/m4/progtest.m4 \ $(top_srcdir)/m4/putenv.m4 $(top_srcdir)/m4/quote.m4 \ $(top_srcdir)/m4/quotearg.m4 $(top_srcdir)/m4/read-file.m4 \ $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/readtokens.m4 \ $(top_srcdir)/m4/readutmp.m4 $(top_srcdir)/m4/realloc.m4 \ - $(top_srcdir)/m4/regex.m4 \ - $(top_srcdir)/m4/rename-dest-slash.m4 \ - $(top_srcdir)/m4/rename.m4 $(top_srcdir)/m4/rmdir-errno.m4 \ - $(top_srcdir)/m4/rmdir.m4 $(top_srcdir)/m4/root-dev-ino.m4 \ - $(top_srcdir)/m4/rpmatch.m4 $(top_srcdir)/m4/safe-read.m4 \ - $(top_srcdir)/m4/safe-write.m4 $(top_srcdir)/m4/same.m4 \ - $(top_srcdir)/m4/save-cwd.m4 $(top_srcdir)/m4/savedir.m4 \ - $(top_srcdir)/m4/savewd.m4 $(top_srcdir)/m4/select.m4 \ + $(top_srcdir)/m4/regex.m4 $(top_srcdir)/m4/remove.m4 \ + $(top_srcdir)/m4/rename.m4 $(top_srcdir)/m4/rmdir.m4 \ + $(top_srcdir)/m4/root-dev-ino.m4 $(top_srcdir)/m4/rpmatch.m4 \ + $(top_srcdir)/m4/safe-read.m4 $(top_srcdir)/m4/safe-write.m4 \ + $(top_srcdir)/m4/same.m4 $(top_srcdir)/m4/save-cwd.m4 \ + $(top_srcdir)/m4/savedir.m4 $(top_srcdir)/m4/savewd.m4 \ + $(top_srcdir)/m4/select.m4 \ $(top_srcdir)/m4/selinux-context-h.m4 \ $(top_srcdir)/m4/selinux-selinux-h.m4 \ $(top_srcdir)/m4/servent.m4 $(top_srcdir)/m4/setenv.m4 \ @@ -193,38 +201,45 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/socklen.m4 $(top_srcdir)/m4/sockpfaf.m4 \ $(top_srcdir)/m4/ssize_t.m4 $(top_srcdir)/m4/st_dm_mode.m4 \ $(top_srcdir)/m4/stat-prog.m4 $(top_srcdir)/m4/stat-time.m4 \ - $(top_srcdir)/m4/stdarg.m4 $(top_srcdir)/m4/stdbool.m4 \ - $(top_srcdir)/m4/stddef_h.m4 $(top_srcdir)/m4/stdint.m4 \ - $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/stdio-safer.m4 \ - $(top_srcdir)/m4/stdio_h.m4 $(top_srcdir)/m4/stdlib-safer.m4 \ - $(top_srcdir)/m4/stdlib_h.m4 $(top_srcdir)/m4/stpcpy.m4 \ - $(top_srcdir)/m4/stpncpy.m4 $(top_srcdir)/m4/strcspn.m4 \ - $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \ - $(top_srcdir)/m4/strftime.m4 $(top_srcdir)/m4/string_h.m4 \ - $(top_srcdir)/m4/strndup.m4 $(top_srcdir)/m4/strnlen.m4 \ - $(top_srcdir)/m4/strnumcmp.m4 $(top_srcdir)/m4/strpbrk.m4 \ + $(top_srcdir)/m4/stat.m4 $(top_srcdir)/m4/stdarg.m4 \ + $(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stddef_h.m4 \ + $(top_srcdir)/m4/stdint.m4 $(top_srcdir)/m4/stdint_h.m4 \ + $(top_srcdir)/m4/stdio-safer.m4 $(top_srcdir)/m4/stdio_h.m4 \ + $(top_srcdir)/m4/stdlib-safer.m4 $(top_srcdir)/m4/stdlib_h.m4 \ + $(top_srcdir)/m4/stpcpy.m4 $(top_srcdir)/m4/stpncpy.m4 \ + $(top_srcdir)/m4/strcspn.m4 $(top_srcdir)/m4/strdup.m4 \ + $(top_srcdir)/m4/strerror.m4 $(top_srcdir)/m4/strftime.m4 \ + $(top_srcdir)/m4/string_h.m4 $(top_srcdir)/m4/strndup.m4 \ + $(top_srcdir)/m4/strnlen.m4 $(top_srcdir)/m4/strnumcmp.m4 \ + $(top_srcdir)/m4/strpbrk.m4 $(top_srcdir)/m4/strsignal.m4 \ $(top_srcdir)/m4/strstr.m4 $(top_srcdir)/m4/strtod.m4 \ $(top_srcdir)/m4/strtoimax.m4 $(top_srcdir)/m4/strtol.m4 \ $(top_srcdir)/m4/strtoll.m4 $(top_srcdir)/m4/strtoul.m4 \ $(top_srcdir)/m4/strtoull.m4 $(top_srcdir)/m4/strtoumax.m4 \ - $(top_srcdir)/m4/strverscmp.m4 $(top_srcdir)/m4/sys_ioctl_h.m4 \ + $(top_srcdir)/m4/symlink.m4 $(top_srcdir)/m4/symlinkat.m4 \ + $(top_srcdir)/m4/sys_ioctl_h.m4 \ $(top_srcdir)/m4/sys_select_h.m4 \ $(top_srcdir)/m4/sys_socket_h.m4 \ $(top_srcdir)/m4/sys_stat_h.m4 $(top_srcdir)/m4/sys_time_h.m4 \ - $(top_srcdir)/m4/tempname.m4 $(top_srcdir)/m4/time_h.m4 \ - $(top_srcdir)/m4/time_r.m4 $(top_srcdir)/m4/timespec.m4 \ + $(top_srcdir)/m4/sys_utsname_h.m4 $(top_srcdir)/m4/tempname.m4 \ + $(top_srcdir)/m4/thread.m4 $(top_srcdir)/m4/threadlib.m4 \ + $(top_srcdir)/m4/time_h.m4 $(top_srcdir)/m4/time_r.m4 \ + $(top_srcdir)/m4/timespec.m4 $(top_srcdir)/m4/tls.m4 \ $(top_srcdir)/m4/tm_gmtoff.m4 $(top_srcdir)/m4/tzset.m4 \ - $(top_srcdir)/m4/ungetc.m4 $(top_srcdir)/m4/unicodeio.m4 \ - $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/unistd_h.m4 \ - $(top_srcdir)/m4/unlink-busy.m4 $(top_srcdir)/m4/unlinkdir.m4 \ + $(top_srcdir)/m4/uname.m4 $(top_srcdir)/m4/ungetc.m4 \ + $(top_srcdir)/m4/unicodeio.m4 $(top_srcdir)/m4/unistd-safer.m4 \ + $(top_srcdir)/m4/unistd_h.m4 $(top_srcdir)/m4/unlink-busy.m4 \ + $(top_srcdir)/m4/unlink.m4 $(top_srcdir)/m4/unlinkdir.m4 \ $(top_srcdir)/m4/unlocked-io.m4 $(top_srcdir)/m4/uptime.m4 \ - $(top_srcdir)/m4/userspec.m4 $(top_srcdir)/m4/utimbuf.m4 \ - $(top_srcdir)/m4/utimecmp.m4 $(top_srcdir)/m4/utimens.m4 \ - $(top_srcdir)/m4/utimes.m4 $(top_srcdir)/m4/vasnprintf.m4 \ + $(top_srcdir)/m4/userspec.m4 $(top_srcdir)/m4/usleep.m4 \ + $(top_srcdir)/m4/utimbuf.m4 $(top_srcdir)/m4/utimecmp.m4 \ + $(top_srcdir)/m4/utimens.m4 $(top_srcdir)/m4/utimes.m4 \ + $(top_srcdir)/m4/vasnprintf.m4 \ $(top_srcdir)/m4/vasprintf-posix.m4 \ $(top_srcdir)/m4/vasprintf.m4 $(top_srcdir)/m4/version-etc.m4 \ $(top_srcdir)/m4/vfprintf-posix.m4 \ - $(top_srcdir)/m4/vprintf-posix.m4 $(top_srcdir)/m4/warnings.m4 \ + $(top_srcdir)/m4/vprintf-posix.m4 \ + $(top_srcdir)/m4/warn-on-use.m4 $(top_srcdir)/m4/warnings.m4 \ $(top_srcdir)/m4/wchar.m4 $(top_srcdir)/m4/wchar_t.m4 \ $(top_srcdir)/m4/wcrtomb.m4 $(top_srcdir)/m4/wctob.m4 \ $(top_srcdir)/m4/wctype.m4 $(top_srcdir)/m4/wcwidth.m4 \ @@ -235,7 +250,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/m4/xstrndup.m4 \ $(top_srcdir)/m4/xstrtod.m4 $(top_srcdir)/m4/xstrtol.m4 \ $(top_srcdir)/m4/xvasprintf.m4 $(top_srcdir)/m4/yesno.m4 \ - $(top_srcdir)/configure.ac + $(top_srcdir)/m4/yield.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ @@ -246,7 +261,7 @@ CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) -am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_0 = @echo " GEN " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ @@ -263,9 +278,10 @@ RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ - distdir dist dist-all distcheck + cscope distdir dist dist-all distcheck ETAGS = etags CTAGS = ctags +CSCOPE = cscope DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) @@ -274,6 +290,7 @@ am__remove_distdir = \ { test ! -d "$(distdir)" \ || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -fr "$(distdir)"; }; } +am__post_remove_distdir = $(am__remove_distdir) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ @@ -301,6 +318,7 @@ am__relativize = \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz $(distdir).tar.xz GZIP_ENV = --best +DIST_TARGETS = dist-xz dist-gzip distuninstallcheck_listfiles = find . -type f -print distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ @@ -309,7 +327,6 @@ ALLOCA_H = @ALLOCA_H@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@ -ARPA_INET_H = @ARPA_INET_H@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -329,7 +346,6 @@ CYGPATH_W = @CYGPATH_W@ DEFAULT_POSIX2_VERSION = @DEFAULT_POSIX2_VERSION@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ -DIRENT_H = @DIRENT_H@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ @@ -342,7 +358,6 @@ EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@ EOVERFLOW_VALUE = @EOVERFLOW_VALUE@ ERRNO_H = @ERRNO_H@ EXEEXT = @EXEEXT@ -FCNTL_H = @FCNTL_H@ FLOAT_H = @FLOAT_H@ FNMATCH_H = @FNMATCH_H@ GETADDRINFO_LIB = @GETADDRINFO_LIB@ @@ -360,6 +375,7 @@ GNULIB_ATOLL = @GNULIB_ATOLL@ GNULIB_BIND = @GNULIB_BIND@ GNULIB_BTOWC = @GNULIB_BTOWC@ GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@ +GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@ GNULIB_CEILF = @GNULIB_CEILF@ GNULIB_CEILL = @GNULIB_CEILL@ GNULIB_CHOWN = @GNULIB_CHOWN@ @@ -369,6 +385,7 @@ GNULIB_DIRFD = @GNULIB_DIRFD@ GNULIB_DPRINTF = @GNULIB_DPRINTF@ GNULIB_DUP2 = @GNULIB_DUP2@ GNULIB_DUP3 = @GNULIB_DUP3@ +GNULIB_DUPLOCALE = @GNULIB_DUPLOCALE@ GNULIB_ENVIRON = @GNULIB_ENVIRON@ GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@ GNULIB_FACCESSAT = @GNULIB_FACCESSAT@ @@ -376,6 +393,7 @@ GNULIB_FCHDIR = @GNULIB_FCHDIR@ GNULIB_FCHMODAT = @GNULIB_FCHMODAT@ GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@ GNULIB_FCLOSE = @GNULIB_FCLOSE@ +GNULIB_FCNTL = @GNULIB_FCNTL@ GNULIB_FDOPENDIR = @GNULIB_FDOPENDIR@ GNULIB_FFLUSH = @GNULIB_FFLUSH@ GNULIB_FLOORF = @GNULIB_FLOORF@ @@ -396,15 +414,18 @@ GNULIB_FSYNC = @GNULIB_FSYNC@ GNULIB_FTELL = @GNULIB_FTELL@ GNULIB_FTELLO = @GNULIB_FTELLO@ GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@ +GNULIB_FUTIMENS = @GNULIB_FUTIMENS@ GNULIB_FWRITE = @GNULIB_FWRITE@ GNULIB_GETADDRINFO = @GNULIB_GETADDRINFO@ GNULIB_GETCWD = @GNULIB_GETCWD@ GNULIB_GETDELIM = @GNULIB_GETDELIM@ GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@ GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@ +GNULIB_GETGROUPS = @GNULIB_GETGROUPS@ GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@ GNULIB_GETLINE = @GNULIB_GETLINE@ GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@ +GNULIB_GETLOGIN = @GNULIB_GETLOGIN@ GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@ GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@ GNULIB_GETPEERNAME = @GNULIB_GETPEERNAME@ @@ -417,6 +438,7 @@ GNULIB_IMAXDIV = @GNULIB_IMAXDIV@ GNULIB_INET_NTOP = @GNULIB_INET_NTOP@ GNULIB_INET_PTON = @GNULIB_INET_PTON@ GNULIB_IOCTL = @GNULIB_IOCTL@ +GNULIB_ISBLANK = @GNULIB_ISBLANK@ GNULIB_ISFINITE = @GNULIB_ISFINITE@ GNULIB_ISINF = @GNULIB_ISINF@ GNULIB_ISNAN = @GNULIB_ISNAN@ @@ -427,6 +449,7 @@ GNULIB_LCHMOD = @GNULIB_LCHMOD@ GNULIB_LCHOWN = @GNULIB_LCHOWN@ GNULIB_LDEXPL = @GNULIB_LDEXPL@ GNULIB_LINK = @GNULIB_LINK@ +GNULIB_LINKAT = @GNULIB_LINKAT@ GNULIB_LISTEN = @GNULIB_LISTEN@ GNULIB_LSEEK = @GNULIB_LSEEK@ GNULIB_LSTAT = @GNULIB_LSTAT@ @@ -457,10 +480,15 @@ GNULIB_MEMPCPY = @GNULIB_MEMPCPY@ GNULIB_MEMRCHR = @GNULIB_MEMRCHR@ GNULIB_MKDIRAT = @GNULIB_MKDIRAT@ GNULIB_MKDTEMP = @GNULIB_MKDTEMP@ +GNULIB_MKFIFO = @GNULIB_MKFIFO@ GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@ +GNULIB_MKNOD = @GNULIB_MKNOD@ GNULIB_MKNODAT = @GNULIB_MKNODAT@ GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@ +GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@ GNULIB_MKSTEMP = @GNULIB_MKSTEMP@ +GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@ +GNULIB_NL_LANGINFO = @GNULIB_NL_LANGINFO@ GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@ GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@ GNULIB_OPEN = @GNULIB_OPEN@ @@ -468,6 +496,7 @@ GNULIB_OPENAT = @GNULIB_OPENAT@ GNULIB_PERROR = @GNULIB_PERROR@ GNULIB_PIPE2 = @GNULIB_PIPE2@ GNULIB_POPEN = @GNULIB_POPEN@ +GNULIB_PREAD = @GNULIB_PREAD@ GNULIB_PRINTF = @GNULIB_PRINTF@ GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@ GNULIB_PUTC = @GNULIB_PUTC@ @@ -479,9 +508,13 @@ GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@ GNULIB_READLINK = @GNULIB_READLINK@ GNULIB_READLINKAT = @GNULIB_READLINKAT@ GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@ +GNULIB_REALPATH = @GNULIB_REALPATH@ GNULIB_RECV = @GNULIB_RECV@ GNULIB_RECVFROM = @GNULIB_RECVFROM@ +GNULIB_REMOVE = @GNULIB_REMOVE@ GNULIB_RENAME = @GNULIB_RENAME@ +GNULIB_RENAMEAT = @GNULIB_RENAMEAT@ +GNULIB_RMDIR = @GNULIB_RMDIR@ GNULIB_ROUND = @GNULIB_ROUND@ GNULIB_ROUNDF = @GNULIB_ROUNDF@ GNULIB_ROUNDL = @GNULIB_ROUNDL@ @@ -501,6 +534,7 @@ GNULIB_SLEEP = @GNULIB_SLEEP@ GNULIB_SNPRINTF = @GNULIB_SNPRINTF@ GNULIB_SOCKET = @GNULIB_SOCKET@ GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@ +GNULIB_STAT = @GNULIB_STAT@ GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@ GNULIB_STPCPY = @GNULIB_STPCPY@ GNULIB_STPNCPY = @GNULIB_STPNCPY@ @@ -521,14 +555,19 @@ GNULIB_STRTOLL = @GNULIB_STRTOLL@ GNULIB_STRTOULL = @GNULIB_STRTOULL@ GNULIB_STRTOUMAX = @GNULIB_STRTOUMAX@ GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@ +GNULIB_SYMLINK = @GNULIB_SYMLINK@ GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@ GNULIB_TRUNC = @GNULIB_TRUNC@ GNULIB_TRUNCF = @GNULIB_TRUNCF@ GNULIB_TRUNCL = @GNULIB_TRUNCL@ +GNULIB_UNAME = @GNULIB_UNAME@ GNULIB_UNISTD_H_GETOPT = @GNULIB_UNISTD_H_GETOPT@ GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@ +GNULIB_UNLINK = @GNULIB_UNLINK@ GNULIB_UNLINKAT = @GNULIB_UNLINKAT@ GNULIB_UNSETENV = @GNULIB_UNSETENV@ +GNULIB_USLEEP = @GNULIB_USLEEP@ +GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@ GNULIB_VASPRINTF = @GNULIB_VASPRINTF@ GNULIB_VDPRINTF = @GNULIB_VDPRINTF@ GNULIB_VFPRINTF = @GNULIB_VFPRINTF@ @@ -537,6 +576,7 @@ GNULIB_VPRINTF = @GNULIB_VPRINTF@ GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@ GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@ GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@ +GNULIB_WARN_CFLAGS = @GNULIB_WARN_CFLAGS@ GNULIB_WCRTOMB = @GNULIB_WCRTOMB@ GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@ GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@ @@ -550,6 +590,8 @@ HAVE_ARPA_INET_H = @HAVE_ARPA_INET_H@ HAVE_ATOLL = @HAVE_ATOLL@ HAVE_BTOWC = @HAVE_BTOWC@ HAVE_CALLOC_POSIX = @HAVE_CALLOC_POSIX@ +HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@ +HAVE_CHOWN = @HAVE_CHOWN@ HAVE_DECL_ACOSL = @HAVE_DECL_ACOSL@ HAVE_DECL_ASINL = @HAVE_DECL_ASINL@ HAVE_DECL_ATANL = @HAVE_DECL_ATANL@ @@ -600,51 +642,69 @@ HAVE_EUIDACCESS = @HAVE_EUIDACCESS@ HAVE_FACCESSAT = @HAVE_FACCESSAT@ HAVE_FCHMODAT = @HAVE_FCHMODAT@ HAVE_FCHOWNAT = @HAVE_FCHOWNAT@ +HAVE_FCNTL = @HAVE_FCNTL@ HAVE_FDOPENDIR = @HAVE_FDOPENDIR@ -HAVE_FSEEKO = @HAVE_FSEEKO@ HAVE_FSTATAT = @HAVE_FSTATAT@ HAVE_FSYNC = @HAVE_FSYNC@ -HAVE_FTELLO = @HAVE_FTELLO@ HAVE_FTRUNCATE = @HAVE_FTRUNCATE@ +HAVE_FUTIMENS = @HAVE_FUTIMENS@ HAVE_GETDOMAINNAME = @HAVE_GETDOMAINNAME@ HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@ +HAVE_GETGROUPS = @HAVE_GETGROUPS@ HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@ +HAVE_GETLOGIN = @HAVE_GETLOGIN@ +HAVE_GETOPT_H = @HAVE_GETOPT_H@ HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@ HAVE_GETSUBOPT = @HAVE_GETSUBOPT@ HAVE_GETUSERSHELL = @HAVE_GETUSERSHELL@ HAVE_INTTYPES_H = @HAVE_INTTYPES_H@ +HAVE_ISBLANK = @HAVE_ISBLANK@ HAVE_ISNAND = @HAVE_ISNAND@ HAVE_ISNANF = @HAVE_ISNANF@ HAVE_ISNANL = @HAVE_ISNANL@ HAVE_ISWCNTRL = @HAVE_ISWCNTRL@ +HAVE_LANGINFO_CODESET = @HAVE_LANGINFO_CODESET@ +HAVE_LANGINFO_ERA = @HAVE_LANGINFO_ERA@ +HAVE_LANGINFO_H = @HAVE_LANGINFO_H@ HAVE_LCHMOD = @HAVE_LCHMOD@ +HAVE_LCHOWN = @HAVE_LCHOWN@ HAVE_LINK = @HAVE_LINK@ +HAVE_LINKAT = @HAVE_LINKAT@ HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@ HAVE_LSTAT = @HAVE_LSTAT@ HAVE_MALLOC_POSIX = @HAVE_MALLOC_POSIX@ HAVE_MBRLEN = @HAVE_MBRLEN@ HAVE_MBRTOWC = @HAVE_MBRTOWC@ HAVE_MBSINIT = @HAVE_MBSINIT@ +HAVE_MBSLEN = @HAVE_MBSLEN@ HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@ HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@ HAVE_MEMPCPY = @HAVE_MEMPCPY@ HAVE_MKDIRAT = @HAVE_MKDIRAT@ HAVE_MKDTEMP = @HAVE_MKDTEMP@ +HAVE_MKFIFO = @HAVE_MKFIFO@ HAVE_MKFIFOAT = @HAVE_MKFIFOAT@ +HAVE_MKNOD = @HAVE_MKNOD@ HAVE_MKNODAT = @HAVE_MKNODAT@ HAVE_MKOSTEMP = @HAVE_MKOSTEMP@ +HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@ +HAVE_MKSTEMPS = @HAVE_MKSTEMPS@ HAVE_NETDB_H = @HAVE_NETDB_H@ HAVE_NETINET_IN_H = @HAVE_NETINET_IN_H@ +HAVE_NL_LANGINFO = @HAVE_NL_LANGINFO@ HAVE_OPENAT = @HAVE_OPENAT@ HAVE_OS_H = @HAVE_OS_H@ HAVE_PIPE2 = @HAVE_PIPE2@ HAVE_POSIX_SIGNALBLOCKING = @HAVE_POSIX_SIGNALBLOCKING@ +HAVE_PREAD = @HAVE_PREAD@ HAVE_RANDOM_H = @HAVE_RANDOM_H@ HAVE_RANDOM_R = @HAVE_RANDOM_R@ HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@ HAVE_READLINK = @HAVE_READLINK@ HAVE_READLINKAT = @HAVE_READLINKAT@ HAVE_REALLOC_POSIX = @HAVE_REALLOC_POSIX@ +HAVE_REALPATH = @HAVE_REALPATH@ +HAVE_RENAMEAT = @HAVE_RENAMEAT@ HAVE_RPMATCH = @HAVE_RPMATCH@ HAVE_SA_FAMILY_T = @HAVE_SA_FAMILY_T@ HAVE_SCANDIR = @HAVE_SCANDIR@ @@ -671,6 +731,7 @@ HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@ HAVE_STRUCT_SIGACTION_SA_SIGACTION = @HAVE_STRUCT_SIGACTION_SA_SIGACTION@ HAVE_STRUCT_SOCKADDR_STORAGE = @HAVE_STRUCT_SOCKADDR_STORAGE@ HAVE_STRUCT_TIMEVAL = @HAVE_STRUCT_TIMEVAL@ +HAVE_STRUCT_UTSNAME = @HAVE_STRUCT_UTSNAME@ HAVE_STRVERSCMP = @HAVE_STRVERSCMP@ HAVE_SYMLINK = @HAVE_SYMLINK@ HAVE_SYMLINKAT = @HAVE_SYMLINKAT@ @@ -683,11 +744,15 @@ HAVE_SYS_SELECT_H = @HAVE_SYS_SELECT_H@ HAVE_SYS_SOCKET_H = @HAVE_SYS_SOCKET_H@ HAVE_SYS_TIME_H = @HAVE_SYS_TIME_H@ HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@ +HAVE_SYS_UTSNAME_H = @HAVE_SYS_UTSNAME_H@ HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@ +HAVE_UNAME = @HAVE_UNAME@ HAVE_UNISTD_H = @HAVE_UNISTD_H@ HAVE_UNLINKAT = @HAVE_UNLINKAT@ HAVE_UNSETENV = @HAVE_UNSETENV@ HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@ +HAVE_USLEEP = @HAVE_USLEEP@ +HAVE_UTIMENSAT = @HAVE_UTIMENSAT@ HAVE_VASPRINTF = @HAVE_VASPRINTF@ HAVE_VDPRINTF = @HAVE_VDPRINTF@ HAVE_WCHAR_H = @HAVE_WCHAR_H@ @@ -699,12 +764,15 @@ HAVE_WCTYPE_H = @HAVE_WCTYPE_H@ HAVE_WINSOCK2_H = @HAVE_WINSOCK2_H@ HAVE_WINT_T = @HAVE_WINT_T@ HAVE_WS2TCPIP_H = @HAVE_WS2TCPIP_H@ +HAVE_XLOCALE_H = @HAVE_XLOCALE_H@ HAVE__BOOL = @HAVE__BOOL@ HELP2MAN = @HELP2MAN@ HOSTENT_LIB = @HOSTENT_LIB@ ICONV_H = @ICONV_H@ INCLUDE_NEXT = @INCLUDE_NEXT@ INCLUDE_NEXT_AS_FIRST_DIRECTIVE = @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ +INET_NTOP_LIB = @INET_NTOP_LIB@ +INET_PTON_LIB = @INET_PTON_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ @@ -715,17 +783,20 @@ INT32_MAX_LT_INTMAX_MAX = @INT32_MAX_LT_INTMAX_MAX@ INT64_MAX_EQ_LONG_MAX = @INT64_MAX_EQ_LONG_MAX@ INTLLIBS = @INTLLIBS@ INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTTYPES_H = @INTTYPES_H@ KMEM_GROUP = @KMEM_GROUP@ LDFLAGS = @LDFLAGS@ LIBCOREUTILS_LIBDEPS = @LIBCOREUTILS_LIBDEPS@ LIBCOREUTILS_LTLIBDEPS = @LIBCOREUTILS_LTLIBDEPS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ +LIBMULTITHREAD = @LIBMULTITHREAD@ LIBOBJS = @LIBOBJS@ +LIBPTH = @LIBPTH@ +LIBPTH_PREFIX = @LIBPTH_PREFIX@ LIBS = @LIBS@ LIBSOCKET = @LIBSOCKET@ LIBTESTS_LIBDEPS = @LIBTESTS_LIBDEPS@ +LIBTHREAD = @LIBTHREAD@ LIB_ACL = @LIB_ACL@ LIB_CAP = @LIB_CAP@ LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@ @@ -746,7 +817,10 @@ LOCALE_TR_UTF8 = @LOCALE_TR_UTF8@ LOCALE_ZH_CN = @LOCALE_ZH_CN@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ +LTLIBMULTITHREAD = @LTLIBMULTITHREAD@ LTLIBOBJS = @LTLIBOBJS@ +LTLIBPTH = @LTLIBPTH@ +LTLIBTHREAD = @LTLIBTHREAD@ MAKEINFO = @MAKEINFO@ MAN = @MAN@ MKDIR_P = @MKDIR_P@ @@ -758,15 +832,20 @@ NETDB_H = @NETDB_H@ NETINET_IN_H = @NETINET_IN_H@ NEXT_ARPA_INET_H = @NEXT_ARPA_INET_H@ NEXT_AS_FIRST_DIRECTIVE_ARPA_INET_H = @NEXT_AS_FIRST_DIRECTIVE_ARPA_INET_H@ +NEXT_AS_FIRST_DIRECTIVE_CTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_CTYPE_H@ NEXT_AS_FIRST_DIRECTIVE_DIRENT_H = @NEXT_AS_FIRST_DIRECTIVE_DIRENT_H@ NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@ NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@ NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@ +NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@ NEXT_AS_FIRST_DIRECTIVE_ICONV_H = @NEXT_AS_FIRST_DIRECTIVE_ICONV_H@ NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H = @NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H@ +NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H = @NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H@ +NEXT_AS_FIRST_DIRECTIVE_LOCALE_H = @NEXT_AS_FIRST_DIRECTIVE_LOCALE_H@ NEXT_AS_FIRST_DIRECTIVE_MATH_H = @NEXT_AS_FIRST_DIRECTIVE_MATH_H@ NEXT_AS_FIRST_DIRECTIVE_NETDB_H = @NEXT_AS_FIRST_DIRECTIVE_NETDB_H@ NEXT_AS_FIRST_DIRECTIVE_NETINET_IN_H = @NEXT_AS_FIRST_DIRECTIVE_NETINET_IN_H@ +NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H = @NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H@ NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H = @NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H@ NEXT_AS_FIRST_DIRECTIVE_STDARG_H = @NEXT_AS_FIRST_DIRECTIVE_STDARG_H@ NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@ @@ -779,19 +858,25 @@ NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H@ +NEXT_AS_FIRST_DIRECTIVE_SYS_UTSNAME_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_UTSNAME_H@ NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@ NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@ NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@ NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@ +NEXT_CTYPE_H = @NEXT_CTYPE_H@ NEXT_DIRENT_H = @NEXT_DIRENT_H@ NEXT_ERRNO_H = @NEXT_ERRNO_H@ NEXT_FCNTL_H = @NEXT_FCNTL_H@ NEXT_FLOAT_H = @NEXT_FLOAT_H@ +NEXT_GETOPT_H = @NEXT_GETOPT_H@ NEXT_ICONV_H = @NEXT_ICONV_H@ NEXT_INTTYPES_H = @NEXT_INTTYPES_H@ +NEXT_LANGINFO_H = @NEXT_LANGINFO_H@ +NEXT_LOCALE_H = @NEXT_LOCALE_H@ NEXT_MATH_H = @NEXT_MATH_H@ NEXT_NETDB_H = @NEXT_NETDB_H@ NEXT_NETINET_IN_H = @NEXT_NETINET_IN_H@ +NEXT_SELINUX_SELINUX_H = @NEXT_SELINUX_SELINUX_H@ NEXT_SIGNAL_H = @NEXT_SIGNAL_H@ NEXT_STDARG_H = @NEXT_STDARG_H@ NEXT_STDDEF_H = @NEXT_STDDEF_H@ @@ -804,6 +889,7 @@ NEXT_SYS_SELECT_H = @NEXT_SYS_SELECT_H@ NEXT_SYS_SOCKET_H = @NEXT_SYS_SOCKET_H@ NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@ NEXT_SYS_TIME_H = @NEXT_SYS_TIME_H@ +NEXT_SYS_UTSNAME_H = @NEXT_SYS_UTSNAME_H@ NEXT_TIME_H = @NEXT_TIME_H@ NEXT_UNISTD_H = @NEXT_UNISTD_H@ NEXT_WCHAR_H = @NEXT_WCHAR_H@ @@ -831,15 +917,21 @@ PRI_MACROS_BROKEN = @PRI_MACROS_BROKEN@ PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@ RANLIB = @RANLIB@ REPLACE_BTOWC = @REPLACE_BTOWC@ +REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@ REPLACE_CEILF = @REPLACE_CEILF@ REPLACE_CEILL = @REPLACE_CEILL@ REPLACE_CHOWN = @REPLACE_CHOWN@ REPLACE_CLOSE = @REPLACE_CLOSE@ +REPLACE_CLOSEDIR = @REPLACE_CLOSEDIR@ REPLACE_DPRINTF = @REPLACE_DPRINTF@ +REPLACE_DUP = @REPLACE_DUP@ REPLACE_DUP2 = @REPLACE_DUP2@ +REPLACE_DUPLOCALE = @REPLACE_DUPLOCALE@ REPLACE_FCHDIR = @REPLACE_FCHDIR@ REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@ REPLACE_FCLOSE = @REPLACE_FCLOSE@ +REPLACE_FCNTL = @REPLACE_FCNTL@ +REPLACE_FDOPENDIR = @REPLACE_FDOPENDIR@ REPLACE_FFLUSH = @REPLACE_FFLUSH@ REPLACE_FLOORF = @REPLACE_FLOORF@ REPLACE_FLOORL = @REPLACE_FLOORL@ @@ -851,10 +943,13 @@ REPLACE_FREXP = @REPLACE_FREXP@ REPLACE_FREXPL = @REPLACE_FREXPL@ REPLACE_FSEEK = @REPLACE_FSEEK@ REPLACE_FSEEKO = @REPLACE_FSEEKO@ +REPLACE_FSTAT = @REPLACE_FSTAT@ REPLACE_FSTATAT = @REPLACE_FSTATAT@ REPLACE_FTELL = @REPLACE_FTELL@ REPLACE_FTELLO = @REPLACE_FTELLO@ +REPLACE_FUTIMENS = @REPLACE_FUTIMENS@ REPLACE_GETCWD = @REPLACE_GETCWD@ +REPLACE_GETGROUPS = @REPLACE_GETGROUPS@ REPLACE_GETLINE = @REPLACE_GETLINE@ REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@ REPLACE_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@ @@ -869,6 +964,7 @@ REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@ REPLACE_LCHOWN = @REPLACE_LCHOWN@ REPLACE_LDEXPL = @REPLACE_LDEXPL@ REPLACE_LINK = @REPLACE_LINK@ +REPLACE_LINKAT = @REPLACE_LINKAT@ REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@ REPLACE_LSEEK = @REPLACE_LSEEK@ REPLACE_LSTAT = @REPLACE_LSTAT@ @@ -881,26 +977,40 @@ REPLACE_MBSTATE_T = @REPLACE_MBSTATE_T@ REPLACE_MEMCHR = @REPLACE_MEMCHR@ REPLACE_MEMMEM = @REPLACE_MEMMEM@ REPLACE_MKDIR = @REPLACE_MKDIR@ +REPLACE_MKFIFO = @REPLACE_MKFIFO@ +REPLACE_MKNOD = @REPLACE_MKNOD@ REPLACE_MKSTEMP = @REPLACE_MKSTEMP@ REPLACE_MKTIME = @REPLACE_MKTIME@ REPLACE_NAN = @REPLACE_NAN@ REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@ +REPLACE_NL_LANGINFO = @REPLACE_NL_LANGINFO@ REPLACE_NULL = @REPLACE_NULL@ REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@ REPLACE_OPEN = @REPLACE_OPEN@ +REPLACE_OPENAT = @REPLACE_OPENAT@ +REPLACE_OPENDIR = @REPLACE_OPENDIR@ REPLACE_PERROR = @REPLACE_PERROR@ REPLACE_POPEN = @REPLACE_POPEN@ +REPLACE_PREAD = @REPLACE_PREAD@ REPLACE_PRINTF = @REPLACE_PRINTF@ REPLACE_PUTENV = @REPLACE_PUTENV@ +REPLACE_READLINK = @REPLACE_READLINK@ +REPLACE_REALPATH = @REPLACE_REALPATH@ +REPLACE_REMOVE = @REPLACE_REMOVE@ REPLACE_RENAME = @REPLACE_RENAME@ +REPLACE_RENAMEAT = @REPLACE_RENAMEAT@ +REPLACE_RMDIR = @REPLACE_RMDIR@ REPLACE_ROUND = @REPLACE_ROUND@ REPLACE_ROUNDF = @REPLACE_ROUNDF@ REPLACE_ROUNDL = @REPLACE_ROUNDL@ REPLACE_SELECT = @REPLACE_SELECT@ +REPLACE_SETENV = @REPLACE_SETENV@ REPLACE_SIGNBIT = @REPLACE_SIGNBIT@ REPLACE_SIGNBIT_USING_GCC = @REPLACE_SIGNBIT_USING_GCC@ +REPLACE_SLEEP = @REPLACE_SLEEP@ REPLACE_SNPRINTF = @REPLACE_SNPRINTF@ REPLACE_SPRINTF = @REPLACE_SPRINTF@ +REPLACE_STAT = @REPLACE_STAT@ REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@ REPLACE_STRCASESTR = @REPLACE_STRCASESTR@ REPLACE_STRDUP = @REPLACE_STRDUP@ @@ -911,8 +1021,14 @@ REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@ REPLACE_STRSTR = @REPLACE_STRSTR@ REPLACE_STRTOD = @REPLACE_STRTOD@ REPLACE_STRTOK_R = @REPLACE_STRTOK_R@ +REPLACE_SYMLINK = @REPLACE_SYMLINK@ REPLACE_TIMEGM = @REPLACE_TIMEGM@ REPLACE_TRUNCL = @REPLACE_TRUNCL@ +REPLACE_UNLINK = @REPLACE_UNLINK@ +REPLACE_UNLINKAT = @REPLACE_UNLINKAT@ +REPLACE_UNSETENV = @REPLACE_UNSETENV@ +REPLACE_USLEEP = @REPLACE_USLEEP@ +REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@ REPLACE_VASPRINTF = @REPLACE_VASPRINTF@ REPLACE_VDPRINTF = @REPLACE_VDPRINTF@ REPLACE_VFPRINTF = @REPLACE_VFPRINTF@ @@ -926,7 +1042,6 @@ REPLACE_WCTOB = @REPLACE_WCTOB@ REPLACE_WCWIDTH = @REPLACE_WCWIDTH@ REPLACE_WRITE = @REPLACE_WRITE@ SELINUX_CONTEXT_H = @SELINUX_CONTEXT_H@ -SELINUX_SELINUX_H = @SELINUX_SELINUX_H@ SEQ_LIBM = @SEQ_LIBM@ SERVENT_LIB = @SERVENT_LIB@ SET_MAKE = @SET_MAKE@ @@ -938,10 +1053,8 @@ STDBOOL_H = @STDBOOL_H@ STDDEF_H = @STDDEF_H@ STDINT_H = @STDINT_H@ STRIP = @STRIP@ -SYS_IOCTL_H = @SYS_IOCTL_H@ SYS_IOCTL_H_HAVE_WINSOCK2_H = @SYS_IOCTL_H_HAVE_WINSOCK2_H@ SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ -SYS_SELECT_H = @SYS_SELECT_H@ SYS_SOCKET_H = @SYS_SOCKET_H@ SYS_TIME_H = @SYS_TIME_H@ SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ @@ -955,9 +1068,7 @@ UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOC USE_ACL = @USE_ACL@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ -VOID_UNSETENV = @VOID_UNSETENV@ WARN_CFLAGS = @WARN_CFLAGS@ -WCHAR_H = @WCHAR_H@ WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@ WCTYPE_H = @WCTYPE_H@ WERROR_CFLAGS = @WERROR_CFLAGS@ @@ -967,6 +1078,7 @@ XGETTEXT_015 = @XGETTEXT_015@ XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ YACC = @YACC@ YFLAGS = @YFLAGS@ +YIELD_LIB = @YIELD_LIB@ abs_aux_dir = @abs_aux_dir@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ @@ -1054,6 +1166,8 @@ syntax_check_exceptions = \ .x-sc_po_check \ .x-sc_program_name \ .x-sc_prohibit_atoi_atof \ + .x-sc_prohibit_fail_0 \ + .x-sc_prohibit_magic_number_exit \ .x-sc_prohibit_stat_st_blocks \ .x-sc_prohibit_strcmp \ .x-sc_prohibit_tab_based_indentation \ @@ -1144,7 +1258,7 @@ $(am__aclocal_m4_deps): # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): - @failcom='exit 1'; \ + @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ @@ -1169,7 +1283,7 @@ $(RECURSIVE_TARGETS): fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): - @failcom='exit 1'; \ + @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ @@ -1206,6 +1320,10 @@ ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done +cscopelist-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) cscopelist); \ + done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ @@ -1269,8 +1387,32 @@ GTAGS: && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" +cscope: cscope.files + test ! -s cscope.files \ + || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) + +clean-cscope: + -rm -f cscope.files + +cscope.files: clean-cscope cscopelist-recursive cscopelist + +cscopelist: cscopelist-recursive $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + -rm -f cscope.out cscope.in.out cscope.po.out cscope.files distdir: $(DISTFILES) $(am__remove_distdir) @@ -1336,43 +1478,43 @@ distdir: $(DISTFILES) top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-hook -test -n "$(am__skip_mode_fix)" \ - || find "$(distdir)" -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ + || find "$(distdir)" -type d ! -perm -755 \ + -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__remove_distdir) + $(am__post_remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 - $(am__remove_distdir) + $(am__post_remove_distdir) dist-lzma: distdir tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma - $(am__remove_distdir) + $(am__post_remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz - $(am__remove_distdir) + $(am__post_remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z - $(am__remove_distdir) + $(am__post_remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz - $(am__remove_distdir) + $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) - $(am__remove_distdir) + $(am__post_remove_distdir) -dist dist-all: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz - $(am__remove_distdir) +dist dist-all: + $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' + $(am__post_remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another @@ -1380,17 +1522,17 @@ dist dist-all: distdir distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ - GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ - bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ + bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lzma*) \ - unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\ + lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ - GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac @@ -1428,7 +1570,7 @@ distcheck: dist && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 - $(am__remove_distdir) + $(am__post_remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' @@ -1555,21 +1697,22 @@ ps-am: uninstall-am: .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check \ - ctags-recursive install install-am install-strip \ - tags-recursive + cscopelist-recursive ctags-recursive install install-am \ + install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ - all all-am am--refresh check check-am clean clean-generic \ - ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \ - dist-hook dist-lzma dist-shar dist-tarZ dist-xz dist-zip \ - distcheck distclean distclean-generic distclean-tags \ - distcleancheck distdir distuninstallcheck dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ + all all-am am--refresh check check-am clean clean-cscope \ + clean-generic cscope cscopelist cscopelist-recursive ctags \ + ctags-recursive dist dist-all dist-bzip2 dist-gzip dist-hook \ + dist-lzma dist-shar dist-tarZ dist-xz dist-zip distcheck \ + distclean distclean-generic distclean-tags distcleancheck \ + distdir distuninstallcheck dvi dvi-am html html-am info \ + info-am install install-am install-data install-data-am \ + install-dvi install-dvi-am install-exec install-exec-am \ + install-html install-html-am install-info install-info-am \ + install-man install-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ pdf-am ps ps-am tags tags-recursive uninstall uninstall-am diff --git a/src/bin/coreutils/NEWS b/src/bin/coreutils/NEWS index fdc42818f8..1ccb407082 100644 --- a/src/bin/coreutils/NEWS +++ b/src/bin/coreutils/NEWS @@ -1,5 +1,282 @@ GNU coreutils NEWS -*- outline -*- +* Noteworthy changes in release 8.4 (2010-01-13) [stable] + +** Bug fixes + + nproc --all is now guaranteed to be as large as the count + of available processors, which may not have been the case + on GNU/Linux systems with neither /proc nor /sys available. + [bug introduced in coreutils-8.1] + +** Build-related + + Work around a build failure when using buggy . + Alternatively, configure with --disable-libcap. + + Compilation would fail on systems using glibc-2.7..2.9 due to changes in + gnulib's wchar.h that tickled a bug in at least those versions of glibc's + own header. Now, gnulib works around the bug in those older + glibc headers. + + Building would fail with a link error (cp/copy.o) when XATTR headers + were installed without the corresponding library. Now, configure + detects that and disables xattr support, as one would expect. + + +* Noteworthy changes in release 8.3 (2010-01-07) [stable] + +** Bug fixes + + cp -p, install -p, mv, and touch -c could trigger a spurious error + message when using new glibc coupled with an old kernel. + [bug introduced in coreutils-6.12]. + + ls -l --color no longer prints "argetm" in front of dangling + symlinks when the 'LINK target' directive was given to dircolors. + [bug introduced in fileutils-4.0] + + pr's page header was improperly formatted for long file names. + [bug introduced in coreutils-7.2] + + rm -r --one-file-system works once again. + The rewrite to make rm use fts introduced a regression whereby + a commmand of the above form would fail for all subdirectories. + [bug introduced in coreutils-8.0] + + stat -f recognizes more file system types: k-afs, fuseblk, gfs/gfs2, ocfs2, + and rpc_pipefs. Also Minix V3 is displayed correctly as minix3, not minux3. + [bug introduced in coreutils-8.1] + + tail -f (inotify-enabled) once again works with remote files. + The use of inotify with remote files meant that any changes to those + files that was not done from the local system would go unnoticed. + [bug introduced in coreutils-7.5] + + tail -F (inotify-enabled) would abort when a tailed file is repeatedly + renamed-aside and then recreated. + [bug introduced in coreutils-7.5] + + tail -F (inotify-enabled) could fail to follow renamed files. + E.g., given a "tail -F a b" process, running "mv a b" would + make tail stop tracking additions to "b". + [bug introduced in coreutils-7.5] + + touch -a and touch -m could trigger bugs in some file systems, such + as xfs or ntfs-3g, and fail to update timestamps. + [bug introduced in coreutils-8.1] + + wc now prints counts atomically so that concurrent + processes will not intersperse their output. + [the issue dates back to the initial implementation] + + +* Noteworthy changes in release 8.2 (2009-12-11) [stable] + +** Bug fixes + + id's use of mgetgroups no longer writes beyond the end of a malloc'd buffer + [bug introduced in coreutils-8.1] + + id no longer crashes on systems without supplementary group support. + [bug introduced in coreutils-8.1] + + rm once again handles zero-length arguments properly. + The rewrite to make rm use fts introduced a regression whereby + a command like "rm a '' b" would fail to remove "a" and "b", due to + the presence of the empty string argument. + [bug introduced in coreutils-8.0] + + sort is now immune to the signal handling of its parent. + Specifically sort now doesn't exit with an error message + if it uses helper processes for compression and its parent + ignores CHLD signals. [bug introduced in coreutils-6.9] + + tail without -f no longer access uninitialized memory + [bug introduced in coreutils-7.6] + + timeout is now immune to the signal handling of its parent. + Specifically timeout now doesn't exit with an error message + if its parent ignores CHLD signals. [bug introduced in coreutils-7.6] + + a user running "make distcheck" in the coreutils source directory, + with TMPDIR unset or set to the name of a world-writable directory, + and with a malicious user on the same system + was vulnerable to arbitrary code execution + [bug introduced in coreutils-5.0] + + +* Noteworthy changes in release 8.1 (2009-11-18) [stable] + +** Bug fixes + + chcon no longer exits immediately just because SELinux is disabled. + Even then, chcon may still be useful. + [bug introduced in coreutils-8.0] + + chcon, chgrp, chmod, chown and du now diagnose an ostensible directory cycle + and arrange to exit nonzero. Before, they would silently ignore the + offending directory and all "contents." + + env -u A=B now fails, rather than silently adding A to the + environment. Likewise, printenv A=B silently ignores the invalid + name. [the bugs date back to the initial implementation] + + ls --color now handles files with capabilities correctly. Previously + files with capabilities were often not colored, and also sometimes, files + without capabilites were colored in error. [bug introduced in coreutils-7.0] + + md5sum now prints checksums atomically so that concurrent + processes will not intersperse their output. + This also affected sum, sha1sum, sha224sum, sha384sum and sha512sum. + [the bug dates back to the initial implementation] + + mktemp no longer leaves a temporary file behind if it was unable to + output the name of the file to stdout. + [the bug dates back to the initial implementation] + + nice -n -1 PROGRAM now runs PROGRAM even when its internal setpriority + call fails with errno == EACCES. + [the bug dates back to the initial implementation] + + nice, nohup, and su now refuse to execute the subsidiary program if + they detect write failure in printing an otherwise non-fatal warning + message to stderr. + + stat -f recognizes more file system types: afs, cifs, anon-inode FS, + btrfs, cgroupfs, cramfs-wend, debugfs, futexfs, hfs, inotifyfs, minux3, + nilfs, securityfs, selinux, xenfs + + tail -f (inotify-enabled) now avoids a race condition. + Before, any data appended in the tiny interval between the initial + read-to-EOF and the inotify watch initialization would be ignored + initially (until more data was appended), or forever, if the file + were first renamed or unlinked or never modified. + [The race was introduced in coreutils-7.5] + + tail -F (inotify-enabled) now consistently tails a file that has been + replaced via renaming. That operation provokes either of two sequences + of inotify events. The less common sequence is now handled as well. + [The bug came with the implementation change in coreutils-7.5] + + timeout now doesn't exit unless the command it is monitoring does, + for any specified signal. [bug introduced in coreutils-7.0]. + +** Changes in behavior + + chroot, env, nice, and su fail with status 125, rather than 1, on + internal error such as failure to parse command line arguments; this + is for consistency with stdbuf and timeout, and avoids ambiguity + with the invoked command failing with status 1. Likewise, nohup + fails with status 125 instead of 127. + + du (due to a change in gnulib's fts) can now traverse NFSv4 automounted + directories in which the stat'd device number of the mount point differs + during a traversal. Before, it would fail, because such a mismatch would + usually represent a serious error or a subversion attempt. + + echo and printf now interpret \e as the Escape character (0x1B). + + rm -f /read-only-fs/nonexistent now succeeds and prints no diagnostic + on systems with an unlinkat syscall that sets errno to EROFS in that case. + Before, it would fail with a "Read-only file system" diagnostic. + Also, "rm /read-only-fs/nonexistent" now reports "file not found" rather + than the less precise "Read-only file system" error. + +** New programs + + nproc: Print the number of processing units available to a process. + +** New features + + env and printenv now accept the option --null (-0), as a means to + avoid ambiguity with newlines embedded in the environment. + + md5sum --check now also accepts openssl-style checksums. + So do sha1sum, sha224sum, sha384sum and sha512sum. + + mktemp now accepts the option --suffix to provide a known suffix + after the substitution in the template. Additionally, uses such as + "mktemp fileXXXXXX.txt" are able to infer an appropriate --suffix. + + touch now accepts the option --no-dereference (-h), as a means to + change symlink timestamps on platforms with enough support. + + +* Noteworthy changes in release 8.0 (2009-10-06) [beta] + +** Bug fixes + + cp --preserve=xattr and --archive now preserve extended attributes even + when the source file doesn't have write access. + [bug introduced in coreutils-7.1] + + touch -t [[CC]YY]MMDDhhmm[.ss] now accepts a timestamp string ending in .60, + to accommodate leap seconds. + [the bug dates back to the initial implementation] + + ls --color now reverts to the color of a base file type consistently + when the color of a more specific type is disabled. + [bug introduced in coreutils-5.90] + + ls -LR exits with status 2, not 0, when it encounters a cycle + + ls -is is now consistent with ls -lis in ignoring values returned + from a failed stat/lstat. For example ls -Lis now prints "?", not "0", + for the inode number and allocated size of a dereferenced dangling symlink. + + tail --follow --pid now avoids a race condition where data written + just before the process dies might not have been output by tail. + Also, tail no longer delays at all when the specified pid is not live. + [The race was introduced in coreutils-7.5, + and the unnecessary delay was present since textutils-1.22o] + +** Portability + + On Solaris 9, many commands would mistakenly treat file/ the same as + file. Now, even on such a system, path resolution obeys the POSIX + rules that a trailing slash ensures that the preceeding name is a + directory or a symlink to a directory. + +** Changes in behavior + + id no longer prints SELinux " context=..." when the POSIXLY_CORRECT + environment variable is set. + + readlink -f now ignores a trailing slash when deciding if the + last component (possibly via a dangling symlink) can be created, + since mkdir will succeed in that case. + +** New features + + ln now accepts the options --logical (-L) and --physical (-P), + added by POSIX 2008. The default behavior is -P on systems like + GNU/Linux where link(2) creates hard links to symlinks, and -L on + BSD systems where link(2) follows symlinks. + + stat: without -f, a command-line argument of "-" now means standard input. + With --file-system (-f), an argument of "-" is now rejected. + If you really must operate on a file named "-", specify it as + "./-" or use "--" to separate options from arguments. + +** Improvements + + rm: rewrite to use gnulib's fts + This makes rm -rf significantly faster (400-500%) in some pathological + cases, and slightly slower (20%) in at least one pathological case. + + rm -r deletes deep hierarchies more efficiently. Before, execution time + was quadratic in the depth of the hierarchy, now it is merely linear. + However, this improvement is not as pronounced as might be expected for + very deep trees, because prior to this change, for any relative name + length longer than 8KiB, rm -r would sacrifice official conformance to + avoid the disproportionate quadratic performance penalty. Leading to + another improvement: + + rm -r is now slightly more standards-conformant when operating on + write-protected files with relative names longer than 8KiB. + + * Noteworthy changes in release 7.6 (2009-09-11) [stable] ** Bug fixes @@ -2629,10 +2906,10 @@ packages, see ./old/*/NEWS. ======================================================================== -Copyright (C) 2001-2009 Free Software Foundation, Inc. +Copyright (C) 2001-2010 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.2 or +under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the ``GNU Free diff --git a/src/bin/coreutils/README b/src/bin/coreutils/README index 7545eabe99..3ecafc362b 100644 --- a/src/bin/coreutils/README +++ b/src/bin/coreutils/README @@ -11,7 +11,7 @@ The programs that can be built with this package are: csplit cut date dd df dir dircolors dirname du echo env expand expr factor false fmt fold groups head hostid hostname id install join kill link ln logname ls md5sum mkdir mkfifo mknod mktemp mv nice nl nohup - od paste pathchk pinky pr printenv printf ptx pwd readlink rm rmdir + nproc od paste pathchk pinky pr printenv printf ptx pwd readlink rm rmdir runcon seq sha1sum sha224sum sha256sum sha384sum sha512sum shred shuf sleep sort split stat stdbuf stty su sum sync tac tail tee test timeout touch tr true truncate tsort tty uname unexpand uniq unlink uptime users @@ -229,10 +229,10 @@ the address on the last line of --help output. ======================================================================== -Copyright (C) 1998, 2002-2009 Free Software Foundation, Inc. +Copyright (C) 1998, 2002-2010 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.2 or +under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the ``GNU Free diff --git a/src/bin/coreutils/THANKS b/src/bin/coreutils/THANKS index c6655eb785..583ea60844 100644 --- a/src/bin/coreutils/THANKS +++ b/src/bin/coreutils/THANKS @@ -52,6 +52,7 @@ Andy Longton alongton@metamark.com Anthony Thyssen anthony@griffith.edu.au Antonio Rendas ajrendas@yahoo.com Ariel Faigon ariel@cthulhu.engr.sgi.com +Arjan Opmeer arjan.opmeer@gmail.com Arne H. Juul arnej@solan.unit.no Arne Henrik Juul arnej@imf.unit.no Arnold Robbins arnold@skeeve.com @@ -66,8 +67,9 @@ Barry Kelly http://barrkel.blogspot.com/ Bauke Jan Douma bjdouma@xs4all.nl Ben Elliston bje@air.net.au Ben Harris bjh21@netbsd.org -Benjamin Cutler cutlerbc@simla.colostate.edu Bengt Martensson bengt@mathematik.uni-Bremen.de +Benjamin Cutler cutlerbc@simla.colostate.edu +Benno Schulenberg bensberg@justemail.net Bernard Giroud bernard.giroud@creditlyonnais.ch Bernd Eckenfels ecki@debian.org Bernd Leibing bernd.leibing@rz.uni-ulm.de @@ -100,8 +102,10 @@ Carlos Canau Carlos.Canau@relay.puug.pt Charles Karney karney@pppl.gov Charles Randall crandall@matchlogic.com Chip Salzenberg chip@valinux.com +Chris Clayton chris2553@googlemail.com Chris Faylor cgf@cygnus.com Chris J. Bednar cjb@AdvancedDataSolutions.com +Chris Jones cjns1989@gmail.com Chris Lesniewski ctl@mit.edu Chris Sylvain csylvain@umm.edu Chris Yeo cyeo@biking.org @@ -148,6 +152,7 @@ Dawson Engler engler@stanford.edu Dean Gaudet dean-savannah@arctic.org Deepak Goel deego@gnufans.org Denis Excoffier denis.excoffier@airbus.com +Denis McKeon dmckeon@swcp.com Dennis Henriksen opus@flamingo.osrl.dk Dennis Smit ds@nerds-incorporated.org Derek Clegg dclegg@next.com @@ -209,6 +214,7 @@ Geoff Whale geoffw@cse.unsw.EDU.AU Gerald Pfeifer gerald@pfeifer.com Gerhard Poul gpoul@gnu.org Germano Leichsenring germano@jedi.cs.kobe-u.ac.jp +Gilles Espinasse g.esp@free.fr Glen Lenker glen.lenker@gmail.com Göran Uddeborg goeran@uddeborg.se Guochun Shi gshi@ncsa.uiuc.edu @@ -245,12 +251,14 @@ Ian Turner vectro@pipeline.com Iida Yosiaki iida@gnu.org Ilya N. Golubev gin@mo.msk.ru Ingo Saitz ingo@debian.org +Ivan Labath labath3@st.fmph.uniba.sk Ivo Timmermans ivo@debian.org James james@albion.glarp.com James Antill jmanti%essex.ac.uk@seralph21.essex.ac.uk James Lemley James.Lemley@acxiom.com James Hunt jamesodhunt@hotmail.com James Ralston ralston@pobox.com +James R. Van Zandt jrvz@comcast.net James Sneeringer jvs@ocslink.com James Tanis jtt@soscorp.com James Youngman jay@gnu.org @@ -260,6 +268,7 @@ Jan Engelhardt jengelh@medozas.de Jan Fedak J.Fedak@sh.cvut.cz Jan Moringen jan.moringen@uni-bielefeld.de Jan Nieuwenhuizen janneke@gnu.org +Jan-Pawel Wrozstinski jpwroz@gmail.com Janos Farkas chexum@shadow.banki.hu Jarkko Hietaniemi jhi@epsilon.hut.fi Jarod Wilson jwilson@redhat.com @@ -294,6 +303,7 @@ John Kodis kodis@acm.org John Murphy jam@philabs.research.philips.com John Roll john@panic.harvard.edu John Salmon johns@mullet.anu.edu.au +John Stanley johnstops@verizon.net John Summerfield summer@OS2.ami.com.au Jon Peatfield J.S.Peatfield@damtp.cam.ac.uk Joost van Baal joostvb@xs4all.nl @@ -328,12 +338,14 @@ Kirk Kelsey kirk.kelsey@0x4b.net Kristin E Thomas kristint@us.ibm.com Kjetil Torgrim Homme kjetilho@ifi.uio.no Kristoffer Rose kris@diku.dk +Ladislav Hagara ladislav.hagara@unob.cz Larry McVoy lm@sgi.com Lars Hecking lhecking@nmrc.ucc.ie Leah Q eequor@earthlink.net Lehti Rami rammer@cs.tut.fi Leonard N. Zubkoff lnz@dandelion.com Leonardo Milano lmilano@udel.edu +Lluís Batlle viriketo@gmail.com Lorne Baker lbaker@nitro.avint.net Luke Hassell lukehassell@yahoo.com Luke Kendall lukekendall@optushome.com.au @@ -365,6 +377,7 @@ Martin martin@dresden.nacamar.de Martin Buck martin.buck@ascom.ch Martin Gallant martyg@goodbit.net Martin Hippe martin.hippe@schlund.de +Martin Jacobs martin.jacobs@arcor.de Martin Michlmayr tbm@cyrius.com Martin Mitchell martin@debian.org Martin P.J. Zinser zinser@decus.de @@ -372,6 +385,7 @@ Marty Leisner leisner@sdsp.mc.xerox.com Masami Takikawa takikawm@CS.ORST.EDU Mate Wierdl mw@moni.msci.memphis.edu Matej Vela mvela@public.srce.hr +Matias A. Fonzo selk@dragora.org Matt Kraai kraai@ftbfs.org Matt Perry matt@primefactor.com Matt Pham mattvpham@gmail.com @@ -393,7 +407,7 @@ Max Chang maxchang@ucla.edu Meelis Roos mroos@tartu.cyber.ee Michael michael@aplatform.com Michael ??? michael@roka.net -Michael Bacarella mbac@netgraft.com> +Michael Bacarella mbac@netgraft.com Michael Deutschmann michael@talamasca.ocis.net Michael Elizabeth Chastain mec.gnu@mindspring.com Michael Gaughen mgaughen@polyserve.com @@ -490,7 +504,7 @@ Ralph Loader loader@maths.ox.ac.uk Raul Miller moth@magenta.com Raúl Núñez de Arenas Coronado raul@pleyades.net Reuben Thomas rrt@sc3d.org -Ren Yang ryang@redhat.com +Yang Ren ryang@redhat.com Richard A Downing richard.downing@bcs.org.uk Richard Braakman dark@xs4all.nl Richard Dawe rich@phekda.freeserve.co.uk @@ -500,9 +514,11 @@ Richard Sharman rsharman@magmacom.com Rick Sladkey jrs@world.std.com Rik Faith faith@cs.unc.edu Risto Kankkunen kankkune@lingsoft.fi +Rob Wortman wyrm@haell.com Robert H. de Vries robert@and.nl Robert Lindgren robert@orcafat.com Robert Millan zeratul2@wanadoo.es +Robert Schwebel r.schwebel@pengutronix.de Rogier Wolff R.E.Wolff@BitWizard.nl Roland Huebner ro-huebner@gmx.de Roland Turner raz.tah.bet@raz.cx @@ -519,6 +535,7 @@ Samuli Karkkainen Samuli.Karkkainen@hut.fi Sander van Malssen svm@kozmix.ow.nl Santiago Vila Doncel sanvila@unex.es Savochkin Andrey Vladimirovich saw@msu.ru +Scott Harrison scott.gnu.2009@scottrix.co.uk Scott Lurndal slurn@griffin.engr.sgi.com Sébastien Maret smaret@umich.edu Sergei Steshenko sergstesh@yahoo.com @@ -528,6 +545,7 @@ Solar Designer solar@owl.openwall.com Stanislav Ievlev inger@altlinux.ru Stavros Passas stabat@ics.forth.gr Stéphane Chazelas Stephane_CHAZELAS@yahoo.fr +Stéphane Raimbault stephane.raimbault@makina-corpus.com Stephen Depooter sbdep@myrealbox.com Stephen Eglen eglen@pcg.wustl.edu Stephen Gildea gildea@stop.mail-abuse.org @@ -535,11 +553,13 @@ Stephen Smoogen smooge@mindspring.com Steve McConnel steve@acadcomp.sil.org Steve McIntyre steve@einval.com Steve Ward planet36@gmail.com +Steven Drake sbd@users.sourceforge.net Steven G. Johnson stevenj@alum.mit.edu Steven Mocking ufo@quicknet.nl Steven Parkes smparkes@smparkes.net Steven Schveighoffer schveiguy@yahoo.com Steven P Watson steven@magelico.net +Stuart Citrin ctrn3e8@gmail.com Stuart Kemp skemp@peter.bmc.com Stuart Shelton stuart@shelton.me Sven Joachim svenjoac@gmx.de @@ -608,6 +628,7 @@ Wis Macomson wis.macomson@intel.com Wojciech Purczynski cliph@isec.pl Wolfram Kleff kleff@cs.uni-bonn.de Won-kyu Park wkpark@chem.skku.ac.kr +Yanko Kaneti yaneti@declera.com Yann Dirson dirson@debian.org Zvi Har'El rl@math.technion.ac.il diff --git a/src/bin/coreutils/THANKS-to-translators b/src/bin/coreutils/THANKS-to-translators index 6fe4cc5599..6a51dad65e 100644 --- a/src/bin/coreutils/THANKS-to-translators +++ b/src/bin/coreutils/THANKS-to-translators @@ -10,6 +10,7 @@ http://translationproject.org/team/cs.html http://translationproject.org/team/da.html http://translationproject.org/team/de.html http://translationproject.org/team/el.html +http://translationproject.org/team/en.html http://translationproject.org/team/es.html http://translationproject.org/team/et.html http://translationproject.org/team/eu.html @@ -22,6 +23,7 @@ http://translationproject.org/team/id.html http://translationproject.org/team/it.html http://translationproject.org/team/ja.html http://translationproject.org/team/ko.html +http://translationproject.org/team/lg.html http://translationproject.org/team/lt.html http://translationproject.org/team/ms.html http://translationproject.org/team/nb.html diff --git a/src/bin/coreutils/TODO b/src/bin/coreutils/TODO index 9128ddf779..717372982b 100644 --- a/src/bin/coreutils/TODO +++ b/src/bin/coreutils/TODO @@ -12,7 +12,6 @@ Modify chmod so that it does not change an inode's st_ctime Discussed more recently on . document the following in coreutils.texi: - mktemp [ pinky @@ -60,10 +59,6 @@ Integrate use of sendfile, suggested here: http://mail.gnu.org/archive/html/bug-fileutils/2003-03/msg00030.html I don't plan to do that, since a few tests demonstrate no significant benefit. -Should printf '\0123' print "\n3"? - per report from TAKAI Kousuke on Mar 27 - http://mail.gnu.org/archive/html/bug-coreutils/2003-03/index.html - printf: consider adapting builtins/printf.def from bash tail: don't use xlseek; it *exits*. @@ -170,7 +165,7 @@ pr's use of nstrftime can make it malloc a very large (up to SIZE_MAX) buffer ----- -Copyright (C) 2002-2009 Free Software Foundation, Inc. +Copyright (C) 2002-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/aclocal.m4 b/src/bin/coreutils/aclocal.m4 index 359166dc74..15b1f50249 100644 --- a/src/bin/coreutils/aclocal.m4 +++ b/src/bin/coreutils/aclocal.m4 @@ -13,8 +13,8 @@ m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.64.27-5b5d],, -[m4_warning([this file was generated for autoconf 2.64.27-5b5d. +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65.23-13e35],, +[m4_warning([this file was generated for autoconf 2.65.23-13e35. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) @@ -1069,6 +1069,7 @@ m4_include([m4/closein.m4]) m4_include([m4/closeout.m4]) m4_include([m4/codeset.m4]) m4_include([m4/config-h.m4]) +m4_include([m4/ctype.m4]) m4_include([m4/cycle-check.m4]) m4_include([m4/d-ino.m4]) m4_include([m4/d-type.m4]) @@ -1091,9 +1092,12 @@ m4_include([m4/exponentd.m4]) m4_include([m4/exponentf.m4]) m4_include([m4/exponentl.m4]) m4_include([m4/extensions.m4]) +m4_include([m4/faccessat.m4]) m4_include([m4/fchdir.m4]) m4_include([m4/fclose.m4]) +m4_include([m4/fcntl-o.m4]) m4_include([m4/fcntl-safer.m4]) +m4_include([m4/fcntl.m4]) m4_include([m4/fcntl_h.m4]) m4_include([m4/fd-reopen.m4]) m4_include([m4/fdopendir.m4]) @@ -1111,11 +1115,13 @@ m4_include([m4/fpieee.m4]) m4_include([m4/fprintftime.m4]) m4_include([m4/fpurge.m4]) m4_include([m4/freading.m4]) +m4_include([m4/freopen.m4]) m4_include([m4/frexp.m4]) m4_include([m4/frexpl.m4]) m4_include([m4/fseeko.m4]) m4_include([m4/fstypename.m4]) m4_include([m4/fsusage.m4]) +m4_include([m4/fsync.m4]) m4_include([m4/ftello.m4]) m4_include([m4/ftruncate.m4]) m4_include([m4/fts.m4]) @@ -1125,6 +1131,7 @@ m4_include([m4/getcwd-path-max.m4]) m4_include([m4/getcwd.m4]) m4_include([m4/getdate.m4]) m4_include([m4/getdelim.m4]) +m4_include([m4/getdtablesize.m4]) m4_include([m4/getgroups.m4]) m4_include([m4/gethostname.m4]) m4_include([m4/gethrxtime.m4]) @@ -1167,12 +1174,14 @@ m4_include([m4/inttypes-pri.m4]) m4_include([m4/inttypes.m4]) m4_include([m4/inttypes_h.m4]) m4_include([m4/isapipe.m4]) +m4_include([m4/isblank.m4]) m4_include([m4/isnand.m4]) m4_include([m4/isnanf.m4]) m4_include([m4/isnanl.m4]) m4_include([m4/jm-macros.m4]) m4_include([m4/jm-winsz1.m4]) m4_include([m4/jm-winsz2.m4]) +m4_include([m4/langinfo_h.m4]) m4_include([m4/lchmod.m4]) m4_include([m4/lchown.m4]) m4_include([m4/ldexpl.m4]) @@ -1183,11 +1192,14 @@ m4_include([m4/lib-link.m4]) m4_include([m4/lib-prefix.m4]) m4_include([m4/link-follow.m4]) m4_include([m4/link.m4]) +m4_include([m4/linkat.m4]) m4_include([m4/localcharset.m4]) m4_include([m4/locale-fr.m4]) m4_include([m4/locale-ja.m4]) m4_include([m4/locale-tr.m4]) m4_include([m4/locale-zh.m4]) +m4_include([m4/locale_h.m4]) +m4_include([m4/lock.m4]) m4_include([m4/long-options.m4]) m4_include([m4/longlong.m4]) m4_include([m4/ls-mntd-fs.m4]) @@ -1202,6 +1214,7 @@ m4_include([m4/mbiter.m4]) m4_include([m4/mbrlen.m4]) m4_include([m4/mbrtowc.m4]) m4_include([m4/mbsinit.m4]) +m4_include([m4/mbslen.m4]) m4_include([m4/mbsrtowcs.m4]) m4_include([m4/mbstate_t.m4]) m4_include([m4/mbswidth.m4]) @@ -1219,7 +1232,7 @@ m4_include([m4/memxfrm.m4]) m4_include([m4/mgetgroups.m4]) m4_include([m4/mkancesdirs.m4]) m4_include([m4/mkdir-p.m4]) -m4_include([m4/mkdir-slash.m4]) +m4_include([m4/mkdir.m4]) m4_include([m4/mkstemp.m4]) m4_include([m4/mktime.m4]) m4_include([m4/mmap-anon.m4]) @@ -1231,8 +1244,10 @@ m4_include([m4/multiarch.m4]) m4_include([m4/nanosleep.m4]) m4_include([m4/netdb_h.m4]) m4_include([m4/netinet_in_h.m4]) +m4_include([m4/nl_langinfo.m4]) m4_include([m4/nls.m4]) m4_include([m4/nocrash.m4]) +m4_include([m4/nproc.m4]) m4_include([m4/open.m4]) m4_include([m4/openat.m4]) m4_include([m4/pathmax.m4]) @@ -1258,9 +1273,8 @@ m4_include([m4/readtokens.m4]) m4_include([m4/readutmp.m4]) m4_include([m4/realloc.m4]) m4_include([m4/regex.m4]) -m4_include([m4/rename-dest-slash.m4]) +m4_include([m4/remove.m4]) m4_include([m4/rename.m4]) -m4_include([m4/rmdir-errno.m4]) m4_include([m4/rmdir.m4]) m4_include([m4/root-dev-ino.m4]) m4_include([m4/rpmatch.m4]) @@ -1294,6 +1308,7 @@ m4_include([m4/ssize_t.m4]) m4_include([m4/st_dm_mode.m4]) m4_include([m4/stat-prog.m4]) m4_include([m4/stat-time.m4]) +m4_include([m4/stat.m4]) m4_include([m4/stdarg.m4]) m4_include([m4/stdbool.m4]) m4_include([m4/stddef_h.m4]) @@ -1314,6 +1329,7 @@ m4_include([m4/strndup.m4]) m4_include([m4/strnlen.m4]) m4_include([m4/strnumcmp.m4]) m4_include([m4/strpbrk.m4]) +m4_include([m4/strsignal.m4]) m4_include([m4/strstr.m4]) m4_include([m4/strtod.m4]) m4_include([m4/strtoimax.m4]) @@ -1322,27 +1338,35 @@ m4_include([m4/strtoll.m4]) m4_include([m4/strtoul.m4]) m4_include([m4/strtoull.m4]) m4_include([m4/strtoumax.m4]) -m4_include([m4/strverscmp.m4]) +m4_include([m4/symlink.m4]) +m4_include([m4/symlinkat.m4]) m4_include([m4/sys_ioctl_h.m4]) m4_include([m4/sys_select_h.m4]) m4_include([m4/sys_socket_h.m4]) m4_include([m4/sys_stat_h.m4]) m4_include([m4/sys_time_h.m4]) +m4_include([m4/sys_utsname_h.m4]) m4_include([m4/tempname.m4]) +m4_include([m4/thread.m4]) +m4_include([m4/threadlib.m4]) m4_include([m4/time_h.m4]) m4_include([m4/time_r.m4]) m4_include([m4/timespec.m4]) +m4_include([m4/tls.m4]) m4_include([m4/tm_gmtoff.m4]) m4_include([m4/tzset.m4]) +m4_include([m4/uname.m4]) m4_include([m4/ungetc.m4]) m4_include([m4/unicodeio.m4]) m4_include([m4/unistd-safer.m4]) m4_include([m4/unistd_h.m4]) m4_include([m4/unlink-busy.m4]) +m4_include([m4/unlink.m4]) m4_include([m4/unlinkdir.m4]) m4_include([m4/unlocked-io.m4]) m4_include([m4/uptime.m4]) m4_include([m4/userspec.m4]) +m4_include([m4/usleep.m4]) m4_include([m4/utimbuf.m4]) m4_include([m4/utimecmp.m4]) m4_include([m4/utimens.m4]) @@ -1353,6 +1377,7 @@ m4_include([m4/vasprintf.m4]) m4_include([m4/version-etc.m4]) m4_include([m4/vfprintf-posix.m4]) m4_include([m4/vprintf-posix.m4]) +m4_include([m4/warn-on-use.m4]) m4_include([m4/warnings.m4]) m4_include([m4/wchar.m4]) m4_include([m4/wchar_t.m4]) @@ -1374,3 +1399,4 @@ m4_include([m4/xstrtod.m4]) m4_include([m4/xstrtol.m4]) m4_include([m4/xvasprintf.m4]) m4_include([m4/yesno.m4]) +m4_include([m4/yield.m4]) diff --git a/src/bin/coreutils/bootstrap b/src/bin/coreutils/bootstrap index 4be24b6aab..3280c32dc4 100755 --- a/src/bin/coreutils/bootstrap +++ b/src/bin/coreutils/bootstrap @@ -2,7 +2,7 @@ # Bootstrap this package from checked-out sources. -# Copyright (C) 2003-2009 Free Software Foundation, Inc. +# Copyright (C) 2003-2010 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -70,6 +70,10 @@ gnulib_modules= # Any gnulib files needed that are not in modules. gnulib_files= +# A function to be called after everything else in this script. +# Override it via your own definition in bootstrap.conf. +bootstrap_epilogue() { :; } + # The command to download all .po files for a specified domain into # a specified directory. Fill in the first %s is the domain name, and # the second with the destination directory. Use rsync's -L and -r @@ -150,12 +154,18 @@ vc_ignore=auto # find_tool ENVVAR NAMES... # ------------------------- +# Search for a required program. Use the value of ENVVAR, if set, +# otherwise find the first of the NAMES that can be run (i.e., +# supports --version). If found, set ENVVAR to the program name, +# die otherwise. find_tool () { # Find sha1sum, named gsha1sum on MacPorts. find_tool_envvar=$1 shift - if eval test x"\$$find_tool_envvar" = x; then + find_tool_names=$@ + eval "find_tool_res=\$$find_tool_envvar" + if test x"$find_tool_res" = x; then for i do if ($i --version /dev/null 2>&1; then @@ -163,16 +173,18 @@ find_tool () break fi done + else + find_tool_error_prefix="\$$find_tool_envvar: " fi if test x"$find_tool_res" = x; then - echo >&2 "$0: $find_tool_name is required" + echo >&2 "$0: one of these is required: $find_tool_names" exit 1 fi ($find_tool_res --version /dev/null 2>&1 || { - echo >&2 "$0: cannot run $find_tool_res --version" + echo >&2 "$0: ${find_tool_error_prefix}cannot run $find_tool_res --version" exit 1 } - eval "$find_tool_envvar=\"$find_tool_res\"" + eval "$find_tool_envvar=\$find_tool_res" eval "export $find_tool_envvar" } @@ -302,10 +314,20 @@ get_version() { $app --version >/dev/null 2>&1 || return 1 $app --version 2>&1 | - sed -n 's/[^0-9.]*\([0-9]\{1,\}\.[.a-z0-9-]*\).*/\1/p + sed -n '# extract version within line + s/.*[v ]\{1,\}\([0-9]\{1,\}\.[.a-z0-9-]*\).*/\1/ t done + + # extract version at start of line + s/^\([0-9]\{1,\}\.[.a-z0-9-]*\).*/\1/ + t done + d + :done + #the following essentially does s/5.005/5.5/ + s/\.0*\([1-9]\)/.\1/g + p q' } @@ -405,7 +427,7 @@ case ${GNULIB_SRCDIR--} in git_modules_config submodule.gnulib.url >/dev/null; then git submodule init GNULIB_SRCDIR=`cd $GNULIB_SRCDIR && pwd` - git config --replace-all submodule.gnulib.url $GNULIB_SRCDIR + git_modules_config --replace-all submodule.gnulib.url $GNULIB_SRCDIR echo "$0: getting gnulib files..." git submodule update || exit $? GNULIB_SRCDIR=gnulib @@ -721,6 +743,10 @@ find "$m4_base" "$source_base" \ # Reconfigure, getting other files. +# Skip autoheader if it's not needed. +grep -E '^[ ]*AC_CONFIG_HEADERS?\>' configure.ac >/dev/null || + AUTOHEADER=true + for command in \ libtool \ "${ACLOCAL-aclocal} --force -I m4" \ @@ -789,10 +815,6 @@ if test $with_gettext = yes; then fi fi -# Horrible, coreutils-specific kludges. -# Change paths in gnulib-tests/gnulib.mk from "../.." to "..". -m=gnulib-tests/gnulib.mk -sed 's,\.\./\.\.,..,g' $m > $m-t -mv -f $m-t $m +bootstrap_epilogue echo "$0: done. Now you can run './configure'." diff --git a/src/bin/coreutils/bootstrap.conf b/src/bin/coreutils/bootstrap.conf index c2bf753cc1..9cdf984ba0 100644 --- a/src/bin/coreutils/bootstrap.conf +++ b/src/bin/coreutils/bootstrap.conf @@ -1,6 +1,6 @@ # Bootstrap configuration. -# Copyright (C) 2006-2009 Free Software Foundation, Inc. +# Copyright (C) 2006-2010 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,7 +20,6 @@ avoided_gnulib_modules=' --avoid=canonicalize-lgpl --avoid=dummy - --avoid=lock ' # These modules are obsolete and can probably be removed soon, @@ -31,7 +30,6 @@ obsolete_gnulib_modules=' memcpy memmove memset - rename strcspn strtod strtol @@ -73,11 +71,14 @@ gnulib_modules=" diacrit dirfd dirname + do-release-commit-and-tag dup2 + environ error euidaccess exclude exitfail + faccessat fchdir fcntl fcntl-safer @@ -90,12 +91,14 @@ gnulib_modules=" fnmatch-gnu fopen-safer fprintftime + freopen + freopen-safer fseeko fsusage + fsync ftello ftruncate fts - gendocs getdate getgroups gethrxtime @@ -113,6 +116,7 @@ gnulib_modules=" git-version-gen gitlog-to-changelog gnu-make + gnu-web-doc-update gnumakefile gnupload group-member @@ -126,12 +130,14 @@ gnulib_modules=" inttostr inttypes isapipe + isblank lchmod lchown lib-ignore linebuffer link link-follow + linkat long-options lstat maintainer-makefile @@ -154,6 +160,7 @@ gnulib_modules=" modechange mountlist mpsort + nproc obstack pathmax perl @@ -176,9 +183,9 @@ gnulib_modules=" readutmp realloc regex - rename-dest-slash + remove + rename rmdir - rmdir-errno root-dev-ino rpmatch safe-read @@ -197,20 +204,22 @@ gnulib_modules=" stdlib-safer stpcpy stpncpy - strdup + strdup-posix strftime strpbrk + strsignal strtoimax strtoumax - strverscmp + symlink sys_stat timespec tzset + uname unicodeio unistd-safer unlink-busy - unlinkdir unlocked-io + unsetenv update-copyright uptime useless-if-before-free @@ -222,7 +231,6 @@ gnulib_modules=" verify verror version-etc-fsf - warnings wcwidth winsz-ioctl winsz-termios @@ -235,6 +243,7 @@ gnulib_modules=" xnanosleep xprintf xprintf-posix + xreadlink xstrtod xstrtoimax xstrtol @@ -291,7 +300,6 @@ if test $gettext_external = 1; then m4/glibc2.m4 m4/intdiv0.m4 m4/lcmessage.m4 - m4/lock.m4 m4/uintmax_t.m4 m4/ulonglong.m4 m4/visibility.m4 @@ -302,8 +310,8 @@ gnulib_tool_option_extras="--tests-base=$bt/gnulib-tests --with-tests" # Build prerequisites buildreq="\ -autoconf 2.61 -automake 1.11 +autoconf 2.62 +automake 1.11.1 autopoint - bison - gettext - @@ -318,3 +326,11 @@ tar - # Automake requires that ChangeLog exist. touch ChangeLog || exit 1 + +bootstrap_epilogue() +{ + # Change paths in gnulib-tests/gnulib.mk from "../.." to "..". + m=gnulib-tests/gnulib.mk + sed 's,\.\./\.\.,..,g' $m > $m-t + mv -f $m-t $m +} diff --git a/src/bin/coreutils/configure b/src/bin/coreutils/configure index f16d284a6b..3e751f410d 100755 --- a/src/bin/coreutils/configure +++ b/src/bin/coreutils/configure @@ -1,13 +1,13 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.64.27-5b5d for GNU coreutils 7.6. +# Generated by GNU Autoconf 2.65.23-13e35 for GNU coreutils 8.4. # # Report bugs to . # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software +# Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -529,7 +529,8 @@ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" -exec 7<&0 &1 +test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, @@ -551,8 +552,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='GNU coreutils' PACKAGE_TARNAME='coreutils' -PACKAGE_VERSION='7.6' -PACKAGE_STRING='GNU coreutils 7.6' +PACKAGE_VERSION='8.4' +PACKAGE_STRING='GNU coreutils 8.4' PACKAGE_BUGREPORT='bug-coreutils@gnu.org' PACKAGE_URL='http://www.gnu.org/software/coreutils/' @@ -593,6 +594,7 @@ ac_includes_default="\ # include #endif" +gl_use_threads_default= ac_header_list= ac_func_list= gl_fnmatch_required=POSIX @@ -628,6 +630,7 @@ OPTIONAL_BIN_PROGS INSTALL_SU LIB_GMP LIB_CRYPT +GNULIB_WARN_CFLAGS WERROR_CFLAGS SEQ_LIBM LIB_CAP @@ -641,11 +644,12 @@ HELP2MAN LIBTESTS_LIBDEPS LIBCOREUTILS_LTLIBDEPS LIBCOREUTILS_LIBDEPS +YIELD_LIB abs_aux_dir NEXT_AS_FIRST_DIRECTIVE_SYS_IOCTL_H NEXT_SYS_IOCTL_H HAVE_SYS_IOCTL_H -HAVE_SYMLINK +INET_PTON_LIB LOCALE_TR_UTF8 REPLACE_ISWCNTRL WCTYPE_H @@ -653,10 +657,10 @@ HAVE_WCTYPE_H NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H NEXT_WCTYPE_H HAVE_ISWCNTRL +HAVE_WINT_T +HAVE_WCHAR_H NEXT_AS_FIRST_DIRECTIVE_WCHAR_H NEXT_WCHAR_H -HAVE_WCHAR_H -HAVE_WINT_T WARN_CFLAGS HAVE_UNISTD_H NEXT_AS_FIRST_DIRECTIVE_UNISTD_H @@ -665,9 +669,14 @@ SYS_TIME_H_DEFINES_STRUCT_TIMESPEC TIME_H_DEFINES_STRUCT_TIMESPEC NEXT_AS_FIRST_DIRECTIVE_TIME_H NEXT_TIME_H +HAVE_SYS_UTSNAME_H +NEXT_AS_FIRST_DIRECTIVE_SYS_UTSNAME_H +NEXT_SYS_UTSNAME_H +HAVE_STRUCT_UTSNAME +HAVE_UNAME +GNULIB_UNAME NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H NEXT_SYS_STAT_H -HAVE_LSTAT POW_LIB NEXT_AS_FIRST_DIRECTIVE_STRING_H NEXT_STRING_H @@ -676,15 +685,9 @@ NEXT_AS_FIRST_DIRECTIVE_STDLIB_H NEXT_STDLIB_H NEXT_AS_FIRST_DIRECTIVE_STDIO_H NEXT_STDIO_H -NEXT_AS_FIRST_DIRECTIVE_STDDEF_H -NEXT_STDDEF_H -STDDEF_H -HAVE_WCHAR_T -REPLACE_NULL NEXT_AS_FIRST_DIRECTIVE_STDARG_H NEXT_STDARG_H STDARG_H -LIBSOCKET NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H NEXT_SIGNAL_H HAVE_TYPE_VOLATILE_SIG_ATOMIC_T @@ -697,14 +700,9 @@ GNULIB_SIGACTION GNULIB_SIGPROCMASK GNULIB_SIGNAL_H_SIGPIPE SELINUX_CONTEXT_H -SELINUX_SELINUX_H +NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H +NEXT_SELINUX_SELINUX_H LIB_SELINUX -SYS_SELECT_H -HAVE_SYS_SELECT_H -NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H -NEXT_SYS_SELECT_H -REPLACE_SELECT -GNULIB_SELECT DEFAULT_POSIX2_VERSION PREFERABLY_POSIX_SHELL POSIX_SHELL @@ -714,6 +712,12 @@ HAVE_NETINET_IN_H NEXT_AS_FIRST_DIRECTIVE_NETINET_IN_H NEXT_NETINET_IN_H LIB_NANOSLEEP +LIBSOCKET +HAVE_SYS_SELECT_H +NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H +NEXT_SYS_SELECT_H +REPLACE_SELECT +GNULIB_SELECT REPLACE_TIMEGM REPLACE_STRPTIME REPLACE_NANOSLEEP @@ -746,6 +750,7 @@ HAVE_RAWMEMCHR HAVE_DECL_MEMRCHR HAVE_MEMPCPY HAVE_DECL_MEMMEM +HAVE_MBSLEN GNULIB_STRVERSCMP GNULIB_STRSIGNAL GNULIB_STRERROR @@ -784,9 +789,33 @@ LOCALE_ZH_CN LOCALE_JA NEXT_AS_FIRST_DIRECTIVE_MATH_H NEXT_MATH_H +LTLIBMULTITHREAD +LIBMULTITHREAD +LTLIBTHREAD +LIBTHREAD +LIBPTH_PREFIX +LTLIBPTH +LIBPTH +NEXT_AS_FIRST_DIRECTIVE_LOCALE_H +NEXT_LOCALE_H +HAVE_XLOCALE_H +NEXT_AS_FIRST_DIRECTIVE_STDDEF_H +NEXT_STDDEF_H +STDDEF_H +HAVE_WCHAR_T +REPLACE_NULL +REPLACE_DUPLOCALE +GNULIB_DUPLOCALE LOCALCHARSET_TESTS_ENVIRONMENT GLIBC21 -INTTYPES_H +HAVE_LANGINFO_ERA +HAVE_LANGINFO_CODESET +HAVE_LANGINFO_H +NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H +NEXT_LANGINFO_H +REPLACE_NL_LANGINFO +HAVE_NL_LANGINFO +GNULIB_NL_LANGINFO UINT64_MAX_EQ_ULONG_MAX UINT32_MAX_LT_UINTMAX_MAX INT64_MAX_EQ_LONG_MAX @@ -846,6 +875,9 @@ NEXT_SYS_TIME_H LTLIBINTL LIBINTL GETOPT_H +HAVE_GETOPT_H +NEXT_AS_FIRST_DIRECTIVE_GETOPT_H +NEXT_GETOPT_H GETLOADAVG_LIBS KMEM_GROUP NEED_SETGID @@ -856,6 +888,7 @@ YACC HAVE__BOOL STDBOOL_H GETADDRINFO_LIB +INET_NTOP_LIB SERVENT_LIB HOSTENT_LIB NETDB_H @@ -950,29 +983,48 @@ FNMATCH_H FLOAT_H NEXT_AS_FIRST_DIRECTIVE_FLOAT_H NEXT_FLOAT_H -FCNTL_H NEXT_AS_FIRST_DIRECTIVE_FCNTL_H NEXT_FCNTL_H -REPLACE_OPEN -HAVE_OPENAT -GNULIB_OPENAT -GNULIB_OPEN +REPLACE_UTIMENSAT +REPLACE_STAT +REPLACE_MKNOD +REPLACE_MKFIFO REPLACE_MKDIR REPLACE_LSTAT +REPLACE_FUTIMENS REPLACE_FSTATAT +REPLACE_FSTAT +HAVE_UTIMENSAT HAVE_MKNODAT +HAVE_MKNOD HAVE_MKFIFOAT +HAVE_MKFIFO HAVE_MKDIRAT +HAVE_LSTAT HAVE_LCHMOD +HAVE_FUTIMENS HAVE_FSTATAT HAVE_FCHMODAT +GNULIB_UTIMENSAT +GNULIB_STAT GNULIB_MKNODAT +GNULIB_MKNOD GNULIB_MKFIFOAT +GNULIB_MKFIFO GNULIB_MKDIRAT GNULIB_LSTAT GNULIB_LCHMOD +GNULIB_FUTIMENS GNULIB_FSTATAT GNULIB_FCHMODAT +REPLACE_OPENAT +REPLACE_OPEN +REPLACE_FCNTL +HAVE_OPENAT +HAVE_FCNTL +GNULIB_OPENAT +GNULIB_OPEN +GNULIB_FCNTL LIB_EACCESS EOVERFLOW_VALUE EOVERFLOW_HIDDEN @@ -985,7 +1037,9 @@ NEXT_AS_FIRST_DIRECTIVE_ERRNO_H NEXT_ERRNO_H NEXT_AS_FIRST_DIRECTIVE_DIRENT_H NEXT_DIRENT_H -DIRENT_H +REPLACE_OPENDIR +REPLACE_FDOPENDIR +REPLACE_CLOSEDIR HAVE_ALPHASORT HAVE_SCANDIR HAVE_FDOPENDIR @@ -994,6 +1048,10 @@ GNULIB_ALPHASORT GNULIB_SCANDIR GNULIB_FDOPENDIR GNULIB_DIRFD +NEXT_AS_FIRST_DIRECTIVE_CTYPE_H +NEXT_CTYPE_H +HAVE_ISBLANK +GNULIB_ISBLANK REPLACE_VSPRINTF REPLACE_VSNPRINTF REPLACE_VPRINTF @@ -1003,7 +1061,9 @@ REPLACE_VASPRINTF REPLACE_STDIO_WRITE_FUNCS REPLACE_SPRINTF REPLACE_SNPRINTF +REPLACE_RENAMEAT REPLACE_RENAME +REPLACE_REMOVE REPLACE_PRINTF REPLACE_POPEN REPLACE_PERROR @@ -1022,8 +1082,7 @@ REPLACE_FCLOSE REPLACE_DPRINTF HAVE_VDPRINTF HAVE_VASPRINTF -HAVE_FTELLO -HAVE_FSEEKO +HAVE_RENAMEAT HAVE_DPRINTF HAVE_DECL_VSNPRINTF HAVE_DECL_SNPRINTF @@ -1042,7 +1101,9 @@ GNULIB_VASPRINTF GNULIB_STDIO_H_SIGPIPE GNULIB_SPRINTF_POSIX GNULIB_SNPRINTF +GNULIB_RENAMEAT GNULIB_RENAME +GNULIB_REMOVE GNULIB_PUTS GNULIB_PUTCHAR GNULIB_PUTC @@ -1070,7 +1131,6 @@ GNULIB_FFLUSH GNULIB_FCLOSE GNULIB_DPRINTF HAVE_WINSOCK2_H -SYS_IOCTL_H SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS SYS_IOCTL_H_HAVE_WINSOCK2_H GNULIB_IOCTL @@ -1078,30 +1138,48 @@ LIB_CLOCK_GETTIME UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS UNISTD_H_HAVE_WINSOCK2_H REPLACE_WRITE +REPLACE_USLEEP +REPLACE_UNLINKAT +REPLACE_UNLINK +REPLACE_SYMLINK +REPLACE_SLEEP +REPLACE_RMDIR +REPLACE_READLINK +REPLACE_PREAD REPLACE_LSEEK +REPLACE_LINKAT REPLACE_LINK REPLACE_LCHOWN REPLACE_GETPAGESIZE +REPLACE_GETGROUPS REPLACE_GETCWD REPLACE_FCHOWNAT REPLACE_FCHDIR REPLACE_DUP2 +REPLACE_DUP REPLACE_CLOSE REPLACE_CHOWN +HAVE_USLEEP HAVE_UNLINKAT HAVE_SYS_PARAM_H HAVE_OS_H HAVE_DECL_GETLOGIN_R HAVE_DECL_ENVIRON HAVE_SYMLINKAT +HAVE_SYMLINK HAVE_SLEEP HAVE_READLINKAT HAVE_READLINK +HAVE_PREAD HAVE_PIPE2 +HAVE_LINKAT HAVE_LINK +HAVE_LCHOWN HAVE_GETUSERSHELL HAVE_GETPAGESIZE +HAVE_GETLOGIN HAVE_GETHOSTNAME +HAVE_GETGROUPS HAVE_GETDTABLESIZE HAVE_GETDOMAINNAME HAVE_FTRUNCATE @@ -1111,22 +1189,31 @@ HAVE_FACCESSAT HAVE_EUIDACCESS HAVE_DUP3 HAVE_DUP2 +HAVE_CHOWN GNULIB_WRITE +GNULIB_USLEEP GNULIB_UNLINKAT +GNULIB_UNLINK GNULIB_UNISTD_H_SIGPIPE GNULIB_UNISTD_H_GETOPT GNULIB_SYMLINKAT +GNULIB_SYMLINK GNULIB_SLEEP +GNULIB_RMDIR GNULIB_READLINKAT GNULIB_READLINK +GNULIB_PREAD GNULIB_PIPE2 GNULIB_LSEEK +GNULIB_LINKAT GNULIB_LINK GNULIB_LCHOWN GNULIB_GETUSERSHELL GNULIB_GETPAGESIZE GNULIB_GETLOGIN_R +GNULIB_GETLOGIN GNULIB_GETHOSTNAME +GNULIB_GETGROUPS GNULIB_GETDTABLESIZE GNULIB_GETDOMAINNAME GNULIB_GETCWD @@ -1141,11 +1228,13 @@ GNULIB_DUP3 GNULIB_DUP2 GNULIB_CLOSE GNULIB_CHOWN -VOID_UNSETENV +REPLACE_UNSETENV REPLACE_STRTOD +REPLACE_SETENV +REPLACE_REALPATH REPLACE_PUTENV REPLACE_MKSTEMP -HAVE_DECL_GETLOADAVG +REPLACE_CANONICALIZE_FILE_NAME HAVE_UNSETENV HAVE_SYS_LOADAVG_H HAVE_STRUCT_RANDOM_DATA @@ -1154,12 +1243,17 @@ HAVE_STRTOLL HAVE_STRTOD HAVE_SETENV HAVE_RPMATCH -HAVE_RANDOM_R +HAVE_REALPATH HAVE_REALLOC_POSIX +HAVE_RANDOM_R +HAVE_MKSTEMPS +HAVE_MKOSTEMPS HAVE_MKOSTEMP HAVE_MKDTEMP HAVE_MALLOC_POSIX HAVE_GETSUBOPT +HAVE_DECL_GETLOADAVG +HAVE_CANONICALIZE_FILE_NAME HAVE_ATOLL GNULIB_UNSETENV GNULIB_STRTOULL @@ -1167,20 +1261,23 @@ GNULIB_STRTOLL GNULIB_STRTOD GNULIB_SETENV GNULIB_RPMATCH +GNULIB_REALPATH +GNULIB_REALLOC_POSIX GNULIB_RANDOM_R GNULIB_PUTENV +GNULIB_MKSTEMPS GNULIB_MKSTEMP +GNULIB_MKOSTEMPS GNULIB_MKOSTEMP GNULIB_MKDTEMP +GNULIB_MALLOC_POSIX GNULIB_GETSUBOPT GNULIB_GETLOADAVG -GNULIB_ATOLL +GNULIB_CANONICALIZE_FILE_NAME GNULIB_CALLOC_POSIX -GNULIB_REALLOC_POSIX -GNULIB_MALLOC_POSIX +GNULIB_ATOLL HAVE_CALLOC_POSIX LOCALE_FR -WCHAR_H REPLACE_WCWIDTH REPLACE_WCSNRTOMBS REPLACE_WCSRTOMBS @@ -1221,7 +1318,6 @@ PRAGMA_SYSTEM_HEADER INCLUDE_NEXT_AS_FIRST_DIRECTIVE INCLUDE_NEXT HAVE_ARPA_INET_H -ARPA_INET_H HAVE_DECL_INET_PTON HAVE_DECL_INET_NTOP GNULIB_INET_PTON @@ -1329,11 +1425,13 @@ ac_user_opts=' enable_option_checking enable_silent_rules enable_dependency_tracking +enable_threads enable_acl enable_assert with_gnu_ld enable_rpath with_libiconv_prefix +with_libpth_prefix enable_largefile with_included_regex with_packager @@ -1901,7 +1999,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures GNU coreutils 7.6 to adapt to many kinds of systems. +\`configure' configures GNU coreutils 8.4 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1971,7 +2069,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of GNU coreutils 7.6:";; + short | recursive ) echo "Configuration of GNU coreutils 8.4:";; esac cat <<\_ACEOF @@ -1983,6 +2081,9 @@ Optional Features: --disable-silent-rules verbose build output (undo: `make V=0') --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors + --enable-threads={posix|solaris|pth|win32} + specify multithreading API + --disable-threads build without multithread safety --disable-acl do not support ACLs --disable-assert turn off assertions --disable-rpath do not hardcode runtime library paths @@ -2004,6 +2105,8 @@ Optional Packages: --with-gnu-ld assume the C compiler uses GNU ld default=no --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib --without-libiconv-prefix don't search for libiconv in includedir and libdir + --with-libpth-prefix[=DIR] search for libpth in DIR/include and DIR/lib + --without-libpth-prefix don't search for libpth in includedir and libdir --without-included-regex don't compile regex; this is the default on systems with recent-enough versions of the GNU C Library @@ -2023,7 +2126,7 @@ Some influential environment variables: LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor YACC The `Yet Another C Compiler' implementation to use. Defaults to @@ -2104,10 +2207,10 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -GNU coreutils configure 7.6 -generated by GNU Autoconf 2.64.27-5b5d +GNU coreutils configure 8.4 +generated by GNU Autoconf 2.65.23-13e35 -Copyright (C) 2009 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -2152,7 +2255,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - return $ac_retval + as_fn_set_status $ac_retval } # ac_fn_c_try_compile @@ -2189,7 +2292,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - return $ac_retval + as_fn_set_status $ac_retval } # ac_fn_c_try_cpp @@ -2324,7 +2427,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - return $ac_retval + as_fn_set_status $ac_retval } # ac_fn_c_try_run @@ -2401,7 +2504,7 @@ fi # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - return $ac_retval + as_fn_set_status $ac_retval } # ac_fn_c_try_link @@ -2526,9 +2629,10 @@ $as_echo "$ac_res" >&6; } } # ac_fn_c_check_type -# ac_fn_c_check_decl LINENO SYMBOL VAR -# ------------------------------------ -# Tests whether SYMBOL is declared, setting cache variable VAR accordingly. +# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES +# --------------------------------------------- +# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR +# accordingly. ac_fn_c_check_decl () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack @@ -2739,7 +2843,7 @@ rm -f conftest.val fi eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - return $ac_retval + as_fn_set_status $ac_retval } # ac_fn_c_compute_int @@ -2803,8 +2907,8 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by GNU coreutils $as_me 7.6, which was -generated by GNU Autoconf 2.64.27-5b5d. Invocation command line was +It was created by GNU coreutils $as_me 8.4, which was +generated by GNU Autoconf 2.65.23-13e35. Invocation command line was $ $0 $@ @@ -3057,7 +3161,7 @@ fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue - if test -r "$ac_site_file"; then + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 @@ -3066,9 +3170,9 @@ $as_echo "$as_me: loading site script $ac_site_file" >&6;} done if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special - # files actually), so we avoid doing that. - if test -f "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in @@ -3085,19 +3189,24 @@ fi as_fn_append ac_header_list " arpa/inet.h" as_fn_append ac_func_list " pathconf" as_fn_append ac_func_list " btowc" -as_fn_append ac_header_list " sys/param.h" as_fn_append ac_func_list " canonicalize_file_name" -as_fn_append ac_func_list " resolvepath" +as_fn_append ac_func_list " realpath" as_fn_append ac_func_list " chown" +as_fn_append ac_func_list " fchown" as_fn_append ac_header_list " sys/socket.h" +as_fn_append ac_header_list " ctype.h" as_fn_append ac_header_list " dirent.h" as_fn_append ac_func_list " fdopendir" as_fn_append ac_func_list " dup2" as_fn_append ac_header_list " errno.h" as_fn_append ac_func_list " faccessat" as_fn_append ac_header_list " libgen.h" +as_fn_append ac_func_list " lchmod" +as_fn_append ac_func_list " access" as_fn_append ac_func_list " fchdir" +as_fn_append ac_func_list " fcntl" as_fn_append ac_header_list " fcntl.h" +as_fn_append ac_header_list " sys/param.h" as_fn_append ac_func_list " mempcpy" as_fn_append ac_header_list " float.h" as_fn_append ac_func_list " isblank" @@ -3115,8 +3224,8 @@ as_fn_append ac_func_list " __fpurge" as_fn_append ac_func_list " __freading" as_fn_append ac_header_list " sys/vfs.h" as_fn_append ac_header_list " sys/fs_types.h" +as_fn_append ac_func_list " fsync" as_fn_append ac_func_list " ftruncate" -as_fn_append ac_func_list " lchmod" as_fn_append ac_func_list " fstatfs" as_fn_append ac_header_list " netdb.h" as_fn_append ac_header_list " netinet/in.h" @@ -3125,6 +3234,7 @@ as_fn_append ac_func_list " nanouptime" as_fn_append ac_func_list " flockfile" as_fn_append ac_func_list " funlockfile" gl_getopt_required=GNU +as_fn_append ac_header_list " getopt.h" as_fn_append ac_header_list " termios.h" as_fn_append ac_func_list " __fsetlocking" as_fn_append ac_func_list " tcgetattr" @@ -3132,32 +3242,42 @@ as_fn_append ac_func_list " tcsetattr" as_fn_append ac_func_list " gettimeofday" as_fn_append ac_func_list " nanotime" as_fn_append ac_header_list " sys/time.h" +as_fn_append ac_header_list " grp.h" as_fn_append ac_header_list " iconv.h" as_fn_append ac_header_list " stdint.h" as_fn_append ac_header_list " wchar.h" as_fn_append ac_header_list " inttypes.h" +as_fn_append ac_header_list " langinfo.h" as_fn_append ac_func_list " link" as_fn_append ac_func_list " readlink" +as_fn_append ac_func_list " linkat" +as_fn_append ac_func_list " symlink" +as_fn_append ac_header_list " stddef.h" +as_fn_append ac_header_list " xlocale.h" +as_fn_append ac_header_list " locale.h" as_fn_append ac_func_list " lstat" as_fn_append ac_header_list " math.h" as_fn_append ac_func_list " mbsinit" as_fn_append ac_func_list " mbrtowc" as_fn_append ac_func_list " mbrlen" +as_fn_append ac_func_list " mbslen" as_fn_append ac_func_list " isascii" as_fn_append ac_header_list " sys/mman.h" as_fn_append ac_func_list " mprotect" +as_fn_append ac_func_list " getgrouplist" as_fn_append ac_header_list " unistd.h" as_fn_append ac_func_list " fchmod" as_fn_append ac_func_list " alarm" as_fn_append ac_header_list " sys/statvfs.h" as_fn_append ac_header_list " sys/select.h" +as_fn_append ac_func_list " nl_langinfo" gl_printf_safe=yes as_fn_append ac_header_list " utmp.h" as_fn_append ac_header_list " utmpx.h" as_fn_append ac_func_list " utmpname" as_fn_append ac_func_list " utmpxname" -as_fn_append ac_header_list " locale.h" as_fn_append ac_func_list " wcscoll" +as_fn_append ac_header_list " selinux/selinux.h" as_fn_append ac_func_list " setenv" as_fn_append ac_func_list " settimeofday" as_fn_append ac_func_list " stime" @@ -3166,28 +3286,36 @@ as_fn_append ac_func_list " sigaltstack" as_fn_append ac_func_list " siginterrupt" as_fn_append ac_header_list " signal.h" as_fn_append ac_header_list " stdarg.h" -as_fn_append ac_header_list " stddef.h" as_fn_append ac_header_list " stdio.h" as_fn_append ac_header_list " stdlib.h" as_fn_append ac_func_list " tzset" as_fn_append ac_header_list " string.h" as_fn_append ac_func_list " strndup" +as_fn_append ac_func_list " symlinkat" +as_fn_append ac_func_list " readlinkat" as_fn_append ac_header_list " sys/stat.h" +as_fn_append ac_header_list " sys/utsname.h" as_fn_append ac_header_list " time.h" as_fn_append ac_func_list " pipe" -as_fn_append ac_header_list " priv.h" as_fn_append ac_header_list " utime.h" as_fn_append ac_func_list " futimes" as_fn_append ac_func_list " futimesat" as_fn_append ac_func_list " futimens" as_fn_append ac_func_list " utimensat" +as_fn_append ac_func_list " lutimes" as_fn_append ac_func_list " vasnprintf" as_fn_append ac_func_list " wcrtomb" as_fn_append ac_func_list " iswcntrl" as_fn_append ac_func_list " wcwidth" -as_fn_append ac_func_list " symlink" +as_fn_append ac_header_list " priv.h" +as_fn_append ac_func_list " getegid" +as_fn_append ac_func_list " getdtablesize" +as_fn_append ac_func_list " newlocale" as_fn_append ac_header_list " sys/wait.h" +as_fn_append ac_func_list " sleep" as_fn_append ac_header_list " sys/ioctl.h" +as_fn_append ac_func_list " shutdown" +as_fn_append ac_func_list " usleep" as_fn_append ac_func_list " wctob" as_fn_append ac_header_list " hurd.h" as_fn_append ac_header_list " paths.h" @@ -3195,14 +3323,11 @@ as_fn_append ac_header_list " stropts.h" as_fn_append ac_header_list " sys/resource.h" as_fn_append ac_header_list " sys/systeminfo.h" as_fn_append ac_header_list " syslog.h" -as_fn_append ac_header_list " grp.h" as_fn_append ac_header_list " pwd.h" as_fn_append ac_func_list " strxfrm" as_fn_append ac_func_list " directio" -as_fn_append ac_func_list " nl_langinfo" as_fn_append ac_func_list " endgrent" as_fn_append ac_func_list " endpwent" -as_fn_append ac_func_list " fchown" as_fn_append ac_func_list " iswspace" as_fn_append ac_func_list " mkfifo" as_fn_append ac_func_list " setgroups" @@ -3286,13 +3411,19 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_aux_dir= for ac_dir in build-aux "$srcdir"/build-aux; do - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/$ac_t -c" - break 2 - fi - done + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi done if test -z "$ac_aux_dir"; then as_fn_error "cannot find install-sh, install.sh, or shtool in build-aux \"$srcdir\"/build-aux" "$LINENO" 5 @@ -3628,6 +3759,7 @@ IFS=$as_save_IFS fi + test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else @@ -3635,7 +3767,6 @@ fi # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. - test -d ./--version && rmdir ./--version MKDIR_P="$ac_install_sh -d" fi fi @@ -3752,7 +3883,7 @@ fi # Define the identity of the package. PACKAGE='coreutils' - VERSION='7.6' + VERSION='8.4' cat >>confdefs.h <<_ACEOF @@ -4189,8 +4320,8 @@ $as_echo "$ac_try_echo"; } >&5 ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 - rm -f conftest.er1 conftest.err fi + rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done @@ -4329,7 +4460,7 @@ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." "$LINENO" 5; } fi -rm -f conftest$ac_cv_exeext +rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } @@ -5859,8 +5990,8 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -# define __EXTENSIONS__ 1 - $ac_includes_default +# define __EXTENSIONS__ 1 + $ac_includes_default int main () { @@ -5996,6 +6127,54 @@ fi + # Check whether --enable-threads was given. +if test "${enable_threads+set}" = set; then : + enableval=$enable_threads; gl_use_threads=$enableval +else + if test -n "$gl_use_threads_default"; then + gl_use_threads="$gl_use_threads_default" + else + case "$host_os" in + osf*) gl_use_threads=no ;; + cygwin*) + case `uname -r` in + 1.[0-5].*) gl_use_threads=no ;; + *) gl_use_threads=yes ;; + esac + ;; + *) gl_use_threads=yes ;; + esac + fi + +fi + + if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then + # For using : + case "$host_os" in + osf*) + # On OSF/1, the compiler needs the flag -D_REENTRANT so that it + # groks . cc also understands the flag -pthread, but + # we don't use it because 1. gcc-2.95 doesn't understand -pthread, + # 2. putting a flag into CPPFLAGS that has an effect on the linker + # causes the AC_TRY_LINK test below to succeed unexpectedly, + # leading to wrong values of LIBTHREAD and LTLIBTHREAD. + CPPFLAGS="$CPPFLAGS -D_REENTRANT" + ;; + esac + # Some systems optimize for single-threaded programs by default, and + # need special flags to disable these optimizations. For example, the + # definition of 'errno' in . + case "$host_os" in + aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;; + solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;; + esac + fi + + + + + + if test -z "$AB_PACKAGE"; then @@ -6039,6 +6218,9 @@ $as_echo "$as_me: autobuild timestamp... $date" >&6;} + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } if test "${ac_cv_c_inline+set}" = set; then : @@ -6280,7 +6462,6 @@ fi GNULIB_INET_PTON=0; HAVE_DECL_INET_NTOP=1; HAVE_DECL_INET_PTON=1; - ARPA_INET_H=''; @@ -6396,21 +6577,21 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include - #include - #include + #include + #include int main () { DIR *dp = opendir ("."); - struct dirent *e; - struct stat st; - if (! dp) - return 1; - e = readdir (dp); - return ! (e - && stat (e->d_name, &st) == 0 - && e->d_ino == st.st_ino); + struct dirent *e; + struct stat st; + if (! dp) + return 1; + e = readdir (dp); + return ! (e + && stat (e->d_name, &st) == 0 + && e->d_ino == st.st_ino); ; return 0; } @@ -6441,7 +6622,7 @@ if test "${ac_cv_win_or_dos+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -6475,7 +6656,7 @@ if test "${ac_cv_drive_letter_can_be_relative+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -6500,9 +6681,9 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_drive_letter_can_be_relative" >&5 $as_echo "$ac_cv_drive_letter_can_be_relative" >&6; } if test x"$ac_cv_drive_letter_can_be_relative" = xyes; then - ac_fs_drive_letter_can_be_relative=1 + ac_fs_drive_letter_can_be_relative=1 else - ac_fs_drive_letter_can_be_relative=0 + ac_fs_drive_letter_can_be_relative=0 fi else ac_fs_accepts_drive_letter_prefix=0 @@ -6599,16 +6780,16 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ typedef int * int_ptr; - int foo (int_ptr $ac_kw ip) { - return ip[0]; + int foo (int_ptr $ac_kw ip) { + return ip[0]; } int main () { int s[1]; - int * $ac_kw t = s; - t[0] = 0; - return foo(t) + int * $ac_kw t = s; + t[0] = 0; + return foo(t) ; return 0; } @@ -6669,7 +6850,66 @@ _ACEOF REPLACE_WCSRTOMBS=0; REPLACE_WCSNRTOMBS=0; REPLACE_WCWIDTH=0; - WCHAR_H=''; + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether uses 'inline' correctly" >&5 +$as_echo_n "checking whether uses 'inline' correctly... " >&6; } +if test "${gl_cv_header_wchar_h_correct_inline+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + gl_cv_header_wchar_h_correct_inline=yes + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #define wcstod renamed_wcstod +#include +extern int zero (void); +int main () { return zero(); } + +_ACEOF + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + mv conftest.$ac_objext conftest1.$ac_objext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #define wcstod renamed_wcstod +#include +int zero (void) { return 0; } + +_ACEOF + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + mv conftest.$ac_objext conftest2.$ac_objext + if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&5 2>&1; then + : + else + gl_cv_header_wchar_h_correct_inline=no + fi + fi + fi + rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_wchar_h_correct_inline" >&5 +$as_echo "$gl_cv_header_wchar_h_correct_inline" >&6; } + if test $gl_cv_header_wchar_h_correct_inline = no; then + as_fn_error " cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS). +This is a known interoperability problem of glibc <= 2.5 with gcc >= 4.3 in +C99 mode. You have four options: + - Add the flag -fgnu89-inline to CC and reconfigure, or + - Fix your include files, using parts of + , or + - Use a gcc version older than 4.3, or + - Don't use the flags -std=c99 or -std=gnu99. +Configuration aborted." "$LINENO" 5 + fi @@ -6817,17 +7057,17 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* On HP-UX before 11.23, strtold returns a struct instead of - long double. Reject implementations like that, by requiring - compatibility with the C99 prototype. */ - #include - static long double (*p) (char const *, char **) = strtold; - static long double - test (char const *nptr, char **endptr) - { - long double r; - r = strtold (nptr, endptr); - return r; - } + long double. Reject implementations like that, by requiring + compatibility with the C99 prototype. */ + #include + static long double (*p) (char const *, char **) = strtold; + static long double + test (char const *nptr, char **endptr) + { + long double r; + r = strtold (nptr, endptr); + return r; + } int main () { @@ -6896,17 +7136,21 @@ fi $as_echo "$gl_cv_func_malloc_posix" >&6; } - GNULIB_MALLOC_POSIX=0; - GNULIB_REALLOC_POSIX=0; - GNULIB_CALLOC_POSIX=0; GNULIB_ATOLL=0; + GNULIB_CALLOC_POSIX=0; + GNULIB_CANONICALIZE_FILE_NAME=0; GNULIB_GETLOADAVG=0; GNULIB_GETSUBOPT=0; + GNULIB_MALLOC_POSIX=0; GNULIB_MKDTEMP=0; GNULIB_MKOSTEMP=0; + GNULIB_MKOSTEMPS=0; GNULIB_MKSTEMP=0; + GNULIB_MKSTEMPS=0; GNULIB_PUTENV=0; GNULIB_RANDOM_R=0; + GNULIB_REALLOC_POSIX=0; + GNULIB_REALPATH=0; GNULIB_RPMATCH=0; GNULIB_SETENV=0; GNULIB_STRTOD=0; @@ -6915,12 +7159,17 @@ $as_echo "$gl_cv_func_malloc_posix" >&6; } GNULIB_UNSETENV=0; HAVE_ATOLL=1; HAVE_CALLOC_POSIX=1; + HAVE_CANONICALIZE_FILE_NAME=1; + HAVE_DECL_GETLOADAVG=1; HAVE_GETSUBOPT=1; HAVE_MALLOC_POSIX=1; HAVE_MKDTEMP=1; HAVE_MKOSTEMP=1; - HAVE_REALLOC_POSIX=1; + HAVE_MKOSTEMPS=1; + HAVE_MKSTEMPS=1; HAVE_RANDOM_R=1; + HAVE_REALLOC_POSIX=1; + HAVE_REALPATH=1; HAVE_RPMATCH=1; HAVE_SETENV=1; HAVE_STRTOD=1; @@ -6929,28 +7178,107 @@ $as_echo "$gl_cv_func_malloc_posix" >&6; } HAVE_STRUCT_RANDOM_DATA=1; HAVE_SYS_LOADAVG_H=0; HAVE_UNSETENV=1; - HAVE_DECL_GETLOADAVG=1; + REPLACE_CANONICALIZE_FILE_NAME=0; REPLACE_MKSTEMP=0; REPLACE_PUTENV=0; + REPLACE_REALPATH=0; + REPLACE_SETENV=0; REPLACE_STRTOD=0; - VOID_UNSETENV=0; + REPLACE_UNSETENV=0; -ac_fn_c_check_decl "$LINENO" "canonicalize_file_name" "ac_cv_have_decl_canonicalize_file_name" "$ac_includes_default" -if test "x$ac_cv_have_decl_canonicalize_file_name" = x""yes; then : - ac_have_decl=1 + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether // is distinct from /" >&5 +$as_echo_n "checking whether // is distinct from /... " >&6; } +if test "${gl_cv_double_slash_root+set}" = set; then : + $as_echo_n "(cached) " >&6 else - ac_have_decl=0 + if test x"$cross_compiling" = xyes ; then + # When cross-compiling, there is no way to tell whether // is special + # short of a list of hosts. However, the only known hosts to date + # that have a distinct // are Apollo DomainOS (too old to port to), + # Cygwin, and z/OS. If anyone knows of another system for which // has + # special semantics and is distinct from /, please report it to + # . + case $host in + *-cygwin | i370-ibm-openedition) + gl_cv_double_slash_root=yes ;; + *) + # Be optimistic and assume that / and // are the same when we + # don't know. + gl_cv_double_slash_root='unknown, assuming no' ;; + esac + else + set x `ls -di / // 2>/dev/null` + if test "$2" = "$4" && wc //dev/null >/dev/null 2>&1; then + gl_cv_double_slash_root=no + else + gl_cv_double_slash_root=yes + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_double_slash_root" >&5 +$as_echo "$gl_cv_double_slash_root" >&6; } + if test "$gl_cv_double_slash_root" = yes; then + +$as_echo "#define DOUBLE_SLASH_IS_DISTINCT_ROOT 1" >>confdefs.h + + fi + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether realpath works" >&5 +$as_echo_n "checking whether realpath works... " >&6; } +if test "${gl_cv_func_realpath_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + touch conftest.a + if test "$cross_compiling" = yes; then : + gl_cv_func_realpath_works="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + + #include + +int +main () +{ + + char *name1 = realpath ("conftest.a", NULL); + char *name2 = realpath ("conftest.b/../conftest.a", NULL); + char *name3 = realpath ("conftest.a/", NULL); + return !(name1 && *name1 == '/' && !name2 && !name3); + + ; + return 0; +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_realpath_works=yes +else + gl_cv_func_realpath_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_CANONICALIZE_FILE_NAME $ac_have_decl -_ACEOF - +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_realpath_works" >&5 +$as_echo "$gl_cv_func_realpath_works" >&6; } + if test "$gl_cv_func_realpath_works" = yes; then +$as_echo "#define FUNC_REALPATH_WORKS 1" >>confdefs.h + fi GNULIB_CHOWN=0; @@ -6967,23 +7295,32 @@ _ACEOF GNULIB_GETCWD=0; GNULIB_GETDOMAINNAME=0; GNULIB_GETDTABLESIZE=0; + GNULIB_GETGROUPS=0; GNULIB_GETHOSTNAME=0; + GNULIB_GETLOGIN=0; GNULIB_GETLOGIN_R=0; GNULIB_GETPAGESIZE=0; GNULIB_GETUSERSHELL=0; GNULIB_LCHOWN=0; GNULIB_LINK=0; + GNULIB_LINKAT=0; GNULIB_LSEEK=0; GNULIB_PIPE2=0; + GNULIB_PREAD=0; GNULIB_READLINK=0; GNULIB_READLINKAT=0; + GNULIB_RMDIR=0; GNULIB_SLEEP=0; + GNULIB_SYMLINK=0; GNULIB_SYMLINKAT=0; GNULIB_UNISTD_H_GETOPT=0; GNULIB_UNISTD_H_SIGPIPE=0; + GNULIB_UNLINK=0; GNULIB_UNLINKAT=0; + GNULIB_USLEEP=0; GNULIB_WRITE=0; - HAVE_DUP2=1; + HAVE_CHOWN=1; + HAVE_DUP2=1; HAVE_DUP3=1; HAVE_EUIDACCESS=1; HAVE_FACCESSAT=1; @@ -6992,30 +7329,48 @@ _ACEOF HAVE_FTRUNCATE=1; HAVE_GETDOMAINNAME=1; HAVE_GETDTABLESIZE=1; + HAVE_GETGROUPS=1; HAVE_GETHOSTNAME=1; + HAVE_GETLOGIN=1; HAVE_GETPAGESIZE=1; HAVE_GETUSERSHELL=1; + HAVE_LCHOWN=1; HAVE_LINK=1; + HAVE_LINKAT=1; HAVE_PIPE2=1; + HAVE_PREAD=1; HAVE_READLINK=1; HAVE_READLINKAT=1; HAVE_SLEEP=1; + HAVE_SYMLINK=1; HAVE_SYMLINKAT=1; HAVE_DECL_ENVIRON=1; HAVE_DECL_GETLOGIN_R=1; HAVE_OS_H=0; HAVE_SYS_PARAM_H=0; HAVE_UNLINKAT=1; + HAVE_USLEEP=1; REPLACE_CHOWN=0; REPLACE_CLOSE=0; + REPLACE_DUP=0; REPLACE_DUP2=0; REPLACE_FCHDIR=0; REPLACE_FCHOWNAT=0; REPLACE_GETCWD=0; + REPLACE_GETGROUPS=0; REPLACE_GETPAGESIZE=0; REPLACE_LCHOWN=0; REPLACE_LINK=0; + REPLACE_LINKAT=0; REPLACE_LSEEK=0; + REPLACE_PREAD=0; + REPLACE_READLINK=0; + REPLACE_RMDIR=0; + REPLACE_SLEEP=0; + REPLACE_SYMLINK=0; + REPLACE_UNLINK=0; + REPLACE_UNLINKAT=0; + REPLACE_USLEEP=0; REPLACE_WRITE=0; UNISTD_H_HAVE_WINSOCK2_H=0; UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0; @@ -7117,8 +7472,8 @@ $as_echo "#define HAVE_CHOWN 1" >>confdefs.h fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether chown(2) dereferences symlinks" >&5 -$as_echo_n "checking whether chown(2) dereferences symlinks... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether chown dereferences symlinks" >&5 +$as_echo_n "checking whether chown dereferences symlinks... " >&6; } if test "${gl_cv_func_chown_follows_symlink+set}" = set; then : $as_echo_n "(cached) " >&6 else @@ -7134,20 +7489,20 @@ else #include #include - int - main () - { - char const *dangling_symlink = "conftest.dangle"; + int + main () + { + char const *dangling_symlink = "conftest.dangle"; - unlink (dangling_symlink); - if (symlink ("conftest.no-such", dangling_symlink)) - abort (); + unlink (dangling_symlink); + if (symlink ("conftest.no-such", dangling_symlink)) + abort (); - /* Exit successfully on a conforming system, - i.e., where chown must fail with ENOENT. */ - exit ( ! (chown (dangling_symlink, getuid (), getgid ()) != 0 - && errno == ENOENT)); - } + /* Exit successfully on a conforming system, + i.e., where chown must fail with ENOENT. */ + exit ( ! (chown (dangling_symlink, getuid (), getgid ()) != 0 + && errno == ENOENT)); + } _ACEOF if ac_fn_c_try_run "$LINENO"; then : @@ -7174,11 +7529,195 @@ $as_echo "#define CHOWN_MODIFIES_SYMLINK 1" >>confdefs.h + + + + + + + + + if test $ac_cv_func_chown = no; then + HAVE_CHOWN=0 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS chown.$ac_objext" + + else + if test $gl_cv_func_chown_follows_symlink = no; then + REPLACE_CHOWN=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS chown.$ac_objext" + + fi + + if test $ac_cv_func_chown_works = no; then + +$as_echo "#define CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE 1" >>confdefs.h + + REPLACE_CHOWN=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS chown.$ac_objext" + + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether chown honors trailing slash" >&5 +$as_echo_n "checking whether chown honors trailing slash... " >&6; } +if test "${gl_cv_func_chown_slash_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + touch conftest.file && rm -f conftest.link + if test "$cross_compiling" = yes; then : + gl_cv_func_chown_slash_works="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include + +int +main () +{ + if (symlink ("conftest.file", "conftest.link")) return 1; + if (chown ("conftest.link/", getuid (), getgid ()) == 0) return 2; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_chown_slash_works=yes +else + gl_cv_func_chown_slash_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + rm -f conftest.link conftest.file +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_chown_slash_works" >&5 +$as_echo "$gl_cv_func_chown_slash_works" >&6; } + if test "$gl_cv_func_chown_slash_works" != yes; then + +$as_echo "#define CHOWN_TRAILING_SLASH_BUG 1" >>confdefs.h + + REPLACE_CHOWN=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS chown.$ac_objext" + + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether chown always updates ctime" >&5 +$as_echo_n "checking whether chown always updates ctime... " >&6; } +if test "${gl_cv_func_chown_ctime_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + gl_cv_func_chown_ctime_works="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include +#include + +int +main () +{ + struct stat st1, st2; + if (close (creat ("conftest.file", 0600))) return 1; + if (stat ("conftest.file", &st1)) return 2; + sleep (1); + if (chown ("conftest.file", st1.st_uid, st1.st_gid)) return 3; + if (stat ("conftest.file", &st2)) return 4; + if (st2.st_ctime <= st1.st_ctime) return 5; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_chown_ctime_works=yes +else + gl_cv_func_chown_ctime_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + rm -f conftest.file +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_chown_ctime_works" >&5 +$as_echo "$gl_cv_func_chown_ctime_works" >&6; } + if test "$gl_cv_func_chown_ctime_works" != yes; then + +$as_echo "#define CHOWN_CHANGE_TIME_BUG 1" >>confdefs.h + + REPLACE_CHOWN=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS chown.$ac_objext" + + fi + + if test $REPLACE_CHOWN = 1 && test $ac_cv_func_fchown = no; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS fchown-stub.$ac_objext" + + fi + fi + + GNULIB_IOCTL=0; SYS_IOCTL_H_HAVE_WINSOCK2_H=0; SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0; - SYS_IOCTL_H=''; @@ -7209,7 +7748,9 @@ $as_echo "#define CHOWN_MODIFIES_SYMLINK 1" >>confdefs.h GNULIB_PUTC=0; GNULIB_PUTCHAR=0; GNULIB_PUTS=0; + GNULIB_REMOVE=0; GNULIB_RENAME=0; + GNULIB_RENAMEAT=0; GNULIB_SNPRINTF=0; GNULIB_SPRINTF_POSIX=0; GNULIB_STDIO_H_SIGPIPE=0; @@ -7228,8 +7769,7 @@ $as_echo "#define CHOWN_MODIFIES_SYMLINK 1" >>confdefs.h HAVE_DECL_SNPRINTF=1; HAVE_DECL_VSNPRINTF=1; HAVE_DPRINTF=1; - HAVE_FSEEKO=1; - HAVE_FTELLO=1; + HAVE_RENAMEAT=1; HAVE_VASPRINTF=1; HAVE_VDPRINTF=1; REPLACE_DPRINTF=0; @@ -7248,7 +7788,9 @@ $as_echo "#define CHOWN_MODIFIES_SYMLINK 1" >>confdefs.h REPLACE_PERROR=0; REPLACE_POPEN=0; REPLACE_PRINTF=0; + REPLACE_REMOVE=0; REPLACE_RENAME=0; + REPLACE_RENAMEAT=0; REPLACE_SNPRINTF=0; REPLACE_SPRINTF=0; REPLACE_STDIO_WRITE_FUNCS=0; @@ -7486,6 +8028,12 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h + GNULIB_ISBLANK=0; + HAVE_ISBLANK=1; + + + + GNULIB_DIRFD=0; GNULIB_FDOPENDIR=0; GNULIB_SCANDIR=0; @@ -7494,7 +8042,9 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h HAVE_FDOPENDIR=1; HAVE_SCANDIR=1; HAVE_ALPHASORT=1; - DIRENT_H=''; + REPLACE_CLOSEDIR=0; + REPLACE_FDOPENDIR=0; + REPLACE_OPENDIR=0; @@ -7502,44 +8052,85 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether // is distinct from /" >&5 -$as_echo_n "checking whether // is distinct from /... " >&6; } -if test "${gl_cv_double_slash_root+set}" = set; then : + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS basename-lgpl.$ac_objext" + + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS dirname-lgpl.$ac_objext" + + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS stripslash.$ac_objext" + + + + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if environ is properly declared" >&5 +$as_echo_n "checking if environ is properly declared... " >&6; } + if test "${gt_cv_var_environ_declaration+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test x"$cross_compiling" = xyes ; then - # When cross-compiling, there is no way to tell whether // is special - # short of a list of hosts. However, the only known hosts to date - # that have a distinct // are Apollo DomainOS (too old to port to), - # Cygwin, and z/OS. If anyone knows of another system for which // has - # special semantics and is distinct from /, please report it to - # . - case $host in - *-cygwin | i370-ibm-openedition) - gl_cv_double_slash_root=yes ;; - *) - # Be optimistic and assume that / and // are the same when we - # don't know. - gl_cv_double_slash_root='unknown, assuming no' ;; - esac - else - set x `ls -di / // 2>/dev/null` - if test "$2" = "$4" && wc //dev/null >/dev/null 2>&1; then - gl_cv_double_slash_root=no - else - gl_cv_double_slash_root=yes - fi - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_double_slash_root" >&5 -$as_echo "$gl_cv_double_slash_root" >&6; } - if test "$gl_cv_double_slash_root" = yes; then -$as_echo "#define DOUBLE_SLASH_IS_DISTINCT_ROOT 1" >>confdefs.h + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + extern struct { int foo; } environ; +int +main () +{ +environ.foo = 1; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gt_cv_var_environ_declaration=no +else + gt_cv_var_environ_declaration=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_var_environ_declaration" >&5 +$as_echo "$gt_cv_var_environ_declaration" >&6; } + if test $gt_cv_var_environ_declaration = yes; then + +$as_echo "#define HAVE_ENVIRON_DECL 1" >>confdefs.h fi + if test $gt_cv_var_environ_declaration != yes; then + HAVE_DECL_ENVIRON=0 + fi @@ -7617,26 +8208,26 @@ if test "${gl_cv_next_errno_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_errno_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_errno_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_errno_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/errno.h#{ - s#.*"\(.*/errno.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_errno_h='<'errno.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_errno_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/errno.h#{ + s#.*"\(.*/errno.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_errno_h='<'errno.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_errno_h" >&5 @@ -8148,30 +8739,176 @@ fi LIBS=$ac_save_LIBS + GNULIB_FCNTL=0; + GNULIB_OPEN=0; + GNULIB_OPENAT=0; + HAVE_FCNTL=1; + HAVE_OPENAT=1; + REPLACE_FCNTL=0; + REPLACE_OPEN=0; + REPLACE_OPENAT=0; + + GNULIB_FCHMODAT=0; GNULIB_FSTATAT=0; + GNULIB_FUTIMENS=0; GNULIB_LCHMOD=0; GNULIB_LSTAT=0; GNULIB_MKDIRAT=0; + GNULIB_MKFIFO=0; GNULIB_MKFIFOAT=0; + GNULIB_MKNOD=0; GNULIB_MKNODAT=0; + GNULIB_STAT=0; + GNULIB_UTIMENSAT=0; HAVE_FCHMODAT=1; HAVE_FSTATAT=1; + HAVE_FUTIMENS=1; HAVE_LCHMOD=1; + HAVE_LSTAT=1; HAVE_MKDIRAT=1; + HAVE_MKFIFO=1; HAVE_MKFIFOAT=1; + HAVE_MKNOD=1; HAVE_MKNODAT=1; + HAVE_UTIMENSAT=1; + REPLACE_FSTAT=0; REPLACE_FSTATAT=0; + REPLACE_FUTIMENS=0; REPLACE_LSTAT=0; REPLACE_MKDIR=0; + REPLACE_MKFIFO=0; + REPLACE_MKNOD=0; + REPLACE_STAT=0; + REPLACE_UTIMENSAT=0; + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether lstat correctly handles trailing slash" >&5 +$as_echo_n "checking whether lstat correctly handles trailing slash... " >&6; } +if test "${ac_cv_func_lstat_dereferences_slashed_symlink+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + rm -f conftest.sym conftest.file +echo >conftest.file +if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then + if test "$cross_compiling" = yes; then : + ac_cv_func_lstat_dereferences_slashed_symlink=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +struct stat sbuf; + /* Linux will dereference the symlink and fail, as required by POSIX. + That is better in the sense that it means we will not + have to compile and use the lstat wrapper. */ + return lstat ("conftest.sym/", &sbuf) == 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_func_lstat_dereferences_slashed_symlink=yes +else + ac_cv_func_lstat_dereferences_slashed_symlink=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +else + # If the `ln -s' command failed, then we probably don't even + # have an lstat function. + ac_cv_func_lstat_dereferences_slashed_symlink=no +fi +rm -f conftest.sym conftest.file + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_lstat_dereferences_slashed_symlink" >&5 +$as_echo "$ac_cv_func_lstat_dereferences_slashed_symlink" >&6; } + +test $ac_cv_func_lstat_dereferences_slashed_symlink = yes && + +cat >>confdefs.h <<_ACEOF +#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 +_ACEOF + + +if test "x$ac_cv_func_lstat_dereferences_slashed_symlink" = xno; then - GNULIB_OPEN=0; - GNULIB_OPENAT=0; - HAVE_OPENAT=1; - REPLACE_OPEN=0; + + + + + gl_LIBOBJS="$gl_LIBOBJS lstat.$ac_objext" + +fi + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether unlink honors trailing slashes" >&5 +$as_echo_n "checking whether unlink honors trailing slashes... " >&6; } +if test "${gl_cv_func_unlink_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + touch conftest.file + # Assume that if we have lstat, we can also check symlinks. + if test $ac_cv_func_lstat = yes; then + ln -s conftest.file conftest.lnk + fi + if test "$cross_compiling" = yes; then : + gl_cv_func_unlink_works="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + +int +main () +{ +if (!unlink ("conftest.file/") || errno != ENOTDIR) return 1; +#if HAVE_LSTAT + if (!unlink ("conftest.lnk/") || errno != ENOTDIR) return 2; +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_unlink_works=yes +else + gl_cv_func_unlink_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + rm -f conftest.file conftest.lnk +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_unlink_works" >&5 +$as_echo "$gl_cv_func_unlink_works" >&6; } + if test x"$gl_cv_func_unlink_works" != xyes; then + REPLACE_UNLINK=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS unlink.$ac_objext" + + fi ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default" if test "x$ac_cv_type_mode_t" = x""yes; then : @@ -8221,6 +8958,339 @@ _ACEOF + GNULIB_OPENAT=1 + + + GNULIB_FCHMODAT=1 + GNULIB_FSTATAT=1 + GNULIB_MKDIRAT=1 + + + GNULIB_FCHOWNAT=1 + GNULIB_UNLINKAT=1 + + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS openat-proc.$ac_objext" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + for ac_func in fchmodat fstatat mkdirat openat unlinkat +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +eval as_val=\$$as_ac_var + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +else + + gl_LIBOBJS="$gl_LIBOBJS $ac_func.$ac_objext" + +fi +done + + + + + case $ac_cv_func_openat+$ac_cv_func_lstat_dereferences_slashed_symlink in + yes+yes) + # GNU/Hurd has unlinkat, but it has the same bug as unlink. + if test $REPLACE_UNLINK = 1; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS unlinkat.$ac_objext" + + REPLACE_UNLINKAT=1 + fi ;; + yes+*) + # Solaris 9 has *at functions, but uniformly mishandles trailing + # slash in all of them. + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS openat.$ac_objext" + + REPLACE_OPENAT=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS fstatat.$ac_objext" + + REPLACE_FSTATAT=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS unlinkat.$ac_objext" + + REPLACE_UNLINKAT=1 + ;; + *) + HAVE_OPENAT=0 + HAVE_UNLINKAT=0 # No known system with unlinkat but not openat + HAVE_FSTATAT=0 # No known system with fstatat but not openat + + + + : +;; + esac + if test $ac_cv_func_fchmodat != yes; then + HAVE_FCHMODAT=0 + fi + if test $ac_cv_func_mkdirat != yes; then + HAVE_MKDIRAT=0 + fi + + + ac_fn_c_check_func "$LINENO" "fchownat" "ac_cv_func_fchownat" +if test "x$ac_cv_func_fchownat" = x""yes; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fchownat works with AT_SYMLINK_NOFOLLOW" >&5 +$as_echo_n "checking whether fchownat works with AT_SYMLINK_NOFOLLOW... " >&6; } +if test "${gl_cv_func_fchownat_nofollow_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + gl_dangle=conftest.dangle + # Remove any remnants of a previous test. + rm -f $gl_dangle + # Arrange for deletion of the temporary file this test creates. + ac_clean_files="$ac_clean_files $gl_dangle" + ln -s conftest.no-such $gl_dangle + if test "$cross_compiling" = yes; then : + gl_cv_func_fchownat_nofollow_works=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include +#include +int +main () +{ + return (fchownat (AT_FDCWD, "$gl_dangle", -1, getgid (), + AT_SYMLINK_NOFOLLOW) != 0 + && errno == ENOENT); +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_fchownat_nofollow_works=yes +else + gl_cv_func_fchownat_nofollow_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fchownat_nofollow_works" >&5 +$as_echo "$gl_cv_func_fchownat_nofollow_works" >&6; } + if test $gl_cv_func_fchownat_nofollow_works = no; then : + REPLACE_FCHOWNAT=1 + +$as_echo "#define FCHOWNAT_NOFOLLOW_BUG 1" >>confdefs.h + +fi + +else + HAVE_FCHOWNAT=0 +fi + + if test $REPLACE_CHOWN = 1; then + REPLACE_FCHOWNAT=1 + fi + if test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS fchownat.$ac_objext" + + fi + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working fcntl.h" >&5 +$as_echo_n "checking for working fcntl.h... " >&6; } +if test "${gl_cv_header_working_fcntl_h+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + gl_cv_header_working_fcntl_h=cross-compiling +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + #include + #include + #ifndef O_NOATIME + #define O_NOATIME 0 + #endif + #ifndef O_NOFOLLOW + #define O_NOFOLLOW 0 + #endif + static int const constants[] = + { + O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND, + O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY + }; + +int +main () +{ + + int status = !constants; + { + static char const sym[] = "conftest.sym"; + if (symlink (".", sym) != 0 + || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0) + status |= 32; + unlink (sym); + } + { + static char const file[] = "confdefs.h"; + int fd = open (file, O_RDONLY | O_NOATIME); + char c; + struct stat st0, st1; + if (fd < 0 + || fstat (fd, &st0) != 0 + || sleep (1) != 0 + || read (fd, &c, 1) != 1 + || close (fd) != 0 + || stat (file, &st1) != 0 + || st0.st_atime != st1.st_atime) + status |= 64; + } + return status; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_header_working_fcntl_h=yes +else + case $? in #( + 32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #( + 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #( + 96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #( + *) gl_cv_header_working_fcntl_h='no';; + esac +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_working_fcntl_h" >&5 +$as_echo "$gl_cv_header_working_fcntl_h" >&6; } + + case $gl_cv_header_working_fcntl_h in #( + *O_NOATIME* | no | cross-compiling) ac_val=0;; #( + *) ac_val=1;; + esac + +cat >>confdefs.h <<_ACEOF +#define HAVE_WORKING_O_NOATIME $ac_val +_ACEOF + + + case $gl_cv_header_working_fcntl_h in #( + *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #( + *) ac_val=1;; + esac + +cat >>confdefs.h <<_ACEOF +#define HAVE_WORKING_O_NOFOLLOW $ac_val +_ACEOF + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for st_dm_mode in struct stat" >&5 $as_echo_n "checking for st_dm_mode in struct stat... " >&6; } if test "${ac_cv_struct_st_dm_mode+set}" = set; then : @@ -8273,6 +9343,20 @@ _ACEOF + + + + + + gl_LIBOBJS="$gl_LIBOBJS filenamecat-lgpl.$ac_objext" + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mbstate_t" >&5 $as_echo_n "checking for mbstate_t... " >&6; } if test "${ac_cv_type_mbstate_t+set}" = set; then : @@ -8281,7 +9365,7 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default -# include +# include int main () { @@ -8434,72 +9518,6 @@ $as_echo "$gl_cv_var_stdin_large_offset" >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether lstat dereferences a symlink specified with a trailing slash" >&5 -$as_echo_n "checking whether lstat dereferences a symlink specified with a trailing slash... " >&6; } -if test "${ac_cv_func_lstat_dereferences_slashed_symlink+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - rm -f conftest.sym conftest.file -echo >conftest.file -if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then - if test "$cross_compiling" = yes; then : - ac_cv_func_lstat_dereferences_slashed_symlink=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -struct stat sbuf; - /* Linux will dereference the symlink and fail. - That is better in the sense that it means we will not - have to compile and use the lstat wrapper. */ - return lstat ("conftest.sym/", &sbuf) == 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_lstat_dereferences_slashed_symlink=yes -else - ac_cv_func_lstat_dereferences_slashed_symlink=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -else - # If the `ln -s' command failed, then we probably don't even - # have an lstat function. - ac_cv_func_lstat_dereferences_slashed_symlink=no -fi -rm -f conftest.sym conftest.file - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_lstat_dereferences_slashed_symlink" >&5 -$as_echo "$ac_cv_func_lstat_dereferences_slashed_symlink" >&6; } - -test $ac_cv_func_lstat_dereferences_slashed_symlink = yes && - -cat >>confdefs.h <<_ACEOF -#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 -_ACEOF - - -if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then - - - - - - - - - gl_LIBOBJS="$gl_LIBOBJS lstat.$ac_objext" - -fi - @@ -8618,26 +9636,26 @@ if test "${gl_cv_next_sys_socket_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_sys_socket_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_sys_socket_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_sys_socket_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/sys/socket.h#{ - s#.*"\(.*/sys/socket.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_sys_socket_h='<'sys/socket.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_sys_socket_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/sys/socket.h#{ + s#.*"\(.*/sys/socket.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_sys_socket_h='<'sys/socket.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_socket_h" >&5 @@ -8782,6 +9800,7 @@ done + if test $gl_cv_have_include_next = yes; then gl_cv_next_netdb_h='<'netdb.h'>' else @@ -8791,26 +9810,26 @@ if test "${gl_cv_next_netdb_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_netdb_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_netdb_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_netdb_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/netdb.h#{ - s#.*"\(.*/netdb.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_netdb_h='<'netdb.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_netdb_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/netdb.h#{ + s#.*"\(.*/netdb.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_netdb_h='<'netdb.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_netdb_h" >&5 @@ -9185,6 +10204,123 @@ $as_echo "#define HAVE_IPV6 1" >>confdefs.h fi + + + + : + + + gl_save_LIBS=$LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing inet_ntop" >&5 +$as_echo_n "checking for library containing inet_ntop... " >&6; } +if test "${ac_cv_search_inet_ntop+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char inet_ntop (); +int +main () +{ +return inet_ntop (); + ; + return 0; +} +_ACEOF +for ac_lib in '' nsl; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_inet_ntop=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if test "${ac_cv_search_inet_ntop+set}" = set; then : + break +fi +done +if test "${ac_cv_search_inet_ntop+set}" = set; then : + +else + ac_cv_search_inet_ntop=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_inet_ntop" >&5 +$as_echo "$ac_cv_search_inet_ntop" >&6; } +ac_res=$ac_cv_search_inet_ntop +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +else + + + + + + + + + for ac_func in inet_ntop +do : + ac_fn_c_check_func "$LINENO" "inet_ntop" "ac_cv_func_inet_ntop" +if test "x$ac_cv_func_inet_ntop" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_INET_NTOP 1 +_ACEOF + +else + + gl_LIBOBJS="$gl_LIBOBJS $ac_func.$ac_objext" + +fi +done + + +fi + + LIBS=$gl_save_LIBS + INET_NTOP_LIB= + if test "$ac_cv_search_inet_ntop" != "no" && + test "$ac_cv_search_inet_ntop" != "none required"; then + INET_NTOP_LIB="$ac_cv_search_inet_ntop" + fi + + + + ac_fn_c_check_decl "$LINENO" "inet_ntop" "ac_cv_have_decl_inet_ntop" "#include +" +if test "x$ac_cv_have_decl_inet_ntop" = x""yes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_INET_NTOP $ac_have_decl +_ACEOF + + if test $ac_cv_have_decl_inet_ntop = no; then + HAVE_DECL_INET_NTOP=0 + fi + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getcwd (NULL, 0) allocates memory for result" >&5 $as_echo_n "checking whether getcwd (NULL, 0) allocates memory for result... " >&6; } if test "${gl_cv_func_getcwd_null+set}" = set; then : @@ -9207,10 +10343,10 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -# include -# ifndef getcwd - char *getcwd (); -# endif +# include +# ifndef getcwd + char *getcwd (); +# endif int main () @@ -9219,13 +10355,13 @@ main () #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* mingw cwd does not start with '/', but getcwd does allocate. */ #else - if (chdir ("/") != 0) - return 1; - else - { - char *f = getcwd (NULL, 0); - return ! (f && f[0] == '/' && !f[1]); - } + if (chdir ("/") != 0) + return 1; + else + { + char *f = getcwd (NULL, 0); + return ! (f && f[0] == '/' && !f[1]); + } #endif ; @@ -9264,76 +10400,76 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include - #ifndef bool - "error: bool is not defined" - #endif - #ifndef false - "error: false is not defined" - #endif - #if false - "error: false is not 0" - #endif - #ifndef true - "error: true is not defined" - #endif - #if true != 1 - "error: true is not 1" - #endif - #ifndef __bool_true_false_are_defined - "error: __bool_true_false_are_defined is not defined" - #endif + #include + #ifndef bool + "error: bool is not defined" + #endif + #ifndef false + "error: false is not defined" + #endif + #if false + "error: false is not 0" + #endif + #ifndef true + "error: true is not defined" + #endif + #if true != 1 + "error: true is not 1" + #endif + #ifndef __bool_true_false_are_defined + "error: __bool_true_false_are_defined is not defined" + #endif - struct s { _Bool s: 1; _Bool t; } s; + struct s { _Bool s: 1; _Bool t; } s; - char a[true == 1 ? 1 : -1]; - char b[false == 0 ? 1 : -1]; - char c[__bool_true_false_are_defined == 1 ? 1 : -1]; - char d[(bool) 0.5 == true ? 1 : -1]; - bool e = &s; - char f[(_Bool) 0.0 == false ? 1 : -1]; - char g[true]; - char h[sizeof (_Bool)]; - char i[sizeof s.t]; - enum { j = false, k = true, l = false * true, m = true * 256 }; - _Bool n[m]; - char o[sizeof n == m * sizeof n[0] ? 1 : -1]; - char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; - #if defined __xlc__ || defined __GNUC__ - /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 - reported by James Lemley on 2005-10-05; see - http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html - This test is not quite right, since xlc is allowed to - reject this program, as the initializer for xlcbug is - not one of the forms that C requires support for. - However, doing the test right would require a run-time - test, and that would make cross-compilation harder. - Let us hope that IBM fixes the xlc bug, and also adds - support for this kind of constant expression. In the - meantime, this test will reject xlc, which is OK, since - our stdbool.h substitute should suffice. We also test - this with GCC, where it should work, to detect more - quickly whether someone messes up the test in the - future. */ - char digs[] = "0123456789"; - int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1); - #endif - /* Catch a bug in an HP-UX C compiler. See - http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html - http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html - */ - _Bool q = true; - _Bool *pq = &q; + char a[true == 1 ? 1 : -1]; + char b[false == 0 ? 1 : -1]; + char c[__bool_true_false_are_defined == 1 ? 1 : -1]; + char d[(bool) 0.5 == true ? 1 : -1]; + bool e = &s; + char f[(_Bool) 0.0 == false ? 1 : -1]; + char g[true]; + char h[sizeof (_Bool)]; + char i[sizeof s.t]; + enum { j = false, k = true, l = false * true, m = true * 256 }; + _Bool n[m]; + char o[sizeof n == m * sizeof n[0] ? 1 : -1]; + char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; + #if defined __xlc__ || defined __GNUC__ + /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 + reported by James Lemley on 2005-10-05; see + http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html + This test is not quite right, since xlc is allowed to + reject this program, as the initializer for xlcbug is + not one of the forms that C requires support for. + However, doing the test right would require a run-time + test, and that would make cross-compilation harder. + Let us hope that IBM fixes the xlc bug, and also adds + support for this kind of constant expression. In the + meantime, this test will reject xlc, which is OK, since + our stdbool.h substitute should suffice. We also test + this with GCC, where it should work, to detect more + quickly whether someone messes up the test in the + future. */ + char digs[] = "0123456789"; + int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1); + #endif + /* Catch a bug in an HP-UX C compiler. See + http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html + http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html + */ + _Bool q = true; + _Bool *pq = &q; int main () { - *pq |= q; - *pq |= ! q; - /* Refer to every declared value, to avoid compiler optimizations. */ - return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l - + !m + !n + !o + !p + !q + !pq); + *pq |= q; + *pq |= ! q; + /* Refer to every declared value, to avoid compiler optimizations. */ + return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + + !m + !n + !o + !p + !q + !pq); ; return 0; @@ -9402,7 +10538,7 @@ int main () { struct s t = (struct s) { 3, 4 }; - if (t.i != 0) return 0; + if (t.i != 0) return 0; ; return 0; } @@ -9521,18 +10657,18 @@ else /* end confdefs.h. */ /* For now, do not test the preprocessor; as of 2007 there are too many - implementations with broken preprocessors. Perhaps this can - be revisited in 2012. In the meantime, code should not expect - #if to work with literals wider than 32 bits. */ + implementations with broken preprocessors. Perhaps this can + be revisited in 2012. In the meantime, code should not expect + #if to work with literals wider than 32 bits. */ /* Test literals. */ long long int ll = 9223372036854775807ll; long long int nll = -9223372036854775807LL; unsigned long long int ull = 18446744073709551615ULL; /* Test constant expressions. */ typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) - ? 1 : -1)]; + ? 1 : -1)]; typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1 - ? 1 : -1)]; + ? 1 : -1)]; int i = 63; int main () @@ -9541,40 +10677,40 @@ main () long long int llmax = 9223372036854775807ll; unsigned long long int ullmax = 18446744073709551615ull; return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) - | (llmax / ll) | (llmax % ll) - | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) - | (ullmax / ull) | (ullmax % ull)); + | (llmax / ll) | (llmax % ll) + | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) + | (ullmax / ull) | (ullmax % ull)); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - if test "$cross_compiling" = yes; then : + if test "$cross_compiling" = yes; then : ac_cv_type_long_long_int=yes else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include - #ifndef LLONG_MAX - # define HALF \ - (1LL << (sizeof (long long int) * CHAR_BIT - 2)) - # define LLONG_MAX (HALF - 1 + HALF) - #endif + #ifndef LLONG_MAX + # define HALF \ + (1LL << (sizeof (long long int) * CHAR_BIT - 2)) + # define LLONG_MAX (HALF - 1 + HALF) + #endif int main () { long long int n = 1; - int i; - for (i = 0; ; i++) - { - long long int m = n << i; - if (m >> i != n) - return 1; - if (LLONG_MAX / 2 < m) - break; - } - return 0; + int i; + for (i = 0; ; i++) + { + long long int m = n << i; + if (m >> i != n) + return 1; + if (LLONG_MAX / 2 < m) + break; + } + return 0; ; return 0; } @@ -9663,6 +10799,69 @@ $as_echo "#define ssize_t int" >>confdefs.h + + + + + + + + + if test $gl_cv_have_include_next = yes; then + gl_cv_next_getopt_h='<'getopt.h'>' + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 +$as_echo_n "checking absolute name of ... " >&6; } +if test "${gl_cv_next_getopt_h+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + if test $ac_cv_header_getopt_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_getopt_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/getopt.h#{ + s#.*"\(.*/getopt.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_getopt_h='<'getopt.h'>' + fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_getopt_h" >&5 +$as_echo "$gl_cv_next_getopt_h" >&6; } + fi + NEXT_GETOPT_H=$gl_cv_next_getopt_h + + if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' + gl_next_as_first_directive='<'getopt.h'>' + else + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' + gl_next_as_first_directive=$gl_cv_next_getopt_h + fi + NEXT_AS_FIRST_DIRECTIVE_GETOPT_H=$gl_next_as_first_directive + + + + + if test $ac_cv_header_getopt_h = yes; then + HAVE_GETOPT_H=1 + else + HAVE_GETOPT_H=0 + fi + + gl_replace_getopt= if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then @@ -9698,16 +10897,22 @@ done fi - if false && test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then + if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then ac_fn_c_check_decl "$LINENO" "optreset" "ac_cv_have_decl_optreset" "#include " if test "x$ac_cv_have_decl_optreset" = x""yes; then : - gl_replace_getopt=yes + ac_have_decl=1 +else + ac_have_decl=0 fi +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_OPTRESET $ac_have_decl +_ACEOF + fi - if test -z "$gl_replace_getopt"; then + if test -z "$gl_replace_getopt"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getopt is POSIX compatible" >&5 $as_echo_n "checking whether getopt is POSIX compatible... " >&6; } if test "${gl_cv_func_getopt_posix+set}" = set; then : @@ -9728,9 +10933,7 @@ else #include #include -/* The glibc implementation of getopt supports setting optind = 0 as a means - of clearing the internal state, but other implementations don't. */ -#if (__GLIBC__ >= 2) +#if !HAVE_DECL_OPTRESET # define OPTIND_MIN 0 #else # define OPTIND_MIN 1 @@ -9748,6 +10951,7 @@ main () argv[argc++] = "-a"; argv[argc++] = "foo"; argv[argc++] = "bar"; + argv[argc] = NULL; optind = OPTIND_MIN; opterr = 0; @@ -9773,6 +10977,7 @@ main () argv[argc++] = "duck"; argv[argc++] = "-a"; argv[argc++] = "bar"; + argv[argc] = NULL; optind = OPTIND_MIN; opterr = 0; @@ -9825,18 +11030,27 @@ $as_echo_n "checking for working GNU getopt function... " >&6; } if test "${gl_cv_func_getopt_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test "$cross_compiling" = yes; then : - case "$host_os" in - *-gnu* | mingw*) gl_cv_func_getopt_gnu=no;; - *) gl_cv_func_getopt_gnu=yes;; + # Even with POSIXLY_CORRECT, the GNU extension of leading '-' in the + # optstring is necessary for programs like m4 that have POSIX-mandated + # semantics for supporting options interspersed with files. + # Also, since getopt_long is a GNU extension, we require optind=0. + gl_had_POSIXLY_CORRECT=${POSIXLY_CORRECT:+yes} + POSIXLY_CORRECT=1 + export POSIXLY_CORRECT + if test "$cross_compiling" = yes; then : + case $host_os:$ac_cv_have_decl_optreset in + *-gnu*:* | mingw*:*) gl_cv_func_getopt_gnu=no;; + *:yes) gl_cv_func_getopt_gnu=no;; + *) gl_cv_func_getopt_gnu=yes;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include - #include - #include + #include + #include + int main () { @@ -9855,9 +11069,9 @@ main () } /* This code succeeds on glibc 2.8, mingw, and fails on MacOS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11, - IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin. */ + IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x. */ { - char *argv[] = { "program", "-p", "foo", "bar" }; + char *argv[] = { "program", "-p", "foo", "bar", NULL }; optind = 1; if (getopt (4, argv, "p::") != 'p') @@ -9869,6 +11083,15 @@ main () if (optind != 2) return 5; } + /* This code succeeds on glibc 2.8 and fails on Cygwin 1.7.0. */ + { + char *argv[] = { "program", "foo", "-p", NULL }; + optind = 0; + if (getopt (3, argv, "-p") != 1) + return 6; + if (getopt (3, argv, "-p") != 'p') + return 7; + } return 0; ; @@ -9884,6 +11107,9 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi + if test "$gl_had_POSIXLY_CORRECT" != yes; then + { POSIXLY_CORRECT=; unset POSIXLY_CORRECT;} + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getopt_gnu" >&5 @@ -10036,6 +11262,7 @@ _ACEOF + if test $gl_cv_have_include_next = yes; then gl_cv_next_sys_time_h='<'sys/time.h'>' else @@ -10045,26 +11272,26 @@ if test "${gl_cv_next_sys_time_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_sys_time_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_sys_time_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_sys_time_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/sys/time.h#{ - s#.*"\(.*/sys/time.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_sys_time_h='<'sys/time.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_sys_time_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/sys/time.h#{ + s#.*"\(.*/sys/time.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_sys_time_h='<'sys/time.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_time_h" >&5 @@ -10099,9 +11326,9 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if HAVE_SYS_TIME_H - #include - #endif - #include + #include + #endif + #include int main () @@ -10140,6 +11367,8 @@ $as_echo "$gl_cv_sys_struct_timeval" >&6; } + + if test "X$prefix" = "XNONE"; then acl_final_prefix="$ac_default_prefix" else @@ -10195,7 +11424,7 @@ $as_echo_n "checking for ld used by GCC... " >&6; } # Canonicalize the path of ld ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do - ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; @@ -10229,9 +11458,9 @@ else # Break only if it was the GNU/non-GNU ld that we prefer. case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in *GNU* | *'with BFD'*) - test "$with_gnu_ld" != no && break ;; + test "$with_gnu_ld" != no && break ;; *) - test "$with_gnu_ld" != yes && break ;; + test "$with_gnu_ld" != yes && break ;; esac fi done @@ -10860,18 +12089,18 @@ else /* end confdefs.h. */ /* For now, do not test the preprocessor; as of 2007 there are too many - implementations with broken preprocessors. Perhaps this can - be revisited in 2012. In the meantime, code should not expect - #if to work with literals wider than 32 bits. */ + implementations with broken preprocessors. Perhaps this can + be revisited in 2012. In the meantime, code should not expect + #if to work with literals wider than 32 bits. */ /* Test literals. */ long long int ll = 9223372036854775807ll; long long int nll = -9223372036854775807LL; unsigned long long int ull = 18446744073709551615ULL; /* Test constant expressions. */ typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) - ? 1 : -1)]; + ? 1 : -1)]; typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1 - ? 1 : -1)]; + ? 1 : -1)]; int i = 63; int main () @@ -10880,9 +12109,9 @@ main () long long int llmax = 9223372036854775807ll; unsigned long long int ullmax = 18446744073709551615ull; return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) - | (llmax / ll) | (llmax % ll) - | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) - | (ullmax / ull) | (ullmax % ull)); + | (llmax / ll) | (llmax % ll) + | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) + | (ullmax / ull) | (ullmax % ull)); ; return 0; } @@ -10999,26 +12228,26 @@ if test "${gl_cv_next_stdint_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_stdint_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_stdint_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_stdint_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/stdint.h#{ - s#.*"\(.*/stdint.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_stdint_h='<'stdint.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_stdint_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/stdint.h#{ + s#.*"\(.*/stdint.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_stdint_h='<'stdint.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stdint_h" >&5 @@ -11512,12 +12741,12 @@ else for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do case $glsuf in '') gltype1='int';; - l) gltype1='long int';; - ll) gltype1='long long int';; - i64) gltype1='__int64';; - u) gltype1='unsigned int';; - ul) gltype1='unsigned long int';; - ull) gltype1='unsigned long long int';; + l) gltype1='long int';; + ll) gltype1='long long int';; + i64) gltype1='__int64';; + u) gltype1='unsigned int';; + ul) gltype1='unsigned long int';; + ull) gltype1='unsigned long long int';; ui64)gltype1='unsigned __int64';; esac cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -11584,12 +12813,12 @@ else for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do case $glsuf in '') gltype1='int';; - l) gltype1='long int';; - ll) gltype1='long long int';; - i64) gltype1='__int64';; - u) gltype1='unsigned int';; - ul) gltype1='unsigned long int';; - ull) gltype1='unsigned long long int';; + l) gltype1='long int';; + ll) gltype1='long long int';; + i64) gltype1='__int64';; + u) gltype1='unsigned int';; + ul) gltype1='unsigned long int';; + ull) gltype1='unsigned long long int';; ui64)gltype1='unsigned __int64';; esac cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -11700,6 +12929,8 @@ _ACEOF fi + + ac_fn_c_check_decl "$LINENO" "imaxabs" "ac_cv_have_decl_imaxabs" "$ac_includes_default" if test "x$ac_cv_have_decl_imaxabs" = x""yes; then : ac_have_decl=1 @@ -11755,8 +12986,6 @@ _ACEOF HAVE_DECL_STRTOUMAX=1; - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the exponent in a 'float'" >&5 $as_echo_n "checking where to find the exponent in a 'float'... " >&6; } if test "${gl_cv_cc_float_expbit0+set}" = set; then : @@ -11866,6 +13095,17 @@ _ACEOF esac + GNULIB_NL_LANGINFO=0; + HAVE_NL_LANGINFO=1; + REPLACE_NL_LANGINFO=0; + + + + + + + + @@ -11915,6 +13155,1005 @@ $as_echo "$ac_cv_gnu_library_2_1" >&6; } + GNULIB_DUPLOCALE=0; + REPLACE_DUPLOCALE=0; + + + REPLACE_NULL=0; + HAVE_WCHAR_T=1; + STDDEF_H=''; + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wchar_t" >&5 +$as_echo_n "checking for wchar_t... " >&6; } +if test "${gt_cv_c_wchar_t+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + wchar_t foo = (wchar_t)'\0'; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gt_cv_c_wchar_t=yes +else + gt_cv_c_wchar_t=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_c_wchar_t" >&5 +$as_echo "$gt_cv_c_wchar_t" >&6; } + if test $gt_cv_c_wchar_t = yes; then + +$as_echo "#define HAVE_WCHAR_T 1" >>confdefs.h + + fi + + + + + + + if test $gt_cv_c_wchar_t = no; then + HAVE_WCHAR_T=0 + STDDEF_H=stddef.h + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether NULL can be used in arbitrary expressions" >&5 +$as_echo_n "checking whether NULL can be used in arbitrary expressions... " >&6; } +if test "${gl_cv_decl_null_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + int test[2 * (sizeof NULL == sizeof (void *)) -1]; + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_decl_null_works=yes +else + gl_cv_decl_null_works=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_decl_null_works" >&5 +$as_echo "$gl_cv_decl_null_works" >&6; } + if test $gl_cv_decl_null_works = no; then + REPLACE_NULL=1 + STDDEF_H=stddef.h + fi + if test -n "$STDDEF_H"; then + + + + + + + if test $gl_cv_have_include_next = yes; then + gl_cv_next_stddef_h='<'stddef.h'>' + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 +$as_echo_n "checking absolute name of ... " >&6; } +if test "${gl_cv_next_stddef_h+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + if test $ac_cv_header_stddef_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_stddef_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/stddef.h#{ + s#.*"\(.*/stddef.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_stddef_h='<'stddef.h'>' + fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stddef_h" >&5 +$as_echo "$gl_cv_next_stddef_h" >&6; } + fi + NEXT_STDDEF_H=$gl_cv_next_stddef_h + + if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' + gl_next_as_first_directive='<'stddef.h'>' + else + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' + gl_next_as_first_directive=$gl_cv_next_stddef_h + fi + NEXT_AS_FIRST_DIRECTIVE_STDDEF_H=$gl_next_as_first_directive + + + + fi + + + + + + + + gl_threads_api=none + LIBTHREAD= + LTLIBTHREAD= + LIBMULTITHREAD= + LTLIBMULTITHREAD= + if test "$gl_use_threads" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether imported symbols can be declared weak" >&5 +$as_echo_n "checking whether imported symbols can be declared weak... " >&6; } + gl_have_weak=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +extern void xyzzy (); +#pragma weak xyzzy +int +main () +{ +xyzzy(); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + gl_have_weak=yes +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_have_weak" >&5 +$as_echo "$gl_have_weak" >&6; } + if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then + # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that + # it groks . It's added above, in gl_THREADLIB_EARLY_BODY. + ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" +if test "x$ac_cv_header_pthread_h" = x""yes; then : + gl_have_pthread_h=yes +else + gl_have_pthread_h=no +fi + + + if test "$gl_have_pthread_h" = yes; then + # Other possible tests: + # -lpthreads (FSU threads, PCthreads) + # -lgthreads + gl_have_pthread= + # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist + # in libc. IRIX 6.5 has the first one in both libc and libpthread, but + # the second one only in libpthread, and lock.c needs it. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +pthread_mutex_lock((pthread_mutex_t*)0); + pthread_mutexattr_init((pthread_mutexattr_t*)0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + gl_have_pthread=yes +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + # Test for libpthread by looking for pthread_kill. (Not pthread_self, + # since it is defined as a macro on OSF/1.) + if test -n "$gl_have_pthread"; then + # The program links fine without libpthread. But it may actually + # need to link with libpthread in order to create multiple threads. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_kill in -lpthread" >&5 +$as_echo_n "checking for pthread_kill in -lpthread... " >&6; } +if test "${ac_cv_lib_pthread_pthread_kill+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpthread $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_kill (); +int +main () +{ +return pthread_kill (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_pthread_pthread_kill=yes +else + ac_cv_lib_pthread_pthread_kill=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_kill" >&5 +$as_echo "$ac_cv_lib_pthread_pthread_kill" >&6; } +if test "x$ac_cv_lib_pthread_pthread_kill" = x""yes; then : + LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread + # On Solaris and HP-UX, most pthread functions exist also in libc. + # Therefore pthread_in_use() needs to actually try to create a + # thread: pthread_create from libc will fail, whereas + # pthread_create will actually create a thread. + case "$host_os" in + solaris* | hpux*) + +$as_echo "#define PTHREAD_IN_USE_DETECTION_HARD 1" >>confdefs.h + + esac + +fi + + else + # Some library is needed. Try libpthread and libc_r. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_kill in -lpthread" >&5 +$as_echo_n "checking for pthread_kill in -lpthread... " >&6; } +if test "${ac_cv_lib_pthread_pthread_kill+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpthread $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_kill (); +int +main () +{ +return pthread_kill (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_pthread_pthread_kill=yes +else + ac_cv_lib_pthread_pthread_kill=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_kill" >&5 +$as_echo "$ac_cv_lib_pthread_pthread_kill" >&6; } +if test "x$ac_cv_lib_pthread_pthread_kill" = x""yes; then : + gl_have_pthread=yes + LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread + LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread +fi + + if test -z "$gl_have_pthread"; then + # For FreeBSD 4. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_kill in -lc_r" >&5 +$as_echo_n "checking for pthread_kill in -lc_r... " >&6; } +if test "${ac_cv_lib_c_r_pthread_kill+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lc_r $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_kill (); +int +main () +{ +return pthread_kill (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_c_r_pthread_kill=yes +else + ac_cv_lib_c_r_pthread_kill=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_r_pthread_kill" >&5 +$as_echo "$ac_cv_lib_c_r_pthread_kill" >&6; } +if test "x$ac_cv_lib_c_r_pthread_kill" = x""yes; then : + gl_have_pthread=yes + LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r + LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r +fi + + fi + fi + if test -n "$gl_have_pthread"; then + gl_threads_api=posix + +$as_echo "#define USE_POSIX_THREADS 1" >>confdefs.h + + if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then + if test $gl_have_weak = yes; then + +$as_echo "#define USE_POSIX_THREADS_WEAK 1" >>confdefs.h + + LIBTHREAD= + LTLIBTHREAD= + fi + fi + fi + fi + fi + if test -z "$gl_have_pthread"; then + if test "$gl_use_threads" = yes || test "$gl_use_threads" = solaris; then + gl_have_solaristhread= + gl_save_LIBS="$LIBS" + LIBS="$LIBS -lthread" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +int +main () +{ +thr_self(); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + gl_have_solaristhread=yes +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS="$gl_save_LIBS" + if test -n "$gl_have_solaristhread"; then + gl_threads_api=solaris + LIBTHREAD=-lthread + LTLIBTHREAD=-lthread + LIBMULTITHREAD="$LIBTHREAD" + LTLIBMULTITHREAD="$LTLIBTHREAD" + +$as_echo "#define USE_SOLARIS_THREADS 1" >>confdefs.h + + if test $gl_have_weak = yes; then + +$as_echo "#define USE_SOLARIS_THREADS_WEAK 1" >>confdefs.h + + LIBTHREAD= + LTLIBTHREAD= + fi + fi + fi + fi + if test "$gl_use_threads" = pth; then + gl_save_CPPFLAGS="$CPPFLAGS" + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libpth" >&5 +$as_echo_n "checking how to link with libpth... " >&6; } +if test "${ac_cv_libpth_libs+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + + + + + + + + use_additional=yes + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + +# Check whether --with-libpth-prefix was given. +if test "${with_libpth_prefix+set}" = set; then : + withval=$with_libpth_prefix; + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + else + additional_includedir="$withval/include" + additional_libdir="$withval/$acl_libdirstem" + if test "$acl_libdirstem2" != "$acl_libdirstem" \ + && ! test -d "$withval/$acl_libdirstem"; then + additional_libdir="$withval/$acl_libdirstem2" + fi + fi + fi + +fi + + LIBPTH= + LTLIBPTH= + INCPTH= + LIBPTH_PREFIX= + HAVE_LIBPTH= + rpathdirs= + ltrpathdirs= + names_already_handled= + names_next_round='pth ' + while test -n "$names_next_round"; do + names_this_round="$names_next_round" + names_next_round= + for name in $names_this_round; do + already_handled= + for n in $names_already_handled; do + if test "$n" = "$name"; then + already_handled=yes + break + fi + done + if test -z "$already_handled"; then + names_already_handled="$names_already_handled $name" + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` + eval value=\"\$HAVE_LIB$uppername\" + if test -n "$value"; then + if test "$value" = yes; then + eval value=\"\$LIB$uppername\" + test -z "$value" || LIBPTH="${LIBPTH}${LIBPTH:+ }$value" + eval value=\"\$LTLIB$uppername\" + test -z "$value" || LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }$value" + else + : + fi + else + found_dir= + found_la= + found_so= + found_a= + eval libname=\"$acl_libname_spec\" # typically: libname=lib$name + if test -n "$acl_shlibext"; then + shrext=".$acl_shlibext" # typically: shrext=.so + else + shrext= + fi + if test $use_additional = yes; then + dir="$additional_libdir" + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi + fi + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext"; then + found_dir="$dir" + found_a="$dir/$libname.$acl_libext" + fi + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi + fi + if test "X$found_dir" = "X"; then + for x in $LDFLAGS $LTLIBPTH; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi + fi + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext"; then + found_dir="$dir" + found_a="$dir/$libname.$acl_libext" + fi + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi + ;; + esac + if test "X$found_dir" != "X"; then + break + fi + done + fi + if test "X$found_dir" != "X"; then + LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }-L$found_dir -l$name" + if test "X$found_so" != "X"; then + if test "$enable_rpath" = no \ + || test "X$found_dir" = "X/usr/$acl_libdirstem" \ + || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then + LIBPTH="${LIBPTH}${LIBPTH:+ }$found_so" + else + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $found_dir" + fi + if test "$acl_hardcode_direct" = yes; then + LIBPTH="${LIBPTH}${LIBPTH:+ }$found_so" + else + if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then + LIBPTH="${LIBPTH}${LIBPTH:+ }$found_so" + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $found_dir" + fi + else + haveit= + for x in $LDFLAGS $LIBPTH; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + LIBPTH="${LIBPTH}${LIBPTH:+ }-L$found_dir" + fi + if test "$acl_hardcode_minus_L" != no; then + LIBPTH="${LIBPTH}${LIBPTH:+ }$found_so" + else + LIBPTH="${LIBPTH}${LIBPTH:+ }-l$name" + fi + fi + fi + fi + else + if test "X$found_a" != "X"; then + LIBPTH="${LIBPTH}${LIBPTH:+ }$found_a" + else + LIBPTH="${LIBPTH}${LIBPTH:+ }-L$found_dir -l$name" + fi + fi + additional_includedir= + case "$found_dir" in + */$acl_libdirstem | */$acl_libdirstem/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` + if test "$name" = 'pth'; then + LIBPTH_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; + */$acl_libdirstem2 | */$acl_libdirstem2/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` + if test "$name" = 'pth'; then + LIBPTH_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; + esac + if test "X$additional_includedir" != "X"; then + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + for x in $CPPFLAGS $INCPTH; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + INCPTH="${INCPTH}${INCPTH:+ }-I$additional_includedir" + fi + fi + fi + fi + fi + if test -n "$found_la"; then + save_libdir="$libdir" + case "$found_la" in + */* | *\\*) . "$found_la" ;; + *) . "./$found_la" ;; + esac + libdir="$save_libdir" + for dep in $dependency_libs; do + case "$dep" in + -L*) + additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` + if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ + && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then + haveit= + if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ + || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + haveit= + for x in $LDFLAGS $LIBPTH; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + LIBPTH="${LIBPTH}${LIBPTH:+ }-L$additional_libdir" + fi + fi + haveit= + for x in $LDFLAGS $LTLIBPTH; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }-L$additional_libdir" + fi + fi + fi + fi + ;; + -R*) + dir=`echo "X$dep" | sed -e 's/^X-R//'` + if test "$enable_rpath" != no; then + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $dir" + fi + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $dir" + fi + fi + ;; + -l*) + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` + ;; + *.la) + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` + ;; + *) + LIBPTH="${LIBPTH}${LIBPTH:+ }$dep" + LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }$dep" + ;; + esac + done + fi + else + LIBPTH="${LIBPTH}${LIBPTH:+ }-l$name" + LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }-l$name" + fi + fi + fi + done + done + if test "X$rpathdirs" != "X"; then + if test -n "$acl_hardcode_libdir_separator"; then + alldirs= + for found_dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" + done + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIBPTH="${LIBPTH}${LIBPTH:+ }$flag" + else + for found_dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$found_dir" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIBPTH="${LIBPTH}${LIBPTH:+ }$flag" + done + fi + fi + if test "X$ltrpathdirs" != "X"; then + for found_dir in $ltrpathdirs; do + LTLIBPTH="${LTLIBPTH}${LTLIBPTH:+ }-R$found_dir" + done + fi + + + + + + + ac_cv_libpth_libs="$LIBPTH" + ac_cv_libpth_ltlibs="$LTLIBPTH" + ac_cv_libpth_cppflags="$INCPTH" + ac_cv_libpth_prefix="$LIBPTH_PREFIX" + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libpth_libs" >&5 +$as_echo "$ac_cv_libpth_libs" >&6; } + LIBPTH="$ac_cv_libpth_libs" + LTLIBPTH="$ac_cv_libpth_ltlibs" + INCPTH="$ac_cv_libpth_cppflags" + LIBPTH_PREFIX="$ac_cv_libpth_prefix" + + for element in $INCPTH; do + haveit= + for x in $CPPFLAGS; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" + fi + done + + + + + HAVE_LIBPTH=yes + + + + gl_have_pth= + gl_save_LIBS="$LIBS" + LIBS="$LIBS -lpth" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +pth_self(); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + gl_have_pth=yes +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS="$gl_save_LIBS" + if test -n "$gl_have_pth"; then + gl_threads_api=pth + LIBTHREAD="$LIBPTH" + LTLIBTHREAD="$LTLIBPTH" + LIBMULTITHREAD="$LIBTHREAD" + LTLIBMULTITHREAD="$LTLIBTHREAD" + +$as_echo "#define USE_PTH_THREADS 1" >>confdefs.h + + if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then + if test $gl_have_weak = yes; then + +$as_echo "#define USE_PTH_THREADS_WEAK 1" >>confdefs.h + + LIBTHREAD= + LTLIBTHREAD= + fi + fi + else + CPPFLAGS="$gl_save_CPPFLAGS" + fi + fi + if test -z "$gl_have_pthread"; then + if test "$gl_use_threads" = yes || test "$gl_use_threads" = win32; then + if { case "$host_os" in + mingw*) true;; + *) false;; + esac + }; then + gl_threads_api=win32 + +$as_echo "#define USE_WIN32_THREADS 1" >>confdefs.h + + fi + fi + fi + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for multithread API to use" >&5 +$as_echo_n "checking for multithread API to use... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_threads_api" >&5 +$as_echo "$gl_threads_api" >&6; } + + + + + + + + + + for ac_header in stdlib.h @@ -12463,8 +14702,7 @@ $as_echo "$gl_cv_func_mbrtowc_sanitycheck" >&6; } fi if test $REPLACE_MBSTATE_T = 1; then - - WCHAR_H=wchar.h + : fi @@ -12692,8 +14930,7 @@ $as_echo "#define MBRTOWC_NUL_RETVAL_BUG 1" >>confdefs.h fi if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then - - WCHAR_H=wchar.h + : @@ -12746,6 +14983,7 @@ $as_echo "#define MBRTOWC_NUL_RETVAL_BUG 1" >>confdefs.h GNULIB_STRERROR=0; GNULIB_STRSIGNAL=0; GNULIB_STRVERSCMP=0; + HAVE_MBSLEN=0; HAVE_DECL_MEMMEM=1; HAVE_MEMPCPY=1; HAVE_DECL_MEMRCHR=1; @@ -12787,6 +15025,8 @@ $as_echo "#define MBRTOWC_NUL_RETVAL_BUG 1" >>confdefs.h + + # Check for mmap(). Don't use AC_FUNC_MMAP, because it checks too much: it # fails on HP-UX 11, because MAP_FIXED mappings do not work. But this is # irrelevant for anonymous mappings. @@ -12940,11 +15180,11 @@ main () { int pagesize = getpagesize (); char *two_pages = - (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE, - flags, fd, 0); + (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE, + flags, fd, 0); if (two_pages != (char *)(-1) - && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0) - fence = two_pages + pagesize; + && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0) + fence = two_pages + pagesize; } #endif if (fence) @@ -13017,6 +15257,8 @@ _ACEOF + + # Check whether --enable-largefile was given. if test "${enable_largefile+set}" = set; then : enableval=$enable_largefile; @@ -13227,128 +15469,14 @@ fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for external symbol _system_configuration" >&5 -$as_echo_n "checking for external symbol _system_configuration... " >&6; } -if test "${gl_cv_var__system_configuration+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -int -main () -{ -double x = _system_configuration.physmem; - if (x > 0.0) return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - gl_cv_var__system_configuration=yes -else - gl_cv_var__system_configuration=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_var__system_configuration" >&5 -$as_echo "$gl_cv_var__system_configuration" >&6; } - - if test $gl_cv_var__system_configuration = yes; then - -$as_echo "#define HAVE__SYSTEM_CONFIGURATION 1" >>confdefs.h - - fi - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for desired default level of POSIX conformance" >&5 -$as_echo_n "checking for desired default level of POSIX conformance... " >&6; } - gl_default_posix2_version=none-specified - if test -n "$ac_cv_env_DEFAULT_POSIX2_VERSION_set"; then - gl_default_posix2_version=$ac_cv_env_DEFAULT_POSIX2_VERSION_value - -cat >>confdefs.h <<_ACEOF -#define DEFAULT_POSIX2_VERSION $gl_default_posix2_version -_ACEOF - - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_default_posix2_version" >&5 -$as_echo "$gl_default_posix2_version" >&6; } - - - - - - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether lstat accepts an empty string" >&5 -$as_echo_n "checking whether lstat accepts an empty string... " >&6; } -if test "${ac_cv_func_lstat_empty_string_bug+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_func_lstat_empty_string_bug=yes -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -struct stat sbuf; - return lstat ("", &sbuf) == 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_lstat_empty_string_bug=no -else - ac_cv_func_lstat_empty_string_bug=yes -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_lstat_empty_string_bug" >&5 -$as_echo "$ac_cv_func_lstat_empty_string_bug" >&6; } -if test $ac_cv_func_lstat_empty_string_bug = yes; then - - - - - - - - - gl_LIBOBJS="$gl_LIBOBJS lstat.$ac_objext" - - -cat >>confdefs.h <<_ACEOF -#define HAVE_LSTAT_EMPTY_STRING_BUG 1 -_ACEOF - -fi - - GNULIB_SELECT=0; REPLACE_SELECT=0; + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether is self-contained" >&5 $as_echo_n "checking whether is self-contained... " >&6; } if test "${gl_cv_header_sys_select_h_selfcontained+set}" = set; then : @@ -13422,10 +15550,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_sys_select_h_selfcontained" >&5 $as_echo "$gl_cv_header_sys_select_h_selfcontained" >&6; } - if test $gl_cv_header_sys_select_h_selfcontained = yes; then - SYS_SELECT_H='' - else - SYS_SELECT_H='sys/select.h' + @@ -13441,26 +15566,26 @@ if test "${gl_cv_next_sys_select_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_sys_select_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_sys_select_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_sys_select_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/sys/select.h#{ - s#.*"\(.*/sys/select.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_sys_select_h='<'sys/select.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_sys_select_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/sys/select.h#{ + s#.*"\(.*/sys/select.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_sys_select_h='<'sys/select.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_select_h" >&5 @@ -13479,12 +15604,13 @@ $as_echo "$gl_cv_next_sys_select_h" >&6; } - if test $ac_cv_header_sys_select_h = yes; then - HAVE_SYS_SELECT_H=1 - else - HAVE_SYS_SELECT_H=0 - fi + if test $ac_cv_header_sys_select_h = yes; then + HAVE_SYS_SELECT_H=1 + else + HAVE_SYS_SELECT_H=0 + fi + if test $gl_cv_header_sys_select_h_selfcontained != yes; then @@ -13518,6 +15644,483 @@ done + + + + if test $ac_cv_header_sys_socket_h != yes; then + for ac_header in winsock2.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "winsock2.h" "ac_cv_header_winsock2_h" "$ac_includes_default" +if test "x$ac_cv_header_winsock2_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_WINSOCK2_H 1 +_ACEOF + +fi + +done + + fi + if test "$ac_cv_header_winsock2_h" = yes; then + HAVE_WINSOCK2_H=1 + UNISTD_H_HAVE_WINSOCK2_H=1 + SYS_IOCTL_H_HAVE_WINSOCK2_H=1 + else + HAVE_WINSOCK2_H=0 + fi + + LIBSOCKET= + if test $HAVE_WINSOCK2_H = 1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we need to call WSAStartup in winsock2.h and -lws2_32" >&5 +$as_echo_n "checking if we need to call WSAStartup in winsock2.h and -lws2_32... " >&6; } +if test "${gl_cv_func_wsastartup+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + gl_save_LIBS="$LIBS" + LIBS="$LIBS -lws2_32" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef HAVE_WINSOCK2_H +# include +#endif +int +main () +{ + + WORD wVersionRequested = MAKEWORD(1, 1); + WSADATA wsaData; + int err = WSAStartup(wVersionRequested, &wsaData); + WSACleanup (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + gl_cv_func_wsastartup=yes +else + gl_cv_func_wsastartup=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS="$gl_save_LIBS" + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_wsastartup" >&5 +$as_echo "$gl_cv_func_wsastartup" >&6; } + if test "$gl_cv_func_wsastartup" = "yes"; then + +$as_echo "#define WINDOWS_SOCKETS 1" >>confdefs.h + + LIBSOCKET='-lws2_32' + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing setsockopt" >&5 +$as_echo_n "checking for library containing setsockopt... " >&6; } +if test "${gl_cv_lib_socket+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + gl_cv_lib_socket= + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +extern +#ifdef __cplusplus +"C" +#endif +char setsockopt(); +int +main () +{ +setsockopt(); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + +else + gl_save_LIBS="$LIBS" + LIBS="$gl_save_LIBS -lsocket" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +extern +#ifdef __cplusplus +"C" +#endif +char setsockopt(); +int +main () +{ +setsockopt(); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + gl_cv_lib_socket="-lsocket" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test -z "$gl_cv_lib_socket"; then + LIBS="$gl_save_LIBS -lnetwork" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +extern +#ifdef __cplusplus +"C" +#endif +char setsockopt(); +int +main () +{ +setsockopt(); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + gl_cv_lib_socket="-lnetwork" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test -z "$gl_cv_lib_socket"; then + LIBS="$gl_save_LIBS -lnet" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +extern +#ifdef __cplusplus +"C" +#endif +char setsockopt(); +int +main () +{ +setsockopt(); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + gl_cv_lib_socket="-lnet" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + fi + fi + LIBS="$gl_save_LIBS" + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test -z "$gl_cv_lib_socket"; then + gl_cv_lib_socket="none needed" + fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_lib_socket" >&5 +$as_echo "$gl_cv_lib_socket" >&6; } + if test "$gl_cv_lib_socket" != "none needed"; then + LIBSOCKET="$gl_cv_lib_socket" + fi + fi + + + : + + + + + + if test "$ac_cv_header_winsock2_h" = yes; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS select.$ac_objext" + + else + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether select supports a 0 argument" >&5 +$as_echo_n "checking whether select supports a 0 argument... " >&6; } +if test "${gl_cv_func_select_supports0+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + if test "$cross_compiling" = yes; then : + + case "$host_os" in + # Guess no on Interix. + interix*) gl_cv_func_select_supports0="guessing no";; + # Guess yes otherwise. + *) gl_cv_func_select_supports0="guessing yes";; + esac + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#if HAVE_SYS_SELECT_H +#include +#endif +int main () +{ + struct timeval timeout; + timeout.tv_sec = 0; + timeout.tv_usec = 5; + return select (0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &timeout) < 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_select_supports0=yes +else + gl_cv_func_select_supports0=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_select_supports0" >&5 +$as_echo "$gl_cv_func_select_supports0" >&6; } + case "$gl_cv_func_select_supports0" in + *yes) ;; + *) + REPLACE_SELECT=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS select.$ac_objext" + + ;; + esac + fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for external symbol _system_configuration" >&5 +$as_echo_n "checking for external symbol _system_configuration... " >&6; } +if test "${gl_cv_var__system_configuration+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +double x = _system_configuration.physmem; + if (x > 0.0) return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + gl_cv_var__system_configuration=yes +else + gl_cv_var__system_configuration=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_var__system_configuration" >&5 +$as_echo "$gl_cv_var__system_configuration" >&6; } + + if test $gl_cv_var__system_configuration = yes; then + +$as_echo "#define HAVE__SYSTEM_CONFIGURATION 1" >>confdefs.h + + fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for desired default level of POSIX conformance" >&5 +$as_echo_n "checking for desired default level of POSIX conformance... " >&6; } + gl_default_posix2_version=none-specified + if test -n "$ac_cv_env_DEFAULT_POSIX2_VERSION_set"; then + gl_default_posix2_version=$ac_cv_env_DEFAULT_POSIX2_VERSION_value + +cat >>confdefs.h <<_ACEOF +#define DEFAULT_POSIX2_VERSION $gl_default_posix2_version +_ACEOF + + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_default_posix2_version" >&5 +$as_echo "$gl_default_posix2_version" >&6; } + + + + + + + + + + + + + + + + + + + + + + + + for ac_func in rmdir +do : + ac_fn_c_check_func "$LINENO" "rmdir" "ac_cv_func_rmdir" +if test "x$ac_cv_func_rmdir" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_RMDIR 1 +_ACEOF + +else + + gl_LIBOBJS="$gl_LIBOBJS $ac_func.$ac_objext" + +fi +done + + + if test $ac_cv_func_rmdir = no; then + REPLACE_RMDIR=1 + # If someone lacks rmdir, make configure fail, and request + # a bug report to inform us about it. + if test x"$SKIP_RMDIR_CHECK" != xyes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "Your system lacks the rmdir function. + Please report this, along with the output of \"uname -a\", to the + bug-coreutils@gnu.org mailing list. To continue past this point, + rerun configure with SKIP_RMDIR_CHECK=yes. + E.g., ./configure SKIP_RMDIR_CHECK=yes +See \`config.log' for more details." "$LINENO" 5; } + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether rmdir works" >&5 +$as_echo_n "checking whether rmdir works... " >&6; } +if test "${gl_cv_func_rmdir_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + mkdir conftest.dir + touch conftest.file + if test "$cross_compiling" = yes; then : + gl_cv_func_rmdir_works="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + #include + +int +main () +{ +return !rmdir ("conftest.file/") || errno != ENOTDIR + || !rmdir ("conftest.dir/./"); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_rmdir_works=yes +else + gl_cv_func_rmdir_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + rm -rf conftest.dir conftest.file +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_rmdir_works" >&5 +$as_echo "$gl_cv_func_rmdir_works" >&6; } + if test x"$gl_cv_func_rmdir_works" != xyes; then + REPLACE_RMDIR=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS rmdir.$ac_objext" + + fi + fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether lstat accepts an empty string" >&5 +$as_echo_n "checking whether lstat accepts an empty string... " >&6; } +if test "${ac_cv_func_lstat_empty_string_bug+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_func_lstat_empty_string_bug=yes +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +struct stat sbuf; + return lstat ("", &sbuf) == 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_func_lstat_empty_string_bug=no +else + ac_cv_func_lstat_empty_string_bug=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_lstat_empty_string_bug" >&5 +$as_echo "$ac_cv_func_lstat_empty_string_bug" >&6; } +if test $ac_cv_func_lstat_empty_string_bug = yes; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS lstat.$ac_objext" + + +cat >>confdefs.h <<_ACEOF +#define HAVE_LSTAT_EMPTY_STRING_BUG 1 +_ACEOF + +fi + + + + LIB_SELINUX= gl_save_LIBS=$LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing setfilecon" >&5 @@ -13596,6 +16199,96 @@ $as_echo "$as_me: WARNING: GNU coreutils will be compiled without SELinux suppor + if test $ac_cv_func_setenv = no; then + HAVE_SETENV=0 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether setenv validates arguments" >&5 +$as_echo_n "checking whether setenv validates arguments... " >&6; } +if test "${gl_cv_func_setenv_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + gl_cv_func_setenv_works="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #include + +int +main () +{ + + if (setenv ("", "", 0) != -1) return 1; + if (errno != EINVAL) return 2; + if (setenv ("a", "=", 1) != 0) return 3; + if (strcmp (getenv ("a"), "=") != 0) return 4; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_setenv_works=yes +else + gl_cv_func_setenv_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_setenv_works" >&5 +$as_echo "$gl_cv_func_setenv_works" >&6; } + if test "$gl_cv_func_setenv_works" != yes; then + REPLACE_SETENV=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS setenv.$ac_objext" + + fi + fi + + + + + for ac_header in search.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "search.h" "ac_cv_header_search_h" "$ac_includes_default" +if test "x$ac_cv_header_search_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SEARCH_H 1 +_ACEOF + +fi + +done + + for ac_func in tsearch +do : + ac_fn_c_check_func "$LINENO" "tsearch" "ac_cv_func_tsearch" +if test "x$ac_cv_func_tsearch" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_TSEARCH 1 +_ACEOF + +fi +done + + + + + + + + GNULIB_SIGNAL_H_SIGPIPE=0; GNULIB_SIGPROCMASK=0; GNULIB_SIGACTION=0; @@ -13630,46 +16323,6 @@ _ACEOF - REPLACE_NULL=0; - HAVE_WCHAR_T=1; - STDDEF_H=''; - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wchar_t" >&5 -$as_echo_n "checking for wchar_t... " >&6; } -if test "${gt_cv_c_wchar_t+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - wchar_t foo = (wchar_t)'\0'; -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - gt_cv_c_wchar_t=yes -else - gt_cv_c_wchar_t=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_c_wchar_t" >&5 -$as_echo "$gt_cv_c_wchar_t" >&6; } - if test $gt_cv_c_wchar_t = yes; then - -$as_echo "#define HAVE_WCHAR_T 1" >>confdefs.h - - fi - - - - @@ -13798,26 +16451,26 @@ if test "${gl_cv_next_string_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_string_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_string_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_string_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/string.h#{ - s#.*"\(.*/string.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_string_h='<'string.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_string_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/string.h#{ + s#.*"\(.*/string.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_string_h='<'string.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_string_h" >&5 @@ -13861,6 +16514,39 @@ cat >>confdefs.h <<_ACEOF #define HAVE_DECL_STRNLEN $ac_have_decl _ACEOF +ac_fn_c_check_decl "$LINENO" "strsignal" "ac_cv_have_decl_strsignal" "$ac_includes_default" +if test "x$ac_cv_have_decl_strsignal" = x""yes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_STRSIGNAL $ac_have_decl +_ACEOF + +ac_fn_c_check_decl "$LINENO" "sys_siglist" "ac_cv_have_decl_sys_siglist" "#include +/* NetBSD declares sys_siglist in unistd.h. */ +#ifdef HAVE_UNISTD_H +# include +#endif + +" +if test "x$ac_cv_have_decl_sys_siglist" = x""yes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_SYS_SIGLIST $ac_have_decl +_ACEOF + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat file-mode macros are broken" >&5 $as_echo_n "checking whether stat file-mode macros are broken... " >&6; } if test "${ac_cv_header_stat_broken+set}" = set; then : @@ -13906,6 +16592,13 @@ fi + GNULIB_UNAME=0; + HAVE_UNAME=1; + HAVE_STRUCT_UTSNAME=1; + + + + @@ -13992,26 +16685,26 @@ if test "${gl_cv_next_time_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_time_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_time_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_time_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/time.h#{ - s#.*"\(.*/time.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_time_h='<'time.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_time_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/time.h#{ + s#.*"\(.*/time.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_time_h='<'time.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_time_h" >&5 @@ -14034,8 +16727,6 @@ $as_echo "$gl_cv_next_time_h" >&6; } - - ac_fn_c_check_decl "$LINENO" "clearerr_unlocked" "ac_cv_have_decl_clearerr_unlocked" "$ac_includes_default" if test "x$ac_cv_have_decl_clearerr_unlocked" = x""yes; then : ac_have_decl=1 @@ -14136,8 +16827,8 @@ cat >>confdefs.h <<_ACEOF _ACEOF - { $as_echo "$as_me:${as_lineno-$LINENO}: checking determine whether the utimes function works" >&5 -$as_echo_n "checking determine whether the utimes function works... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the utimes function works" >&5 +$as_echo_n "checking whether the utimes function works... " >&6; } if test "${gl_cv_func_working_utimes+set}" = set; then : $as_echo_n "(cached) " >&6 else @@ -14169,11 +16860,11 @@ main () int fd; int ok = ((f = fopen (file, "w")) - && fclose (f) == 0 - && utimes (file, timeval) == 0 - && lstat (file, &sbuf) == 0 - && sbuf.st_atime == timeval[0].tv_sec - && sbuf.st_mtime == timeval[1].tv_sec); + && fclose (f) == 0 + && utimes (file, timeval) == 0 + && lstat (file, &sbuf) == 0 + && sbuf.st_atime == timeval[0].tv_sec + && sbuf.st_mtime == timeval[1].tv_sec); unlink (file); if (!ok) exit (1); @@ -14191,8 +16882,8 @@ main () exit (1); ok = (0 <= (fd = open (file, O_WRONLY|O_CREAT, 0444)) - && close (fd) == 0 - && utimes (file, NULL) == 0); + && close (fd) == 0 + && utimes (file, NULL) == 0); unlink (file); exit (!ok); @@ -14230,12 +16921,12 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if HAVE_SYS_TIME_H - #include - #endif - #include - #ifdef HAVE_UTIME_H - #include - #endif + #include + #endif + #include + #ifdef HAVE_UTIME_H + #include + #endif int main () @@ -14272,6 +16963,8 @@ $as_echo "#define HAVE_STRUCT_UTIMBUF 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wint_t" >&5 $as_echo_n "checking for wint_t... " >&6; } if test "${gt_cv_c_wint_t+set}" = set; then : @@ -15859,6 +18552,8 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sys_tiocgwinsz_needs_termios_h" >&5 $as_echo "$gl_cv_sys_tiocgwinsz_needs_termios_h" >&6; } + + ac_fn_c_check_decl "$LINENO" "alarm" "ac_cv_have_decl_alarm" "$ac_includes_default" if test "x$ac_cv_have_decl_alarm" = x""yes; then : ac_have_decl=1 @@ -15891,20 +18586,20 @@ else int main () { -FILE *f; long l; - if (!(f = fopen ("conftest.tmp", "w+"))) return 1; - if (fputs ("abc", f) < 0) return 2; - rewind (f); - if (fgetc (f) != 'a') return 3; - if (fgetc (f) != 'b') return 4; - if (ungetc ('d', f) != 'd') return 5; - if (ftell (f) != 1) return 6; - if (fgetc (f) != 'd') return 7; - if (ftell (f) != 2) return 8; - if (fseek (f, 0, SEEK_CUR) != 0) return 9; - if (ftell (f) != 2) return 10; - if (fgetc (f) != 'c') return 11; - fclose (f); remove ("conftest.tmp"); +FILE *f; + if (!(f = fopen ("conftest.tmp", "w+"))) return 1; + if (fputs ("abc", f) < 0) return 2; + rewind (f); + if (fgetc (f) != 'a') return 3; + if (fgetc (f) != 'b') return 4; + if (ungetc ('d', f) != 'd') return 5; + if (ftell (f) != 1) return 6; + if (fgetc (f) != 'd') return 7; + if (ftell (f) != 2) return 8; + if (fseek (f, 0, SEEK_CUR) != 0) return 9; + if (ftell (f) != 2) return 10; + if (fgetc (f) != 'c') return 11; + fclose (f); remove ("conftest.tmp"); ; return 0; } @@ -15935,6 +18630,16 @@ $as_echo "#define FUNC_UNGETC_BROKEN 1" >>confdefs.h + + + + + + + + + + if false; then GL_COND_LIBTOOL_TRUE= GL_COND_LIBTOOL_FALSE='#' @@ -15985,7 +18690,7 @@ done ac_save_LIBS=$LIBS if test $use_acl = 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing acl_get_file" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing acl_get_file" >&5 $as_echo_n "checking for library containing acl_get_file... " >&6; } if test "${ac_cv_search_acl_get_file+set}" = set; then : $as_echo_n "(cached) " >&6 @@ -16039,14 +18744,14 @@ ac_res=$ac_cv_search_acl_get_file if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" if test "$ac_cv_search_acl_get_file" != "none required"; then - LIB_ACL=$ac_cv_search_acl_get_file + LIB_ACL=$ac_cv_search_acl_get_file fi - for ac_func in acl_get_file acl_get_fd acl_set_file acl_set_fd \ - acl_free acl_from_mode acl_from_text \ - acl_delete_def_file acl_extended_file \ - acl_delete_fd_np acl_delete_file_np \ - acl_copy_ext_native acl_create_entry_np \ - acl_to_short_text acl_free_text + for ac_func in acl_get_file acl_get_fd acl_set_file acl_set_fd \ + acl_free acl_from_mode acl_from_text \ + acl_delete_def_file acl_extended_file \ + acl_delete_fd_np acl_delete_file_np \ + acl_copy_ext_native acl_create_entry_np \ + acl_to_short_text acl_free_text do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -16059,7 +18764,7 @@ _ACEOF fi done - # If the acl_get_file bug is detected, don't enable the ACL support. + # If the acl_get_file bug is detected, don't enable the ACL support. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working acl_get_file" >&5 $as_echo_n "checking for working acl_get_file... " >&6; } @@ -16072,14 +18777,14 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include - #include - #include + #include + #include int main () { return !! (!acl_get_file (".", ACL_TYPE_ACCESS) - && errno == ENOENT); + && errno == ENOENT); ; return 0; } @@ -16101,8 +18806,8 @@ $as_echo "$gl_cv_func_working_acl_get_file" >&6; } use_acl=1 fi - if test $use_acl = 1; then - for ac_header in acl/libacl.h + if test $use_acl = 1; then + for ac_header in acl/libacl.h do : ac_fn_c_check_header_mongrel "$LINENO" "acl/libacl.h" "ac_cv_header_acl_libacl_h" "$ac_includes_default" if test "x$ac_cv_header_acl_libacl_h" = x""yes; then : @@ -16138,7 +18843,7 @@ fi done - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ACL_FIRST_ENTRY" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ACL_FIRST_ENTRY" >&5 $as_echo_n "checking for ACL_FIRST_ENTRY... " >&6; } if test "${gl_cv_acl_ACL_FIRST_ENTRY+set}" = set; then : $as_echo_n "(cached) " >&6 @@ -16158,12 +18863,12 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_acl_ACL_FIRST_ENTRY" >&5 $as_echo "$gl_cv_acl_ACL_FIRST_ENTRY" >&6; } - if test $gl_cv_acl_ACL_FIRST_ENTRY = yes; then + if test $gl_cv_acl_ACL_FIRST_ENTRY = yes; then $as_echo "#define HAVE_ACL_FIRST_ENTRY 1" >>confdefs.h - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ACL_TYPE_EXTENDED" >&5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ACL_TYPE_EXTENDED" >&5 $as_echo_n "checking for ACL_TYPE_EXTENDED... " >&6; } if test "${gl_cv_acl_ACL_TYPE_EXTENDED+set}" = set; then : $as_echo_n "(cached) " >&6 @@ -16183,21 +18888,21 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_acl_ACL_TYPE_EXTENDED" >&5 $as_echo "$gl_cv_acl_ACL_TYPE_EXTENDED" >&6; } - if test $gl_cv_acl_ACL_TYPE_EXTENDED = yes; then + if test $gl_cv_acl_ACL_TYPE_EXTENDED = yes; then $as_echo "#define HAVE_ACL_TYPE_EXTENDED 1" >>confdefs.h - fi - else - LIB_ACL= - fi + fi + else + LIB_ACL= + fi fi fi if test $use_acl = 0; then - for ac_func in acl + for ac_func in acl do : ac_fn_c_check_func "$LINENO" "acl" "ac_cv_func_acl" if test "x$ac_cv_func_acl" = x""yes; then : @@ -16208,8 +18913,8 @@ _ACEOF fi done - if test $ac_cv_func_acl = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing acl_trivial" >&5 + if test $ac_cv_func_acl = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing acl_trivial" >&5 $as_echo_n "checking for library containing acl_trivial... " >&6; } if test "${ac_cv_search_acl_trivial+set}" = set; then : $as_echo_n "(cached) " >&6 @@ -16263,12 +18968,12 @@ ac_res=$ac_cv_search_acl_trivial if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" if test "$ac_cv_search_acl_trivial" != "none required"; then - LIB_ACL=$ac_cv_search_acl_trivial - fi + LIB_ACL=$ac_cv_search_acl_trivial + fi fi - for ac_func in acl_trivial + for ac_func in acl_trivial do : ac_fn_c_check_func "$LINENO" "acl_trivial" "ac_cv_func_acl_trivial" if test "x$ac_cv_func_acl_trivial" = x""yes; then : @@ -16279,12 +18984,12 @@ _ACEOF fi done - use_acl=1 - fi + use_acl=1 + fi fi if test $use_acl = 0 || test "$ac_cv_func_acl" = yes; then - for ac_func in getacl + for ac_func in getacl do : ac_fn_c_check_func "$LINENO" "getacl" "ac_cv_func_getacl" if test "x$ac_cv_func_getacl" = x""yes; then : @@ -16295,13 +19000,13 @@ _ACEOF fi done - if test $ac_cv_func_getacl = yes; then - use_acl=1 - fi + if test $ac_cv_func_getacl = yes; then + use_acl=1 + fi fi if test $use_acl = 0; then - for ac_func in aclx_get + for ac_func in aclx_get do : ac_fn_c_check_func "$LINENO" "aclx_get" "ac_cv_func_aclx_get" if test "x$ac_cv_func_aclx_get" = x""yes; then : @@ -16312,13 +19017,13 @@ _ACEOF fi done - if test $ac_cv_func_aclx_get = yes; then - use_acl=1 - fi + if test $ac_cv_func_aclx_get = yes; then + use_acl=1 + fi fi if test $use_acl = 0 || test "$ac_cv_func_aclx_get" = yes; then - for ac_func in statacl + for ac_func in statacl do : ac_fn_c_check_func "$LINENO" "statacl" "ac_cv_func_statacl" if test "x$ac_cv_func_statacl" = x""yes; then : @@ -16329,15 +19034,20 @@ _ACEOF fi done - if test $ac_cv_func_statacl = yes; then - use_acl=1 - fi + if test $ac_cv_func_statacl = yes; then + use_acl=1 + fi fi LIBS=$ac_save_LIBS fi if test "x$enable_acl$use_acl" = "xyes0"; then as_fn_error "ACLs enabled but support not detected" "$LINENO" 5 + elif test "x$enable_acl$use_acl" = "xauto0"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libacl development library was not found or not usable." >&5 +$as_echo "$as_me: WARNING: libacl development library was not found or not usable." >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: GNU coreutils will be built without ACL support." >&5 +$as_echo "$as_me: WARNING: GNU coreutils will be built without ACL support." >&2;} fi fi @@ -16401,6 +19111,11 @@ $as_echo "#define HAVE_ALLOCA 1" >>confdefs.h +$as_echo "#define GNULIB_AREADLINKAT 1" >>confdefs.h + + + + @@ -16418,7 +19133,6 @@ $as_echo "#define HAVE_ALLOCA 1" >>confdefs.h if test $ac_cv_header_arpa_inet_h = yes; then HAVE_ARPA_INET_H=1 else - ARPA_INET_H='arpa/inet.h' HAVE_ARPA_INET_H=0 fi @@ -16437,26 +19151,26 @@ if test "${gl_cv_next_arpa_inet_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_arpa_inet_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_arpa_inet_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_arpa_inet_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/arpa/inet.h#{ - s#.*"\(.*/arpa/inet.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_arpa_inet_h='<'arpa/inet.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_arpa_inet_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/arpa/inet.h#{ + s#.*"\(.*/arpa/inet.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_arpa_inet_h='<'arpa/inet.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_arpa_inet_h" >&5 @@ -16557,6 +19271,8 @@ done + + if test $ac_cv_func_btowc = no; then HAVE_BTOWC=0 else @@ -16617,8 +19333,7 @@ $as_echo "$gl_cv_func_btowc_eof" >&6; } fi if test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1; then - - WCHAR_H=wchar.h + : @@ -16785,12 +19500,22 @@ $as_echo "#define HAVE_CALLOC_POSIX 1" >>confdefs.h + if test $ac_cv_func_canonicalize_file_name = no; then + HAVE_CANONICALIZE_FILE_NAME=0 + elif test "$gl_cv_func_realpath_works" != yes; then + REPLACE_CANONICALIZE_FILE_NAME=1 + fi + $as_echo "#define GNULIB_CANONICALIZE 1" >>confdefs.h + + GNULIB_CANONICALIZE_FILE_NAME=1 + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether this system has an arbitrary file name length limit" >&5 $as_echo_n "checking whether this system has an arbitrary file name length limit... " >&6; } if test "${gl_cv_have_arbitrary_file_name_length_limit+set}" = set; then : @@ -16828,6 +19553,7 @@ $as_echo "$gl_cv_have_arbitrary_file_name_length_limit" >&6; } gl_LIBOBJS="$gl_LIBOBJS chdir-long.$ac_objext" + : fi @@ -16835,53 +19561,6 @@ $as_echo "$gl_cv_have_arbitrary_file_name_length_limit" >&6; } - - - - - if test $ac_cv_func_chown_works = no; then - -$as_echo "#define CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE 1" >>confdefs.h - - fi - - # If chown has either of the above problems, then we need the wrapper. - if test $ac_cv_func_chown_works$gl_cv_func_chown_follows_symlink = yesyes; then - : # no wrapper needed - else - REPLACE_CHOWN=1 - - - - - - - - - gl_LIBOBJS="$gl_LIBOBJS chown.$ac_objext" - - - ac_fn_c_check_func "$LINENO" "fchown" "ac_cv_func_fchown" -if test "x$ac_cv_func_fchown" = x""yes; then : - -else - - - - - - - - - gl_LIBOBJS="$gl_LIBOBJS fchown-stub.$ac_objext" - -fi - - - fi - - - GNULIB_CHOWN=1 @@ -16893,6 +19572,8 @@ fi # Save and restore LIBS so e.g., -lrt, isn't added to it. Otherwise, *all* # programs in the package would end up linked with that potentially-shared # library, inducing unnecessary run-time overhead. + LIB_CLOCK_GETTIME= + gl_saved_libs=$LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5 $as_echo_n "checking for library containing clock_gettime... " >&6; } @@ -16951,7 +19632,6 @@ if test "$ac_res" != no; then : LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime fi - for ac_func in clock_gettime clock_settime do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` @@ -16981,6 +19661,11 @@ done +$as_echo "#define GNULIB_CLOEXEC 1" >>confdefs.h + + + + @@ -17162,6 +19847,62 @@ $as_echo "#define GNULIB_CLOSE_STREAM 1" >>confdefs.h + if test $gl_cv_have_include_next = yes; then + gl_cv_next_ctype_h='<'ctype.h'>' + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 +$as_echo_n "checking absolute name of ... " >&6; } +if test "${gl_cv_next_ctype_h+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + if test $ac_cv_header_ctype_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_ctype_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/ctype.h#{ + s#.*"\(.*/ctype.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_ctype_h='<'ctype.h'>' + fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_ctype_h" >&5 +$as_echo "$gl_cv_next_ctype_h" >&6; } + fi + NEXT_CTYPE_H=$gl_cv_next_ctype_h + + if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' + gl_next_as_first_directive='<'ctype.h'>' + else + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' + gl_next_as_first_directive=$gl_cv_next_ctype_h + fi + NEXT_AS_FIRST_DIRECTIVE_CTYPE_H=$gl_next_as_first_directive + + + + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS cycle-check.$ac_objext" @@ -17178,21 +19919,21 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include - #include - #include + #include + #include int main () { DIR *dp = opendir ("."); - struct dirent *e; - struct stat st; - if (! dp) - return 1; - e = readdir (dp); - return ! (e - && stat (e->d_name, &st) == 0 - && e->d_ino == st.st_ino); + struct dirent *e; + struct stat st; + if (! dp) + return 1; + e = readdir (dp); + return ! (e + && stat (e->d_name, &st) == 0 + && e->d_ino == st.st_ino); ; return 0; } @@ -17272,26 +20013,26 @@ if test "${gl_cv_next_dirent_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_dirent_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_dirent_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_dirent_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/dirent.h#{ - s#.*"\(.*/dirent.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_dirent_h='<'dirent.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_dirent_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/dirent.h#{ + s#.*"\(.*/dirent.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_dirent_h='<'dirent.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_dirent_h" >&5 @@ -17332,8 +20073,7 @@ $as_echo "#define GNULIB_DIRENT_SAFER 1" >>confdefs.h - - DIRENT_H='dirent.h' + : @@ -17429,15 +20169,15 @@ if test "${gl_cv_sys_dir_fd_member_name+set}" = set; then : $as_echo_n "(cached) " >&6 else - dirfd_save_CFLAGS=$CFLAGS - for ac_expr in d_fd dd_fd; do + dirfd_save_CFLAGS=$CFLAGS + for ac_expr in d_fd dd_fd; do - CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include - #include + #include + #include int main () { @@ -17451,12 +20191,12 @@ if ac_fn_c_try_compile "$LINENO"; then : fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$dirfd_save_CFLAGS - test "$dir_fd_found" = yes && break - done - test "$dir_fd_found" = yes || ac_expr=no_such_member + CFLAGS=$dirfd_save_CFLAGS + test "$dir_fd_found" = yes && break + done + test "$dir_fd_found" = yes || ac_expr=no_such_member - gl_cv_sys_dir_fd_member_name=$ac_expr + gl_cv_sys_dir_fd_member_name=$ac_expr fi @@ -17485,6 +20225,7 @@ _ACEOF + gl_LIBOBJS="$gl_LIBOBJS basename.$ac_objext" @@ -17500,6 +20241,33 @@ _ACEOF +$as_echo "#define GNULIB_DIRNAME 1" >>confdefs.h + + + + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS basename-lgpl.$ac_objext" + + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS dirname-lgpl.$ac_objext" + + + + @@ -17520,27 +20288,27 @@ if test "${gl_cv_double_slash_root+set}" = set; then : $as_echo_n "(cached) " >&6 else if test x"$cross_compiling" = xyes ; then - # When cross-compiling, there is no way to tell whether // is special - # short of a list of hosts. However, the only known hosts to date - # that have a distinct // are Apollo DomainOS (too old to port to), - # Cygwin, and z/OS. If anyone knows of another system for which // has - # special semantics and is distinct from /, please report it to - # . - case $host in - *-cygwin | i370-ibm-openedition) - gl_cv_double_slash_root=yes ;; - *) - # Be optimistic and assume that / and // are the same when we - # don't know. - gl_cv_double_slash_root='unknown, assuming no' ;; - esac + # When cross-compiling, there is no way to tell whether // is special + # short of a list of hosts. However, the only known hosts to date + # that have a distinct // are Apollo DomainOS (too old to port to), + # Cygwin, and z/OS. If anyone knows of another system for which // has + # special semantics and is distinct from /, please report it to + # . + case $host in + *-cygwin | i370-ibm-openedition) + gl_cv_double_slash_root=yes ;; + *) + # Be optimistic and assume that / and // are the same when we + # don't know. + gl_cv_double_slash_root='unknown, assuming no' ;; + esac else - set x `ls -di / // 2>/dev/null` - if test "$2" = "$4" && wc //dev/null >/dev/null 2>&1; then - gl_cv_double_slash_root=no - else - gl_cv_double_slash_root=yes - fi + set x `ls -di / // 2>/dev/null` + if test "$2" = "$4" && wc //dev/null >/dev/null 2>&1; then + gl_cv_double_slash_root=no + else + gl_cv_double_slash_root=yes + fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_double_slash_root" >&5 @@ -17575,20 +20343,23 @@ if test "${gl_cv_func_dup2_works+set}" = set; then : else if test "$cross_compiling" = yes; then : case "$host_os" in - mingw*) # on this platform, dup2 always returns 0 for success - gl_cv_func_dup2_works=no;; - cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0 - gl_cv_func_dup2_works=no;; - linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a - # closed fd may yield -EBADF instead of -1 / errno=EBADF. - gl_cv_func_dup2_works=no;; - *) gl_cv_func_dup2_works=yes;; - esac + mingw*) # on this platform, dup2 always returns 0 for success + gl_cv_func_dup2_works=no;; + cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0 + gl_cv_func_dup2_works=no;; + linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a + # closed fd may yield -EBADF instead of -1 / errno=EBADF. + gl_cv_func_dup2_works=no;; + freebsd*) # on FreeBSD 6.1, dup2(1,1000000) gives EMFILE, not EBADF. + gl_cv_func_dup2_works=no;; + *) gl_cv_func_dup2_works=yes;; + esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include +#include int main () { @@ -17596,7 +20367,10 @@ if (dup2 (1, 1) == 0) return 1; close (0); if (dup2 (0, 0) != -1) - return 1; + return 2; + /* Many gnulib modules require POSIX conformance of EBADF. */ + if (dup2 (1, 1000000) == -1 && errno != EBADF) + return 3; return 0; ; @@ -17620,7 +20394,9 @@ $as_echo "$gl_cv_func_dup2_works" >&6; } if test "$gl_cv_func_dup2_works" = no; then - REPLACE_DUP2=1 + if test $ac_cv_func_dup2 = yes; then + REPLACE_DUP2=1 + fi @@ -17635,11 +20411,6 @@ $as_echo "$gl_cv_func_dup2_works" >&6; } fi fi -cat >>confdefs.h <<_ACEOF -#define REPLACE_DUP2 $REPLACE_DUP2 -_ACEOF - - GNULIB_DUP2=1 @@ -17647,49 +20418,6 @@ _ACEOF - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if environ is properly declared" >&5 -$as_echo_n "checking if environ is properly declared... " >&6; } - if test "${gt_cv_var_environ_declaration+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - extern struct { int foo; } environ; -int -main () -{ -environ.foo = 1; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - gt_cv_var_environ_declaration=no -else - gt_cv_var_environ_declaration=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_var_environ_declaration" >&5 -$as_echo "$gt_cv_var_environ_declaration" >&6; } - if test $gt_cv_var_environ_declaration = yes; then - -$as_echo "#define HAVE_ENVIRON_DECL 1" >>confdefs.h - - fi - - - if test $gt_cv_var_environ_declaration != yes; then - HAVE_DECL_ENVIRON=0 - fi - - - GNULIB_ENVIRON=1 @@ -17747,6 +20475,7 @@ fi + : @@ -17799,6 +20528,8 @@ done # Save and restore LIBS so -lgen isn't added to it. Otherwise, *all* # programs in the package would end up linked with that potentially-shared # library, inducing unnecessary run-time overhead. + LIB_EACCESS= + gl_saved_libs=$LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing eaccess" >&5 $as_echo_n "checking for library containing eaccess... " >&6; } @@ -17857,7 +20588,6 @@ if test "$ac_res" != no; then : LIB_EACCESS=$ac_cv_search_eaccess fi - for ac_func in eaccess do : ac_fn_c_check_func "$LINENO" "eaccess" "ac_cv_func_eaccess" @@ -17908,6 +20638,36 @@ done + + + if test $ac_cv_func_faccessat = no; then + HAVE_FACCESSAT=0 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS faccessat.$ac_objext" + + fi + + + +$as_echo "#define GNULIB_FACCESSAT 1" >>confdefs.h + + + + + GNULIB_FACCESSAT=1 + + + + + + if test $ac_cv_func_fchdir = no; then REPLACE_FCHDIR=1 @@ -17924,7 +20684,9 @@ done $as_echo "#define REPLACE_FCHDIR 1" >>confdefs.h - REPLACE_FSTAT=1 + REPLACE_OPENDIR=1 + REPLACE_CLOSEDIR=1 + REPLACE_DUP=1 REPLACE_OPEN=1 @@ -17974,7 +20736,9 @@ $as_echo "#define REPLACE_FCHDIR 1" >>confdefs.h - REPLACE_DUP2=1 + if test $ac_cv_func_dup2 = yes; then + REPLACE_DUP2=1 + fi @@ -17988,7 +20752,25 @@ $as_echo "#define REPLACE_FCHDIR 1" >>confdefs.h - DIRENT_H='dirent.h' + + if test $ac_cv_func_fcntl = no; then + HAVE_FCNTL=0 + else + REPLACE_FCNTL=1 + fi + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS fcntl.$ac_objext" + + + + : { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether open can visit directories" >&5 $as_echo_n "checking whether open can visit directories... " >&6; } @@ -18005,7 +20787,7 @@ else int main () { -return open(".", O_RDONLY); +return open(".", O_RDONLY) < 0; ; return 0; } @@ -18026,6 +20808,7 @@ $as_echo "$gl_cv_func_open_directory_works" >&6; } $as_echo "#define REPLACE_OPEN_DIRECTORY 1" >>confdefs.h + REPLACE_FSTAT=1 fi fi @@ -18042,98 +20825,173 @@ $as_echo "#define REPLACE_OPEN_DIRECTORY 1" >>confdefs.h - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working fcntl.h" >&5 -$as_echo_n "checking for working fcntl.h... " >&6; } -if test "${gl_cv_header_working_fcntl_h+set}" = set; then : + + + if test $ac_cv_func_fcntl = no; then + + + + if test $ac_cv_func_fcntl = no; then + HAVE_FCNTL=0 + else + REPLACE_FCNTL=1 + fi + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS fcntl.$ac_objext" + + + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fcntl handles F_DUPFD correctly" >&5 +$as_echo_n "checking whether fcntl handles F_DUPFD correctly... " >&6; } +if test "${gl_cv_func_fcntl_f_dupfd_works+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : - gl_cv_header_working_fcntl_h=cross-compiling + # Guess that it works on glibc systems + case $host_os in #(( + *-gnu*) gl_cv_func_fcntl_f_dupfd_works="guessing yes";; + *) gl_cv_func_fcntl_f_dupfd_works="guessing no";; + esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include - #include - #include - #include - #ifndef O_NOATIME - #define O_NOATIME 0 - #endif - #ifndef O_NOFOLLOW - #define O_NOFOLLOW 0 - #endif - static int const constants[] = - { - O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND, - O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY - }; + +#include int main () { +return fcntl (0, F_DUPFD, -1) != -1; - int status = !constants; - { - static char const sym[] = "conftest.sym"; - if (symlink (".", sym) != 0 - || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0) - status |= 32; - } - { - static char const file[] = "confdefs.h"; - int fd = open (file, O_RDONLY | O_NOATIME); - char c; - struct stat st0, st1; - if (fd < 0 - || fstat (fd, &st0) != 0 - || sleep (1) != 0 - || read (fd, &c, 1) != 1 - || close (fd) != 0 - || stat (file, &st1) != 0 - || st0.st_atime != st1.st_atime) - status |= 64; - } - return status; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : - gl_cv_header_working_fcntl_h=yes + gl_cv_func_fcntl_f_dupfd_works=yes else - case $? in #( - 32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #( - 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #( - 96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #( - *) gl_cv_header_working_fcntl_h='no';; - esac + gl_cv_func_fcntl_f_dupfd_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_working_fcntl_h" >&5 -$as_echo "$gl_cv_header_working_fcntl_h" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fcntl_f_dupfd_works" >&5 +$as_echo "$gl_cv_func_fcntl_f_dupfd_works" >&6; } + case $gl_cv_func_fcntl_f_dupfd_works in + *yes) ;; + *) - case $gl_cv_header_working_fcntl_h in #( - *O_NOATIME* | no | cross-compiling) ac_val=0;; #( - *) ac_val=1;; - esac -cat >>confdefs.h <<_ACEOF -#define HAVE_WORKING_O_NOATIME $ac_val + if test $ac_cv_func_fcntl = no; then + HAVE_FCNTL=0 + else + REPLACE_FCNTL=1 + fi + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS fcntl.$ac_objext" + + + +$as_echo "#define FCNTL_DUPFD_BUGGY 1" >>confdefs.h + ;; + esac + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fcntl understands F_DUPFD_CLOEXEC" >&5 +$as_echo_n "checking whether fcntl understands F_DUPFD_CLOEXEC... " >&6; } +if test "${gl_cv_func_fcntl_f_dupfd_cloexec+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#ifndef F_DUPFD_CLOEXEC +choke me +#endif + +int +main () +{ + + ; + return 0; +} _ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __linux__ +/* The Linux kernel only added F_DUPFD_CLOEXEC in 2.6.24, so we always replace + it to support the semantics on older kernels that failed with EINVAL. */ +choke me +#endif - case $gl_cv_header_working_fcntl_h in #( - *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #( - *) ac_val=1;; - esac +int +main () +{ -cat >>confdefs.h <<_ACEOF -#define HAVE_WORKING_O_NOFOLLOW $ac_val + ; + return 0; +} _ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_func_fcntl_f_dupfd_cloexec=yes +else + gl_cv_func_fcntl_f_dupfd_cloexec="needs runtime check" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + gl_cv_func_fcntl_f_dupfd_cloexec=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fcntl_f_dupfd_cloexec" >&5 +$as_echo "$gl_cv_func_fcntl_f_dupfd_cloexec" >&6; } + if test "$gl_cv_func_fcntl_f_dupfd_cloexec" != yes; then + + + + if test $ac_cv_func_fcntl = no; then + HAVE_FCNTL=0 + else + REPLACE_FCNTL=1 + fi + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS fcntl.$ac_objext" + + + fi + fi + + + + GNULIB_FCNTL=1 + + @@ -18151,26 +21009,26 @@ if test "${gl_cv_next_fcntl_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_fcntl_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_fcntl_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_fcntl_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/fcntl.h#{ - s#.*"\(.*/fcntl.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_fcntl_h='<'fcntl.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_fcntl_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/fcntl.h#{ + s#.*"\(.*/fcntl.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_fcntl_h='<'fcntl.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_fcntl_h" >&5 @@ -18189,8 +21047,6 @@ $as_echo "$gl_cv_next_fcntl_h" >&6; } - FCNTL_H='fcntl.h' - @@ -18223,6 +21079,11 @@ $as_echo "#define GNULIB_FCNTL_SAFER 1" >>confdefs.h +$as_echo "#define GNULIB_FD_SAFER_FLAG 1" >>confdefs.h + + + + if test $ac_cv_func_fdopendir = no; then @@ -18246,10 +21107,62 @@ $as_echo "#define GNULIB_FCNTL_SAFER 1" >>confdefs.h gl_LIBOBJS="$gl_LIBOBJS fdopendir.$ac_objext" - - DIRENT_H='dirent.h' + : HAVE_FDOPENDIR=0 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fdopendir works" >&5 +$as_echo_n "checking whether fdopendir works... " >&6; } +if test "${gl_cv_func_fdopendir_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + gl_cv_func_fdopendir_works="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include + +int +main () +{ +int fd = open ("conftest.c", O_RDONLY); + if (fd < 0) return 2; + return !!fdopendir (fd); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_fdopendir_works=yes +else + gl_cv_func_fdopendir_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fdopendir_works" >&5 +$as_echo "$gl_cv_func_fdopendir_works" >&6; } + if test "$gl_cv_func_fdopendir_works" != yes; then + REPLACE_FDOPENDIR=1 + + : + + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS fdopendir.$ac_objext" + + fi fi @@ -18276,40 +21189,40 @@ int main () { FILE *f = fopen ("conftest.txt", "r"); - char buffer[10]; - int fd; - int c; - if (f == NULL) - return 1; - fd = fileno (f); - if (fd < 0 || fread (buffer, 1, 5, f) != 5) - return 2; - /* For deterministic results, ensure f read a bigger buffer. */ - if (lseek (fd, 0, SEEK_CUR) == 5) - return 3; - /* POSIX requires fflush-fseek to set file offset of fd. This fails - on BSD systems and on mingw. */ - if (fflush (f) != 0 || fseek (f, 0, SEEK_CUR) != 0) - return 4; - if (lseek (fd, 0, SEEK_CUR) != 5) - return 5; - /* Verify behaviour of fflush after ungetc. See - */ - /* Verify behaviour of fflush after a backup ungetc. This fails on - mingw. */ - c = fgetc (f); - ungetc (c, f); - fflush (f); - if (fgetc (f) != c) - return 6; - /* Verify behaviour of fflush after a non-backup ungetc. This fails - on glibc 2.8 and on BSD systems. */ - c = fgetc (f); - ungetc ('@', f); - fflush (f); - if (fgetc (f) != c) - return 7; - return 0; + char buffer[10]; + int fd; + int c; + if (f == NULL) + return 1; + fd = fileno (f); + if (fd < 0 || fread (buffer, 1, 5, f) != 5) + return 2; + /* For deterministic results, ensure f read a bigger buffer. */ + if (lseek (fd, 0, SEEK_CUR) == 5) + return 3; + /* POSIX requires fflush-fseek to set file offset of fd. This fails + on BSD systems and on mingw. */ + if (fflush (f) != 0 || fseek (f, 0, SEEK_CUR) != 0) + return 4; + if (lseek (fd, 0, SEEK_CUR) != 5) + return 5; + /* Verify behaviour of fflush after ungetc. See + */ + /* Verify behaviour of fflush after a backup ungetc. This fails on + mingw. */ + c = fgetc (f); + ungetc (c, f); + fflush (f); + if (fgetc (f) != c) + return 6; + /* Verify behaviour of fflush after a non-backup ungetc. This fails + on glibc 2.8 and on BSD systems. */ + c = fgetc (f); + ungetc ('@', f); + fflush (f); + if (fgetc (f) != c) + return 7; + return 0; ; return 0; @@ -18432,11 +21345,30 @@ fi + gl_LIBOBJS="$gl_LIBOBJS filenamecat.$ac_objext" +$as_echo "#define GNULIB_FILENAMECAT 1" >>confdefs.h + + + + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS filenamecat-lgpl.$ac_objext" + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for flexible array member" >&5 $as_echo_n "checking for flexible array member... " >&6; } @@ -18446,17 +21378,17 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include - #include - #include - struct s { int n; double d[]; }; + #include + #include + struct s { int n; double d[]; }; int main () { int m = getchar (); - struct s *p = malloc (offsetof (struct s, d) - + m * sizeof (double)); - p->d[0] = 0.0; - return p->d != (double *) NULL; + struct s *p = malloc (offsetof (struct s, d) + + m * sizeof (double)); + p->d[0] = 0.0; + return p->d != (double *) NULL; ; return 0; } @@ -18501,26 +21433,26 @@ if test "${gl_cv_next_float_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_float_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_float_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_float_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/float.h#{ - s#.*"\(.*/float.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_float_h='<'float.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_float_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/float.h#{ + s#.*"\(.*/float.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_float_h='<'float.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_float_h" >&5 @@ -18803,43 +21735,43 @@ if test "${ac_cv_sys_pending_output_n_bytes+set}" = set; then : $as_echo_n "(cached) " >&6 else - for ac_expr in \ - \ - '# glibc2' \ - 'fp->_IO_write_ptr - fp->_IO_write_base' \ - \ - '# traditional Unix' \ - 'fp->_ptr - fp->_base' \ - \ - '# BSD' \ - 'fp->_p - fp->_bf._base' \ - \ - '# SCO, Unixware' \ - '(fp->__ptr ? fp->__ptr - fp->__base : 0)' \ - \ - '# QNX' \ - '(fp->_Mode & 0x2000 /*_MWRITE*/ ? fp->_Next - fp->_Buf : 0)' \ - \ - '# old glibc?' \ - 'fp->__bufp - fp->__buffer' \ - \ - '# old glibc iostream?' \ - 'fp->_pptr - fp->_pbase' \ - \ - '# emx+gcc' \ - 'fp->_ptr - fp->_buffer' \ - \ - '# VMS' \ - '(*fp)->_ptr - (*fp)->_base' \ - \ - '# e.g., DGUX R4.11; the info is not available' \ - 1 \ - ; do + for ac_expr in \ + \ + '# glibc2' \ + 'fp->_IO_write_ptr - fp->_IO_write_base' \ + \ + '# traditional Unix' \ + 'fp->_ptr - fp->_base' \ + \ + '# BSD' \ + 'fp->_p - fp->_bf._base' \ + \ + '# SCO, Unixware' \ + '(fp->__ptr ? fp->__ptr - fp->__base : 0)' \ + \ + '# QNX' \ + '(fp->_Mode & 0x2000 /*_MWRITE*/ ? fp->_Next - fp->_Buf : 0)' \ + \ + '# old glibc?' \ + 'fp->__bufp - fp->__buffer' \ + \ + '# old glibc iostream?' \ + 'fp->_pptr - fp->_pbase' \ + \ + '# emx+gcc' \ + 'fp->_ptr - fp->_buffer' \ + \ + '# VMS' \ + '(*fp)->_ptr - (*fp)->_base' \ + \ + '# e.g., DGUX R4.11; the info is not available' \ + 1 \ + ; do - # Skip each embedded comment. - case "$ac_expr" in '#'*) continue;; esac + # Skip each embedded comment. + case "$ac_expr" in '#'*) continue;; esac - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -18855,10 +21787,10 @@ if ac_fn_c_try_compile "$LINENO"; then : fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$fp_done" = yes && break - done + test "$fp_done" = yes && break + done - ac_cv_sys_pending_output_n_bytes=$ac_expr + ac_cv_sys_pending_output_n_bytes=$ac_expr fi @@ -18927,21 +21859,21 @@ int main () { FILE *f = fopen ("conftest.txt", "w+"); - if (!f) return 1; - if (fputc ('a', f) != 'a') return 2; - rewind (f); - if (fgetc (f) != 'a') return 3; - if (fgetc (f) != EOF) return 4; - if (fpurge (f) != 0) return 5; - if (putc ('b', f) != 'b') return 6; - if (fclose (f) != 0) return 7; - if ((f = fopen ("conftest.txt", "r")) == NULL) return 8; - if (fgetc (f) != 'a') return 9; - if (fgetc (f) != 'b') return 10; - if (fgetc (f) != EOF) return 11; - if (fclose (f) != 0) return 12; - if (remove ("conftest.txt") != 0) return 13; - return 0; + if (!f) return 1; + if (fputc ('a', f) != 'a') return 2; + rewind (f); + if (fgetc (f) != 'a') return 3; + if (fgetc (f) != EOF) return 4; + if (fpurge (f) != 0) return 5; + if (putc ('b', f) != 'b') return 6; + if (fclose (f) != 0) return 7; + if ((f = fopen ("conftest.txt", "r")) == NULL) return 8; + if (fgetc (f) != 'a') return 9; + if (fgetc (f) != 'b') return 10; + if (fgetc (f) != EOF) return 11; + if (fclose (f) != 0) return 12; + if (remove ("conftest.txt") != 0) return 13; + return 0; ; return 0; } @@ -18997,6 +21929,49 @@ $as_echo "$gl_cv_func_fpurge_works" >&6; } + + case "$host_os" in + mingw* | pw*) + REPLACE_FREOPEN=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS freopen.$ac_objext" + + + + + ;; + esac + + + + GNULIB_FREOPEN=1 + + + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS freopen-safer.$ac_objext" + + + + +$as_echo "#define GNULIB_FREOPEN_SAFER 1" >>confdefs.h + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether frexp() can be used without linking with libm" >&5 $as_echo_n "checking whether frexp() can be used without linking with libm... " >&6; } if test "${gl_cv_func_frexp_no_libm+set}" = set; then : @@ -19319,6 +22294,7 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include + int main () { @@ -19338,8 +22314,8 @@ rm -f core conftest.err conftest.$ac_objext \ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fseeko" >&5 $as_echo "$gl_cv_func_fseeko" >&6; } - if test $gl_cv_func_fseeko = no; then - HAVE_FSEEKO=0 + if test $gl_cv_func_fseeko = no \ + || test $gl_cv_var_stdin_large_offset = no; then @@ -19354,20 +22330,6 @@ $as_echo "$gl_cv_func_fseeko" >&6; } REPLACE_FSEEKO=1 - elif test $gl_cv_var_stdin_large_offset = no; then - - - - - - - - - - gl_LIBOBJS="$gl_LIBOBJS fseeko.$ac_objext" - - - REPLACE_FSEEKO=1 fi @@ -19790,6 +22752,28 @@ $as_echo "$fu_cv_sys_truncating_statfs" >&6; } + if test $ac_cv_func_fsync = no; then + HAVE_FSYNC=0 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS fsync.$ac_objext" + + : + fi + + + + GNULIB_FSYNC=1 + + + + @@ -19822,23 +22806,8 @@ rm -f core conftest.err conftest.$ac_objext \ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_ftello" >&5 $as_echo "$gl_cv_func_ftello" >&6; } - if test $gl_cv_func_ftello = no; then - HAVE_FTELLO=0 - - - - - - - - - - gl_LIBOBJS="$gl_LIBOBJS ftello.$ac_objext" - - - REPLACE_FTELLO=1 - - elif test $gl_cv_var_stdin_large_offset = no; then + if test $gl_cv_func_ftello = no \ + || test $gl_cv_var_stdin_large_offset = no; then @@ -19899,10 +22868,10 @@ done { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error "Your system lacks the ftruncate function. - Please report this, along with the output of \"uname -a\", to the - bug-coreutils@gnu.org mailing list. To continue past this point, - rerun configure with SKIP_FTRUNCATE_CHECK=yes. - E.g., ./configure SKIP_FTRUNCATE_CHECK=yes + Please report this, along with the output of \"uname -a\", to the + bug-coreutils@gnu.org mailing list. To continue past this point, + rerun configure with SKIP_FTRUNCATE_CHECK=yes. + E.g., ./configure SKIP_FTRUNCATE_CHECK=yes See \`config.log' for more details." "$LINENO" 5; } fi esac @@ -19927,6 +22896,7 @@ See \`config.log' for more details." "$LINENO" 5; } + GNULIB_OPENAT=1 @@ -19972,7 +22942,21 @@ See \`config.log' for more details." "$LINENO" 5; } - for ac_func in fchmodat mkdirat openat + + + + + + + + + + + + + + + for ac_func in fchmodat fstatat mkdirat openat unlinkat do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -19991,9 +22975,37 @@ done + case $ac_cv_func_openat+$ac_cv_func_lstat_dereferences_slashed_symlink in - yes+yes) ;; + yes+yes) + # GNU/Hurd has unlinkat, but it has the same bug as unlink. + if test $REPLACE_UNLINK = 1; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS unlinkat.$ac_objext" + + REPLACE_UNLINKAT=1 + fi ;; yes+*) + # Solaris 9 has *at functions, but uniformly mishandles trailing + # slash in all of them. + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS openat.$ac_objext" + + REPLACE_OPENAT=1 @@ -20005,6 +23017,17 @@ done gl_LIBOBJS="$gl_LIBOBJS fstatat.$ac_objext" REPLACE_FSTATAT=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS unlinkat.$ac_objext" + + REPLACE_UNLINKAT=1 ;; *) HAVE_OPENAT=0 @@ -20012,6 +23035,7 @@ done HAVE_FSTATAT=0 # No known system with fstatat but not openat + : ;; esac @@ -20022,6 +23046,7 @@ done HAVE_MKDIRAT=0 fi + ac_fn_c_check_func "$LINENO" "fchownat" "ac_cv_func_fchownat" if test "x$ac_cv_func_fchownat" = x""yes; then : @@ -20052,8 +23077,8 @@ int main () { return (fchownat (AT_FDCWD, "$gl_dangle", -1, getgid (), - AT_SYMLINK_NOFOLLOW) != 0 - && errno == ENOENT); + AT_SYMLINK_NOFOLLOW) != 0 + && errno == ENOENT); } _ACEOF @@ -20072,12 +23097,18 @@ fi $as_echo "$gl_cv_func_fchownat_nofollow_works" >&6; } if test $gl_cv_func_fchownat_nofollow_works = no; then : REPLACE_FCHOWNAT=1 + +$as_echo "#define FCHOWNAT_NOFOLLOW_BUG 1" >>confdefs.h + fi else HAVE_FCHOWNAT=0 fi + if test $REPLACE_CHOWN = 1; then + REPLACE_FCHOWNAT=1 + fi if test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1; then @@ -20497,6 +23528,11 @@ fi *) GETADDRINFO_LIB="$GETADDRINFO_LIB $SERVENT_LIB" ;; esac + case " $GETADDRINFO_LIB " in + *" $INET_NTOP_LIB "*) ;; + *) GETADDRINFO_LIB="$GETADDRINFO_LIB $INET_NTOP_LIB" ;; + esac + @@ -20582,7 +23618,7 @@ main () exit (0); #else char buf[PATH_MAX * (DIR_NAME_SIZE / DOTDOTSLASH_LEN + 1) - + DIR_NAME_SIZE + BUF_SLOP]; + + DIR_NAME_SIZE + BUF_SLOP]; char *cwd = getcwd (buf, PATH_MAX); size_t initial_cwd_len; size_t cwd_len; @@ -20601,58 +23637,58 @@ main () cwd_len += DIR_NAME_SIZE; /* If mkdir or chdir fails, it could be that this system cannot create - any file with an absolute name longer than PATH_MAX, such as cygwin. - If so, leave fail as 0, because the current working directory can't - be too long for getcwd if it can't even be created. For other - errors, be pessimistic and consider that as a failure, too. */ + any file with an absolute name longer than PATH_MAX, such as cygwin. + If so, leave fail as 0, because the current working directory can't + be too long for getcwd if it can't even be created. For other + errors, be pessimistic and consider that as a failure, too. */ if (mkdir (DIR_NAME, S_IRWXU) < 0 || chdir (DIR_NAME) < 0) - { - if (! (errno == ERANGE || is_ENAMETOOLONG (errno))) - fail = 2; - break; - } + { + if (! (errno == ERANGE || is_ENAMETOOLONG (errno))) + fail = 2; + break; + } if (PATH_MAX <= cwd_len && cwd_len < PATH_MAX + DIR_NAME_SIZE) - { - c = getcwd (buf, PATH_MAX); - if (!c && errno == ENOENT) - { - fail = 1; - break; - } - if (c || ! (errno == ERANGE || is_ENAMETOOLONG (errno))) - { - fail = 2; - break; - } - } + { + c = getcwd (buf, PATH_MAX); + if (!c && errno == ENOENT) + { + fail = 1; + break; + } + if (c || ! (errno == ERANGE || is_ENAMETOOLONG (errno))) + { + fail = 2; + break; + } + } if (dotdot_max <= cwd_len - initial_cwd_len) - { - if (dotdot_max + DIR_NAME_SIZE < cwd_len - initial_cwd_len) - break; - c = getcwd (buf, cwd_len + 1); - if (!c) - { - if (! (errno == ERANGE || errno == ENOENT - || is_ENAMETOOLONG (errno))) - { - fail = 2; - break; - } - if (AT_FDCWD || errno == ERANGE || errno == ENOENT) - { - fail = 1; - break; - } - } - } + { + if (dotdot_max + DIR_NAME_SIZE < cwd_len - initial_cwd_len) + break; + c = getcwd (buf, cwd_len + 1); + if (!c) + { + if (! (errno == ERANGE || errno == ENOENT + || is_ENAMETOOLONG (errno))) + { + fail = 2; + break; + } + if (AT_FDCWD || errno == ERANGE || errno == ENOENT) + { + fail = 1; + break; + } + } + } if (c && strlen (c) != cwd_len) - { - fail = 2; - break; - } + { + fail = 2; + break; + } ++n_chdirs; } @@ -20666,10 +23702,10 @@ main () rmdir (DIR_NAME); for (i = 0; i <= n_chdirs; i++) { - if (chdir ("..") < 0) - break; - if (rmdir (DIR_NAME) != 0) - break; + if (chdir ("..") < 0) + break; + if (rmdir (DIR_NAME) != 0) + break; } } @@ -20774,14 +23810,14 @@ main () initial_cwd_len = strlen (cwd); free (cwd); desired_depth = ((TARGET_LEN - 1 - initial_cwd_len) - / (1 + strlen (dir_name))); + / (1 + strlen (dir_name))); for (d = 0; d < desired_depth; d++) { if (mkdir (dir_name, S_IRWXU) < 0 || chdir (dir_name) < 0) - { - fail = 3; /* Unable to construct deep hierarchy. */ - break; - } + { + fail = 3; /* Unable to construct deep hierarchy. */ + break; + } } /* If libc has the bug in question, this invocation of getcwd @@ -20796,7 +23832,7 @@ main () while (0 < d--) { if (chdir ("..") < 0) - break; + break; rmdir (dir_name); } @@ -20923,6 +23959,26 @@ fi + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include /* for time_t */ +#include /* for CHAR_BIT, LONG_MIN, LONG_MAX */ +#define TYPE_MINIMUM(t) \ + ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))) +#define TYPE_MAXIMUM(t) \ + ((t) ((t) 0 < (t) -1 ? (t) -1 : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))) +typedef int verify_min[2 * (LONG_MIN <= TYPE_MINIMUM (time_t)) - 1]; +typedef int verify_max[2 * (TYPE_MAXIMUM (time_t) <= LONG_MAX) - 1]; + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +$as_echo "#define TIME_T_FITS_IN_LONG_INT 1" >>confdefs.h + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext @@ -20994,7 +24050,9 @@ _ACEOF - if test "$ac_cv_func_getgroups_works" != yes; then + + + if test "$ac_cv_func_getgroups" != yes; then @@ -21005,17 +24063,79 @@ _ACEOF gl_LIBOBJS="$gl_LIBOBJS getgroups.$ac_objext" - -$as_echo "#define getgroups rpl_getgroups" >>confdefs.h + HAVE_GETGROUPS=0 + elif test "$ac_cv_func_getgroups_works.$ac_cv_type_getgroups" != yes.gid_t + then + + + + + gl_LIBOBJS="$gl_LIBOBJS getgroups.$ac_objext" + + REPLACE_GETGROUPS=1 + +$as_echo "#define GETGROUPS_ZERO_BUG 1" >>confdefs.h + + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getgroups handles negative values" >&5 +$as_echo_n "checking whether getgroups handles negative values... " >&6; } +if test "${gl_cv_func_getgroups_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + gl_cv_func_getgroups_works="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +int size = getgroups (0, 0); + gid_t *list = malloc (size * sizeof *list); + return getgroups (-1, list) != -1; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_getgroups_works=yes +else + gl_cv_func_getgroups_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getgroups_works" >&5 +$as_echo "$gl_cv_func_getgroups_works" >&6; } + if test "$gl_cv_func_getgroups_works" != yes; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS getgroups.$ac_objext" + + REPLACE_GETGROUPS=1 + fi fi test -n "$GETGROUPS_LIB" && LIBS="$GETGROUPS_LIB $LIBS" + GNULIB_GETGROUPS=1 + + + @@ -21206,6 +24326,7 @@ cat >>confdefs.h <<_ACEOF #define HAVE_DECL_GETHRTIME $ac_have_decl _ACEOF + LIB_GETHRXTIME= case $ac_cv_have_decl_gethrtime,$gl_cv_arithmetic_hrtime_t in yes,yes) ;; *) @@ -21225,7 +24346,6 @@ _ACEOF if test $ac_cv_func_nanouptime != yes; then - LIB_GETHRXTIME= { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether CLOCK_MONOTONIC or CLOCK_REALTIME is defined" >&5 $as_echo_n "checking whether CLOCK_MONOTONIC or CLOCK_REALTIME is defined... " >&6; } if test "${gl_cv_have_clock_gettime_macro+set}" = set; then : @@ -21236,7 +24356,7 @@ else # include # if defined CLOCK_MONOTONIC || defined CLOCK_REALTIME - have_clock_gettime_macro + have_clock_gettime_macro # endif _ACEOF @@ -21254,7 +24374,6 @@ $as_echo "$gl_cv_have_clock_gettime_macro" >&6; } if test $gl_cv_have_clock_gettime_macro = yes; then LIB_GETHRXTIME=$LIB_CLOCK_GETTIME fi - fi ;; esac @@ -21266,10 +24385,11 @@ $as_echo "$gl_cv_have_clock_gettime_macro" >&6; } + gl_getline_needs_run_time_check=no ac_fn_c_check_func "$LINENO" "getline" "ac_cv_func_getline" if test "x$ac_cv_func_getline" = x""yes; then : - gl_getline_needs_run_time_check=yes + gl_getline_needs_run_time_check=yes else am_cv_func_working_getline=no fi @@ -21316,7 +24436,7 @@ else int len; FILE *in = fopen ("./conftest.data", "r"); if (!in) - return 1; + return 1; len = getline (&line, &siz, in); exit ((len == 4 && line && strcmp (line, "foo\n") == 0) ? 0 : 1); } @@ -21893,11 +25013,11 @@ int main () { struct nlist x; - #ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME - x.n_un.n_name = ""; - #else - x.n_name = ""; - #endif + #ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME + x.n_un.n_name = ""; + #else + x.n_name = ""; + #endif ; return 0; } @@ -21965,8 +25085,8 @@ else test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem` gl_cv_group_kmem=`echo $ac_ls_output \ | sed -ne 's/[ ][ ]*/ /g - s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/ - / /s/.* //;p'` + s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/ + / /s/.* //;p'` fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_group_kmem" >&5 @@ -22227,15 +25347,15 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include - struct timeval c; + struct timeval c; int main () { - int (*f) (struct timeval *restrict, void *restrict) = gettimeofday; - int x = f (&c, 0); - return !(x | c.tv_sec | c.tv_usec); + int (*f) (struct timeval *restrict, void *restrict) = gettimeofday; + int x = f (&c, 0); + return !(x | c.tv_sec | c.tv_usec); ; return 0; @@ -22265,22 +25385,22 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include - #include - #include - #include + #include + #include + #include int main () { - time_t t = 0; - struct tm *lt; - struct tm saved_lt; - struct timeval tv; - lt = localtime (&t); - saved_lt = *lt; - gettimeofday (&tv, NULL); - return memcmp (lt, &saved_lt, sizeof (struct tm)) != 0; + time_t t = 0; + struct tm *lt; + struct tm saved_lt; + struct timeval tv; + lt = localtime (&t); + saved_lt = *lt; + gettimeofday (&tv, NULL); + return memcmp (lt, &saved_lt, sizeof (struct tm)) != 0; ; return 0; @@ -22405,73 +25525,6 @@ done gl_LIBOBJS="$gl_LIBOBJS getugroups.$ac_objext" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking type of array argument to getgroups" >&5 -$as_echo_n "checking type of array argument to getgroups... " >&6; } -if test "${ac_cv_type_getgroups+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_type_getgroups=cross -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -/* Thanks to Mike Rendell for this test. */ -$ac_includes_default -#define NGID 256 -#undef MAX -#define MAX(x, y) ((x) > (y) ? (x) : (y)) - -int -main () -{ - gid_t gidset[NGID]; - int i, n; - union { gid_t gval; long int lval; } val; - - val.lval = -1; - for (i = 0; i < NGID; i++) - gidset[i] = val.gval; - n = getgroups (sizeof (gidset) / MAX (sizeof (int), sizeof (gid_t)) - 1, - gidset); - /* Exit non-zero if getgroups seems to require an array of ints. This - happens when gid_t is short int but getgroups modifies an array - of ints. */ - return n > 0 && gidset[n] != val.gval; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_type_getgroups=gid_t -else - ac_cv_type_getgroups=int -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -if test $ac_cv_type_getgroups = cross; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "getgroups.*int.*gid_t" >/dev/null 2>&1; then : - ac_cv_type_getgroups=gid_t -else - ac_cv_type_getgroups=int -fi -rm -f conftest* - -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_getgroups" >&5 -$as_echo "$ac_cv_type_getgroups" >&6; } - -cat >>confdefs.h <<_ACEOF -#define GETGROUPS_T $ac_cv_type_getgroups -_ACEOF - - @@ -22589,60 +25642,60 @@ else # These operating system names do not use the default heuristic below. # They are in reverse order, so that more-specific prefixes come first. - winnt*) os='Windows NT';; - vos*) os='VOS';; - sysv*) os='Unix System V';; - superux*) os='SUPER-UX';; - sunos*) os='SunOS';; - stop*) os='STOP';; - sco*) os='SCO Unix';; - riscos*) os='RISC OS';; - riscix*) os='RISCiX';; - qnx*) os='QNX';; - pw32*) os='PW32';; - ptx*) os='ptx';; - plan9*) os='Plan 9';; - osf*) os='Tru64';; - os2*) os='OS/2';; - openbsd*) os='OpenBSD';; - nsk*) os='NonStop Kernel';; - nonstopux*) os='NonStop-UX';; - netbsd*-gnu*) os='GNU/NetBSD';; # NetBSD kernel+libc, GNU userland - netbsd*) os='NetBSD';; - knetbsd*-gnu) os='GNU/kNetBSD';; # NetBSD kernel, GNU libc+userland - kfreebsd*-gnu) os='GNU/kFreeBSD';; # FreeBSD kernel, GNU libc+userland - msdosdjgpp*) os='DJGPP';; - mpeix*) os='MPE/iX';; - mint*) os='MiNT';; - mingw*) os='MinGW';; - lynxos*) os='LynxOS';; - linux*) os='GNU/Linux';; - hpux*) os='HP-UX';; - hiux*) os='HI-UX';; - gnu*) os='GNU';; - freebsd*) os='FreeBSD';; - dgux*) os='DG/UX';; - bsdi*) os='BSD/OS';; - bsd*) os='BSD';; - beos*) os='BeOS';; - aux*) os='A/UX';; - atheos*) os='AtheOS';; - amigaos*) os='Amiga OS';; - aix*) os='AIX';; + winnt*) os='Windows NT';; + vos*) os='VOS';; + sysv*) os='Unix System V';; + superux*) os='SUPER-UX';; + sunos*) os='SunOS';; + stop*) os='STOP';; + sco*) os='SCO Unix';; + riscos*) os='RISC OS';; + riscix*) os='RISCiX';; + qnx*) os='QNX';; + pw32*) os='PW32';; + ptx*) os='ptx';; + plan9*) os='Plan 9';; + osf*) os='Tru64';; + os2*) os='OS/2';; + openbsd*) os='OpenBSD';; + nsk*) os='NonStop Kernel';; + nonstopux*) os='NonStop-UX';; + netbsd*-gnu*) os='GNU/NetBSD';; # NetBSD kernel+libc, GNU userland + netbsd*) os='NetBSD';; + knetbsd*-gnu) os='GNU/kNetBSD';; # NetBSD kernel, GNU libc+userland + kfreebsd*-gnu) os='GNU/kFreeBSD';; # FreeBSD kernel, GNU libc+userland + msdosdjgpp*) os='DJGPP';; + mpeix*) os='MPE/iX';; + mint*) os='MiNT';; + mingw*) os='MinGW';; + lynxos*) os='LynxOS';; + linux*) os='GNU/Linux';; + hpux*) os='HP-UX';; + hiux*) os='HI-UX';; + gnu*) os='GNU';; + freebsd*) os='FreeBSD';; + dgux*) os='DG/UX';; + bsdi*) os='BSD/OS';; + bsd*) os='BSD';; + beos*) os='BeOS';; + aux*) os='A/UX';; + atheos*) os='AtheOS';; + amigaos*) os='Amiga OS';; + aix*) os='AIX';; # The default heuristic takes the initial alphabetic string # from $host_os, but capitalizes its first letter. [A-Za-z]*) - os=` - expr "X$host_os" : 'X\([A-Za-z]\)' | tr '[a-z]' '[A-Z]' - `` - expr "X$host_os" : 'X.\([A-Za-z]*\)' - ` - ;; + os=` + expr "X$host_os" : 'X\([A-Za-z]\)' | tr '[a-z]' '[A-Z]' + `` + expr "X$host_os" : 'X.\([A-Za-z]*\)' + ` + ;; # If $host_os does not start with an alphabetic string, use it unchanged. *) - os=$host_os;; + os=$host_os;; esac gl_cv_host_operating_system=$os fi @@ -22926,6 +25979,25 @@ int main () return 1; } } + /* Test against Solaris 10 bug: Failures are not distinguishable from + successful returns. */ + { + iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); + if (cd_ascii_to_88591 != (iconv_t)(-1)) + { + static const char input[] = "\263"; + char buf[10]; + const char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_ascii_to_88591, + (char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res == 0) + return 1; + } + } #if 0 /* This bug could be worked around by the caller. */ /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ { @@ -23058,6 +26130,7 @@ _ACEOF + if test $gl_cv_have_include_next = yes; then gl_cv_next_iconv_h='<'iconv.h'>' else @@ -23067,26 +26140,26 @@ if test "${gl_cv_next_iconv_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_iconv_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_iconv_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_iconv_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/iconv.h#{ - s#.*"\(.*/iconv.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_iconv_h='<'iconv.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_iconv_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/iconv.h#{ + s#.*"\(.*/iconv.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_iconv_h='<'iconv.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_iconv_h" >&5 @@ -23181,11 +26254,10 @@ _ACEOF - - ARPA_INET_H='arpa/inet.h' + : - gl_save_LIBS=$LIBS + gl_save_LIBS=$LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing inet_ntop" >&5 $as_echo_n "checking for library containing inet_ntop... " >&6; } if test "${ac_cv_search_inet_ntop+set}" = set; then : @@ -23268,6 +26340,12 @@ done fi LIBS=$gl_save_LIBS + INET_NTOP_LIB= + if test "$ac_cv_search_inet_ntop" != "no" && + test "$ac_cv_search_inet_ntop" != "none required"; then + INET_NTOP_LIB="$ac_cv_search_inet_ntop" + fi + ac_fn_c_check_decl "$LINENO" "inet_ntop" "ac_cv_have_decl_inet_ntop" "#include @@ -23392,6 +26470,7 @@ $as_echo "#define HAVE_INLINE 1" >>confdefs.h + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether inttypes.h conforms to C99" >&5 $as_echo_n "checking whether inttypes.h conforms to C99... " >&6; } if test "${gl_cv_header_working_inttypes_h+set}" = set; then : @@ -23399,11 +26478,11 @@ if test "${gl_cv_header_working_inttypes_h+set}" = set; then : else gl_cv_header_working_inttypes_h=no if test "$gl_cv_header_working_stdint_h" = yes \ - && test $ac_cv_header_inttypes_h = yes \ - && test "$ac_cv_have_decl_imaxabs" = yes \ - && test "$ac_cv_have_decl_imaxdiv" = yes \ - && test "$ac_cv_have_decl_strtoimax" = yes \ - && test "$ac_cv_have_decl_strtoumax" = yes; then + && test $ac_cv_header_inttypes_h = yes \ + && test "$ac_cv_have_decl_imaxabs" = yes \ + && test "$ac_cv_have_decl_imaxdiv" = yes \ + && test "$ac_cv_have_decl_strtoimax" = yes \ + && test "$ac_cv_have_decl_strtoumax" = yes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -23524,10 +26603,6 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_working_inttypes_h" >&5 $as_echo "$gl_cv_header_working_inttypes_h" >&6; } - if false && test $gl_cv_header_working_inttypes_h = yes; then - INTTYPES_H='' - else - @@ -23544,26 +26619,26 @@ if test "${gl_cv_next_inttypes_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_inttypes_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_inttypes_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_inttypes_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/inttypes.h#{ - s#.*"\(.*/inttypes.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_inttypes_h='<'inttypes.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_inttypes_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/inttypes.h#{ + s#.*"\(.*/inttypes.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_inttypes_h='<'inttypes.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_inttypes_h" >&5 @@ -23590,22 +26665,22 @@ $as_echo "#define GL_TRIGGER_STDC_LIMIT_MACROS 1" >>confdefs.h - PRIPTR_PREFIX= - if test -n "$STDINT_H"; then - PRIPTR_PREFIX='"l"' - else - for glpfx in '' l ll I64; do - case $glpfx in - '') gltype1='int';; - l) gltype1='long int';; - ll) gltype1='long long int';; - I64) gltype1='__int64';; - esac - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + PRIPTR_PREFIX= + if test -n "$STDINT_H"; then + PRIPTR_PREFIX='"l"' + else + for glpfx in '' l ll I64; do + case $glpfx in + '') gltype1='int';; + l) gltype1='long int';; + ll) gltype1='long long int';; + I64) gltype1='__int64';; + esac + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include - extern intptr_t foo; - extern $gltype1 foo; + extern intptr_t foo; + extern $gltype1 foo; int main () { @@ -23618,34 +26693,34 @@ if ac_fn_c_try_compile "$LINENO"; then : PRIPTR_PREFIX='"'$glpfx'"' fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test -n "$PRIPTR_PREFIX" && break - done - fi + test -n "$PRIPTR_PREFIX" && break + done + fi - if test "$ac_cv_have_decl_imaxabs" = yes; then - HAVE_DECL_IMAXABS=1 - else - HAVE_DECL_IMAXABS=0 - fi + if test "$ac_cv_have_decl_imaxabs" = yes; then + HAVE_DECL_IMAXABS=1 + else + HAVE_DECL_IMAXABS=0 + fi - if test "$ac_cv_have_decl_imaxdiv" = yes; then - HAVE_DECL_IMAXDIV=1 - else - HAVE_DECL_IMAXDIV=0 - fi + if test "$ac_cv_have_decl_imaxdiv" = yes; then + HAVE_DECL_IMAXDIV=1 + else + HAVE_DECL_IMAXDIV=0 + fi - if test "$ac_cv_have_decl_strtoimax" = yes; then - HAVE_DECL_STRTOIMAX=1 - else - HAVE_DECL_STRTOIMAX=0 - fi + if test "$ac_cv_have_decl_strtoimax" = yes; then + HAVE_DECL_STRTOIMAX=1 + else + HAVE_DECL_STRTOIMAX=0 + fi - if test "$ac_cv_have_decl_strtoumax" = yes; then - HAVE_DECL_STRTOUMAX=1 - else - HAVE_DECL_STRTOUMAX=0 - fi + if test "$ac_cv_have_decl_strtoumax" = yes; then + HAVE_DECL_STRTOUMAX=1 + else + HAVE_DECL_STRTOUMAX=0 + fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether INT32_MAX < INTMAX_MAX" >&5 @@ -23656,24 +26731,24 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Work also in C++ mode. */ - #define __STDC_LIMIT_MACROS 1 + #define __STDC_LIMIT_MACROS 1 - /* Work if build is not clean. */ - #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H + /* Work if build is not clean. */ + #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H - #include - #if HAVE_STDINT_H - #include - #endif + #include + #if HAVE_STDINT_H + #include + #endif - #if defined INT32_MAX && defined INTMAX_MAX - #define CONDITION (INT32_MAX < INTMAX_MAX) - #elif HAVE_LONG_LONG_INT - #define CONDITION (sizeof (int) < sizeof (long long int)) - #else - #define CONDITION 0 - #endif - int test[CONDITION ? 1 : -1]; + #if defined INT32_MAX && defined INTMAX_MAX + #define CONDITION (INT32_MAX < INTMAX_MAX) + #elif HAVE_LONG_LONG_INT + #define CONDITION (sizeof (int) < sizeof (long long int)) + #else + #define CONDITION 0 + #endif + int test[CONDITION ? 1 : -1]; int main () { @@ -23698,7 +26773,7 @@ $as_echo "$gl_cv_test_INT32_MAX_LT_INTMAX_MAX" >&6; } fi - if test $APPLE_UNIVERSAL_BUILD = 0; then + if test $APPLE_UNIVERSAL_BUILD = 0; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether INT64_MAX == LONG_MAX" >&5 $as_echo_n "checking whether INT64_MAX == LONG_MAX... " >&6; } @@ -23708,24 +26783,24 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Work also in C++ mode. */ - #define __STDC_LIMIT_MACROS 1 + #define __STDC_LIMIT_MACROS 1 - /* Work if build is not clean. */ - #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H + /* Work if build is not clean. */ + #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H - #include - #if HAVE_STDINT_H - #include - #endif + #include + #if HAVE_STDINT_H + #include + #endif - #if defined INT64_MAX - #define CONDITION (INT64_MAX == LONG_MAX) - #elif HAVE_LONG_LONG_INT - #define CONDITION (sizeof (long long int) == sizeof (long int)) - #else - #define CONDITION 0 - #endif - int test[CONDITION ? 1 : -1]; + #if defined INT64_MAX + #define CONDITION (INT64_MAX == LONG_MAX) + #elif HAVE_LONG_LONG_INT + #define CONDITION (sizeof (long long int) == sizeof (long int)) + #else + #define CONDITION 0 + #endif + int test[CONDITION ? 1 : -1]; int main () { @@ -23750,9 +26825,9 @@ $as_echo "$gl_cv_test_INT64_MAX_EQ_LONG_MAX" >&6; } fi - else - INT64_MAX_EQ_LONG_MAX=-1 - fi + else + INT64_MAX_EQ_LONG_MAX=-1 + fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether UINT32_MAX < UINTMAX_MAX" >&5 $as_echo_n "checking whether UINT32_MAX < UINTMAX_MAX... " >&6; } @@ -23762,24 +26837,24 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Work also in C++ mode. */ - #define __STDC_LIMIT_MACROS 1 + #define __STDC_LIMIT_MACROS 1 - /* Work if build is not clean. */ - #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H + /* Work if build is not clean. */ + #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H - #include - #if HAVE_STDINT_H - #include - #endif + #include + #if HAVE_STDINT_H + #include + #endif - #if defined UINT32_MAX && defined UINTMAX_MAX - #define CONDITION (UINT32_MAX < UINTMAX_MAX) - #elif HAVE_LONG_LONG_INT - #define CONDITION (sizeof (unsigned int) < sizeof (unsigned long long int)) - #else - #define CONDITION 0 - #endif - int test[CONDITION ? 1 : -1]; + #if defined UINT32_MAX && defined UINTMAX_MAX + #define CONDITION (UINT32_MAX < UINTMAX_MAX) + #elif HAVE_LONG_LONG_INT + #define CONDITION (sizeof (unsigned int) < sizeof (unsigned long long int)) + #else + #define CONDITION 0 + #endif + int test[CONDITION ? 1 : -1]; int main () { @@ -23804,7 +26879,7 @@ $as_echo "$gl_cv_test_UINT32_MAX_LT_UINTMAX_MAX" >&6; } fi - if test $APPLE_UNIVERSAL_BUILD = 0; then + if test $APPLE_UNIVERSAL_BUILD = 0; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether UINT64_MAX == ULONG_MAX" >&5 $as_echo_n "checking whether UINT64_MAX == ULONG_MAX... " >&6; } @@ -23814,24 +26889,24 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Work also in C++ mode. */ - #define __STDC_LIMIT_MACROS 1 + #define __STDC_LIMIT_MACROS 1 - /* Work if build is not clean. */ - #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H + /* Work if build is not clean. */ + #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H - #include - #if HAVE_STDINT_H - #include - #endif + #include + #if HAVE_STDINT_H + #include + #endif - #if defined UINT64_MAX - #define CONDITION (UINT64_MAX == ULONG_MAX) - #elif HAVE_LONG_LONG_INT - #define CONDITION (sizeof (unsigned long long int) == sizeof (unsigned long int)) - #else - #define CONDITION 0 - #endif - int test[CONDITION ? 1 : -1]; + #if defined UINT64_MAX + #define CONDITION (UINT64_MAX == ULONG_MAX) + #elif HAVE_LONG_LONG_INT + #define CONDITION (sizeof (unsigned long long int) == sizeof (unsigned long int)) + #else + #define CONDITION 0 + #endif + int test[CONDITION ? 1 : -1]; int main () { @@ -23856,15 +26931,11 @@ $as_echo "$gl_cv_test_UINT64_MAX_EQ_ULONG_MAX" >&6; } fi - else - UINT64_MAX_EQ_ULONG_MAX=-1 - fi - - INTTYPES_H='inttypes.h' + else + UINT64_MAX_EQ_ULONG_MAX=-1 fi - # OpenVMS has isapipe already, so check for it. @@ -23903,51 +26974,51 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include - #include - #include - #include - #ifndef S_ISFIFO - #define S_ISFIFO(m) 0 - #endif - #ifndef S_ISSOCK - #define S_ISSOCK(m) 0 - #endif - int - main (int argc, char **argv) - { - int fd[2]; - struct stat st; - if (pipe (fd) != 0 || fstat (fd[0], &st) != 0) - return 1; - if (2 <= argc && argv[1][0] == '-') - { - char const *yesno = (S_ISFIFO (st.st_mode) ? "yes" : "no"); - if (st.st_nlink <= 1) - { - long int i = st.st_nlink; - if (i != st.st_nlink) - return 1; - printf ("%s (%ld)\n", yesno, i); - } - else - { - unsigned long int i = st.st_nlink; - if (i != st.st_nlink) - return 1; - printf ("%s (%lu)\n", yesno, i); - } - } - else - { - if (! S_ISFIFO (st.st_mode) && ! S_ISSOCK (st.st_mode)) - return 1; - } - return 0; - } + #include + #include + #include + #ifndef S_ISFIFO + #define S_ISFIFO(m) 0 + #endif + #ifndef S_ISSOCK + #define S_ISSOCK(m) 0 + #endif + int + main (int argc, char **argv) + { + int fd[2]; + struct stat st; + if (pipe (fd) != 0 || fstat (fd[0], &st) != 0) + return 1; + if (2 <= argc && argv[1][0] == '-') + { + char const *yesno = (S_ISFIFO (st.st_mode) ? "yes" : "no"); + if (st.st_nlink <= 1) + { + long int i = st.st_nlink; + if (i != st.st_nlink) + return 1; + printf ("%s (%ld)\n", yesno, i); + } + else + { + unsigned long int i = st.st_nlink; + if (i != st.st_nlink) + return 1; + printf ("%s (%lu)\n", yesno, i); + } + } + else + { + if (! S_ISFIFO (st.st_mode) && ! S_ISSOCK (st.st_mode)) + return 1; + } + return 0; + } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_pipes_are_fifos=`./conftest$ac_exeext -` - test -z "$gl_cv_pipes_are_fifos" && gl_cv_pipes_are_fifos=no + test -z "$gl_cv_pipes_are_fifos" && gl_cv_pipes_are_fifos=no else gl_cv_pipes_are_fifos=unknown fi @@ -23982,6 +27053,29 @@ _ACEOF + + + + if test $ac_cv_func_isblank = no; then + HAVE_ISBLANK=0 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS isblank.$ac_objext" + + fi + + + + GNULIB_ISBLANK=1 + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether isnan(double) can be used without linking with libm" >&5 $as_echo_n "checking whether isnan(double) can be used without linking with libm... " >&6; } if test "${gl_cv_func_isnand_no_libm+set}" = set; then : @@ -24976,6 +28070,139 @@ _ACEOF + + + + + + if test $gl_cv_have_include_next = yes; then + gl_cv_next_langinfo_h='<'langinfo.h'>' + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 +$as_echo_n "checking absolute name of ... " >&6; } +if test "${gl_cv_next_langinfo_h+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + if test $ac_cv_header_langinfo_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_langinfo_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/langinfo.h#{ + s#.*"\(.*/langinfo.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_langinfo_h='<'langinfo.h'>' + fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_langinfo_h" >&5 +$as_echo "$gl_cv_next_langinfo_h" >&6; } + fi + NEXT_LANGINFO_H=$gl_cv_next_langinfo_h + + if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' + gl_next_as_first_directive='<'langinfo.h'>' + else + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' + gl_next_as_first_directive=$gl_cv_next_langinfo_h + fi + NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H=$gl_next_as_first_directive + + + + + HAVE_LANGINFO_CODESET=0 + HAVE_LANGINFO_ERA=0 + + if test $ac_cv_header_langinfo_h = yes; then + HAVE_LANGINFO_H=1 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether langinfo.h defines CODESET" >&5 +$as_echo_n "checking whether langinfo.h defines CODESET... " >&6; } +if test "${gl_cv_header_langinfo_codeset+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int a = CODESET; + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_header_langinfo_codeset=yes +else + gl_cv_header_langinfo_codeset=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_langinfo_codeset" >&5 +$as_echo "$gl_cv_header_langinfo_codeset" >&6; } + if test $gl_cv_header_langinfo_codeset = yes; then + HAVE_LANGINFO_CODESET=1 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether langinfo.h defines ERA" >&5 +$as_echo_n "checking whether langinfo.h defines ERA... " >&6; } +if test "${gl_cv_header_langinfo_era+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int a = ERA; + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_header_langinfo_era=yes +else + gl_cv_header_langinfo_era=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_langinfo_era" >&5 +$as_echo "$gl_cv_header_langinfo_era" >&6; } + if test $gl_cv_header_langinfo_era = yes; then + HAVE_LANGINFO_ERA=1 + fi + else + HAVE_LANGINFO_H=0 + fi + + + + + + + + + + if test $ac_cv_func_lchmod = no; then HAVE_LCHMOD=0 fi @@ -24995,6 +28222,7 @@ _ACEOF + for ac_func in lchown do : ac_fn_c_check_func "$LINENO" "lchown" "ac_cv_func_lchown" @@ -25012,6 +28240,19 @@ done if test $ac_cv_func_lchown = no; then + HAVE_LCHOWN=0 + elif test "$gl_cv_func_chown_slash_works" != yes \ + || test "$gl_cv_func_chown_ctime_works" != yes; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS lchown.$ac_objext" + REPLACE_LCHOWN=1 fi @@ -25040,9 +28281,9 @@ else # native cc issues annoying warnings and then ignores it, # which would cause us to incorrectly conclude that it worked. for gl_flags in \ - '-Wl,--as-needed' \ - '-Wl,-z,ignore' \ - '-z ignore' + '-Wl,--as-needed' \ + '-Wl,-z,ignore' \ + '-z ignore' do LDFLAGS="$gl_flags $LDFLAGS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -25094,6 +28335,10 @@ if test "${gl_cv_func_link_works+set}" = set; then : $as_echo_n "(cached) " >&6 else touch conftest.a + # Assume that if we have lstat, we can also check symlinks. + if test $ac_cv_func_lstat = yes; then + ln -s conftest.a conftest.lnk + fi if test "$cross_compiling" = yes; then : gl_cv_func_link_works="guessing no" else @@ -25104,7 +28349,11 @@ else int main () { -return !link ("conftest.a", "conftest.b/"); +if (!link ("conftest.a", "conftest.b/")) return 1; +#if HAVE_LSTAT + if (!link ("conftest.lnk/", "conftest.b")) return 2; +#endif + ; return 0; } @@ -25118,11 +28367,11 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi - rm -f conftest.a conftest.b + rm -f conftest.a conftest.b conftest.lnk fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_link_works" >&5 $as_echo "$gl_cv_func_link_works" >&6; } - if test $gl_cv_func_link_works != yes; then + if test "$gl_cv_func_link_works" != yes; then REPLACE_LINK=1 @@ -25153,7 +28402,7 @@ else # Create a regular file. echo > conftest.file if test "$cross_compiling" = yes; then : - gl_cv_func_link_follows_symlink=unknown + gl_cv_func_link_follows_symlink=unknown else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -25164,45 +28413,46 @@ else # include # define SAME_INODE(Stat_buf_1, Stat_buf_2) \ - ((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \ - && (Stat_buf_1).st_dev == (Stat_buf_2).st_dev) + ((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \ + && (Stat_buf_1).st_dev == (Stat_buf_2).st_dev) - int - main () - { - const char *file = "conftest.file"; - const char *sym = "conftest.sym"; - const char *hard = "conftest.hard"; - struct stat sb_file, sb_hard; + int + main () + { + const char *file = "conftest.file"; + const char *sym = "conftest.sym"; + const char *hard = "conftest.hard"; + struct stat sb_file, sb_hard; - /* Create a symlink to the regular file. */ - if (symlink (file, sym)) - abort (); + /* Create a symlink to the regular file. */ + if (symlink (file, sym)) + return 2; - /* Create a hard link to that symlink. */ - if (link (sym, hard)) - abort (); + /* Create a hard link to that symlink. */ + if (link (sym, hard)) + return 3; - if (lstat (hard, &sb_hard)) - abort (); - if (lstat (file, &sb_file)) - abort (); + if (lstat (hard, &sb_hard)) + return 4; + if (lstat (file, &sb_file)) + return 5; - /* If the dev/inode of hard and file are the same, then - the link call followed the symlink. */ - return SAME_INODE (sb_hard, sb_file) ? 1 : 0; - } + /* If the dev/inode of hard and file are the same, then + the link call followed the symlink. */ + return SAME_INODE (sb_hard, sb_file) ? 1 : 0; + } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_link_follows_symlink=no else - gl_cv_func_link_follows_symlink=yes + gl_cv_func_link_follows_symlink=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi + rm -f conftest.file conftest.sym conftest.hard fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_link_follows_symlink" >&5 @@ -25226,6 +28476,94 @@ _ACEOF + + if test $ac_cv_func_linkat = no; then + HAVE_LINKAT=0 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS linkat.$ac_objext" + + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS at-func2.$ac_objext" + + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether linkat(,AT_SYMLINK_FOLLOW) works" >&5 +$as_echo_n "checking whether linkat(,AT_SYMLINK_FOLLOW) works... " >&6; } +if test "${gl_cv_func_linkat_follow+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + rm -rf conftest.f1 conftest.f2 + touch conftest.f1 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#ifdef __linux__ +/* Linux added linkat in 2.6.16, but did not add AT_SYMLINK_FOLLOW + until 2.6.18. Always replace linkat to support older kernels. */ +choke me +#endif + +int +main () +{ +return linkat (AT_FDCWD, "conftest.f1", AT_FDCWD, "conftest.f2", + AT_SYMLINK_FOLLOW); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_func_linkat_follow=yes +else + gl_cv_func_linkat_follow="need runtime check" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + rm -rf conftest.f1 conftest.f2 +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_linkat_follow" >&5 +$as_echo "$gl_cv_func_linkat_follow" >&6; } + if test "$gl_cv_func_linkat_follow" != yes; then + REPLACE_LINKAT=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS linkat.$ac_objext" + + fi + fi + + + + GNULIB_LINKAT=1 + + + + + + + + + LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(top_builddir)/$gl_source_base\"" @@ -25235,6 +28573,184 @@ _ACEOF + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether locale.h conforms to POSIX:2001" >&5 +$as_echo_n "checking whether locale.h conforms to POSIX:2001... " >&6; } +if test "${gl_cv_header_locale_h_posix2001+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int x = LC_MESSAGES; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_header_locale_h_posix2001=yes +else + gl_cv_header_locale_h_posix2001=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_locale_h_posix2001" >&5 +$as_echo "$gl_cv_header_locale_h_posix2001" >&6; } + + + if test $ac_cv_header_xlocale_h = yes; then + HAVE_XLOCALE_H=1 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether locale.h defines locale_t" >&5 +$as_echo_n "checking whether locale.h defines locale_t... " >&6; } +if test "${gl_cv_header_locale_has_locale_t+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +locale_t x; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_header_locale_has_locale_t=yes +else + gl_cv_header_locale_has_locale_t=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_locale_has_locale_t" >&5 +$as_echo "$gl_cv_header_locale_has_locale_t" >&6; } + if test $gl_cv_header_locale_has_locale_t = yes; then + gl_cv_header_locale_h_needs_xlocale_h=no + else + gl_cv_header_locale_h_needs_xlocale_h=yes + fi + else + HAVE_XLOCALE_H=0 + gl_cv_header_locale_h_needs_xlocale_h=no + fi + + + + + + + + + if test $gl_cv_have_include_next = yes; then + gl_cv_next_locale_h='<'locale.h'>' + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 +$as_echo_n "checking absolute name of ... " >&6; } +if test "${gl_cv_next_locale_h+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + if test $ac_cv_header_locale_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_locale_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/locale.h#{ + s#.*"\(.*/locale.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_locale_h='<'locale.h'>' + fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_locale_h" >&5 +$as_echo "$gl_cv_next_locale_h" >&6; } + fi + NEXT_LOCALE_H=$gl_cv_next_locale_h + + if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' + gl_next_as_first_directive='<'locale.h'>' + else + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' + gl_next_as_first_directive=$gl_cv_next_locale_h + fi + NEXT_AS_FIRST_DIRECTIVE_LOCALE_H=$gl_next_as_first_directive + + + + + if test -n "$STDDEF_H" \ + || test $gl_cv_header_locale_h_posix2001 = no \ + || test $gl_cv_header_locale_h_needs_xlocale_h = yes; then + + : + + fi + + + + if test "$gl_threads_api" = posix; then + # OSF/1 4.0 and MacOS X 10.1 lack the pthread_rwlock_t type and the + # pthread_rwlock_* functions. + ac_fn_c_check_type "$LINENO" "pthread_rwlock_t" "ac_cv_type_pthread_rwlock_t" "#include +" +if test "x$ac_cv_type_pthread_rwlock_t" = x""yes; then : + +$as_echo "#define HAVE_PTHREAD_RWLOCK 1" >>confdefs.h + +fi + + # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +#if __FreeBSD__ == 4 +error "No, in FreeBSD 4.0 recursive mutexes actually don't work." +#else +int x = (int)PTHREAD_MUTEX_RECURSIVE; +return !x; +#endif + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +$as_echo "#define HAVE_PTHREAD_MUTEX_RECURSIVE 1" >>confdefs.h + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + + + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS long-options.$ac_objext" @@ -25264,12 +28780,12 @@ int main () _ACEOF if ac_fn_c_try_link "$LINENO"; then : if test -s conftest$ac_exeext \ - && ./conftest$ac_exeext < conftest.$ac_ext \ - && { echo hi | ./conftest$ac_exeext; test $? = 1; }; then - gl_cv_func_lseek_pipe=yes - else - gl_cv_func_lseek_pipe=no - fi + && ./conftest$ac_exeext < conftest.$ac_ext \ + && { echo hi | ./conftest$ac_exeext; test $? = 1; }; then + gl_cv_func_lseek_pipe=yes + else + gl_cv_func_lseek_pipe=no + fi else gl_cv_func_lseek_pipe=no fi @@ -25322,77 +28838,14 @@ $as_echo "#define LSEEK_PIPE_BROKEN 1" >>confdefs.h if test $ac_cv_func_lstat = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether lstat dereferences a symlink specified with a trailing slash" >&5 -$as_echo_n "checking whether lstat dereferences a symlink specified with a trailing slash... " >&6; } -if test "${ac_cv_func_lstat_dereferences_slashed_symlink+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - rm -f conftest.sym conftest.file -echo >conftest.file -if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then - if test "$cross_compiling" = yes; then : - ac_cv_func_lstat_dereferences_slashed_symlink=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -struct stat sbuf; - /* Linux will dereference the symlink and fail. - That is better in the sense that it means we will not - have to compile and use the lstat wrapper. */ - return lstat ("conftest.sym/", &sbuf) == 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_lstat_dereferences_slashed_symlink=yes -else - ac_cv_func_lstat_dereferences_slashed_symlink=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi -else - # If the `ln -s' command failed, then we probably don't even - # have an lstat function. - ac_cv_func_lstat_dereferences_slashed_symlink=no -fi -rm -f conftest.sym conftest.file - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_lstat_dereferences_slashed_symlink" >&5 -$as_echo "$ac_cv_func_lstat_dereferences_slashed_symlink" >&6; } - -test $ac_cv_func_lstat_dereferences_slashed_symlink = yes && - -cat >>confdefs.h <<_ACEOF -#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 -_ACEOF - - -if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then - - - - - - - - - gl_LIBOBJS="$gl_LIBOBJS lstat.$ac_objext" - -fi - - if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then - REPLACE_LSTAT=1 + if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then + REPLACE_LSTAT=1 fi # Prerequisites of lib/lstat.c. + else + HAVE_LSTAT=0 fi @@ -25520,26 +28973,26 @@ if test "${gl_cv_next_math_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_math_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_math_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_math_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/math.h#{ - s#.*"\(.*/math.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_math_h='<'math.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_math_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/math.h#{ + s#.*"\(.*/math.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_math_h='<'math.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_math_h" >&5 @@ -25558,6 +29011,8 @@ $as_echo "$gl_cv_next_math_h" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether NAN macro works" >&5 $as_echo_n "checking whether NAN macro works... " >&6; } if test "${gl_cv_header_math_nan_works+set}" = set; then : @@ -25574,9 +29029,9 @@ main () test only needs to fail when NAN is provided but wrong. */ float f = 1.0f; #ifdef NAN - f = NAN; + f = NAN; #endif - return f == 0; + return f == 0; ; return 0; } @@ -25605,8 +29060,8 @@ int main () { /* Solaris 10 has a broken definition of HUGE_VAL. */ - double d = HUGE_VAL; - return d == 0; + double d = HUGE_VAL; + return d == 0; ; return 0; } @@ -25630,6 +29085,8 @@ $as_echo "$gl_cv_header_math_huge_val_works" >&6; } + + : @@ -25647,8 +29104,7 @@ $as_echo "$gl_cv_header_math_huge_val_works" >&6; } fi if test $HAVE_MBRLEN = 0 || test $REPLACE_MBRLEN = 1; then - - WCHAR_H=wchar.h + : @@ -25810,8 +29266,7 @@ $as_echo "$gl_cv_func_mbrtowc_sanitycheck" >&6; } fi if test $REPLACE_MBSTATE_T = 1; then - - WCHAR_H=wchar.h + : fi @@ -26039,8 +29494,7 @@ $as_echo "#define MBRTOWC_NUL_RETVAL_BUG 1" >>confdefs.h fi if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then - - WCHAR_H=wchar.h + : @@ -26206,8 +29660,7 @@ $as_echo "$gl_cv_func_mbrtowc_sanitycheck" >&6; } fi if test $REPLACE_MBSTATE_T = 1; then - - WCHAR_H=wchar.h + : fi @@ -26220,8 +29673,7 @@ $as_echo "$gl_cv_func_mbrtowc_sanitycheck" >&6; } fi if test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1; then - - WCHAR_H=wchar.h + : @@ -26244,6 +29696,15 @@ $as_echo "$gl_cv_func_mbrtowc_sanitycheck" >&6; } + + if test $ac_cv_func_mbslen = yes; then + HAVE_MBSLEN=1 + else + HAVE_MBSLEN=0 + fi + + + GNULIB_MBSLEN=1 @@ -26387,8 +29848,7 @@ $as_echo "$gl_cv_func_mbrtowc_sanitycheck" >&6; } fi if test $REPLACE_MBSTATE_T = 1; then - - WCHAR_H=wchar.h + : fi @@ -26498,8 +29958,7 @@ $as_echo "$gl_cv_func_mbsrtowcs_works" >&6; } fi if test $HAVE_MBSRTOWCS = 0 || test $REPLACE_MBSRTOWCS = 1; then - - WCHAR_H=wchar.h + : @@ -26596,7 +30055,7 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default -# include +# include int main () { @@ -26628,6 +30087,7 @@ $as_echo "#define mbstate_t int" >>confdefs.h + : @@ -26660,7 +30120,7 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include + #include int main () @@ -26982,16 +30442,6 @@ done fi - for ac_func in getgrouplist -do : - ac_fn_c_check_func "$LINENO" "getgrouplist" "ac_cv_func_getgrouplist" -if test "x$ac_cv_func_getgrouplist" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_GETGROUPLIST 1 -_ACEOF - -fi -done @@ -27018,50 +30468,45 @@ done - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mkdir fails due to a trailing slash" >&5 -$as_echo_n "checking whether mkdir fails due to a trailing slash... " >&6; } -if test "${gl_cv_func_mkdir_trailing_slash_bug+set}" = set; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mkdir handles trailing slash" >&5 +$as_echo_n "checking whether mkdir handles trailing slash... " >&6; } +if test "${gl_cv_func_mkdir_trailing_slash_works+set}" = set; then : $as_echo_n "(cached) " >&6 else - - # Arrange for deletion of the temporary directory this test might create. - ac_clean_files="$ac_clean_files confdir-slash" + rm -rf conftest.dir if test "$cross_compiling" = yes; then : - gl_cv_func_mkdir_trailing_slash_bug=yes - + gl_cv_func_mkdir_trailing_slash_works="guessing no" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # include # include -# include -# ifdef HAVE_UNISTD_H -# include -# endif - int main () - { - rmdir ("confdir-slash"); - exit (mkdir ("confdir-slash/", 0700)); - } +int +main () +{ +return mkdir ("conftest.dir/", 0700); + ; + return 0; +} _ACEOF if ac_fn_c_try_run "$LINENO"; then : - gl_cv_func_mkdir_trailing_slash_bug=no + gl_cv_func_mkdir_trailing_slash_works=yes else - gl_cv_func_mkdir_trailing_slash_bug=yes + gl_cv_func_mkdir_trailing_slash_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi + rm -rf conftest.dir fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mkdir_trailing_slash_bug" >&5 -$as_echo "$gl_cv_func_mkdir_trailing_slash_bug" >&6; } - - if test $gl_cv_func_mkdir_trailing_slash_bug = yes; then +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mkdir_trailing_slash_works" >&5 +$as_echo "$gl_cv_func_mkdir_trailing_slash_works" >&6; } + if test "$gl_cv_func_mkdir_trailing_slash_works" != yes; then REPLACE_MKDIR=1 @@ -27073,7 +30518,61 @@ $as_echo "$gl_cv_func_mkdir_trailing_slash_bug" >&6; } gl_LIBOBJS="$gl_LIBOBJS mkdir.$ac_objext" - : + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mkdir handles trailing dot" >&5 +$as_echo_n "checking whether mkdir handles trailing dot... " >&6; } +if test "${gl_cv_func_mkdir_trailing_dot_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + rm -rf conftest.dir + if test "$cross_compiling" = yes; then : + gl_cv_func_mkdir_trailing_dot_works="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +# include +# include + +int +main () +{ +return !mkdir ("conftest.dir/./", 0700); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_mkdir_trailing_dot_works=yes +else + gl_cv_func_mkdir_trailing_dot_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + rm -rf conftest.dir + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mkdir_trailing_dot_works" >&5 +$as_echo "$gl_cv_func_mkdir_trailing_dot_works" >&6; } + if test "$gl_cv_func_mkdir_trailing_dot_works" != yes; then + REPLACE_MKDIR=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS mkdir.$ac_objext" + + +$as_echo "#define FUNC_MKDIR_DOT_BUG 1" >>confdefs.h + fi @@ -27123,19 +30622,19 @@ int main () { int i; - off_t large = (off_t) 4294967295u; - if (large < 0) - large = 2147483647; - for (i = 0; i < 70; i++) - { - char templ[] = "conftest.mkstemp/coXXXXXX"; - int (*mkstemp_function) (char *) = mkstemp; - int fd = mkstemp_function (templ); - if (fd < 0 || lseek (fd, large, SEEK_SET) != large) - return 1; - close (fd); - } - return 0; + off_t large = (off_t) 4294967295u; + if (large < 0) + large = 2147483647; + for (i = 0; i < 70; i++) + { + char templ[] = "conftest.mkstemp/coXXXXXX"; + int (*mkstemp_function) (char *) = mkstemp; + int fd = mkstemp_function (templ); + if (fd < 0 || lseek (fd, large, SEEK_SET) != large) + return 1; + close (fd); + } + return 0; ; return 0; } @@ -27257,8 +30756,8 @@ static int mktime_test (time_t now) { return (mktime_test1 (now) - && mktime_test1 ((time_t) (time_t_max - now)) - && mktime_test1 ((time_t) (time_t_min + now))); + && mktime_test1 ((time_t) (time_t_max - now)) + && mktime_test1 ((time_t) (time_t_min + now))); } static int @@ -27288,17 +30787,17 @@ bigtime_test (int j) { struct tm *lt = localtime (&now); if (! (lt - && lt->tm_year == tm.tm_year - && lt->tm_mon == tm.tm_mon - && lt->tm_mday == tm.tm_mday - && lt->tm_hour == tm.tm_hour - && lt->tm_min == tm.tm_min - && lt->tm_sec == tm.tm_sec - && lt->tm_yday == tm.tm_yday - && lt->tm_wday == tm.tm_wday - && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst) - == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst)))) - return 0; + && lt->tm_year == tm.tm_year + && lt->tm_mon == tm.tm_mon + && lt->tm_mday == tm.tm_mday + && lt->tm_hour == tm.tm_hour + && lt->tm_min == tm.tm_min + && lt->tm_sec == tm.tm_sec + && lt->tm_yday == tm.tm_yday + && lt->tm_wday == tm.tm_wday + && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst) + == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst)))) + return 0; } return 1; } @@ -27330,7 +30829,7 @@ year_2050_test () to the correct answer that we can assume the discrepancy is due to leap seconds. */ return (t == (time_t) -1 - || (0 < t && answer - 120 <= t && t <= answer + 120)); + || (0 < t && answer - 120 <= t && t <= answer + 120)); } int @@ -27348,7 +30847,7 @@ main () { t = (time_t_max << 1) + 1; if (t <= time_t_max) - break; + break; time_t_max = t; } time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max; @@ -27357,23 +30856,23 @@ main () for (i = 0; i < N_STRINGS; i++) { if (tz_strings[i]) - putenv (tz_strings[i]); + putenv (tz_strings[i]); for (t = 0; t <= time_t_max - delta; t += delta) - if (! mktime_test (t)) - return 1; + if (! mktime_test (t)) + return 1; if (! (mktime_test ((time_t) 1) - && mktime_test ((time_t) (60 * 60)) - && mktime_test ((time_t) (60 * 60 * 24)))) - return 1; + && mktime_test ((time_t) (60 * 60)) + && mktime_test ((time_t) (60 * 60 * 24)))) + return 1; for (j = 1; ; j <<= 1) - if (! bigtime_test (j)) - return 1; - else if (INT_MAX / 2 < j) - break; + if (! bigtime_test (j)) + return 1; + else if (INT_MAX / 2 < j) + break; if (! bigtime_test (INT_MAX)) - return 1; + return 1; } return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ()); } @@ -27619,7 +31118,7 @@ _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then : test $ac_cv_func_listmntent = yes \ - && fu_cv_sys_mounted_cray_listmntent=yes + && fu_cv_sys_mounted_cray_listmntent=yes fi rm -f conftest* @@ -27687,13 +31186,13 @@ else #include #if !defined MOUNTED -# if defined _PATH_MOUNTED /* GNU libc */ +# if defined _PATH_MOUNTED /* GNU libc */ # define MOUNTED _PATH_MOUNTED # endif -# if defined MNT_MNTTAB /* HP-UX. */ +# if defined MNT_MNTTAB /* HP-UX. */ # define MOUNTED MNT_MNTTAB # endif -# if defined MNTTABNAME /* Dynix. */ +# if defined MNTTABNAME /* Dynix. */ # define MOUNTED MNTTABNAME # endif #endif @@ -27860,8 +31359,8 @@ $as_echo_n "checking for getmntinfo function... " >&6; } else test "$ac_cv_func_getmntinfo" = yes \ - && fu_cv_sys_mounted_getmntinfo=yes \ - || fu_cv_sys_mounted_getmntinfo=no + && fu_cv_sys_mounted_getmntinfo=yes \ + || fu_cv_sys_mounted_getmntinfo=no fi @@ -27984,7 +31483,7 @@ done $as_echo_n "checking for BEOS mounted file system support functions... " >&6; } if test $ac_cv_header_fs_info_h = yes \ && test $ac_cv_func_next_dev = yes \ - && test $ac_cv_func_fs_stat_dev = yes; then + && test $ac_cv_func_fs_stat_dev = yes; then fu_result=yes else fu_result=no @@ -28110,6 +31609,8 @@ fi # Solaris 2.5.1 needs -lposix4 to get the nanosleep function. # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4. + LIB_NANOSLEEP= + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing nanosleep" >&5 $as_echo_n "checking for library containing nanosleep... " >&6; } if test "${ac_cv_search_nanosleep+set}" = set; then : @@ -28164,7 +31665,7 @@ ac_res=$ac_cv_search_nanosleep if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" test "$ac_cv_search_nanosleep" = "none required" || - LIB_NANOSLEEP=$ac_cv_search_nanosleep + LIB_NANOSLEEP=$ac_cv_search_nanosleep fi @@ -28189,51 +31690,51 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include - #include - #include - #if HAVE_SYS_TIME_H - #include - #endif - #include - #include - #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) - #define TYPE_MAXIMUM(t) \ - ((t) (! TYPE_SIGNED (t) \ - ? (t) -1 \ - : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))) + #include + #include + #include + #if HAVE_SYS_TIME_H + #include + #endif + #include + #include + #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) + #define TYPE_MAXIMUM(t) \ + ((t) (! TYPE_SIGNED (t) \ + ? (t) -1 \ + : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))) - static void - check_for_SIGALRM (int sig) - { - if (sig != SIGALRM) - _exit (1); - } + static void + check_for_SIGALRM (int sig) + { + if (sig != SIGALRM) + _exit (1); + } - int - main () - { - static struct timespec ts_sleep; - static struct timespec ts_remaining; - static struct sigaction act; - if (! nanosleep) - return 1; - act.sa_handler = check_for_SIGALRM; - sigemptyset (&act.sa_mask); - sigaction (SIGALRM, &act, NULL); - ts_sleep.tv_sec = 0; - ts_sleep.tv_nsec = 1; - alarm (1); - if (nanosleep (&ts_sleep, NULL) != 0) - return 1; - ts_sleep.tv_sec = TYPE_MAXIMUM (time_t); - ts_sleep.tv_nsec = 999999999; - alarm (1); - if (nanosleep (&ts_sleep, &ts_remaining) == -1 && errno == EINTR - && TYPE_MAXIMUM (time_t) - 10 < ts_remaining.tv_sec) - return 0; - return 119; - } + int + main () + { + static struct timespec ts_sleep; + static struct timespec ts_remaining; + static struct sigaction act; + if (! nanosleep) + return 1; + act.sa_handler = check_for_SIGALRM; + sigemptyset (&act.sa_mask); + sigaction (SIGALRM, &act, NULL); + ts_sleep.tv_sec = 0; + ts_sleep.tv_nsec = 1; + alarm (1); + if (nanosleep (&ts_sleep, NULL) != 0) + return 1; + ts_sleep.tv_sec = TYPE_MAXIMUM (time_t); + ts_sleep.tv_nsec = 999999999; + alarm (1); + if (nanosleep (&ts_sleep, &ts_remaining) == -1 && errno == EINTR + && TYPE_MAXIMUM (time_t) - 10 < ts_remaining.tv_sec) + return 0; + return 119; + } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_nanosleep=yes @@ -28257,11 +31758,12 @@ $as_echo "$gl_cv_func_nanosleep" >&6; } $as_echo "#define HAVE_BUG_BIG_NANOSLEEP 1" >>confdefs.h - for ac_lib in $LIB_CLOCK_GETTIME; do - case " $LIB_NANOSLEEP " in - *" $ac_lib "*) ;; - *) LIB_NANOSLEEP="$LIB_NANOSLEEP $ac_lib";; - esac + else + for ac_lib in $LIBSOCKET; do + case " $LIB_NANOSLEEP " in + *" $ac_lib "*) ;; + *) LIB_NANOSLEEP="$LIB_NANOSLEEP $ac_lib";; + esac done fi @@ -28282,7 +31784,6 @@ $as_echo "#define HAVE_BUG_BIG_NANOSLEEP 1" >>confdefs.h fi - LIBS=$nanosleep_save_libs @@ -28293,6 +31794,7 @@ $as_echo "#define HAVE_BUG_BIG_NANOSLEEP 1" >>confdefs.h + if test $gl_cv_have_include_next = yes; then gl_cv_next_netdb_h='<'netdb.h'>' else @@ -28302,26 +31804,26 @@ if test "${gl_cv_next_netdb_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_netdb_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_netdb_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_netdb_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/netdb.h#{ - s#.*"\(.*/netdb.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_netdb_h='<'netdb.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_netdb_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/netdb.h#{ + s#.*"\(.*/netdb.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_netdb_h='<'netdb.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_netdb_h" >&5 @@ -28430,26 +31932,26 @@ if test "${gl_cv_next_netinet_in_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_netinet_in_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_netinet_in_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_netinet_in_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/netinet/in.h#{ - s#.*"\(.*/netinet/in.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_netinet_in_h='<'netinet/in.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_netinet_in_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/netinet/in.h#{ + s#.*"\(.*/netinet/in.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_netinet_in_h='<'netinet/in.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_netinet_in_h" >&5 @@ -28482,6 +31984,134 @@ $as_echo "$gl_cv_next_netinet_in_h" >&6; } + if test $ac_cv_func_nl_langinfo = yes; then + if test $HAVE_LANGINFO_CODESET = 1 && test $HAVE_LANGINFO_ERA = 1; then + : + else + REPLACE_NL_LANGINFO=1 + +$as_echo "#define REPLACE_NL_LANGINFO 1" >>confdefs.h + + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS nl_langinfo.$ac_objext" + + fi + else + HAVE_NL_LANGINFO=0 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS nl_langinfo.$ac_objext" + + fi + + + + GNULIB_NL_LANGINFO=1 + + + + + + for ac_header in sys/pstat.h sys/sysmp.h sys/param.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + for ac_header in sys/sysctl.h +do : + ac_fn_c_check_header_compile "$LINENO" "sys/sysctl.h" "ac_cv_header_sys_sysctl_h" "$ac_includes_default + #if HAVE_SYS_PARAM_H + # include + #endif + +" +if test "x$ac_cv_header_sys_sysctl_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_SYSCTL_H 1 +_ACEOF + +fi + +done + + + for ac_func in sched_getaffinity sched_getaffinity_np \ + pstat_getdynamic sysmp sysctl +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +eval as_val=\$$as_ac_var + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + if test $ac_cv_func_sched_getaffinity = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for glibc compatible sched_getaffinity" >&5 +$as_echo_n "checking for glibc compatible sched_getaffinity... " >&6; } +if test "${gl_cv_func_sched_getaffinity3+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +sched_getaffinity (0, 0, (cpu_set_t *) 0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_func_sched_getaffinity3=yes +else + gl_cv_func_sched_getaffinity3=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_sched_getaffinity3" >&5 +$as_echo "$gl_cv_func_sched_getaffinity3" >&6; } + if test $gl_cv_func_sched_getaffinity3 = yes; then + +$as_echo "#define HAVE_SCHED_GETAFFINITY_LIKE_GLIBC 1" >>confdefs.h + + fi + fi + + + + + + @@ -28563,15 +32193,21 @@ fi ;; *) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether open recognizes a trailing slash" >&5 + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether open recognizes a trailing slash" >&5 $as_echo_n "checking whether open recognizes a trailing slash... " >&6; } if test "${gl_cv_func_open_slash+set}" = set; then : $as_echo_n "(cached) " >&6 else - + # Assume that if we have lstat, we can also check symlinks. + if test $ac_cv_func_lstat = yes; then + touch conftest.tmp + ln -s conftest.tmp conftest.lnk + fi if test "$cross_compiling" = yes; then : case "$host_os" in + freebsd*) gl_cv_func_open_slash="guessing no" ;; solaris2.[0-9]*) gl_cv_func_open_slash="guessing no" ;; hpux*) gl_cv_func_open_slash="guessing no" ;; *) gl_cv_func_open_slash="guessing yes" ;; @@ -28587,6 +32223,9 @@ else #endif int main () { +#if HAVE_LSTAT + if (open ("conftest.lnk/", O_RDONLY) != -1) return 2; +#endif return open ("conftest.sl/", O_CREAT, 0600) >= 0; } _ACEOF @@ -28599,7 +32238,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi - rm -f conftest.sl + rm -f conftest.sl conftest.tmp conftest.lnk fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_open_slash" >&5 @@ -28689,7 +32328,21 @@ $as_echo "#define GNULIB_OPEN 1" >>confdefs.h - for ac_func in fchmodat mkdirat openat + + + + + + + + + + + + + + + for ac_func in fchmodat fstatat mkdirat openat unlinkat do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -28708,9 +32361,37 @@ done + case $ac_cv_func_openat+$ac_cv_func_lstat_dereferences_slashed_symlink in - yes+yes) ;; + yes+yes) + # GNU/Hurd has unlinkat, but it has the same bug as unlink. + if test $REPLACE_UNLINK = 1; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS unlinkat.$ac_objext" + + REPLACE_UNLINKAT=1 + fi ;; yes+*) + # Solaris 9 has *at functions, but uniformly mishandles trailing + # slash in all of them. + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS openat.$ac_objext" + + REPLACE_OPENAT=1 @@ -28722,6 +32403,17 @@ done gl_LIBOBJS="$gl_LIBOBJS fstatat.$ac_objext" REPLACE_FSTATAT=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS unlinkat.$ac_objext" + + REPLACE_UNLINKAT=1 ;; *) HAVE_OPENAT=0 @@ -28729,6 +32421,7 @@ done HAVE_FSTATAT=0 # No known system with fstatat but not openat + : ;; esac @@ -28739,6 +32432,7 @@ done HAVE_MKDIRAT=0 fi + ac_fn_c_check_func "$LINENO" "fchownat" "ac_cv_func_fchownat" if test "x$ac_cv_func_fchownat" = x""yes; then : @@ -28769,8 +32463,8 @@ int main () { return (fchownat (AT_FDCWD, "$gl_dangle", -1, getgid (), - AT_SYMLINK_NOFOLLOW) != 0 - && errno == ENOENT); + AT_SYMLINK_NOFOLLOW) != 0 + && errno == ENOENT); } _ACEOF @@ -28789,12 +32483,18 @@ fi $as_echo "$gl_cv_func_fchownat_nofollow_works" >&6; } if test $gl_cv_func_fchownat_nofollow_works = no; then : REPLACE_FCHOWNAT=1 + +$as_echo "#define FCHOWNAT_NOFOLLOW_BUG 1" >>confdefs.h + fi else HAVE_FCHOWNAT=0 fi + if test $REPLACE_CHOWN = 1; then + REPLACE_FCHOWNAT=1 + fi if test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1; then @@ -28885,8 +32585,7 @@ WARNING: You don't seem to have perl5.005 or newer installed, or you lack # Prerequisites of lib/physmem.c. for ac_header in sys/pstat.h sys/sysmp.h sys/sysinfo.h \ - machine/hal_sysinfo.h sys/table.h sys/param.h sys/sysctl.h \ - sys/systemcfg.h + machine/hal_sysinfo.h sys/table.h sys/param.h sys/systemcfg.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default @@ -28899,6 +32598,23 @@ _ACEOF fi +done + + for ac_header in sys/sysctl.h +do : + ac_fn_c_check_header_compile "$LINENO" "sys/sysctl.h" "ac_cv_header_sys_sysctl_h" "$ac_includes_default + #if HAVE_SYS_PARAM_H + # include + #endif + +" +if test "x$ac_cv_header_sys_sysctl_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_SYSCTL_H 1 +_ACEOF + +fi + done @@ -28925,22 +32641,22 @@ if test "${gl_cv_posix_shell+set}" = set; then : else gl_test_posix_shell_script=' func_return () { - (exit $1) + (exit $1) } func_success () { - func_return 0 + func_return 0 } func_failure () { - func_return 1 + func_return 1 } func_ret_success () { - return 0 + return 0 } func_ret_failure () { - return 1 + return 1 } subshell_umask_sanity () { - (umask 22; (umask 0); test $(umask) -eq 22) + (umask 22; (umask 0); test $(umask) -eq 22) } test "$(echo foo)" = foo && func_success && @@ -28951,11 +32667,11 @@ else subshell_umask_sanity ' for gl_cv_posix_shell in \ - "$CONFIG_SHELL" "$SHELL" /bin/sh /bin/bash /bin/ksh /bin/sh5 no; do + "$CONFIG_SHELL" "$SHELL" /bin/sh /bin/bash /bin/ksh /bin/sh5 no; do case $gl_cv_posix_shell in /*) - "$gl_cv_posix_shell" -c "$gl_test_posix_shell_script" 2>/dev/null \ - && break;; + "$gl_cv_posix_shell" -c "$gl_test_posix_shell_script" 2>/dev/null \ + && break;; esac done fi @@ -29426,6 +33142,18 @@ cat >>confdefs.h <<_ACEOF #define HAVE_DECL_PROGRAM_INVOCATION_NAME $ac_have_decl _ACEOF + ac_fn_c_check_decl "$LINENO" "program_invocation_short_name" "ac_cv_have_decl_program_invocation_short_name" "#include +" +if test "x$ac_cv_have_decl_program_invocation_short_name" = x""yes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME $ac_have_decl +_ACEOF + XGETTEXT_EXTRA_OPTIONS="$XGETTEXT_EXTRA_OPTIONS --keyword='proper_name:1,\"This is a proper name. See the gettext manual, section Names.\"'" @@ -29442,7 +33170,7 @@ if test "${gl_cv_func_svid_putenv+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : - gl_cv_func_svid_putenv=no + gl_cv_func_svid_putenv=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -29567,6 +33295,99 @@ done : + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether readlink signature is correct" >&5 +$as_echo_n "checking whether readlink signature is correct... " >&6; } +if test "${gl_cv_decl_readlink_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + /* Cause compilation failure if original declaration has wrong type. */ + ssize_t readlink (const char *, char *, size_t); +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_decl_readlink_works=yes +else + gl_cv_decl_readlink_works=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_decl_readlink_works" >&5 +$as_echo "$gl_cv_decl_readlink_works" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether readlink handles trailing slash correctly" >&5 +$as_echo_n "checking whether readlink handles trailing slash correctly... " >&6; } +if test "${gl_cv_func_readlink_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + # We have readlink, so assume ln -s works. + ln -s conftest.no-such conftest.link + ln -s conftest.link conftest.lnk2 + if test "$cross_compiling" = yes; then : + gl_cv_func_readlink_works="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +char buf[20]; + return readlink ("conftest.lnk2/", buf, sizeof buf) != -1; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_readlink_works=yes +else + gl_cv_func_readlink_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + rm -f conftest.link conftest.lnk2 +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_readlink_works" >&5 +$as_echo "$gl_cv_func_readlink_works" >&6; } + if test "$gl_cv_func_readlink_works" != yes; then + +$as_echo "#define READLINK_TRAILING_SLASH_BUG 1" >>confdefs.h + + REPLACE_READLINK=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS readlink.$ac_objext" + + elif test "$gl_cv_decl_readlink_works" != yes; then + REPLACE_READLINK=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS readlink.$ac_objext" + + fi fi @@ -29971,7 +33792,7 @@ fi case $with_included_regex in #( yes|no) ac_use_included_regex=$with_included_regex - ;; + ;; '') # If the system regex support is good enough that it passes the # following run test, then default to *not* using the included regex.c. @@ -29988,132 +33809,132 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default - #if HAVE_LOCALE_H - #include - #endif - #include - #include + #if HAVE_LOCALE_H + #include + #endif + #include + #include int main () { static struct re_pattern_buffer regex; - unsigned char folded_chars[UCHAR_MAX + 1]; - int i; - const char *s; - struct re_registers regs; + unsigned char folded_chars[UCHAR_MAX + 1]; + int i; + const char *s; + struct re_registers regs; - #if HAVE_LOCALE_H - /* http://sourceware.org/ml/libc-hacker/2006-09/msg00008.html - This test needs valgrind to catch the bug on Debian - GNU/Linux 3.1 x86, but it might catch the bug better - on other platforms and it shouldn't hurt to try the - test here. */ - if (setlocale (LC_ALL, "en_US.UTF-8")) - { - static char const pat[] = "insert into"; - static char const data[] = - "\xFF\0\x12\xA2\xAA\xC4\xB1,K\x12\xC4\xB1*\xACK"; - re_set_syntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE - | RE_ICASE); - memset (®ex, 0, sizeof regex); - s = re_compile_pattern (pat, sizeof pat - 1, ®ex); - if (s) - return 1; - if (re_search (®ex, data, sizeof data - 1, - 0, sizeof data - 1, ®s) - != -1) - return 1; - if (! setlocale (LC_ALL, "C")) - return 1; - } - #endif + #if HAVE_LOCALE_H + /* http://sourceware.org/ml/libc-hacker/2006-09/msg00008.html + This test needs valgrind to catch the bug on Debian + GNU/Linux 3.1 x86, but it might catch the bug better + on other platforms and it shouldn't hurt to try the + test here. */ + if (setlocale (LC_ALL, "en_US.UTF-8")) + { + static char const pat[] = "insert into"; + static char const data[] = + "\xFF\0\x12\xA2\xAA\xC4\xB1,K\x12\xC4\xB1*\xACK"; + re_set_syntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE + | RE_ICASE); + memset (®ex, 0, sizeof regex); + s = re_compile_pattern (pat, sizeof pat - 1, ®ex); + if (s) + return 1; + if (re_search (®ex, data, sizeof data - 1, + 0, sizeof data - 1, ®s) + != -1) + return 1; + if (! setlocale (LC_ALL, "C")) + return 1; + } + #endif - /* This test is from glibc bug 3957, reported by Andrew Mackey. */ - re_set_syntax (RE_SYNTAX_EGREP | RE_HAT_LISTS_NOT_NEWLINE); - memset (®ex, 0, sizeof regex); - s = re_compile_pattern ("a[^x]b", 6, ®ex); - if (s) - return 1; + /* This test is from glibc bug 3957, reported by Andrew Mackey. */ + re_set_syntax (RE_SYNTAX_EGREP | RE_HAT_LISTS_NOT_NEWLINE); + memset (®ex, 0, sizeof regex); + s = re_compile_pattern ("a[^x]b", 6, ®ex); + if (s) + return 1; - /* This should fail, but succeeds for glibc-2.5. */ - if (re_search (®ex, "a\nb", 3, 0, 3, ®s) != -1) - return 1; + /* This should fail, but succeeds for glibc-2.5. */ + if (re_search (®ex, "a\nb", 3, 0, 3, ®s) != -1) + return 1; - /* This regular expression is from Spencer ere test number 75 - in grep-2.3. */ - re_set_syntax (RE_SYNTAX_POSIX_EGREP); - memset (®ex, 0, sizeof regex); - for (i = 0; i <= UCHAR_MAX; i++) - folded_chars[i] = i; - regex.translate = folded_chars; - s = re_compile_pattern ("a[[:]:]]b\n", 11, ®ex); - /* This should fail with _Invalid character class name_ error. */ - if (!s) - return 1; + /* This regular expression is from Spencer ere test number 75 + in grep-2.3. */ + re_set_syntax (RE_SYNTAX_POSIX_EGREP); + memset (®ex, 0, sizeof regex); + for (i = 0; i <= UCHAR_MAX; i++) + folded_chars[i] = i; + regex.translate = folded_chars; + s = re_compile_pattern ("a[[:]:]]b\n", 11, ®ex); + /* This should fail with _Invalid character class name_ error. */ + if (!s) + return 1; - /* This should succeed, but does not for glibc-2.1.3. */ - memset (®ex, 0, sizeof regex); - s = re_compile_pattern ("{1", 2, ®ex); + /* This should succeed, but does not for glibc-2.1.3. */ + memset (®ex, 0, sizeof regex); + s = re_compile_pattern ("{1", 2, ®ex); - if (s) - return 1; + if (s) + return 1; - /* The following example is derived from a problem report - against gawk from Jorge Stolfi . */ - memset (®ex, 0, sizeof regex); - s = re_compile_pattern ("[an\371]*n", 7, ®ex); - if (s) - return 1; + /* The following example is derived from a problem report + against gawk from Jorge Stolfi . */ + memset (®ex, 0, sizeof regex); + s = re_compile_pattern ("[an\371]*n", 7, ®ex); + if (s) + return 1; - /* This should match, but does not for glibc-2.2.1. */ - if (re_match (®ex, "an", 2, 0, ®s) != 2) - return 1; + /* This should match, but does not for glibc-2.2.1. */ + if (re_match (®ex, "an", 2, 0, ®s) != 2) + return 1; - memset (®ex, 0, sizeof regex); - s = re_compile_pattern ("x", 1, ®ex); - if (s) - return 1; + memset (®ex, 0, sizeof regex); + s = re_compile_pattern ("x", 1, ®ex); + if (s) + return 1; - /* glibc-2.2.93 does not work with a negative RANGE argument. */ - if (re_search (®ex, "wxy", 3, 2, -2, ®s) != 1) - return 1; + /* glibc-2.2.93 does not work with a negative RANGE argument. */ + if (re_search (®ex, "wxy", 3, 2, -2, ®s) != 1) + return 1; - /* The version of regex.c in older versions of gnulib - ignored RE_ICASE. Detect that problem too. */ - re_set_syntax (RE_SYNTAX_EMACS | RE_ICASE); - memset (®ex, 0, sizeof regex); - s = re_compile_pattern ("x", 1, ®ex); - if (s) - return 1; + /* The version of regex.c in older versions of gnulib + ignored RE_ICASE. Detect that problem too. */ + re_set_syntax (RE_SYNTAX_EMACS | RE_ICASE); + memset (®ex, 0, sizeof regex); + s = re_compile_pattern ("x", 1, ®ex); + if (s) + return 1; - if (re_search (®ex, "WXY", 3, 0, 3, ®s) < 0) - return 1; + if (re_search (®ex, "WXY", 3, 0, 3, ®s) < 0) + return 1; - /* Catch a bug reported by Vin Shelton in - http://lists.gnu.org/archive/html/bug-coreutils/2007-06/msg00089.html - */ - re_set_syntax (RE_SYNTAX_POSIX_BASIC - & ~RE_CONTEXT_INVALID_DUP - & ~RE_NO_EMPTY_RANGES); - memset (®ex, 0, sizeof regex); - s = re_compile_pattern ("[[:alnum:]_-]\\\\+$", 16, ®ex); - if (s) - return 1; + /* Catch a bug reported by Vin Shelton in + http://lists.gnu.org/archive/html/bug-coreutils/2007-06/msg00089.html + */ + re_set_syntax (RE_SYNTAX_POSIX_BASIC + & ~RE_CONTEXT_INVALID_DUP + & ~RE_NO_EMPTY_RANGES); + memset (®ex, 0, sizeof regex); + s = re_compile_pattern ("[[:alnum:]_-]\\\\+$", 16, ®ex); + if (s) + return 1; - /* REG_STARTEND was added to glibc on 2004-01-15. - Reject older versions. */ - if (! REG_STARTEND) - return 1; + /* REG_STARTEND was added to glibc on 2004-01-15. + Reject older versions. */ + if (! REG_STARTEND) + return 1; - /* Reject hosts whose regoff_t values are too narrow. - These include glibc 2.3.5 on hosts with 64-bit ptrdiff_t - and 32-bit int. */ - if (sizeof (regoff_t) < sizeof (ptrdiff_t) - || sizeof (regoff_t) < sizeof (ssize_t)) - return 1; + /* Reject hosts whose regoff_t values are too narrow. + These include glibc 2.3.5 on hosts with 64-bit ptrdiff_t + and 32-bit int. */ + if (sizeof (regoff_t) < sizeof (ptrdiff_t) + || sizeof (regoff_t) < sizeof (ssize_t)) + return 1; - return 0; + return 0; ; return 0; } @@ -30202,6 +34023,7 @@ $as_echo "#define regfree rpl_regfree" >>confdefs.h + for ac_header in libintl.h do : ac_fn_c_check_header_mongrel "$LINENO" "libintl.h" "ac_cv_header_libintl_h" "$ac_includes_default" @@ -30233,61 +34055,131 @@ _ACEOF - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether rename is broken with a trailing slash" >&5 -$as_echo_n "checking whether rename is broken with a trailing slash... " >&6; } -if test "${gl_cv_func_rename_trailing_slash_bug+set}" = set; then : + + + if test "$gl_cv_func_rmdir_works:$gl_cv_func_unlink_works" != yes:yes; then + REPLACE_REMOVE=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS remove.$ac_objext" + + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether remove handles directories" >&5 +$as_echo_n "checking whether remove handles directories... " >&6; } +if test "${gl_cv_func_remove_dir_works+set}" = set; then : $as_echo_n "(cached) " >&6 else + mkdir conftest.dir + if test "$cross_compiling" = yes; then : + case $host_os in + mingw*) gl_cv_func_remove_dir_works="guessing no";; + *) gl_cv_func_remove_dir_works="guessing yes";; + esac +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include - rm -rf conftest.d1 conftest.d2 - mkdir conftest.d1 || - as_fn_error "cannot create temporary directory" "$LINENO" 5 +int +main () +{ +return remove ("conftest.dir"); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_remove_dir_works=yes +else + gl_cv_func_remove_dir_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + rm -rf conftest.dir +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_remove_dir_works" >&5 +$as_echo "$gl_cv_func_remove_dir_works" >&6; } + case $gl_cv_func_remove_dir_works in + *no*) REPLACE_REMOVE=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS remove.$ac_objext" +;; + esac + fi + + + + GNULIB_REMOVE=1 + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether rename honors trailing slash on destination" >&5 +$as_echo_n "checking whether rename honors trailing slash on destination... " >&6; } +if test "${gl_cv_func_rename_slash_dst_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + rm -rf conftest.f conftest.f1 conftest.d1 conftest.d2 conftest.lnk + touch conftest.f && mkdir conftest.d1 || + as_fn_error "cannot create temporary files" "$LINENO" 5 + # Assume that if we have lstat, we can also check symlinks. + if test $ac_cv_func_lstat = yes; then + ln -s conftest.f conftest.lnk + fi if test "$cross_compiling" = yes; then : - gl_cv_func_rename_trailing_slash_bug=yes + gl_cv_func_rename_slash_dst_works="guessing no" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # include # include - int - main () - { - exit (rename ("conftest.d1/", "conftest.d2") ? 1 : 0); - } +int +main () +{ +if (rename ("conftest.f", "conftest.f1/") == 0) return 1; + if (rename ("conftest.d1", "conftest.d2/") != 0) return 2; +#if HAVE_LSTAT + if (rename ("conftest.f", "conftest.lnk/") == 0) return 3; +#endif + + ; + return 0; +} _ACEOF if ac_fn_c_try_run "$LINENO"; then : - gl_cv_func_rename_trailing_slash_bug=no + gl_cv_func_rename_slash_dst_works=yes else - gl_cv_func_rename_trailing_slash_bug=yes + gl_cv_func_rename_slash_dst_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi - - rm -rf conftest.d1 conftest.d2 + rm -rf conftest.f conftest.f1 conftest.d1 conftest.d2 conftest.lnk fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_rename_trailing_slash_bug" >&5 -$as_echo "$gl_cv_func_rename_trailing_slash_bug" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether rename is broken when the destination exists" >&5 -$as_echo_n "checking whether rename is broken when the destination exists... " >&6; } -if test "${gl_cv_func_rename_dest_exists_bug+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - - case "$host_os" in - mingw*) gl_cv_func_rename_dest_exists_bug=yes ;; - *) gl_cv_func_rename_dest_exists_bug=no ;; - esac - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_rename_dest_exists_bug" >&5 -$as_echo "$gl_cv_func_rename_dest_exists_bug" >&6; } - if test $gl_cv_func_rename_trailing_slash_bug = yes || - test $gl_cv_func_rename_dest_exists_bug = yes; then +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_rename_slash_dst_works" >&5 +$as_echo "$gl_cv_func_rename_slash_dst_works" >&6; } + if test "x$gl_cv_func_rename_slash_dst_works" != xyes; then @@ -30299,17 +34191,194 @@ $as_echo "$gl_cv_func_rename_dest_exists_bug" >&6; } gl_LIBOBJS="$gl_LIBOBJS rename.$ac_objext" REPLACE_RENAME=1 - if test $gl_cv_func_rename_trailing_slash_bug = yes; then -$as_echo "#define RENAME_TRAILING_SLASH_BUG 1" >>confdefs.h +$as_echo "#define RENAME_TRAILING_SLASH_DEST_BUG 1" >>confdefs.h + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether rename honors trailing slash on source" >&5 +$as_echo_n "checking whether rename honors trailing slash on source... " >&6; } +if test "${gl_cv_func_rename_slash_src_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + rm -rf conftest.f conftest.d1 conftest.d2 conftest.lnk + touch conftest.f && mkdir conftest.d1 || + as_fn_error "cannot create temporary files" "$LINENO" 5 + # Assume that if we have lstat, we can also check symlinks. + if test $ac_cv_func_lstat = yes; then + ln -s conftest.f conftest.lnk fi - if test $gl_cv_func_rename_dest_exists_bug = yes; then + if test "$cross_compiling" = yes; then : + gl_cv_func_rename_slash_src_works="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +# include +# include + +int +main () +{ +if (rename ("conftest.f/", "conftest.d2") == 0) return 1; + if (rename ("conftest.d1/", "conftest.d2") != 0) return 2; +#if HAVE_LSTAT + if (rename ("conftest.lnk/", "conftest.f") == 0) return 3; +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_rename_slash_src_works=yes +else + gl_cv_func_rename_slash_src_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + rm -rf conftest.f conftest.d1 conftest.d2 conftest.lnk + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_rename_slash_src_works" >&5 +$as_echo "$gl_cv_func_rename_slash_src_works" >&6; } + if test "x$gl_cv_func_rename_slash_src_works" != xyes; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS rename.$ac_objext" + + REPLACE_RENAME=1 + +$as_echo "#define RENAME_TRAILING_SLASH_SOURCE_BUG 1" >>confdefs.h + + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether rename manages hard links correctly" >&5 +$as_echo_n "checking whether rename manages hard links correctly... " >&6; } +if test "${gl_cv_func_rename_link_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + rm -rf conftest.f conftest.f1 + if touch conftest.f && ln conftest.f conftest.f1 && + set x `ls -i conftest.f conftest.f1` && test "" = ""; then + if test "$cross_compiling" = yes; then : + gl_cv_func_rename_link_works="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +# include +# include +# include + +int +main () +{ +if (rename ("conftest.f", "conftest.f1")) return 1; + if (unlink ("conftest.f1")) return 2; + if (rename ("conftest.f", "conftest.f")) return 3; + if (rename ("conftest.f1", "conftest.f1") == 0) return 4; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_rename_link_works=yes +else + gl_cv_func_rename_link_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + else + gl_cv_func_rename_link_works="guessing no" + fi + rm -rf conftest.f conftest.f1 + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_rename_link_works" >&5 +$as_echo "$gl_cv_func_rename_link_works" >&6; } + if test "x$gl_cv_func_rename_link_works" != xyes; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS rename.$ac_objext" + + REPLACE_RENAME=1 + +$as_echo "#define RENAME_HARD_LINK_BUG 1" >>confdefs.h + + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether rename manages existing destinations correctly" >&5 +$as_echo_n "checking whether rename manages existing destinations correctly... " >&6; } +if test "${gl_cv_func_rename_dest_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + rm -rf conftest.f conftest.d1 conftest.d2 + touch conftest.f && mkdir conftest.d1 conftest.d2 || + as_fn_error "cannot create temporary files" "$LINENO" 5 + if test "$cross_compiling" = yes; then : + gl_cv_func_rename_dest_works="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +# include +# include + +int +main () +{ +if (rename ("conftest.d1", "conftest.d2") != 0) return 1; + if (rename ("conftest.d2", "conftest.f") == 0) return 2; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_rename_dest_works=yes +else + gl_cv_func_rename_dest_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + rm -rf conftest.f conftest.d1 conftest.d2 + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_rename_dest_works" >&5 +$as_echo "$gl_cv_func_rename_dest_works" >&6; } + if test "x$gl_cv_func_rename_dest_works" != xyes; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS rename.$ac_objext" + + REPLACE_RENAME=1 $as_echo "#define RENAME_DEST_EXISTS_BUG 1" >>confdefs.h - fi - : fi @@ -30317,59 +34386,6 @@ $as_echo "#define RENAME_DEST_EXISTS_BUG 1" >>confdefs.h GNULIB_RENAME=1 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether rename is broken with respect to destination slashes" >&5 -$as_echo_n "checking whether rename is broken with respect to destination slashes... " >&6; } -if test "${gl_cv_func_rename_trailing_dest_slash_bug+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - - rm -rf conftest.d1 conftest.d2 - mkdir conftest.d1 || - as_fn_error "cannot create temporary directory" "$LINENO" 5 - if test "$cross_compiling" = yes; then : - gl_cv_func_rename_trailing_dest_slash_bug=yes -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -# include - int - main () - { - return (rename ("conftest.d1", "conftest.d2/") ? 1 : 0); - } - -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - gl_cv_func_rename_trailing_dest_slash_bug=no -else - gl_cv_func_rename_trailing_dest_slash_bug=yes -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - - - rm -rf conftest.d1 conftest.d2 - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_rename_trailing_dest_slash_bug" >&5 -$as_echo "$gl_cv_func_rename_trailing_dest_slash_bug" >&6; } - if test $gl_cv_func_rename_trailing_dest_slash_bug = yes; then - - - - - - - - - gl_LIBOBJS="$gl_LIBOBJS rename-dest-slash.$ac_objext" - - -$as_echo "#define rename rpl_rename_dest_slash" >>confdefs.h - - fi @@ -30396,66 +34412,82 @@ fi done - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rmdir-not-empty errno value" >&5 -$as_echo_n "checking for rmdir-not-empty errno value... " >&6; } -if test "${gl_cv_func_rmdir_errno_not_empty+set}" = set; then : + if test $ac_cv_func_rmdir = no; then + REPLACE_RMDIR=1 + # If someone lacks rmdir, make configure fail, and request + # a bug report to inform us about it. + if test x"$SKIP_RMDIR_CHECK" != xyes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "Your system lacks the rmdir function. + Please report this, along with the output of \"uname -a\", to the + bug-coreutils@gnu.org mailing list. To continue past this point, + rerun configure with SKIP_RMDIR_CHECK=yes. + E.g., ./configure SKIP_RMDIR_CHECK=yes +See \`config.log' for more details." "$LINENO" 5; } + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether rmdir works" >&5 +$as_echo_n "checking whether rmdir works... " >&6; } +if test "${gl_cv_func_rmdir_works+set}" = set; then : $as_echo_n "(cached) " >&6 else - - # Arrange for deletion of the temporary directory this test creates. - ac_clean_files="$ac_clean_files confdir2" - mkdir confdir2; : > confdir2/file - if test "$cross_compiling" = yes; then : - gl_cv_func_rmdir_errno_not_empty=ENOTEMPTY - + mkdir conftest.dir + touch conftest.file + if test "$cross_compiling" = yes; then : + gl_cv_func_rmdir_works="guessing no" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include -#include -#ifdef HAVE_UNISTD_H -# include -#endif - int main () - { - FILE *s; - int val; - rmdir ("confdir2"); - val = errno; - s = fopen ("confdir2/errno", "w"); - fprintf (s, "%d\n", val); - return 0; - } + #include + #include +int +main () +{ +return !rmdir ("conftest.file/") || errno != ENOTDIR + || !rmdir ("conftest.dir/./"); + ; + return 0; +} _ACEOF if ac_fn_c_try_run "$LINENO"; then : - gl_cv_func_rmdir_errno_not_empty=`cat confdir2/errno` + gl_cv_func_rmdir_works=yes else - gl_cv_func_rmdir_errno_not_empty='configure error in rmdir-errno.m4' + gl_cv_func_rmdir_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi - - + rm -rf conftest.dir conftest.file fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_rmdir_errno_not_empty" >&5 -$as_echo "$gl_cv_func_rmdir_errno_not_empty" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_rmdir_works" >&5 +$as_echo "$gl_cv_func_rmdir_works" >&6; } + if test x"$gl_cv_func_rmdir_works" != xyes; then + REPLACE_RMDIR=1 -cat >>confdefs.h <<_ACEOF -#define RMDIR_ERRNO_NOT_EMPTY $gl_cv_func_rmdir_errno_not_empty -_ACEOF + gl_LIBOBJS="$gl_LIBOBJS rmdir.$ac_objext" + + fi + fi + + + + GNULIB_RMDIR=1 + + + + + @@ -30614,7 +34646,8 @@ $as_echo "#define HAVE_LANGINFO_YESEXPR 1" >>confdefs.h - if test "$ac_cv_header_winsock2_h" = yes; then + + if test "$ac_cv_header_winsock2_h" = yes; then @@ -30725,14 +34758,88 @@ if test "x$ac_cv_header_selinux_selinux_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SELINUX_SELINUX_H 1 _ACEOF - SELINUX_SELINUX_H= -else - SELINUX_SELINUX_H=selinux/selinux.h + fi done + if test "$ac_cv_header_selinux_selinux_h" = yes; then + # We do have , so do compile getfilecon.c + # and arrange to use its wrappers. + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS getfilecon.$ac_objext" + + + + + + + + if test $gl_cv_have_include_next = yes; then + gl_cv_next_selinux_selinux_h='<'selinux/selinux.h'>' + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 +$as_echo_n "checking absolute name of ... " >&6; } +if test "${gl_cv_next_selinux_selinux_h+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + if test $ac_cv_header_selinux_selinux_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_selinux_selinux_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/selinux/selinux.h#{ + s#.*"\(.*/selinux/selinux.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_selinux_selinux_h='<'selinux/selinux.h'>' + fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_selinux_selinux_h" >&5 +$as_echo "$gl_cv_next_selinux_selinux_h" >&6; } + fi + NEXT_SELINUX_SELINUX_H=$gl_cv_next_selinux_selinux_h + + if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' + gl_next_as_first_directive='<'selinux/selinux.h'>' + else + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' + gl_next_as_first_directive=$gl_cv_next_selinux_selinux_h + fi + NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H=$gl_next_as_first_directive + + + + +$as_echo "#define getfilecon rpl_getfilecon" >>confdefs.h + + +$as_echo "#define lgetfilecon rpl_lgetfilecon" >>confdefs.h + + +$as_echo "#define fgetfilecon rpl_fgetfilecon" >>confdefs.h + + fi case "$ac_cv_search_setfilecon:$ac_cv_header_selinux_selinux_h" in no:*) # already warned @@ -30881,9 +34988,7 @@ done - - if test $ac_cv_func_setenv = no; then - HAVE_SETENV=0 + if test $HAVE_SETENV$REPLACE_SETENV != 10; then @@ -30894,34 +34999,6 @@ done gl_LIBOBJS="$gl_LIBOBJS setenv.$ac_objext" - - - - - for ac_header in search.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "search.h" "ac_cv_header_search_h" "$ac_includes_default" -if test "x$ac_cv_header_search_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_SEARCH_H 1 -_ACEOF - -fi - -done - - for ac_func in tsearch -do : - ac_fn_c_check_func "$LINENO" "tsearch" "ac_cv_func_tsearch" -if test "x$ac_cv_func_tsearch" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_TSEARCH 1 -_ACEOF - -fi -done - - fi @@ -31052,26 +35129,26 @@ if test "${gl_cv_next_signal_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_signal_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_signal_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_signal_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/signal.h#{ - s#.*"\(.*/signal.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_signal_h='<'signal.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_signal_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/signal.h#{ + s#.*"\(.*/signal.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_signal_h='<'signal.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_signal_h" >&5 @@ -31105,6 +35182,7 @@ fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for signbit macro" >&5 $as_echo_n "checking for signbit macro... " >&6; } if test "${gl_cv_func_signbit+set}" = set; then : @@ -32104,10 +36182,10 @@ int main () { - WORD wVersionRequested = MAKEWORD(1, 1); - WSADATA wsaData; - int err = WSAStartup(wVersionRequested, &wsaData); - WSACleanup (); + WORD wVersionRequested = MAKEWORD(1, 1); + WSADATA wsaData; + int err = WSAStartup(wVersionRequested, &wsaData); + WSACleanup (); ; return 0; } @@ -32261,21 +36339,21 @@ $as_echo_n "checking for socklen_t equivalent... " >&6; } $as_echo_n "(cached) " >&6 else # Systems have either "struct sockaddr *" or - # "void *" as the second argument to getpeername - gl_cv_socklen_t_equiv= - for arg2 in "struct sockaddr" void; do - for t in int size_t "unsigned int" "long int" "unsigned long int"; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + # "void *" as the second argument to getpeername + gl_cv_socklen_t_equiv= + for arg2 in "struct sockaddr" void; do + for t in int size_t "unsigned int" "long int" "unsigned long int"; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include - #include + #include - int getpeername (int, $arg2 *, $t *); + int getpeername (int, $arg2 *, $t *); int main () { $t len; - getpeername (0, 0, &len); + getpeername (0, 0, &len); ; return 0; } @@ -32284,15 +36362,15 @@ if ac_fn_c_try_compile "$LINENO"; then : gl_cv_socklen_t_equiv="$t" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$gl_cv_socklen_t_equiv" != "" && break - done - test "$gl_cv_socklen_t_equiv" != "" && break - done + test "$gl_cv_socklen_t_equiv" != "" && break + done + test "$gl_cv_socklen_t_equiv" != "" && break + done fi if test "$gl_cv_socklen_t_equiv" = ""; then - as_fn_error "Cannot find a type to use in place of socklen_t" "$LINENO" 5 + as_fn_error "Cannot find a type to use in place of socklen_t" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_socklen_t_equiv" >&5 $as_echo "$gl_cv_socklen_t_equiv" >&6; } @@ -32340,6 +36418,118 @@ $as_echo "#define ssize_t int" >>confdefs.h + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat handles trailing slashes on directories" >&5 +$as_echo_n "checking whether stat handles trailing slashes on directories... " >&6; } +if test "${gl_cv_func_stat_dir_slash+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + case $host_os in + mingw*) gl_cv_func_stat_dir_slash="guessing no";; + *) gl_cv_func_stat_dir_slash="guessing yes";; + esac +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +struct stat st; return stat (".", &st) != stat ("./", &st); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_stat_dir_slash=yes +else + gl_cv_func_stat_dir_slash=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_stat_dir_slash" >&5 +$as_echo "$gl_cv_func_stat_dir_slash" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat handles trailing slashes on files" >&5 +$as_echo_n "checking whether stat handles trailing slashes on files... " >&6; } +if test "${gl_cv_func_stat_file_slash+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + touch conftest.tmp + # Assume that if we have lstat, we can also check symlinks. + if test $ac_cv_func_lstat = yes; then + ln -s conftest.tmp conftest.lnk + fi + if test "$cross_compiling" = yes; then : + gl_cv_func_stat_file_slash="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +struct stat st; + if (!stat ("conftest.tmp/", &st)) return 1; +#if HAVE_LSTAT + if (!stat ("conftest.lnk/", &st)) return 2; +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_stat_file_slash=yes +else + gl_cv_func_stat_file_slash=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + rm -f conftest.tmp conftest.lnk +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_stat_file_slash" >&5 +$as_echo "$gl_cv_func_stat_file_slash" >&6; } + case $gl_cv_func_stat_dir_slash in + *no) REPLACE_STAT=1 + +$as_echo "#define REPLACE_FUNC_STAT_DIR 1" >>confdefs.h +;; + esac + case $gl_cv_func_stat_file_slash in + *no) REPLACE_STAT=1 + +$as_echo "#define REPLACE_FUNC_STAT_FILE 1" >>confdefs.h +;; + esac + if test $REPLACE_STAT = 1; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS stat.$ac_objext" + + + fi + + + + GNULIB_STAT=1 + + + + + ac_fn_c_check_member "$LINENO" "struct stat" "st_atim.tv_nsec" "ac_cv_member_struct_stat_st_atim_tv_nsec" "#include #include @@ -32358,20 +36548,20 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include - #include - #if HAVE_SYS_TIME_H - # include - #endif - #include - struct timespec ts; - struct stat st; + #include + #include + #if HAVE_SYS_TIME_H + # include + #endif + #include + struct timespec ts; + struct stat st; int main () { - st.st_atim = ts; + st.st_atim = ts; ; return 0; @@ -32393,7 +36583,7 @@ $as_echo "#define TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC 1" >>confdefs.h fi else ac_fn_c_check_member "$LINENO" "struct stat" "st_atimespec.tv_nsec" "ac_cv_member_struct_stat_st_atimespec_tv_nsec" "#include - #include + #include " if test "x$ac_cv_member_struct_stat_st_atimespec_tv_nsec" = x""yes; then : @@ -32404,7 +36594,7 @@ _ACEOF else ac_fn_c_check_member "$LINENO" "struct stat" "st_atimensec" "ac_cv_member_struct_stat_st_atimensec" "#include - #include + #include " if test "x$ac_cv_member_struct_stat_st_atimensec" = x""yes; then : @@ -32415,7 +36605,7 @@ _ACEOF else ac_fn_c_check_member "$LINENO" "struct stat" "st_atim.st__tim.tv_nsec" "ac_cv_member_struct_stat_st_atim_st__tim_tv_nsec" "#include - #include + #include " if test "x$ac_cv_member_struct_stat_st_atim_st__tim_tv_nsec" = x""yes; then : @@ -32449,7 +36639,7 @@ _ACEOF else ac_fn_c_check_member "$LINENO" "struct stat" "st_birthtimensec" "ac_cv_member_struct_stat_st_birthtimensec" "#include - #include + #include " if test "x$ac_cv_member_struct_stat_st_birthtimensec" = x""yes; then : @@ -32460,7 +36650,7 @@ _ACEOF else ac_fn_c_check_member "$LINENO" "struct stat" "st_birthtim.tv_nsec" "ac_cv_member_struct_stat_st_birthtim_tv_nsec" "#include - #include + #include " if test "x$ac_cv_member_struct_stat_st_birthtim_tv_nsec" = x""yes; then : @@ -32543,26 +36733,26 @@ if test "${gl_cv_next_stdarg_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_stdarg_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_stdarg_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_stdarg_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/stdarg.h#{ - s#.*"\(.*/stdarg.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_stdarg_h='<'stdarg.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_stdarg_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/stdarg.h#{ + s#.*"\(.*/stdarg.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_stdarg_h='<'stdarg.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stdarg_h" >&5 @@ -32704,26 +36894,26 @@ if test "${gl_cv_next_stddef_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_stddef_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_stddef_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_stddef_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/stddef.h#{ - s#.*"\(.*/stddef.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_stddef_h='<'stddef.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_stddef_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/stddef.h#{ + s#.*"\(.*/stddef.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_stddef_h='<'stddef.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stddef_h" >&5 @@ -32790,26 +36980,26 @@ if test "${gl_cv_next_stdint_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_stdint_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_stdint_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_stdint_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/stdint.h#{ - s#.*"\(.*/stdint.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_stdint_h='<'stdint.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_stdint_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/stdint.h#{ + s#.*"\(.*/stdint.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_stdint_h='<'stdint.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stdint_h" >&5 @@ -33303,12 +37493,12 @@ else for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do case $glsuf in '') gltype1='int';; - l) gltype1='long int';; - ll) gltype1='long long int';; - i64) gltype1='__int64';; - u) gltype1='unsigned int';; - ul) gltype1='unsigned long int';; - ull) gltype1='unsigned long long int';; + l) gltype1='long int';; + ll) gltype1='long long int';; + i64) gltype1='__int64';; + u) gltype1='unsigned int';; + ul) gltype1='unsigned long int';; + ull) gltype1='unsigned long long int';; ui64)gltype1='unsigned __int64';; esac cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -33375,12 +37565,12 @@ else for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do case $glsuf in '') gltype1='int';; - l) gltype1='long int';; - ll) gltype1='long long int';; - i64) gltype1='__int64';; - u) gltype1='unsigned int';; - ul) gltype1='unsigned long int';; - ull) gltype1='unsigned long long int';; + l) gltype1='long int';; + ll) gltype1='long long int';; + i64) gltype1='__int64';; + u) gltype1='unsigned int';; + ul) gltype1='unsigned long int';; + ull) gltype1='unsigned long long int';; ui64)gltype1='unsigned __int64';; esac cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -33441,6 +37631,7 @@ _ACEOF + if test $gl_cv_have_include_next = yes; then gl_cv_next_stdio_h='<'stdio.h'>' else @@ -33450,26 +37641,26 @@ if test "${gl_cv_next_stdio_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_stdio_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_stdio_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_stdio_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/stdio.h#{ - s#.*"\(.*/stdio.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_stdio_h='<'stdio.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_stdio_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/stdio.h#{ + s#.*"\(.*/stdio.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_stdio_h='<'stdio.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stdio_h" >&5 @@ -33501,6 +37692,48 @@ $as_echo "$gl_cv_next_stdio_h" >&6; } + for gl_func in fseeko ftello; do + as_gl_Symbol=`$as_echo "gl_cv_have_raw_decl_$gl_func" | $as_tr_sh` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $gl_func is declared without a macro" >&5 +$as_echo_n "checking whether $gl_func is declared without a macro... " >&6; } +if { as_var=$as_gl_Symbol; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +#undef $gl_func + (void) $gl_func; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$as_gl_Symbol=yes" +else + eval "$as_gl_Symbol=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$as_gl_Symbol + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval as_val=\$$as_gl_Symbol + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_RAW_DECL_$gl_func" | $as_tr_cpp` 1 +_ACEOF + + eval ac_cv_have_decl_$gl_func=yes +fi + done + + + @@ -33517,26 +37750,26 @@ if test "${gl_cv_next_stdlib_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_stdlib_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_stdlib_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_stdlib_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/stdlib.h#{ - s#.*"\(.*/stdlib.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_stdlib_h='<'stdlib.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_stdlib_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/stdlib.h#{ + s#.*"\(.*/stdlib.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_stdlib_h='<'stdlib.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stdlib_h" >&5 @@ -33776,42 +38009,6 @@ done - - - - - - - - for ac_func in strdup -do : - ac_fn_c_check_func "$LINENO" "strdup" "ac_cv_func_strdup" -if test "x$ac_cv_func_strdup" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_STRDUP 1 -_ACEOF - -else - - gl_LIBOBJS="$gl_LIBOBJS $ac_func.$ac_objext" - -fi -done - - - - if test $ac_cv_have_decl_strdup = no; then - HAVE_DECL_STRDUP=0 - fi - : - - - - GNULIB_STRDUP=1 - - - - if test $gl_cv_func_malloc_posix != yes; then REPLACE_STRDUP=1 @@ -33945,7 +38142,7 @@ else /* end confdefs.h. */ #include - #include + #include int main () { @@ -34125,6 +38322,103 @@ done + + + + if test $ac_cv_have_decl_strsignal = no; then + HAVE_DECL_STRSIGNAL=0 + fi + + for ac_func in strsignal +do : + ac_fn_c_check_func "$LINENO" "strsignal" "ac_cv_func_strsignal" +if test "x$ac_cv_func_strsignal" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_STRSIGNAL 1 +_ACEOF + +fi +done + + if test $ac_cv_func_strsignal = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strsignal always returns a string" >&5 +$as_echo_n "checking whether strsignal always returns a string... " >&6; } +if test "${gl_cv_func_working_strsignal+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + case "$host_os" in + solaris* | aix*) gl_cv_func_working_strsignal=no;; + *) gl_cv_func_working_strsignal="guessing yes";; + esac +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +char *s = strsignal (-1); + return !(s != (char *) 0 && s != (char *) -1); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_working_strsignal=yes +else + gl_cv_func_working_strsignal=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_working_strsignal" >&5 +$as_echo "$gl_cv_func_working_strsignal" >&6; } + else + gl_cv_func_working_strsignal=no + fi + + if test "$gl_cv_func_working_strsignal" = no; then + if test $ac_cv_func_strsignal = yes; then + REPLACE_STRSIGNAL=1 + fi + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS strsignal.$ac_objext" + + + + ac_fn_c_check_decl "$LINENO" "_sys_siglist" "ac_cv_have_decl__sys_siglist" "#include +" +if test "x$ac_cv_have_decl__sys_siglist" = x""yes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL__SYS_SIGLIST $ac_have_decl +_ACEOF + + + fi + + + + GNULIB_STRSIGNAL=1 + + + + if test "$gl_cv_func_memchr_works" != yes; then REPLACE_STRSTR=1 @@ -34330,6 +38624,14 @@ main () if (numeric_equal (value, value) || term != (string + 5)) return 1; } + { + /* darwin 10.6.1 misparses "nan(". */ + const char *string = "nan("; + char *term; + double value = strtod (string, &term); + if (numeric_equal (value, value) || term != (string + 3)) + return 1; + } ; return 0; @@ -34703,6 +39005,8 @@ _ACEOF + if test $ac_cv_func_symlink = no; then + HAVE_SYMLINK=0 @@ -34711,33 +39015,91 @@ _ACEOF + gl_LIBOBJS="$gl_LIBOBJS symlink.$ac_objext" - for ac_func in strverscmp -do : - ac_fn_c_check_func "$LINENO" "strverscmp" "ac_cv_func_strverscmp" -if test "x$ac_cv_func_strverscmp" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_STRVERSCMP 1 -_ACEOF - + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether symlink handles trailing slash correctly" >&5 +$as_echo_n "checking whether symlink handles trailing slash correctly... " >&6; } +if test "${gl_cv_func_symlink_works+set}" = set; then : + $as_echo_n "(cached) " >&6 else + if test "$cross_compiling" = yes; then : + gl_cv_func_symlink_works="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include - gl_LIBOBJS="$gl_LIBOBJS $ac_func.$ac_objext" - +int +main () +{ +if (!symlink ("a", "conftest.link/")) return 1; + if (symlink ("conftest.f", "conftest.lnk2")) return 2; + if (!symlink ("a", "conftest.lnk2/")) return 3; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_symlink_works=yes +else + gl_cv_func_symlink_works=no fi -done +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + rm -f conftest.f conftest.link conftest.lnk2 +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_symlink_works" >&5 +$as_echo "$gl_cv_func_symlink_works" >&6; } + if test "$gl_cv_func_symlink_works" != yes; then + REPLACE_SYMLINK=1 - if test $ac_cv_func_strverscmp = no; then - : - HAVE_STRVERSCMP=0 + + + + + gl_LIBOBJS="$gl_LIBOBJS symlink.$ac_objext" + + fi fi - GNULIB_STRVERSCMP=1 + GNULIB_SYMLINK=1 + + + + + + + if test $ac_cv_func_symlinkat = no; then + # No known system has readlinkat but not symlinkat + HAVE_SYMLINKAT=0 + HAVE_READLINKAT=0 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS symlinkat.$ac_objext" + + fi + + + + GNULIB_SYMLINKAT=1 + + + + GNULIB_READLINKAT=1 @@ -34815,10 +39177,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_sys_select_h_selfcontained" >&5 $as_echo "$gl_cv_header_sys_select_h_selfcontained" >&6; } - if test $gl_cv_header_sys_select_h_selfcontained = yes; then - SYS_SELECT_H='' - else - SYS_SELECT_H='sys/select.h' + @@ -34834,26 +39193,26 @@ if test "${gl_cv_next_sys_select_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_sys_select_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_sys_select_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_sys_select_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/sys/select.h#{ - s#.*"\(.*/sys/select.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_sys_select_h='<'sys/select.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_sys_select_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/sys/select.h#{ + s#.*"\(.*/sys/select.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_sys_select_h='<'sys/select.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_select_h" >&5 @@ -34872,12 +39231,13 @@ $as_echo "$gl_cv_next_sys_select_h" >&6; } - if test $ac_cv_header_sys_select_h = yes; then - HAVE_SYS_SELECT_H=1 - else - HAVE_SYS_SELECT_H=0 - fi + if test $ac_cv_header_sys_select_h = yes; then + HAVE_SYS_SELECT_H=1 + else + HAVE_SYS_SELECT_H=0 + fi + if test $gl_cv_header_sys_select_h_selfcontained != yes; then @@ -34912,7 +39272,6 @@ done - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether is self-contained" >&5 $as_echo_n "checking whether is self-contained... " >&6; } if test "${gl_cv_header_sys_socket_h_selfcontained+set}" = set; then : @@ -35005,26 +39364,26 @@ if test "${gl_cv_next_sys_socket_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_sys_socket_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_sys_socket_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_sys_socket_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/sys/socket.h#{ - s#.*"\(.*/sys/socket.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_sys_socket_h='<'sys/socket.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_sys_socket_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/sys/socket.h#{ + s#.*"\(.*/sys/socket.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_sys_socket_h='<'sys/socket.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_socket_h" >&5 @@ -35156,14 +39515,6 @@ done - if test $ac_cv_func_lstat = yes; then - HAVE_LSTAT=1 - else - HAVE_LSTAT=0 - fi - - - @@ -35182,26 +39533,26 @@ if test "${gl_cv_next_sys_stat_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_sys_stat_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_sys_stat_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_sys_stat_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/sys/stat.h#{ - s#.*"\(.*/sys/stat.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_sys_stat_h='<'sys/stat.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_sys_stat_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/sys/stat.h#{ + s#.*"\(.*/sys/stat.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_sys_stat_h='<'sys/stat.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_stat_h" >&5 @@ -35248,6 +39599,87 @@ fi + if test $gl_cv_have_include_next = yes; then + gl_cv_next_sys_utsname_h='<'sys/utsname.h'>' + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of " >&5 +$as_echo_n "checking absolute name of ... " >&6; } +if test "${gl_cv_next_sys_utsname_h+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + if test $ac_cv_header_sys_utsname_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_sys_utsname_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/sys/utsname.h#{ + s#.*"\(.*/sys/utsname.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_sys_utsname_h='<'sys/utsname.h'>' + fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_utsname_h" >&5 +$as_echo "$gl_cv_next_sys_utsname_h" >&6; } + fi + NEXT_SYS_UTSNAME_H=$gl_cv_next_sys_utsname_h + + if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' + gl_next_as_first_directive='<'sys/utsname.h'>' + else + # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' + gl_next_as_first_directive=$gl_cv_next_sys_utsname_h + fi + NEXT_AS_FIRST_DIRECTIVE_SYS_UTSNAME_H=$gl_next_as_first_directive + + + + + if test $ac_cv_header_sys_utsname_h != yes; then + HAVE_SYS_UTSNAME_H=0 + HAVE_STRUCT_UTSNAME=0 + else + HAVE_SYS_UTSNAME_H=1 + ac_fn_c_check_type "$LINENO" "struct utsname" "ac_cv_type_struct_utsname" " +#include + +" +if test "x$ac_cv_type_struct_utsname" = x""yes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_UTSNAME 1 +_ACEOF + + +else + HAVE_STRUCT_UTSNAME=0 +fi + + fi + + + + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS tempname.$ac_objext" @@ -35265,6 +39697,10 @@ fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether localtime_r is compatible with its POSIX signature" >&5 $as_echo_n "checking whether localtime_r is compatible with its POSIX signature... " >&6; } if test "${gl_cv_time_r_posix+set}" = set; then : @@ -35277,12 +39713,12 @@ int main () { /* We don't need to append 'restrict's to the argument types, - even though the POSIX signature has the 'restrict's, - since C99 says they can't affect type compatibility. */ - struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r; - if (ptr) return 0; - /* Check the return type is a pointer. On HP-UX 10 it is 'int'. */ - *localtime_r (0, 0); + even though the POSIX signature has the 'restrict's, + since C99 says they can't affect type compatibility. */ + struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r; + if (ptr) return 0; + /* Check the return type is a pointer. On HP-UX 10 it is 'int'. */ + *localtime_r (0, 0); ; return 0; } @@ -35320,6 +39756,9 @@ $as_echo "$gl_cv_time_r_posix" >&6; } + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether tzset clobbers localtime buffer" >&5 $as_echo_n "checking whether tzset clobbers localtime buffer... " >&6; } if test "${gl_cv_func_tzset_clobber+set}" = set; then : @@ -35346,11 +39785,11 @@ main () putenv ("TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"); tzset (); return (p->tm_year != s.tm_year - || p->tm_mon != s.tm_mon - || p->tm_mday != s.tm_mday - || p->tm_hour != s.tm_hour - || p->tm_min != s.tm_min - || p->tm_sec != s.tm_sec); + || p->tm_mon != s.tm_mon + || p->tm_mday != s.tm_mday + || p->tm_hour != s.tm_hour + || p->tm_min != s.tm_min + || p->tm_sec != s.tm_sec); } _ACEOF @@ -35425,6 +39864,44 @@ $as_echo "#define TZSET_CLOBBERS_LOCALTIME 1" >>confdefs.h fi + + + + + + + + + + + for ac_func in uname +do : + ac_fn_c_check_func "$LINENO" "uname" "ac_cv_func_uname" +if test "x$ac_cv_func_uname" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_UNAME 1 +_ACEOF + +else + + gl_LIBOBJS="$gl_LIBOBJS $ac_func.$ac_objext" + +fi +done + + + if test $ac_cv_func_uname = no; then + HAVE_UNAME=0 + + : + + fi + + + + GNULIB_UNAME=1 + + : @@ -35436,6 +39913,7 @@ $as_echo "#define TZSET_CLOBBERS_LOCALTIME 1" >>confdefs.h + if test $gl_cv_have_include_next = yes; then gl_cv_next_unistd_h='<'unistd.h'>' else @@ -35445,26 +39923,26 @@ if test "${gl_cv_next_unistd_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_unistd_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_unistd_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_unistd_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/unistd.h#{ - s#.*"\(.*/unistd.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_unistd_h='<'unistd.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_unistd_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/unistd.h#{ + s#.*"\(.*/unistd.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_unistd_h='<'unistd.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_unistd_h" >&5 @@ -35493,6 +39971,52 @@ $as_echo "$gl_cv_next_unistd_h" >&6; } + for gl_func in environ; do + as_gl_Symbol=`$as_echo "gl_cv_have_raw_decl_$gl_func" | $as_tr_sh` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $gl_func is declared without a macro" >&5 +$as_echo_n "checking whether $gl_func is declared without a macro... " >&6; } +if { as_var=$as_gl_Symbol; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +/* Some systems declare environ in the wrong header. */ +#ifndef __GLIBC__ +# include +#endif + +int +main () +{ +#undef $gl_func + (void) $gl_func; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$as_gl_Symbol=yes" +else + eval "$as_gl_Symbol=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$as_gl_Symbol + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval as_val=\$$as_gl_Symbol + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_RAW_DECL_$gl_func" | $as_tr_cpp` 1 +_ACEOF + + eval ac_cv_have_decl_$gl_func=yes +fi + done + + + @@ -35527,14 +40051,73 @@ $as_echo "$gl_cv_next_unistd_h" >&6; } -$as_echo "#define GNULIB_UNISTD_SAFER 1" >>confdefs.h - - - - $as_echo "#define GNULIB_UNISTR_U8_UCTOMB 1" >>confdefs.h + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether unlink honors trailing slashes" >&5 +$as_echo_n "checking whether unlink honors trailing slashes... " >&6; } +if test "${gl_cv_func_unlink_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + touch conftest.file + # Assume that if we have lstat, we can also check symlinks. + if test $ac_cv_func_lstat = yes; then + ln -s conftest.file conftest.lnk + fi + if test "$cross_compiling" = yes; then : + gl_cv_func_unlink_works="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + +int +main () +{ +if (!unlink ("conftest.file/") || errno != ENOTDIR) return 1; +#if HAVE_LSTAT + if (!unlink ("conftest.lnk/") || errno != ENOTDIR) return 2; +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_unlink_works=yes +else + gl_cv_func_unlink_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + rm -f conftest.file conftest.lnk +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_unlink_works" >&5 +$as_echo "$gl_cv_func_unlink_works" >&6; } + if test x"$gl_cv_func_unlink_works" != xyes; then + REPLACE_UNLINK=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS unlink.$ac_objext" + + fi + + + + GNULIB_UNLINK=1 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a running program can be unlinked" >&5 $as_echo_n "checking whether a running program can be unlinked... " >&6; } if test "${gl_cv_func_unlink_busy_text+set}" = set; then : @@ -35548,11 +40131,11 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default - int - main (int argc, char **argv) - { - return !argc || unlink (argv[0]) != 0; - } + int + main (int argc, char **argv) + { + return !argc || unlink (argv[0]) != 0; + } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_unlink_busy_text=yes @@ -35575,38 +40158,6 @@ $as_echo "$gl_cv_func_unlink_busy_text" >&6; } - - - - - - - - - - - gl_LIBOBJS="$gl_LIBOBJS unlinkdir.$ac_objext" - - - # The Hurd, the Linux kernel, the FreeBSD kernel version 2.2 and later, - # and Cygwin never let anyone (even root) unlink directories. - # If anyone knows of another system for which unlink can never - # remove a directory, please report it to . - # Unfortunately this is difficult to test for, since it requires root access - # and might create garbage in the file system, - # so the code below simply relies on the kernel name and version number. - case $host in - *-*-gnu[0-9]* | \ - *-*-linux-* | *-*-linux | \ - *-*-freebsd2.2* | *-*-freebsd[3-9]* | *-*-freebsd[1-9][0-9]* | \ - *-cygwin) - -$as_echo "#define UNLINK_CANNOT_UNLINK_DIR 1" >>confdefs.h -;; - esac - - - $as_echo "#define USE_UNLOCKED_IO 1" >>confdefs.h @@ -35656,7 +40207,7 @@ done else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for unsetenv() return type" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for unsetenv() return type" >&5 $as_echo_n "checking for unsetenv() return type... " >&6; } if test "${gt_cv_func_unsetenv_ret+set}" = set; then : $as_echo_n "(cached) " >&6 @@ -35692,7 +40243,74 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_unsetenv_ret" >&5 $as_echo "$gt_cv_func_unsetenv_ret" >&6; } if test $gt_cv_func_unsetenv_ret = 'void'; then - VOID_UNSETENV=1 + +$as_echo "#define VOID_UNSETENV 1" >>confdefs.h + + REPLACE_UNSETENV=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS unsetenv.$ac_objext" + + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether unsetenv works on duplicates" >&5 +$as_echo_n "checking whether unsetenv works on duplicates... " >&6; } +if test "${gl_cv_func_unsetenv_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + gl_cv_func_unsetenv_works="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + +int +main () +{ + + char entry[] = "b=2"; + if (putenv ((char *) "a=1")) return 1; + if (putenv (entry)) return 2; + entry[0] = 'a'; + unsetenv ("a"); + if (getenv ("a")) return 3; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_unsetenv_works=yes +else + gl_cv_func_unsetenv_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_unsetenv_works" >&5 +$as_echo "$gl_cv_func_unsetenv_works" >&6; } + if test "$gl_cv_func_unsetenv_works" != yes; then + REPLACE_UNSETENV=1 + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS unsetenv.$ac_objext" + fi fi @@ -35766,6 +40384,53 @@ $as_echo "#define HAVE_PROC_UPTIME 1" >>confdefs.h + if test $ac_cv_func_futimens = no && test $ac_cv_func_futimesat = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether futimesat handles NULL file" >&5 +$as_echo_n "checking whether futimesat handles NULL file... " >&6; } +if test "${gl_cv_func_futimesat_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + touch conftest.file + if test "$cross_compiling" = yes; then : + gl_cv_func_futimesat_works="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include + +int +main () +{ + int fd = open ("conftest.file", O_RDWR); + if (fd < 0) return 1; + if (futimesat (fd, NULL, NULL)) return 2; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_futimesat_works=yes +else + gl_cv_func_futimesat_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + rm -f conftest.file +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_futimesat_works" >&5 +$as_echo "$gl_cv_func_futimesat_works" >&6; } + if test "$gl_cv_func_futimesat_works" != yes; then + +$as_echo "#define FUTIMESAT_NULL_BUG 1" >>confdefs.h + + fi + fi + if test $ac_cv_func_vasnprintf = no; then @@ -36266,8 +40931,8 @@ fi # Check whether --with-packager was given. if test "${with_packager+set}" = set; then : withval=$with_packager; case $withval in - yes|no) ;; - *) + yes|no) ;; + *) cat >>confdefs.h <<_ACEOF #define PACKAGE_PACKAGER "$withval" _ACEOF @@ -36281,8 +40946,8 @@ fi # Check whether --with-packager-version was given. if test "${with_packager_version+set}" = set; then : withval=$with_packager_version; case $withval in - yes|no) ;; - *) + yes|no) ;; + *) cat >>confdefs.h <<_ACEOF #define PACKAGE_PACKAGER_VERSION "$withval" _ACEOF @@ -36296,8 +40961,8 @@ fi # Check whether --with-packager-bug-reports was given. if test "${with_packager_bug_reports+set}" = set; then : withval=$with_packager_bug_reports; case $withval in - yes|no) ;; - *) + yes|no) ;; + *) cat >>confdefs.h <<_ACEOF #define PACKAGE_PACKAGER_BUG_REPORTS "$withval" _ACEOF @@ -36665,47 +41330,8 @@ $as_echo "#define REPLACE_VPRINTF_POSIX 1" >>confdefs.h - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether is standalone" >&5 -$as_echo_n "checking whether is standalone... " >&6; } -if test "${gl_cv_header_wchar_h_standalone+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -wchar_t w; -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - gl_cv_header_wchar_h_standalone=yes -else - gl_cv_header_wchar_h_standalone=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_wchar_h_standalone" >&5 -$as_echo "$gl_cv_header_wchar_h_standalone" >&6; } - if test $gt_cv_c_wint_t = yes; then - HAVE_WINT_T=1 - else - HAVE_WINT_T=0 - fi - - - - - if test $gl_cv_header_wchar_h_standalone != yes || test $gt_cv_c_wint_t != yes || test -n "$STDDEF_H"; then - WCHAR_H=wchar.h - fi - - - if test $ac_cv_header_wchar_h = yes; then - HAVE_WCHAR_H=1 - else - HAVE_WCHAR_H=0 - fi - @@ -36721,26 +41347,26 @@ if test "${gl_cv_next_wchar_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_wchar_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_wchar_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_wchar_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/wchar.h#{ - s#.*"\(.*/wchar.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_wchar_h='<'wchar.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_wchar_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/wchar.h#{ + s#.*"\(.*/wchar.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_wchar_h='<'wchar.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_wchar_h" >&5 @@ -36759,6 +41385,20 @@ $as_echo "$gl_cv_next_wchar_h" >&6; } + if test $ac_cv_header_wchar_h = yes; then + HAVE_WCHAR_H=1 + else + HAVE_WCHAR_H=0 + fi + + + + if test $gt_cv_c_wint_t = yes; then + HAVE_WINT_T=1 + else + HAVE_WINT_T=0 + fi + @@ -36901,8 +41541,7 @@ $as_echo "$gl_cv_func_mbrtowc_sanitycheck" >&6; } fi if test $REPLACE_MBSTATE_T = 1; then - - WCHAR_H=wchar.h + : fi @@ -36988,8 +41627,7 @@ $as_echo "$gl_cv_func_wcrtomb_retval" >&6; } fi if test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1; then - - WCHAR_H=wchar.h + : @@ -37065,12 +41703,13 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include - #include - #include - #include - #include - int main () { return iswprint ('x') == 0; } + + #include + #include + #include + #include + #include + int main () { return iswprint ('x') == 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : gl_cv_func_iswcntrl_works=yes @@ -37110,26 +41749,26 @@ if test "${gl_cv_next_wctype_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_wctype_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_wctype_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_wctype_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/wctype.h#{ - s#.*"\(.*/wctype.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_wctype_h='<'wctype.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_wctype_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/wctype.h#{ + s#.*"\(.*/wctype.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_wctype_h='<'wctype.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_wctype_h" >&5 @@ -37280,8 +41919,7 @@ $as_echo "$gl_cv_func_wcwidth_works" >&6; } if test $REPLACE_WCWIDTH = 1 || test $HAVE_DECL_WCWIDTH = 0; then - - WCHAR_H=wchar.h + : fi @@ -37362,14 +42000,14 @@ if test "${gl_cv_sys_struct_winsize_needs_sys_ptem_h+set}" = set; then : else gl_cv_sys_struct_winsize_needs_sys_ptem_h=yes if test $ac_cv_sys_posix_termios = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { struct winsize x; - if (sizeof x > 0) return 0; + if (sizeof x > 0) return 0; ; return 0; } @@ -37380,14 +42018,14 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $gl_cv_sys_struct_winsize_needs_sys_ptem_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { struct winsize x; - if (sizeof x > 0) return 0; + if (sizeof x > 0) return 0; ; return 0; } @@ -38044,8 +42682,6 @@ $as_echo "$gt_cv_locale_tr_utf8" >&6; } - HAVE_SYMLINK=$ac_cv_func_symlink - if test "$ac_cv_header_winsock2_h" = yes; then @@ -38068,15 +42704,315 @@ $as_echo "$gt_cv_locale_tr_utf8" >&6; } + if test $ac_cv_func_getdtablesize != yes; then + HAVE_GETDTABLESIZE=0 - ARPA_INET_H='arpa/inet.h' + gltests_LIBOBJS="$gltests_LIBOBJS getdtablesize.$ac_objext" + + fi + + + + GNULIB_GETDTABLESIZE=1 + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 +$as_echo_n "checking whether byte ordering is bigendian... " >&6; } +if test "${ac_cv_c_bigendian+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_c_bigendian=unknown + # See if we're dealing with a universal compiler. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifndef __APPLE_CC__ + not a universal capable compiler + #endif + typedef int dummy; + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + # Check for potential -arch flags. It is not universal unless + # there are at least two -arch flags with different values. + ac_arch= + ac_prev= + for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do + if test -n "$ac_prev"; then + case $ac_word in + i?86 | x86_64 | ppc | ppc64) + if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then + ac_arch=$ac_word + else + ac_cv_c_bigendian=universal + break + fi + ;; + esac + ac_prev= + elif test "x$ac_word" = "x-arch"; then + ac_prev=arch + fi + done +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if test $ac_cv_c_bigendian = unknown; then + # See if sys/param.h defines the BYTE_ORDER macro. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + +int +main () +{ +#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ + && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ + && LITTLE_ENDIAN) + bogus endian macros + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + # It does; now see whether it defined to BIG_ENDIAN or not. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + +int +main () +{ +#if BYTE_ORDER != BIG_ENDIAN + not big endian + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_bigendian=yes +else + ac_cv_c_bigendian=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + if test $ac_cv_c_bigendian = unknown; then + # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) + bogus endian macros + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + # It does; now see whether it defined to _BIG_ENDIAN or not. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +#ifndef _BIG_ENDIAN + not big endian + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_bigendian=yes +else + ac_cv_c_bigendian=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + if test $ac_cv_c_bigendian = unknown; then + # Compile a test program. + if test "$cross_compiling" = yes; then : + # Try to guess by grepping values from an object file. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +short int ascii_mm[] = + { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; + short int ascii_ii[] = + { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; + int use_ascii (int i) { + return ascii_mm[i] + ascii_ii[i]; + } + short int ebcdic_ii[] = + { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; + short int ebcdic_mm[] = + { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; + int use_ebcdic (int i) { + return ebcdic_mm[i] + ebcdic_ii[i]; + } + extern int foo; + +int +main () +{ +return use_ascii (foo) == use_ebcdic (foo); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then + ac_cv_c_bigendian=yes + fi + if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$ac_cv_c_bigendian" = unknown; then + ac_cv_c_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + ac_cv_c_bigendian=unknown + fi + fi +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ + + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long int l; + char c[sizeof (long int)]; + } u; + u.l = 1; + return u.c[sizeof (long int) - 1] == 1; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_c_bigendian=no +else + ac_cv_c_bigendian=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 +$as_echo "$ac_cv_c_bigendian" >&6; } + case $ac_cv_c_bigendian in #( + yes) + $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h +;; #( + no) + ;; #( + universal) + +$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h + + ;; #( + *) + as_fn_error "unknown endianness + presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; + esac + + + + + + : + + + gl_save_LIBS=$LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing inet_pton" >&5 +$as_echo_n "checking for library containing inet_pton... " >&6; } +if test "${ac_cv_search_inet_pton+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char inet_pton (); +int +main () +{ +return inet_pton (); + ; + return 0; +} +_ACEOF +for ac_lib in '' nsl; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_inet_pton=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if test "${ac_cv_search_inet_pton+set}" = set; then : + break +fi +done +if test "${ac_cv_search_inet_pton+set}" = set; then : + +else + ac_cv_search_inet_pton=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_inet_pton" >&5 +$as_echo "$ac_cv_search_inet_pton" >&6; } +ac_res=$ac_cv_search_inet_pton +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +else + + + + @@ -38097,6 +43033,16 @@ fi done +fi + + LIBS=$gl_save_LIBS + INET_PTON_LIB= + if test "$ac_cv_search_inet_pton" != "no" && + test "$ac_cv_search_inet_pton" != "none required"; then + INET_PTON_LIB="$ac_cv_search_inet_pton" + fi + + ac_fn_c_check_decl "$LINENO" "inet_pton" "ac_cv_have_decl_inet_pton" "#include " @@ -38121,6 +43067,230 @@ _ACEOF GNULIB_INET_PTON=1 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 +$as_echo_n "checking whether byte ordering is bigendian... " >&6; } +if test "${ac_cv_c_bigendian+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_c_bigendian=unknown + # See if we're dealing with a universal compiler. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifndef __APPLE_CC__ + not a universal capable compiler + #endif + typedef int dummy; + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + # Check for potential -arch flags. It is not universal unless + # there are at least two -arch flags with different values. + ac_arch= + ac_prev= + for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do + if test -n "$ac_prev"; then + case $ac_word in + i?86 | x86_64 | ppc | ppc64) + if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then + ac_arch=$ac_word + else + ac_cv_c_bigendian=universal + break + fi + ;; + esac + ac_prev= + elif test "x$ac_word" = "x-arch"; then + ac_prev=arch + fi + done +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if test $ac_cv_c_bigendian = unknown; then + # See if sys/param.h defines the BYTE_ORDER macro. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + +int +main () +{ +#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ + && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ + && LITTLE_ENDIAN) + bogus endian macros + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + # It does; now see whether it defined to BIG_ENDIAN or not. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + +int +main () +{ +#if BYTE_ORDER != BIG_ENDIAN + not big endian + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_bigendian=yes +else + ac_cv_c_bigendian=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + if test $ac_cv_c_bigendian = unknown; then + # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) + bogus endian macros + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + # It does; now see whether it defined to _BIG_ENDIAN or not. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +#ifndef _BIG_ENDIAN + not big endian + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_bigendian=yes +else + ac_cv_c_bigendian=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + if test $ac_cv_c_bigendian = unknown; then + # Compile a test program. + if test "$cross_compiling" = yes; then : + # Try to guess by grepping values from an object file. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +short int ascii_mm[] = + { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; + short int ascii_ii[] = + { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; + int use_ascii (int i) { + return ascii_mm[i] + ascii_ii[i]; + } + short int ebcdic_ii[] = + { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; + short int ebcdic_mm[] = + { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; + int use_ebcdic (int i) { + return ebcdic_mm[i] + ebcdic_ii[i]; + } + extern int foo; + +int +main () +{ +return use_ascii (foo) == use_ebcdic (foo); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then + ac_cv_c_bigendian=yes + fi + if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$ac_cv_c_bigendian" = unknown; then + ac_cv_c_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + ac_cv_c_bigendian=unknown + fi + fi +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ + + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long int l; + char c[sizeof (long int)]; + } u; + u.l = 1; + return u.c[sizeof (long int) - 1] == 1; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_c_bigendian=no +else + ac_cv_c_bigendian=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 +$as_echo "$ac_cv_c_bigendian" >&6; } + case $ac_cv_c_bigendian in #( + yes) + $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h +;; #( + no) + ;; #( + universal) + +$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h + + ;; #( + *) + as_fn_error "unknown endianness + presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; + esac + if test "$ac_cv_header_winsock2_h" = yes; then @@ -38134,8 +43304,7 @@ _ACEOF gltests_LIBOBJS="$gltests_LIBOBJS ioctl.$ac_objext" - - SYS_IOCTL_H='sys/ioctl.h' + : fi @@ -38716,6 +43885,7 @@ _ACEOF esac + if test "$ac_cv_header_winsock2_h" = yes; then @@ -38735,6 +43905,7 @@ _ACEOF + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a traditional french locale" >&5 $as_echo_n "checking for a traditional french locale... " >&6; } if test "${gt_cv_locale_fr+set}" = set; then : @@ -40134,6 +45305,206 @@ $as_echo "#define HAVE_MAP_ANONYMOUS 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a traditional french locale" >&5 +$as_echo_n "checking for a traditional french locale... " >&6; } +if test "${gt_cv_locale_fr+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#if HAVE_LANGINFO_CODESET +# include +#endif +#include +#include +struct tm t; +char buf[16]; +int main () { + /* Check whether the given locale name is recognized by the system. */ + if (setlocale (LC_ALL, "") == NULL) return 1; + /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". + On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) + is empty, and the behaviour of Tcl 8.4 in this locale is not useful. + On OpenBSD 4.0, when an unsupported locale is specified, setlocale() + succeeds but then nl_langinfo(CODESET) is "646". In this situation, + some unit tests fail. */ +#if HAVE_LANGINFO_CODESET + { + const char *cs = nl_langinfo (CODESET); + if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0) + return 1; + } +#endif +#ifdef __CYGWIN__ + /* On Cygwin, avoid locale names without encoding suffix, because the + locale_charset() function relies on the encoding suffix. Note that + LC_ALL is set on the command line. */ + if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; +#endif + /* Check whether in the abbreviation of the second month, the second + character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only + one byte long. This excludes the UTF-8 encoding. */ + t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; + if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1; + /* Check whether the decimal separator is a comma. + On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point + are nl_langinfo(RADIXCHAR) are both ".". */ + if (localeconv () ->decimal_point[0] != ',') return 1; + return 0; +} + +_ACEOF + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s conftest$ac_exeext; then + # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because + # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the + # configure script would override the LC_ALL setting. Likewise for + # LC_CTYPE, which is also set at the beginning of the configure script. + # Test for the usual locale name. + if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr=fr_FR + else + # Test for the locale name with explicit encoding suffix. + if (LC_ALL=fr_FR.ISO-8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr=fr_FR.ISO-8859-1 + else + # Test for the AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name. + if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr=fr_FR.ISO8859-1 + else + # Test for the HP-UX locale name. + if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr=fr_FR.iso88591 + else + # Test for the Solaris 7 locale name. + if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr=fr + else + # None found. + gt_cv_locale_fr=none + fi + fi + fi + fi + fi + fi + rm -fr conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_fr" >&5 +$as_echo "$gt_cv_locale_fr" >&6; } + LOCALE_FR=$gt_cv_locale_fr + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a french Unicode locale" >&5 +$as_echo_n "checking for a french Unicode locale... " >&6; } +if test "${gt_cv_locale_fr_utf8+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#if HAVE_LANGINFO_CODESET +# include +#endif +#include +#include +struct tm t; +char buf[16]; +int main () { + /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl + imitates locale dependent behaviour by looking at the environment + variables, and all locales use the UTF-8 encoding. */ +#if !(defined __BEOS__ || defined __HAIKU__) + /* Check whether the given locale name is recognized by the system. */ + if (setlocale (LC_ALL, "") == NULL) return 1; + /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". + On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) + is empty, and the behaviour of Tcl 8.4 in this locale is not useful. + On OpenBSD 4.0, when an unsupported locale is specified, setlocale() + succeeds but then nl_langinfo(CODESET) is "646". In this situation, + some unit tests fail. */ +# if HAVE_LANGINFO_CODESET + { + const char *cs = nl_langinfo (CODESET); + if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0) + return 1; + } +# endif +# ifdef __CYGWIN__ + /* On Cygwin, avoid locale names without encoding suffix, because the + locale_charset() function relies on the encoding suffix. Note that + LC_ALL is set on the command line. */ + if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; +# endif + /* Check whether in the abbreviation of the second month, the second + character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is + two bytes long, with UTF-8 encoding. */ + t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; + if (strftime (buf, sizeof (buf), "%b", &t) < 4 + || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v') + return 1; +#endif + /* Check whether the decimal separator is a comma. + On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point + are nl_langinfo(RADIXCHAR) are both ".". */ + if (localeconv () ->decimal_point[0] != ',') return 1; + return 0; +} + +_ACEOF + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s conftest$ac_exeext; then + # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because + # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the + # configure script would override the LC_ALL setting. Likewise for + # LC_CTYPE, which is also set at the beginning of the configure script. + # Test for the usual locale name. + if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr_utf8=fr_FR + else + # Test for the locale name with explicit encoding suffix. + if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr_utf8=fr_FR.UTF-8 + else + # Test for the Solaris 7 locale name. + if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then + gt_cv_locale_fr_utf8=fr.UTF-8 + else + # None found. + gt_cv_locale_fr_utf8=none + fi + fi + fi + fi + rm -fr conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_locale_fr_utf8" >&5 +$as_echo "$gt_cv_locale_fr_utf8" >&6; } + LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8 + + + + + + if test -n "$ERRNO_H"; then REPLACE_PERROR=1 @@ -40398,6 +45769,7 @@ cat >>confdefs.h <<_ACEOF #define HAVE_DECL_SLEEP $ac_have_decl _ACEOF + if test $ac_cv_have_decl_sleep != yes; then HAVE_SLEEP=0 @@ -40410,7 +45782,69 @@ _ACEOF gltests_LIBOBJS="$gltests_LIBOBJS sleep.$ac_objext" - : + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working sleep" >&5 +$as_echo_n "checking for working sleep... " >&6; } +if test "${gl_cv_func_sleep_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + gl_cv_func_sleep_works="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +static void +handle_alarm (int sig) +{ + if (sig != SIGALRM) + _exit (2); +} + +int +main () +{ + + /* Failure to compile this test due to missing alarm is okay, + since all such platforms (mingw) also lack sleep. */ + unsigned int pentecost = 50 * 24 * 60 * 60; /* 50 days. */ + unsigned int remaining; + signal (SIGALRM, handle_alarm); + alarm (1); + remaining = sleep (pentecost); + return !(pentecost - 10 < remaining && remaining <= pentecost); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_sleep_works=yes +else + gl_cv_func_sleep_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_sleep_works" >&5 +$as_echo "$gl_cv_func_sleep_works" >&6; } + if test "$gl_cv_func_sleep_works" != yes; then + REPLACE_SLEEP=1 + + + + + + + + + gltests_LIBOBJS="$gltests_LIBOBJS sleep.$ac_objext" + + fi fi @@ -40418,6 +45852,7 @@ _ACEOF GNULIB_SLEEP=1 + if test "$ac_cv_header_winsock2_h" = yes; then @@ -40550,12 +45985,8 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_decl_ioctl_in_sys_ioctl_h" >&5 $as_echo "$gl_cv_decl_ioctl_in_sys_ioctl_h" >&6; } - if test $gl_cv_decl_ioctl_in_sys_ioctl_h != yes; then - SYS_IOCTL_H='sys/ioctl.h' - fi else HAVE_SYS_IOCTL_H=0 - SYS_IOCTL_H='sys/ioctl.h' fi @@ -40573,26 +46004,26 @@ if test "${gl_cv_next_sys_ioctl_h+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test $ac_cv_header_sys_ioctl_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test $ac_cv_header_sys_ioctl_h = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF - case "$host_os" in - aix*) gl_absname_cpp="$ac_cpp -C" ;; - *) gl_absname_cpp="$ac_cpp" ;; - esac - gl_cv_next_sys_ioctl_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | - sed -n '\#/sys/ioctl.h#{ - s#.*"\(.*/sys/ioctl.h\)".*#\1# - s#^/[^/]#//&# - p - q - }'`'"' - else - gl_cv_next_sys_ioctl_h='<'sys/ioctl.h'>' - fi + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_sys_ioctl_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | + sed -n '\#/sys/ioctl.h#{ + s#.*"\(.*/sys/ioctl.h\)".*#\1# + s#^/[^/]#//&# + p + q + }'`'"' + else + gl_cv_next_sys_ioctl_h='<'sys/ioctl.h'>' + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_ioctl_h" >&5 @@ -40613,19 +46044,141 @@ $as_echo "$gl_cv_next_sys_ioctl_h" >&6; } - for ac_func in shutdown + + + + + + if test $gl_threads_api = posix; then + gl_save_LIBS="$LIBS" + LIBS="$LIBS $LIBMULTITHREAD" + for ac_func in pthread_atfork do : - ac_fn_c_check_func "$LINENO" "shutdown" "ac_cv_func_shutdown" -if test "x$ac_cv_func_shutdown" = x""yes; then : + ac_fn_c_check_func "$LINENO" "pthread_atfork" "ac_cv_func_pthread_atfork" +if test "x$ac_cv_func_pthread_atfork" = x""yes; then : cat >>confdefs.h <<_ACEOF -#define HAVE_SHUTDOWN 1 +#define HAVE_PTHREAD_ATFORK 1 _ACEOF fi done + LIBS="$gl_save_LIBS" + fi + + + + + + + + + + + + + + gltests_LIBOBJS="$gltests_LIBOBJS unlinkdir.$ac_objext" + + + # The Hurd, the Linux kernel, the FreeBSD kernel version 2.2 and later, + # Cygwin, and mingw never let anyone (even root) unlink directories. + # If anyone knows of another system for which unlink can never + # remove a directory, please report it to . + # Unfortunately this is difficult to test for, since it requires root access + # and might create garbage in the file system, + # so the code below simply relies on the kernel name and version number. + case $host_os in + gnu[0-9]* | \ + linux-* | linux | \ + freebsd2.2* | freebsd[3-9]* | freebsd[1-9][0-9]* | \ + cygwin | \ + mingw*) + +$as_echo "#define UNLINK_CANNOT_UNLINK_DIR 1" >>confdefs.h +;; + esac + abs_aux_dir=`cd "$ac_aux_dir"; pwd` + + + + + ac_fn_c_check_type "$LINENO" "useconds_t" "ac_cv_type_useconds_t" "$ac_includes_default" +if test "x$ac_cv_type_useconds_t" = x""yes; then : + +else + +$as_echo "#define useconds_t unsigned int" >>confdefs.h + +fi + + if test $ac_cv_func_usleep = no; then + HAVE_USLEEP=0 + + + + + + + + + gltests_LIBOBJS="$gltests_LIBOBJS usleep.$ac_objext" + + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usleep allows large arguments" >&5 +$as_echo_n "checking whether usleep allows large arguments... " >&6; } +if test "${gl_cv_func_usleep_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + gl_cv_func_usleep_works="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include + +int +main () +{ +return !!usleep (1000000); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_usleep_works=yes +else + gl_cv_func_usleep_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_usleep_works" >&5 +$as_echo "$gl_cv_func_usleep_works" >&6; } + if test "$gl_cv_func_usleep_works" != yes; then + REPLACE_USLEEP=1 + + + + + + + + + gltests_LIBOBJS="$gltests_LIBOBJS usleep.$ac_objext" + + fi + fi + + + + GNULIB_USLEEP=1 + abs_aux_dir=`cd "$ac_aux_dir"; pwd` @@ -41038,8 +46591,7 @@ $as_echo "$gt_cv_locale_zh_CN" >&6; } if test $ac_cv_func_wctob = no; then HAVE_DECL_WCTOB=0 - - WCHAR_H=wchar.h + : @@ -41114,8 +46666,7 @@ $as_echo "$gl_cv_func_wctob_works" >&6; } esac if test $REPLACE_WCTOB = 1; then - - WCHAR_H=wchar.h + : @@ -41156,8 +46707,7 @@ _ACEOF if test $ac_cv_have_decl_wctob != yes; then HAVE_DECL_WCTOB=0 - - WCHAR_H=wchar.h + : fi fi @@ -41169,6 +46719,94 @@ _ACEOF + YIELD_LIB= + if test $gl_threads_api = posix; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sched_yield in -lrt" >&5 +$as_echo_n "checking for sched_yield in -lrt... " >&6; } +if test "${ac_cv_lib_rt_sched_yield+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lrt $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char sched_yield (); +int +main () +{ +return sched_yield (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_rt_sched_yield=yes +else + ac_cv_lib_rt_sched_yield=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_sched_yield" >&5 +$as_echo "$ac_cv_lib_rt_sched_yield" >&6; } +if test "x$ac_cv_lib_rt_sched_yield" = x""yes; then : + YIELD_LIB=-lrt +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sched_yield in -lposix4" >&5 +$as_echo_n "checking for sched_yield in -lposix4... " >&6; } +if test "${ac_cv_lib_posix4_sched_yield+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lposix4 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char sched_yield (); +int +main () +{ +return sched_yield (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_posix4_sched_yield=yes +else + ac_cv_lib_posix4_sched_yield=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_posix4_sched_yield" >&5 +$as_echo "$ac_cv_lib_posix4_sched_yield" >&6; } +if test "x$ac_cv_lib_posix4_sched_yield" = x""yes; then : + YIELD_LIB=-lposix4 +fi + +fi + + fi + + + + @@ -41439,19 +47077,6 @@ fi - - -ac_fn_c_check_decl "$LINENO" "free" "ac_cv_have_decl_free" "$ac_includes_default" -if test "x$ac_cv_have_decl_free" = x""yes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_FREE $ac_have_decl -_ACEOF - ac_fn_c_check_decl "$LINENO" "geteuid" "ac_cv_have_decl_geteuid" "$ac_includes_default" if test "x$ac_cv_have_decl_geteuid" = x""yes; then : ac_have_decl=1 @@ -41485,50 +47110,6 @@ cat >>confdefs.h <<_ACEOF #define HAVE_DECL_GETUID $ac_have_decl _ACEOF -ac_fn_c_check_decl "$LINENO" "lseek" "ac_cv_have_decl_lseek" "$ac_includes_default" -if test "x$ac_cv_have_decl_lseek" = x""yes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_LSEEK $ac_have_decl -_ACEOF - -ac_fn_c_check_decl "$LINENO" "malloc" "ac_cv_have_decl_malloc" "$ac_includes_default" -if test "x$ac_cv_have_decl_malloc" = x""yes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_MALLOC $ac_have_decl -_ACEOF - -ac_fn_c_check_decl "$LINENO" "memchr" "ac_cv_have_decl_memchr" "$ac_includes_default" -if test "x$ac_cv_have_decl_memchr" = x""yes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_MEMCHR $ac_have_decl -_ACEOF - -ac_fn_c_check_decl "$LINENO" "realloc" "ac_cv_have_decl_realloc" "$ac_includes_default" -if test "x$ac_cv_have_decl_realloc" = x""yes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_REALLOC $ac_have_decl -_ACEOF - @@ -41581,25 +47162,6 @@ cat >>confdefs.h <<_ACEOF _ACEOF - ac_fn_c_check_decl "$LINENO" "isblank" "ac_cv_have_decl_isblank" "#include -" -if test "x$ac_cv_have_decl_isblank" = x""yes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_ISBLANK $ac_have_decl -_ACEOF - - - - - - - - @@ -41637,6 +47199,9 @@ else fi + LIB_XATTR= + + if test "$use_xattr" = "yes"; then for ac_header in attr/error_context.h attr/libattr.h do : @@ -41652,19 +47217,11 @@ fi done + use_xattr=no if test $ac_cv_header_attr_libattr_h = yes \ - && test $ac_cv_header_attr_error_context_h = yes; then - use_xattr=1 - else - use_xattr=0 - fi - -cat >>confdefs.h <<_ACEOF -#define USE_XATTR $use_xattr -_ACEOF - - xattr_saved_LIBS=$LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing attr_copy_file" >&5 + && test $ac_cv_header_attr_error_context_h = yes; then + xattr_saved_LIBS=$LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing attr_copy_file" >&5 $as_echo_n "checking for library containing attr_copy_file... " >&6; } if test "${ac_cv_search_attr_copy_file+set}" = set; then : $as_echo_n "(cached) " >&6 @@ -41718,10 +47275,10 @@ ac_res=$ac_cv_search_attr_copy_file if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" test "$ac_cv_search_attr_copy_file" = "none required" || - LIB_XATTR=$ac_cv_search_attr_copy_file + LIB_XATTR=$ac_cv_search_attr_copy_file fi - for ac_func in attr_copy_file + for ac_func in attr_copy_file do : ac_fn_c_check_func "$LINENO" "attr_copy_file" "ac_cv_func_attr_copy_file" if test "x$ac_cv_func_attr_copy_file" = x""yes; then : @@ -41732,8 +47289,22 @@ _ACEOF fi done - LIBS=$xattr_saved_LIBS + LIBS=$xattr_saved_LIBS + if test $ac_cv_func_attr_copy_file = yes; then + use_xattr=yes + fi + fi +cat >>confdefs.h <<_ACEOF +#define USE_XATTR $use_xattr +_ACEOF + + if test $use_xattr = no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libattr development library was not found or not usable." >&5 +$as_echo "$as_me: WARNING: libattr development library was not found or not usable." >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: GNU coreutils will be built without xattr support." >&5 +$as_echo "$as_me: WARNING: GNU coreutils will be built without xattr support." >&2;} + fi fi @@ -41865,10 +47436,6 @@ esac - - - - @@ -42019,9 +47586,6 @@ done - # for cp.c - - @@ -42188,6 +47752,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # for dd.c and shred.c coreutils_saved_libs=$LIBS + LIB_FDATASYNC= { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing fdatasync" >&5 $as_echo_n "checking for library containing fdatasync... " >&6; } if test "${ac_cv_search_fdatasync+set}" = set; then : @@ -42320,8 +47885,10 @@ fi if test "X$enable_libcap" = "Xyes"; then as_fn_error "libcap library was not found or not usable" "$LINENO" 5 else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libcap library was not found or not usable, support for libcap will not be built" >&5 -$as_echo "$as_me: WARNING: libcap library was not found or not usable, support for libcap will not be built" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libcap library was not found or not usable." >&5 +$as_echo "$as_me: WARNING: libcap library was not found or not usable." >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: GNU coreutils will be built without capability support." >&5 +$as_echo "$as_me: WARNING: GNU coreutils will be built without capability support." >&2;} fi fi else @@ -42726,42 +48293,6 @@ if test "x$gl_cv_warn__Wno_unused_parameter" = x""yes; then : fi # Too many warnings for now - # Offenders in pre-fts remove.c; FIXME: remove upon remove.c rewrite - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler handles -Wno-jump-misses-init" >&5 -$as_echo_n "checking whether compiler handles -Wno-jump-misses-init... " >&6; } -if test "${gl_cv_warn__Wno_jump_misses_init+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - - save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="${CPPFLAGS} -Wno-jump-misses-init" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - gl_cv_warn__Wno_jump_misses_init=yes -else - gl_cv_warn__Wno_jump_misses_init=no -fi -rm -f conftest.err conftest.$ac_ext - CPPFLAGS="$save_CPPFLAGS" - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn__Wno_jump_misses_init" >&5 -$as_echo "$gl_cv_warn__Wno_jump_misses_init" >&6; } -if test "x$gl_cv_warn__Wno_jump_misses_init" = x""yes; then : - as_fn_append WARN_CFLAGS " -Wno-jump-misses-init" -fi - - # In spite of excluding -Wlogical-op above, it is enabled, as of # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler handles -Wno-logical-op" >&5 @@ -42833,6 +48364,40 @@ if test "x$gl_cv_warn__fdiagnostics_show_option" = x""yes; then : as_fn_append WARN_CFLAGS " -fdiagnostics-show-option" fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler handles -funit-at-a-time" >&5 +$as_echo_n "checking whether compiler handles -funit-at-a-time... " >&6; } +if test "${gl_cv_warn__funit_at_a_time+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="${CPPFLAGS} -funit-at-a-time" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + gl_cv_warn__funit_at_a_time=yes +else + gl_cv_warn__funit_at_a_time=no +fi +rm -f conftest.err conftest.$ac_ext + CPPFLAGS="$save_CPPFLAGS" + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn__funit_at_a_time" >&5 +$as_echo "$gl_cv_warn__funit_at_a_time" >&6; } +if test "x$gl_cv_warn__funit_at_a_time" = x""yes; then : + as_fn_append WARN_CFLAGS " -funit-at-a-time" +fi + @@ -42845,6 +48410,30 @@ $as_echo "#define _FORTIFY_SOURCE 2" >>confdefs.h $as_echo "#define GNULIB_PORTCHECK 1" >>confdefs.h + + # We use a slightly smaller set of warning options for lib/. + # Remove the following and save the result in GNULIB_WARN_CFLAGS. + nw= + nw="$nw -Wuninitialized" + nw="$nw -Wunused-macros" + nw="$nw -Wmissing-prototypes" + nw="$nw -Wold-style-definition" + + gl_warn_set= + set x $WARN_CFLAGS; shift + for gl_warn_item + do + case " $nw " in + *" $gl_warn_item "*) + ;; + *) + gl_warn_set="$gl_warn_set $gl_warn_item" + ;; + esac + done + GNULIB_WARN_CFLAGS=$gl_warn_set + + fi for ac_header in vfork.h @@ -43063,23 +48652,6 @@ fi optional_bin_progs= -for ac_func in uname -do : - ac_fn_c_check_func "$LINENO" "uname" "ac_cv_func_uname" -if test "x$ac_cv_func_uname" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_UNAME 1 -_ACEOF - { - if test -z "$optional_bin_progs"; then - optional_bin_progs=uname - else - optional_bin_progs="$optional_bin_progs uname" - fi -} -fi -done - for ac_func in chroot do : ac_fn_c_check_func "$LINENO" "chroot" "ac_cv_func_chroot" @@ -43123,14 +48695,14 @@ if test "${gl_cv_sys_struct_winsize_needs_sys_ptem_h+set}" = set; then : else gl_cv_sys_struct_winsize_needs_sys_ptem_h=yes if test $ac_cv_sys_posix_termios = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { struct winsize x; - if (sizeof x > 0) return 0; + if (sizeof x > 0) return 0; ; return 0; } @@ -43141,14 +48713,14 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $gl_cv_sys_struct_winsize_needs_sys_ptem_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { struct winsize x; - if (sizeof x > 0) return 0; + if (sizeof x > 0) return 0; ; return 0; } @@ -43768,14 +49340,14 @@ if test "${gl_cv_sys_struct_winsize_needs_sys_ptem_h+set}" = set; then : else gl_cv_sys_struct_winsize_needs_sys_ptem_h=yes if test $ac_cv_sys_posix_termios = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { struct winsize x; - if (sizeof x > 0) return 0; + if (sizeof x > 0) return 0; ; return 0; } @@ -43786,14 +49358,14 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $gl_cv_sys_struct_winsize_needs_sys_ptem_h = yes; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { struct winsize x; - if (sizeof x > 0) return 0; + if (sizeof x > 0) return 0; ; return 0; } @@ -44186,6 +49758,7 @@ done # SCO-ODT-3.0 is reported to need -lufc for crypt. # NetBSD needs -lcrypt for crypt. + LIB_CRYPT= cu_saved_libs="$LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing crypt" >&5 $as_echo_n "checking for library containing crypt... " >&6; } @@ -44322,6 +49895,11 @@ if test "$ac_res" != no; then : $as_echo "#define HAVE_GMP 1" >>confdefs.h } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libgmp development library was not found or not usable." >&5 +$as_echo "$as_me: WARNING: libgmp development library was not found or not usable." >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: GNU coreutils will be built without GMP support." >&5 +$as_echo "$as_me: WARNING: GNU coreutils will be built without GMP support." >&2;} fi LIBS=$cu_saved_libs @@ -44548,6 +50126,8 @@ CONFIG_STATUS_DEPENDENCIES='$(top_srcdir)/src/Makefile.am' ############################################################################ +# As long as "grep 'PRI[diouxX]' po/*.pot" reports matches in +# translatable strings, we must use need-formatstring-macros here. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether NLS is requested" >&5 $as_echo_n "checking whether NLS is requested... " >&6; } @@ -45143,6 +50723,25 @@ int main () return 1; } } + /* Test against Solaris 10 bug: Failures are not distinguishable from + successful returns. */ + { + iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); + if (cd_ascii_to_88591 != (iconv_t)(-1)) + { + static const char input[] = "\263"; + char buf[10]; + const char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_ascii_to_88591, + (char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res == 0) + return 1; + } + } #if 0 /* This bug could be worked around by the caller. */ /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ { @@ -46092,7 +51691,7 @@ fi if test -n "$gl_LIBOBJS"; then # Remove the extension. sed_drop_objext='s/\.o$//;s/\.obj$//' - for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed "$sed_drop_objext" | sort | uniq`; do + for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do gl_libobjs="$gl_libobjs $i.$ac_objext" gl_ltlibobjs="$gl_ltlibobjs $i.lo" done @@ -46104,12 +51703,14 @@ fi + + gltests_libobjs= gltests_ltlibobjs= if test -n "$gltests_LIBOBJS"; then # Remove the extension. sed_drop_objext='s/\.o$//;s/\.obj$//' - for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed "$sed_drop_objext" | sort | uniq`; do + for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do gltests_libobjs="$gltests_libobjs $i.$ac_objext" gltests_ltlibobjs="$gltests_ltlibobjs $i.lo" done @@ -46531,8 +52132,8 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by GNU coreutils $as_me 7.6, which was -generated by GNU Autoconf 2.64.27-5b5d. Invocation command line was +This file was extended by GNU coreutils $as_me 8.4, which was +generated by GNU Autoconf 2.65.23-13e35. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -46573,6 +52174,7 @@ Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit + --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files @@ -46600,12 +52202,13 @@ General help using GNU software: ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -GNU coreutils config.status 7.6 -configured by $0, generated by GNU Autoconf 2.64.27-5b5d, - with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" +GNU coreutils config.status 8.4 +configured by $0, generated by GNU Autoconf 2.65.23-13e35, + with options \\"\$ac_cs_config\\" -Copyright (C) 2009 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -46641,6 +52244,8 @@ do ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) @@ -46846,7 +52451,7 @@ s/'"$ac_delim"'$// t delim :nl h -s/\(.\{148\}\).*/\1/ +s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p @@ -46860,7 +52465,7 @@ s/.\{148\}// t nl :delim h -s/\(.\{148\}\).*/\1/ +s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p @@ -47341,7 +52946,7 @@ $as_echo "$as_me: linking $ac_source to $ac_file" >&6;} rm -f "$ac_file" # Try a relative symlink, then a hard link, then a copy. - case $srcdir in + case $ac_source in [\\/$]* | ?:[\\/]* ) ac_rel_source=$ac_source ;; *) ac_rel_source=$ac_top_build_prefix$ac_source ;; esac diff --git a/src/bin/coreutils/configure.ac b/src/bin/coreutils/configure.ac index e718b36b37..b07a52bf51 100644 --- a/src/bin/coreutils/configure.ac +++ b/src/bin/coreutils/configure.ac @@ -1,7 +1,7 @@ # -*- autoconf -*- # Process this file with autoconf to produce a configure script. -# Copyright (C) 1991, 1993-2009 Free Software Foundation, Inc. +# Copyright (C) 1991, 1993-2010 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,7 +18,7 @@ dnl Written by Jim Meyering. -AC_PREREQ([2.61]) +AC_PREREQ([2.62]) # Make inter-release version strings look like, e.g., v6.9-219-g58ddd, which # indicates that it is built from the 219th delta (in _some_ repository) @@ -32,7 +32,7 @@ AC_CONFIG_SRCDIR([src/ls.c]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_HEADERS([lib/config.h:lib/config.hin]) -AM_INIT_AUTOMAKE([1.11 dist-xz color-tests parallel-tests]) +AM_INIT_AUTOMAKE([1.11.1 dist-xz color-tests parallel-tests]) AM_SILENT_RULES([yes]) # make --enable-silent-rules the default. AC_PROG_CC_STDC @@ -101,14 +101,12 @@ if test "$gl_gcc_warnings" = yes; then gl_WARN_ADD([-Wno-pointer-sign]) # Too many warnings for now gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now - # Offenders in pre-fts remove.c; FIXME: remove upon remove.c rewrite - gl_WARN_ADD([-Wno-jump-misses-init]) - # In spite of excluding -Wlogical-op above, it is enabled, as of # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c gl_WARN_ADD([-Wno-logical-op]) gl_WARN_ADD([-fdiagnostics-show-option]) + gl_WARN_ADD([-funit-at-a-time]) AC_SUBST([WARN_CFLAGS]) @@ -116,13 +114,21 @@ if test "$gl_gcc_warnings" = yes; then AC_DEFINE([_FORTIFY_SOURCE], [2], [enable compile-time and run-time bounds-checking, and some warnings]) AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks]) + + # We use a slightly smaller set of warning options for lib/. + # Remove the following and save the result in GNULIB_WARN_CFLAGS. + nw= + nw="$nw -Wuninitialized" + nw="$nw -Wunused-macros" + nw="$nw -Wmissing-prototypes" + nw="$nw -Wold-style-definition" + gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw]) + AC_SUBST([GNULIB_WARN_CFLAGS]) fi AC_FUNC_FORK optional_bin_progs= -AC_CHECK_FUNCS([uname], - gl_ADD_PROG([optional_bin_progs], [uname])) AC_CHECK_FUNCS([chroot], gl_ADD_PROG([optional_bin_progs], [chroot])) AC_CHECK_FUNCS([gethostid], @@ -423,8 +429,10 @@ CONFIG_STATUS_DEPENDENCIES='$(top_srcdir)/src/Makefile.am' AC_SUBST([CONFIG_STATUS_DEPENDENCIES]) ############################################################################ +# As long as "grep 'PRI[diouxX]' po/*.pot" reports matches in +# translatable strings, we must use need-formatstring-macros here. AM_GNU_GETTEXT([external], [need-formatstring-macros]) -AM_GNU_GETTEXT_VERSION([0.15]) +AM_GNU_GETTEXT_VERSION([0.17]) # For a test of uniq: it uses the $LOCALE_FR envvar. gt_LOCALE_FR diff --git a/src/bin/coreutils/doc/ChangeLog-2007 b/src/bin/coreutils/doc/ChangeLog-2007 index bdf7aed895..30d21091f3 100644 --- a/src/bin/coreutils/doc/ChangeLog-2007 +++ b/src/bin/coreutils/doc/ChangeLog-2007 @@ -2002,7 +2002,7 @@ ----- - Copyright (C) 2001-2009 Free Software Foundation, Inc. + Copyright (C) 2001-2010 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted provided the copyright notice diff --git a/src/bin/coreutils/doc/Makefile.am b/src/bin/coreutils/doc/Makefile.am index be610a276e..e7553e057e 100644 --- a/src/bin/coreutils/doc/Makefile.am +++ b/src/bin/coreutils/doc/Makefile.am @@ -1,6 +1,6 @@ # Make coreutils documentation. -*-Makefile-*- -# Copyright (C) 1995-1998, 2001-2009 Free Software Foundation, Inc. +# Copyright (C) 1995-1998, 2001-2010 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -30,13 +30,12 @@ EXTRA_DIST = perm.texi getdate.texi constants.texi fdl.texi AM_MAKEINFOFLAGS = --no-split constants.texi: $(top_srcdir)/src/tail.c $(top_srcdir)/src/shred.c - LC_ALL=C \ - sed -n -e 's/^#define \(DEFAULT_MAX[_A-Z]*\) \(.*\)/@set \1 \2/p' \ - $(top_srcdir)/src/tail.c > t-$@ - LC_ALL=C \ - sed -n -e 's/.*\(DEFAULT_PASSES\)[ =]* \([0-9]*\).*/@set SHRED_\1 \2/p'\ - $(top_srcdir)/src/shred.c >> t-$@ - mv t-$@ $@ + $(AM_V_GEN)LC_ALL=C; export LC_ALL; \ + { sed -n -e 's/^#define \(DEFAULT_MAX[_A-Z]*\) \(.*\)/@set \1 \2/p' \ + $(top_srcdir)/src/tail.c && \ + sed -n -e 's/.*\(DEFAULT_PASSES\)[ =]* \([0-9]*\).*/@set SHRED_\1 \2/p'\ + $(top_srcdir)/src/shred.c; } > t-$@ \ + && mv t-$@ $@ MAINTAINERCLEANFILES = constants.texi @@ -48,8 +47,10 @@ _W = (^|[^A-Za-z0-9_]) W_ = ([^A-Za-z0-9_]|$$) syntax_checks = \ + sc-avoid-builtin \ sc-avoid-io \ sc-avoid-non-zero \ + sc-avoid-path \ sc-avoid-timezone \ sc-avoid-zeroes \ sc-exponent-grouping \ @@ -70,9 +71,18 @@ check-texinfo: $(syntax_checks) $(PERL) -e 1 2> /dev/null && { $(PERL) -ne \ '/\bPOSIX\b/ && !/\@acronym{POSIX}/ && !/^\* / || /{posix}/ and print,exit 1' \ $(srcdir)/*.texi 2> /dev/null || fail=1; }; \ - $(EGREP) -i '$(_W)builtins?$(W_)' $(srcdir)/*.texi && fail=1; \ + exit $$fail + +sc-avoid-builtin: + $(AM_V_GEN)$(EGREP) -i '$(_W)builtins?$(W_)' $(srcdir)/*.texi \ + && exit 1 || : + +sc-avoid-path: + $(AM_V_GEN)fail=0; \ $(EGREP) -i '$(_W)path(name)?s?$(W_)' $(srcdir)/*.texi \ - | $(EGREP) -v 'search path|@vindex PATH$$|@env[{]PATH[}]' && fail=1; \ + | $(EGREP) -v \ + 'PATH=|path search|search path|@vindex PATH$$|@env[{]PATH[}]' \ + && fail=1; \ exit $$fail # Use `time zone', not `timezone'. diff --git a/src/bin/coreutils/doc/Makefile.in b/src/bin/coreutils/doc/Makefile.in index c87f9fc761..d9aa9d2de2 100644 --- a/src/bin/coreutils/doc/Makefile.in +++ b/src/bin/coreutils/doc/Makefile.in @@ -17,7 +17,7 @@ # Make coreutils documentation. -*-Makefile-*- -# Copyright (C) 1995-1998, 2001-2009 Free Software Foundation, Inc. +# Copyright (C) 1995-1998, 2001-2010 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -69,35 +69,40 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/cloexec.m4 $(top_srcdir)/m4/close-stream.m4 \ $(top_srcdir)/m4/close.m4 $(top_srcdir)/m4/closein.m4 \ $(top_srcdir)/m4/closeout.m4 $(top_srcdir)/m4/codeset.m4 \ - $(top_srcdir)/m4/config-h.m4 $(top_srcdir)/m4/cycle-check.m4 \ - $(top_srcdir)/m4/d-ino.m4 $(top_srcdir)/m4/d-type.m4 \ - $(top_srcdir)/m4/dirent-safer.m4 $(top_srcdir)/m4/dirent_h.m4 \ - $(top_srcdir)/m4/dirfd.m4 $(top_srcdir)/m4/dirname.m4 \ - $(top_srcdir)/m4/dos.m4 $(top_srcdir)/m4/double-slash-root.m4 \ - $(top_srcdir)/m4/dup2.m4 $(top_srcdir)/m4/eealloc.m4 \ - $(top_srcdir)/m4/environ.m4 $(top_srcdir)/m4/errno_h.m4 \ - $(top_srcdir)/m4/error.m4 $(top_srcdir)/m4/euidaccess-stat.m4 \ + $(top_srcdir)/m4/config-h.m4 $(top_srcdir)/m4/ctype.m4 \ + $(top_srcdir)/m4/cycle-check.m4 $(top_srcdir)/m4/d-ino.m4 \ + $(top_srcdir)/m4/d-type.m4 $(top_srcdir)/m4/dirent-safer.m4 \ + $(top_srcdir)/m4/dirent_h.m4 $(top_srcdir)/m4/dirfd.m4 \ + $(top_srcdir)/m4/dirname.m4 $(top_srcdir)/m4/dos.m4 \ + $(top_srcdir)/m4/double-slash-root.m4 $(top_srcdir)/m4/dup2.m4 \ + $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/environ.m4 \ + $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/error.m4 \ + $(top_srcdir)/m4/euidaccess-stat.m4 \ $(top_srcdir)/m4/euidaccess.m4 $(top_srcdir)/m4/exclude.m4 \ $(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/exponentd.m4 \ $(top_srcdir)/m4/exponentf.m4 $(top_srcdir)/m4/exponentl.m4 \ - $(top_srcdir)/m4/extensions.m4 $(top_srcdir)/m4/fchdir.m4 \ - $(top_srcdir)/m4/fclose.m4 $(top_srcdir)/m4/fcntl-safer.m4 \ - $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/fd-reopen.m4 \ - $(top_srcdir)/m4/fdopendir.m4 $(top_srcdir)/m4/fflush.m4 \ - $(top_srcdir)/m4/file-type.m4 $(top_srcdir)/m4/fileblocks.m4 \ - $(top_srcdir)/m4/filemode.m4 $(top_srcdir)/m4/filenamecat.m4 \ - $(top_srcdir)/m4/flexmember.m4 $(top_srcdir)/m4/float_h.m4 \ - $(top_srcdir)/m4/fnmatch.m4 $(top_srcdir)/m4/fopen.m4 \ - $(top_srcdir)/m4/fpending.m4 $(top_srcdir)/m4/fpieee.m4 \ - $(top_srcdir)/m4/fprintftime.m4 $(top_srcdir)/m4/fpurge.m4 \ - $(top_srcdir)/m4/freading.m4 $(top_srcdir)/m4/frexp.m4 \ + $(top_srcdir)/m4/extensions.m4 $(top_srcdir)/m4/faccessat.m4 \ + $(top_srcdir)/m4/fchdir.m4 $(top_srcdir)/m4/fclose.m4 \ + $(top_srcdir)/m4/fcntl-o.m4 $(top_srcdir)/m4/fcntl-safer.m4 \ + $(top_srcdir)/m4/fcntl.m4 $(top_srcdir)/m4/fcntl_h.m4 \ + $(top_srcdir)/m4/fd-reopen.m4 $(top_srcdir)/m4/fdopendir.m4 \ + $(top_srcdir)/m4/fflush.m4 $(top_srcdir)/m4/file-type.m4 \ + $(top_srcdir)/m4/fileblocks.m4 $(top_srcdir)/m4/filemode.m4 \ + $(top_srcdir)/m4/filenamecat.m4 $(top_srcdir)/m4/flexmember.m4 \ + $(top_srcdir)/m4/float_h.m4 $(top_srcdir)/m4/fnmatch.m4 \ + $(top_srcdir)/m4/fopen.m4 $(top_srcdir)/m4/fpending.m4 \ + $(top_srcdir)/m4/fpieee.m4 $(top_srcdir)/m4/fprintftime.m4 \ + $(top_srcdir)/m4/fpurge.m4 $(top_srcdir)/m4/freading.m4 \ + $(top_srcdir)/m4/freopen.m4 $(top_srcdir)/m4/frexp.m4 \ $(top_srcdir)/m4/frexpl.m4 $(top_srcdir)/m4/fseeko.m4 \ $(top_srcdir)/m4/fstypename.m4 $(top_srcdir)/m4/fsusage.m4 \ - $(top_srcdir)/m4/ftello.m4 $(top_srcdir)/m4/ftruncate.m4 \ - $(top_srcdir)/m4/fts.m4 $(top_srcdir)/m4/getaddrinfo.m4 \ + $(top_srcdir)/m4/fsync.m4 $(top_srcdir)/m4/ftello.m4 \ + $(top_srcdir)/m4/ftruncate.m4 $(top_srcdir)/m4/fts.m4 \ + $(top_srcdir)/m4/getaddrinfo.m4 \ $(top_srcdir)/m4/getcwd-abort-bug.m4 \ $(top_srcdir)/m4/getcwd-path-max.m4 $(top_srcdir)/m4/getcwd.m4 \ $(top_srcdir)/m4/getdate.m4 $(top_srcdir)/m4/getdelim.m4 \ + $(top_srcdir)/m4/getdtablesize.m4 \ $(top_srcdir)/m4/getgroups.m4 $(top_srcdir)/m4/gethostname.m4 \ $(top_srcdir)/m4/gethrxtime.m4 $(top_srcdir)/m4/getline.m4 \ $(top_srcdir)/m4/getloadavg.m4 $(top_srcdir)/m4/getndelim2.m4 \ @@ -121,24 +126,27 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intmax_t.m4 \ $(top_srcdir)/m4/inttostr.m4 $(top_srcdir)/m4/inttypes-pri.m4 \ $(top_srcdir)/m4/inttypes.m4 $(top_srcdir)/m4/inttypes_h.m4 \ - $(top_srcdir)/m4/isapipe.m4 $(top_srcdir)/m4/isnand.m4 \ - $(top_srcdir)/m4/isnanf.m4 $(top_srcdir)/m4/isnanl.m4 \ - $(top_srcdir)/m4/jm-macros.m4 $(top_srcdir)/m4/jm-winsz1.m4 \ - $(top_srcdir)/m4/jm-winsz2.m4 $(top_srcdir)/m4/lchmod.m4 \ + $(top_srcdir)/m4/isapipe.m4 $(top_srcdir)/m4/isblank.m4 \ + $(top_srcdir)/m4/isnand.m4 $(top_srcdir)/m4/isnanf.m4 \ + $(top_srcdir)/m4/isnanl.m4 $(top_srcdir)/m4/jm-macros.m4 \ + $(top_srcdir)/m4/jm-winsz1.m4 $(top_srcdir)/m4/jm-winsz2.m4 \ + $(top_srcdir)/m4/langinfo_h.m4 $(top_srcdir)/m4/lchmod.m4 \ $(top_srcdir)/m4/lchown.m4 $(top_srcdir)/m4/ldexpl.m4 \ $(top_srcdir)/m4/lib-check.m4 $(top_srcdir)/m4/lib-ignore.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/link-follow.m4 \ - $(top_srcdir)/m4/link.m4 $(top_srcdir)/m4/localcharset.m4 \ - $(top_srcdir)/m4/locale-fr.m4 $(top_srcdir)/m4/locale-ja.m4 \ - $(top_srcdir)/m4/locale-tr.m4 $(top_srcdir)/m4/locale-zh.m4 \ - $(top_srcdir)/m4/long-options.m4 $(top_srcdir)/m4/longlong.m4 \ - $(top_srcdir)/m4/ls-mntd-fs.m4 $(top_srcdir)/m4/lseek.m4 \ - $(top_srcdir)/m4/lstat.m4 $(top_srcdir)/m4/malloc.m4 \ - $(top_srcdir)/m4/malloca.m4 $(top_srcdir)/m4/manywarnings.m4 \ - $(top_srcdir)/m4/math_h.m4 $(top_srcdir)/m4/mbchar.m4 \ - $(top_srcdir)/m4/mbiter.m4 $(top_srcdir)/m4/mbrlen.m4 \ - $(top_srcdir)/m4/mbrtowc.m4 $(top_srcdir)/m4/mbsinit.m4 \ + $(top_srcdir)/m4/link.m4 $(top_srcdir)/m4/linkat.m4 \ + $(top_srcdir)/m4/localcharset.m4 $(top_srcdir)/m4/locale-fr.m4 \ + $(top_srcdir)/m4/locale-ja.m4 $(top_srcdir)/m4/locale-tr.m4 \ + $(top_srcdir)/m4/locale-zh.m4 $(top_srcdir)/m4/locale_h.m4 \ + $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/long-options.m4 \ + $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ls-mntd-fs.m4 \ + $(top_srcdir)/m4/lseek.m4 $(top_srcdir)/m4/lstat.m4 \ + $(top_srcdir)/m4/malloc.m4 $(top_srcdir)/m4/malloca.m4 \ + $(top_srcdir)/m4/manywarnings.m4 $(top_srcdir)/m4/math_h.m4 \ + $(top_srcdir)/m4/mbchar.m4 $(top_srcdir)/m4/mbiter.m4 \ + $(top_srcdir)/m4/mbrlen.m4 $(top_srcdir)/m4/mbrtowc.m4 \ + $(top_srcdir)/m4/mbsinit.m4 $(top_srcdir)/m4/mbslen.m4 \ $(top_srcdir)/m4/mbsrtowcs.m4 $(top_srcdir)/m4/mbstate_t.m4 \ $(top_srcdir)/m4/mbswidth.m4 $(top_srcdir)/m4/md5.m4 \ $(top_srcdir)/m4/memcasecmp.m4 $(top_srcdir)/m4/memchr.m4 \ @@ -147,34 +155,34 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/mempcpy.m4 $(top_srcdir)/m4/memrchr.m4 \ $(top_srcdir)/m4/memset.m4 $(top_srcdir)/m4/memxfrm.m4 \ $(top_srcdir)/m4/mgetgroups.m4 $(top_srcdir)/m4/mkancesdirs.m4 \ - $(top_srcdir)/m4/mkdir-p.m4 $(top_srcdir)/m4/mkdir-slash.m4 \ + $(top_srcdir)/m4/mkdir-p.m4 $(top_srcdir)/m4/mkdir.m4 \ $(top_srcdir)/m4/mkstemp.m4 $(top_srcdir)/m4/mktime.m4 \ $(top_srcdir)/m4/mmap-anon.m4 $(top_srcdir)/m4/mode_t.m4 \ $(top_srcdir)/m4/modechange.m4 $(top_srcdir)/m4/mountlist.m4 \ $(top_srcdir)/m4/mpsort.m4 $(top_srcdir)/m4/multiarch.m4 \ $(top_srcdir)/m4/nanosleep.m4 $(top_srcdir)/m4/netdb_h.m4 \ - $(top_srcdir)/m4/netinet_in_h.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/open.m4 \ - $(top_srcdir)/m4/openat.m4 $(top_srcdir)/m4/pathmax.m4 \ - $(top_srcdir)/m4/perl.m4 $(top_srcdir)/m4/perror.m4 \ - $(top_srcdir)/m4/physmem.m4 $(top_srcdir)/m4/po.m4 \ - $(top_srcdir)/m4/posix-shell.m4 $(top_srcdir)/m4/posixtm.m4 \ - $(top_srcdir)/m4/posixver.m4 $(top_srcdir)/m4/prereq.m4 \ - $(top_srcdir)/m4/printf-frexp.m4 \ + $(top_srcdir)/m4/netinet_in_h.m4 \ + $(top_srcdir)/m4/nl_langinfo.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/nproc.m4 \ + $(top_srcdir)/m4/open.m4 $(top_srcdir)/m4/openat.m4 \ + $(top_srcdir)/m4/pathmax.m4 $(top_srcdir)/m4/perl.m4 \ + $(top_srcdir)/m4/perror.m4 $(top_srcdir)/m4/physmem.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/posix-shell.m4 \ + $(top_srcdir)/m4/posixtm.m4 $(top_srcdir)/m4/posixver.m4 \ + $(top_srcdir)/m4/prereq.m4 $(top_srcdir)/m4/printf-frexp.m4 \ $(top_srcdir)/m4/printf-frexpl.m4 $(top_srcdir)/m4/printf.m4 \ $(top_srcdir)/m4/priv-set.m4 $(top_srcdir)/m4/progtest.m4 \ $(top_srcdir)/m4/putenv.m4 $(top_srcdir)/m4/quote.m4 \ $(top_srcdir)/m4/quotearg.m4 $(top_srcdir)/m4/read-file.m4 \ $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/readtokens.m4 \ $(top_srcdir)/m4/readutmp.m4 $(top_srcdir)/m4/realloc.m4 \ - $(top_srcdir)/m4/regex.m4 \ - $(top_srcdir)/m4/rename-dest-slash.m4 \ - $(top_srcdir)/m4/rename.m4 $(top_srcdir)/m4/rmdir-errno.m4 \ - $(top_srcdir)/m4/rmdir.m4 $(top_srcdir)/m4/root-dev-ino.m4 \ - $(top_srcdir)/m4/rpmatch.m4 $(top_srcdir)/m4/safe-read.m4 \ - $(top_srcdir)/m4/safe-write.m4 $(top_srcdir)/m4/same.m4 \ - $(top_srcdir)/m4/save-cwd.m4 $(top_srcdir)/m4/savedir.m4 \ - $(top_srcdir)/m4/savewd.m4 $(top_srcdir)/m4/select.m4 \ + $(top_srcdir)/m4/regex.m4 $(top_srcdir)/m4/remove.m4 \ + $(top_srcdir)/m4/rename.m4 $(top_srcdir)/m4/rmdir.m4 \ + $(top_srcdir)/m4/root-dev-ino.m4 $(top_srcdir)/m4/rpmatch.m4 \ + $(top_srcdir)/m4/safe-read.m4 $(top_srcdir)/m4/safe-write.m4 \ + $(top_srcdir)/m4/same.m4 $(top_srcdir)/m4/save-cwd.m4 \ + $(top_srcdir)/m4/savedir.m4 $(top_srcdir)/m4/savewd.m4 \ + $(top_srcdir)/m4/select.m4 \ $(top_srcdir)/m4/selinux-context-h.m4 \ $(top_srcdir)/m4/selinux-selinux-h.m4 \ $(top_srcdir)/m4/servent.m4 $(top_srcdir)/m4/setenv.m4 \ @@ -188,38 +196,45 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/socklen.m4 $(top_srcdir)/m4/sockpfaf.m4 \ $(top_srcdir)/m4/ssize_t.m4 $(top_srcdir)/m4/st_dm_mode.m4 \ $(top_srcdir)/m4/stat-prog.m4 $(top_srcdir)/m4/stat-time.m4 \ - $(top_srcdir)/m4/stdarg.m4 $(top_srcdir)/m4/stdbool.m4 \ - $(top_srcdir)/m4/stddef_h.m4 $(top_srcdir)/m4/stdint.m4 \ - $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/stdio-safer.m4 \ - $(top_srcdir)/m4/stdio_h.m4 $(top_srcdir)/m4/stdlib-safer.m4 \ - $(top_srcdir)/m4/stdlib_h.m4 $(top_srcdir)/m4/stpcpy.m4 \ - $(top_srcdir)/m4/stpncpy.m4 $(top_srcdir)/m4/strcspn.m4 \ - $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \ - $(top_srcdir)/m4/strftime.m4 $(top_srcdir)/m4/string_h.m4 \ - $(top_srcdir)/m4/strndup.m4 $(top_srcdir)/m4/strnlen.m4 \ - $(top_srcdir)/m4/strnumcmp.m4 $(top_srcdir)/m4/strpbrk.m4 \ + $(top_srcdir)/m4/stat.m4 $(top_srcdir)/m4/stdarg.m4 \ + $(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stddef_h.m4 \ + $(top_srcdir)/m4/stdint.m4 $(top_srcdir)/m4/stdint_h.m4 \ + $(top_srcdir)/m4/stdio-safer.m4 $(top_srcdir)/m4/stdio_h.m4 \ + $(top_srcdir)/m4/stdlib-safer.m4 $(top_srcdir)/m4/stdlib_h.m4 \ + $(top_srcdir)/m4/stpcpy.m4 $(top_srcdir)/m4/stpncpy.m4 \ + $(top_srcdir)/m4/strcspn.m4 $(top_srcdir)/m4/strdup.m4 \ + $(top_srcdir)/m4/strerror.m4 $(top_srcdir)/m4/strftime.m4 \ + $(top_srcdir)/m4/string_h.m4 $(top_srcdir)/m4/strndup.m4 \ + $(top_srcdir)/m4/strnlen.m4 $(top_srcdir)/m4/strnumcmp.m4 \ + $(top_srcdir)/m4/strpbrk.m4 $(top_srcdir)/m4/strsignal.m4 \ $(top_srcdir)/m4/strstr.m4 $(top_srcdir)/m4/strtod.m4 \ $(top_srcdir)/m4/strtoimax.m4 $(top_srcdir)/m4/strtol.m4 \ $(top_srcdir)/m4/strtoll.m4 $(top_srcdir)/m4/strtoul.m4 \ $(top_srcdir)/m4/strtoull.m4 $(top_srcdir)/m4/strtoumax.m4 \ - $(top_srcdir)/m4/strverscmp.m4 $(top_srcdir)/m4/sys_ioctl_h.m4 \ + $(top_srcdir)/m4/symlink.m4 $(top_srcdir)/m4/symlinkat.m4 \ + $(top_srcdir)/m4/sys_ioctl_h.m4 \ $(top_srcdir)/m4/sys_select_h.m4 \ $(top_srcdir)/m4/sys_socket_h.m4 \ $(top_srcdir)/m4/sys_stat_h.m4 $(top_srcdir)/m4/sys_time_h.m4 \ - $(top_srcdir)/m4/tempname.m4 $(top_srcdir)/m4/time_h.m4 \ - $(top_srcdir)/m4/time_r.m4 $(top_srcdir)/m4/timespec.m4 \ + $(top_srcdir)/m4/sys_utsname_h.m4 $(top_srcdir)/m4/tempname.m4 \ + $(top_srcdir)/m4/thread.m4 $(top_srcdir)/m4/threadlib.m4 \ + $(top_srcdir)/m4/time_h.m4 $(top_srcdir)/m4/time_r.m4 \ + $(top_srcdir)/m4/timespec.m4 $(top_srcdir)/m4/tls.m4 \ $(top_srcdir)/m4/tm_gmtoff.m4 $(top_srcdir)/m4/tzset.m4 \ - $(top_srcdir)/m4/ungetc.m4 $(top_srcdir)/m4/unicodeio.m4 \ - $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/unistd_h.m4 \ - $(top_srcdir)/m4/unlink-busy.m4 $(top_srcdir)/m4/unlinkdir.m4 \ + $(top_srcdir)/m4/uname.m4 $(top_srcdir)/m4/ungetc.m4 \ + $(top_srcdir)/m4/unicodeio.m4 $(top_srcdir)/m4/unistd-safer.m4 \ + $(top_srcdir)/m4/unistd_h.m4 $(top_srcdir)/m4/unlink-busy.m4 \ + $(top_srcdir)/m4/unlink.m4 $(top_srcdir)/m4/unlinkdir.m4 \ $(top_srcdir)/m4/unlocked-io.m4 $(top_srcdir)/m4/uptime.m4 \ - $(top_srcdir)/m4/userspec.m4 $(top_srcdir)/m4/utimbuf.m4 \ - $(top_srcdir)/m4/utimecmp.m4 $(top_srcdir)/m4/utimens.m4 \ - $(top_srcdir)/m4/utimes.m4 $(top_srcdir)/m4/vasnprintf.m4 \ + $(top_srcdir)/m4/userspec.m4 $(top_srcdir)/m4/usleep.m4 \ + $(top_srcdir)/m4/utimbuf.m4 $(top_srcdir)/m4/utimecmp.m4 \ + $(top_srcdir)/m4/utimens.m4 $(top_srcdir)/m4/utimes.m4 \ + $(top_srcdir)/m4/vasnprintf.m4 \ $(top_srcdir)/m4/vasprintf-posix.m4 \ $(top_srcdir)/m4/vasprintf.m4 $(top_srcdir)/m4/version-etc.m4 \ $(top_srcdir)/m4/vfprintf-posix.m4 \ - $(top_srcdir)/m4/vprintf-posix.m4 $(top_srcdir)/m4/warnings.m4 \ + $(top_srcdir)/m4/vprintf-posix.m4 \ + $(top_srcdir)/m4/warn-on-use.m4 $(top_srcdir)/m4/warnings.m4 \ $(top_srcdir)/m4/wchar.m4 $(top_srcdir)/m4/wchar_t.m4 \ $(top_srcdir)/m4/wcrtomb.m4 $(top_srcdir)/m4/wctob.m4 \ $(top_srcdir)/m4/wctype.m4 $(top_srcdir)/m4/wcwidth.m4 \ @@ -230,7 +245,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/m4/xstrndup.m4 \ $(top_srcdir)/m4/xstrtod.m4 $(top_srcdir)/m4/xstrtol.m4 \ $(top_srcdir)/m4/xvasprintf.m4 $(top_srcdir)/m4/yesno.m4 \ - $(top_srcdir)/configure.ac + $(top_srcdir)/m4/yield.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d @@ -239,12 +254,33 @@ CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) -am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_0 = @echo " GEN " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ SOURCES = DIST_SOURCES = +AM_V_DVIPS = $(am__v_DVIPS_$(V)) +am__v_DVIPS_ = $(am__v_DVIPS_$(AM_DEFAULT_VERBOSITY)) +am__v_DVIPS_0 = @echo " DVIPS " $@; +AM_V_MAKEINFO = $(am__v_MAKEINFO_$(V)) +am__v_MAKEINFO_ = $(am__v_MAKEINFO_$(AM_DEFAULT_VERBOSITY)) +am__v_MAKEINFO_0 = @echo " MAKEINFO" $@; +AM_V_INFOHTML = $(am__v_INFOHTML_$(V)) +am__v_INFOHTML_ = $(am__v_INFOHTML_$(AM_DEFAULT_VERBOSITY)) +am__v_INFOHTML_0 = @echo " INFOHTML" $@; +AM_V_TEXI2DVI = $(am__v_TEXI2DVI_$(V)) +am__v_TEXI2DVI_ = $(am__v_TEXI2DVI_$(AM_DEFAULT_VERBOSITY)) +am__v_TEXI2DVI_0 = @echo " TEXI2DVI" $@; +AM_V_TEXI2PDF = $(am__v_TEXI2PDF_$(V)) +am__v_TEXI2PDF_ = $(am__v_TEXI2PDF_$(AM_DEFAULT_VERBOSITY)) +am__v_TEXI2PDF_0 = @echo " TEXI2PDF" $@; +AM_V_texinfo = $(am__v_texinfo_$(V)) +am__v_texinfo_ = $(am__v_texinfo_$(AM_DEFAULT_VERBOSITY)) +am__v_texinfo_0 = -q +AM_V_texidevnull = $(am__v_texidevnull_$(V)) +am__v_texidevnull_ = $(am__v_texidevnull_$(AM_DEFAULT_VERBOSITY)) +am__v_texidevnull_0 = > /dev/null INFO_DEPS = $(srcdir)/coreutils.info TEXINFO_TEX = $(top_srcdir)/build-aux/texinfo.tex am__TEXINFO_TEX_DIR = $(top_srcdir)/build-aux @@ -287,7 +323,6 @@ ALLOCA_H = @ALLOCA_H@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@ -ARPA_INET_H = @ARPA_INET_H@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -307,7 +342,6 @@ CYGPATH_W = @CYGPATH_W@ DEFAULT_POSIX2_VERSION = @DEFAULT_POSIX2_VERSION@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ -DIRENT_H = @DIRENT_H@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ @@ -320,7 +354,6 @@ EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@ EOVERFLOW_VALUE = @EOVERFLOW_VALUE@ ERRNO_H = @ERRNO_H@ EXEEXT = @EXEEXT@ -FCNTL_H = @FCNTL_H@ FLOAT_H = @FLOAT_H@ FNMATCH_H = @FNMATCH_H@ GETADDRINFO_LIB = @GETADDRINFO_LIB@ @@ -338,6 +371,7 @@ GNULIB_ATOLL = @GNULIB_ATOLL@ GNULIB_BIND = @GNULIB_BIND@ GNULIB_BTOWC = @GNULIB_BTOWC@ GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@ +GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@ GNULIB_CEILF = @GNULIB_CEILF@ GNULIB_CEILL = @GNULIB_CEILL@ GNULIB_CHOWN = @GNULIB_CHOWN@ @@ -347,6 +381,7 @@ GNULIB_DIRFD = @GNULIB_DIRFD@ GNULIB_DPRINTF = @GNULIB_DPRINTF@ GNULIB_DUP2 = @GNULIB_DUP2@ GNULIB_DUP3 = @GNULIB_DUP3@ +GNULIB_DUPLOCALE = @GNULIB_DUPLOCALE@ GNULIB_ENVIRON = @GNULIB_ENVIRON@ GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@ GNULIB_FACCESSAT = @GNULIB_FACCESSAT@ @@ -354,6 +389,7 @@ GNULIB_FCHDIR = @GNULIB_FCHDIR@ GNULIB_FCHMODAT = @GNULIB_FCHMODAT@ GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@ GNULIB_FCLOSE = @GNULIB_FCLOSE@ +GNULIB_FCNTL = @GNULIB_FCNTL@ GNULIB_FDOPENDIR = @GNULIB_FDOPENDIR@ GNULIB_FFLUSH = @GNULIB_FFLUSH@ GNULIB_FLOORF = @GNULIB_FLOORF@ @@ -374,15 +410,18 @@ GNULIB_FSYNC = @GNULIB_FSYNC@ GNULIB_FTELL = @GNULIB_FTELL@ GNULIB_FTELLO = @GNULIB_FTELLO@ GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@ +GNULIB_FUTIMENS = @GNULIB_FUTIMENS@ GNULIB_FWRITE = @GNULIB_FWRITE@ GNULIB_GETADDRINFO = @GNULIB_GETADDRINFO@ GNULIB_GETCWD = @GNULIB_GETCWD@ GNULIB_GETDELIM = @GNULIB_GETDELIM@ GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@ GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@ +GNULIB_GETGROUPS = @GNULIB_GETGROUPS@ GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@ GNULIB_GETLINE = @GNULIB_GETLINE@ GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@ +GNULIB_GETLOGIN = @GNULIB_GETLOGIN@ GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@ GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@ GNULIB_GETPEERNAME = @GNULIB_GETPEERNAME@ @@ -395,6 +434,7 @@ GNULIB_IMAXDIV = @GNULIB_IMAXDIV@ GNULIB_INET_NTOP = @GNULIB_INET_NTOP@ GNULIB_INET_PTON = @GNULIB_INET_PTON@ GNULIB_IOCTL = @GNULIB_IOCTL@ +GNULIB_ISBLANK = @GNULIB_ISBLANK@ GNULIB_ISFINITE = @GNULIB_ISFINITE@ GNULIB_ISINF = @GNULIB_ISINF@ GNULIB_ISNAN = @GNULIB_ISNAN@ @@ -405,6 +445,7 @@ GNULIB_LCHMOD = @GNULIB_LCHMOD@ GNULIB_LCHOWN = @GNULIB_LCHOWN@ GNULIB_LDEXPL = @GNULIB_LDEXPL@ GNULIB_LINK = @GNULIB_LINK@ +GNULIB_LINKAT = @GNULIB_LINKAT@ GNULIB_LISTEN = @GNULIB_LISTEN@ GNULIB_LSEEK = @GNULIB_LSEEK@ GNULIB_LSTAT = @GNULIB_LSTAT@ @@ -435,10 +476,15 @@ GNULIB_MEMPCPY = @GNULIB_MEMPCPY@ GNULIB_MEMRCHR = @GNULIB_MEMRCHR@ GNULIB_MKDIRAT = @GNULIB_MKDIRAT@ GNULIB_MKDTEMP = @GNULIB_MKDTEMP@ +GNULIB_MKFIFO = @GNULIB_MKFIFO@ GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@ +GNULIB_MKNOD = @GNULIB_MKNOD@ GNULIB_MKNODAT = @GNULIB_MKNODAT@ GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@ +GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@ GNULIB_MKSTEMP = @GNULIB_MKSTEMP@ +GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@ +GNULIB_NL_LANGINFO = @GNULIB_NL_LANGINFO@ GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@ GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@ GNULIB_OPEN = @GNULIB_OPEN@ @@ -446,6 +492,7 @@ GNULIB_OPENAT = @GNULIB_OPENAT@ GNULIB_PERROR = @GNULIB_PERROR@ GNULIB_PIPE2 = @GNULIB_PIPE2@ GNULIB_POPEN = @GNULIB_POPEN@ +GNULIB_PREAD = @GNULIB_PREAD@ GNULIB_PRINTF = @GNULIB_PRINTF@ GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@ GNULIB_PUTC = @GNULIB_PUTC@ @@ -457,9 +504,13 @@ GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@ GNULIB_READLINK = @GNULIB_READLINK@ GNULIB_READLINKAT = @GNULIB_READLINKAT@ GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@ +GNULIB_REALPATH = @GNULIB_REALPATH@ GNULIB_RECV = @GNULIB_RECV@ GNULIB_RECVFROM = @GNULIB_RECVFROM@ +GNULIB_REMOVE = @GNULIB_REMOVE@ GNULIB_RENAME = @GNULIB_RENAME@ +GNULIB_RENAMEAT = @GNULIB_RENAMEAT@ +GNULIB_RMDIR = @GNULIB_RMDIR@ GNULIB_ROUND = @GNULIB_ROUND@ GNULIB_ROUNDF = @GNULIB_ROUNDF@ GNULIB_ROUNDL = @GNULIB_ROUNDL@ @@ -479,6 +530,7 @@ GNULIB_SLEEP = @GNULIB_SLEEP@ GNULIB_SNPRINTF = @GNULIB_SNPRINTF@ GNULIB_SOCKET = @GNULIB_SOCKET@ GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@ +GNULIB_STAT = @GNULIB_STAT@ GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@ GNULIB_STPCPY = @GNULIB_STPCPY@ GNULIB_STPNCPY = @GNULIB_STPNCPY@ @@ -499,14 +551,19 @@ GNULIB_STRTOLL = @GNULIB_STRTOLL@ GNULIB_STRTOULL = @GNULIB_STRTOULL@ GNULIB_STRTOUMAX = @GNULIB_STRTOUMAX@ GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@ +GNULIB_SYMLINK = @GNULIB_SYMLINK@ GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@ GNULIB_TRUNC = @GNULIB_TRUNC@ GNULIB_TRUNCF = @GNULIB_TRUNCF@ GNULIB_TRUNCL = @GNULIB_TRUNCL@ +GNULIB_UNAME = @GNULIB_UNAME@ GNULIB_UNISTD_H_GETOPT = @GNULIB_UNISTD_H_GETOPT@ GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@ +GNULIB_UNLINK = @GNULIB_UNLINK@ GNULIB_UNLINKAT = @GNULIB_UNLINKAT@ GNULIB_UNSETENV = @GNULIB_UNSETENV@ +GNULIB_USLEEP = @GNULIB_USLEEP@ +GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@ GNULIB_VASPRINTF = @GNULIB_VASPRINTF@ GNULIB_VDPRINTF = @GNULIB_VDPRINTF@ GNULIB_VFPRINTF = @GNULIB_VFPRINTF@ @@ -515,6 +572,7 @@ GNULIB_VPRINTF = @GNULIB_VPRINTF@ GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@ GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@ GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@ +GNULIB_WARN_CFLAGS = @GNULIB_WARN_CFLAGS@ GNULIB_WCRTOMB = @GNULIB_WCRTOMB@ GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@ GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@ @@ -528,6 +586,8 @@ HAVE_ARPA_INET_H = @HAVE_ARPA_INET_H@ HAVE_ATOLL = @HAVE_ATOLL@ HAVE_BTOWC = @HAVE_BTOWC@ HAVE_CALLOC_POSIX = @HAVE_CALLOC_POSIX@ +HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@ +HAVE_CHOWN = @HAVE_CHOWN@ HAVE_DECL_ACOSL = @HAVE_DECL_ACOSL@ HAVE_DECL_ASINL = @HAVE_DECL_ASINL@ HAVE_DECL_ATANL = @HAVE_DECL_ATANL@ @@ -578,51 +638,69 @@ HAVE_EUIDACCESS = @HAVE_EUIDACCESS@ HAVE_FACCESSAT = @HAVE_FACCESSAT@ HAVE_FCHMODAT = @HAVE_FCHMODAT@ HAVE_FCHOWNAT = @HAVE_FCHOWNAT@ +HAVE_FCNTL = @HAVE_FCNTL@ HAVE_FDOPENDIR = @HAVE_FDOPENDIR@ -HAVE_FSEEKO = @HAVE_FSEEKO@ HAVE_FSTATAT = @HAVE_FSTATAT@ HAVE_FSYNC = @HAVE_FSYNC@ -HAVE_FTELLO = @HAVE_FTELLO@ HAVE_FTRUNCATE = @HAVE_FTRUNCATE@ +HAVE_FUTIMENS = @HAVE_FUTIMENS@ HAVE_GETDOMAINNAME = @HAVE_GETDOMAINNAME@ HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@ +HAVE_GETGROUPS = @HAVE_GETGROUPS@ HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@ +HAVE_GETLOGIN = @HAVE_GETLOGIN@ +HAVE_GETOPT_H = @HAVE_GETOPT_H@ HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@ HAVE_GETSUBOPT = @HAVE_GETSUBOPT@ HAVE_GETUSERSHELL = @HAVE_GETUSERSHELL@ HAVE_INTTYPES_H = @HAVE_INTTYPES_H@ +HAVE_ISBLANK = @HAVE_ISBLANK@ HAVE_ISNAND = @HAVE_ISNAND@ HAVE_ISNANF = @HAVE_ISNANF@ HAVE_ISNANL = @HAVE_ISNANL@ HAVE_ISWCNTRL = @HAVE_ISWCNTRL@ +HAVE_LANGINFO_CODESET = @HAVE_LANGINFO_CODESET@ +HAVE_LANGINFO_ERA = @HAVE_LANGINFO_ERA@ +HAVE_LANGINFO_H = @HAVE_LANGINFO_H@ HAVE_LCHMOD = @HAVE_LCHMOD@ +HAVE_LCHOWN = @HAVE_LCHOWN@ HAVE_LINK = @HAVE_LINK@ +HAVE_LINKAT = @HAVE_LINKAT@ HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@ HAVE_LSTAT = @HAVE_LSTAT@ HAVE_MALLOC_POSIX = @HAVE_MALLOC_POSIX@ HAVE_MBRLEN = @HAVE_MBRLEN@ HAVE_MBRTOWC = @HAVE_MBRTOWC@ HAVE_MBSINIT = @HAVE_MBSINIT@ +HAVE_MBSLEN = @HAVE_MBSLEN@ HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@ HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@ HAVE_MEMPCPY = @HAVE_MEMPCPY@ HAVE_MKDIRAT = @HAVE_MKDIRAT@ HAVE_MKDTEMP = @HAVE_MKDTEMP@ +HAVE_MKFIFO = @HAVE_MKFIFO@ HAVE_MKFIFOAT = @HAVE_MKFIFOAT@ +HAVE_MKNOD = @HAVE_MKNOD@ HAVE_MKNODAT = @HAVE_MKNODAT@ HAVE_MKOSTEMP = @HAVE_MKOSTEMP@ +HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@ +HAVE_MKSTEMPS = @HAVE_MKSTEMPS@ HAVE_NETDB_H = @HAVE_NETDB_H@ HAVE_NETINET_IN_H = @HAVE_NETINET_IN_H@ +HAVE_NL_LANGINFO = @HAVE_NL_LANGINFO@ HAVE_OPENAT = @HAVE_OPENAT@ HAVE_OS_H = @HAVE_OS_H@ HAVE_PIPE2 = @HAVE_PIPE2@ HAVE_POSIX_SIGNALBLOCKING = @HAVE_POSIX_SIGNALBLOCKING@ +HAVE_PREAD = @HAVE_PREAD@ HAVE_RANDOM_H = @HAVE_RANDOM_H@ HAVE_RANDOM_R = @HAVE_RANDOM_R@ HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@ HAVE_READLINK = @HAVE_READLINK@ HAVE_READLINKAT = @HAVE_READLINKAT@ HAVE_REALLOC_POSIX = @HAVE_REALLOC_POSIX@ +HAVE_REALPATH = @HAVE_REALPATH@ +HAVE_RENAMEAT = @HAVE_RENAMEAT@ HAVE_RPMATCH = @HAVE_RPMATCH@ HAVE_SA_FAMILY_T = @HAVE_SA_FAMILY_T@ HAVE_SCANDIR = @HAVE_SCANDIR@ @@ -649,6 +727,7 @@ HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@ HAVE_STRUCT_SIGACTION_SA_SIGACTION = @HAVE_STRUCT_SIGACTION_SA_SIGACTION@ HAVE_STRUCT_SOCKADDR_STORAGE = @HAVE_STRUCT_SOCKADDR_STORAGE@ HAVE_STRUCT_TIMEVAL = @HAVE_STRUCT_TIMEVAL@ +HAVE_STRUCT_UTSNAME = @HAVE_STRUCT_UTSNAME@ HAVE_STRVERSCMP = @HAVE_STRVERSCMP@ HAVE_SYMLINK = @HAVE_SYMLINK@ HAVE_SYMLINKAT = @HAVE_SYMLINKAT@ @@ -661,11 +740,15 @@ HAVE_SYS_SELECT_H = @HAVE_SYS_SELECT_H@ HAVE_SYS_SOCKET_H = @HAVE_SYS_SOCKET_H@ HAVE_SYS_TIME_H = @HAVE_SYS_TIME_H@ HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@ +HAVE_SYS_UTSNAME_H = @HAVE_SYS_UTSNAME_H@ HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@ +HAVE_UNAME = @HAVE_UNAME@ HAVE_UNISTD_H = @HAVE_UNISTD_H@ HAVE_UNLINKAT = @HAVE_UNLINKAT@ HAVE_UNSETENV = @HAVE_UNSETENV@ HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@ +HAVE_USLEEP = @HAVE_USLEEP@ +HAVE_UTIMENSAT = @HAVE_UTIMENSAT@ HAVE_VASPRINTF = @HAVE_VASPRINTF@ HAVE_VDPRINTF = @HAVE_VDPRINTF@ HAVE_WCHAR_H = @HAVE_WCHAR_H@ @@ -677,12 +760,15 @@ HAVE_WCTYPE_H = @HAVE_WCTYPE_H@ HAVE_WINSOCK2_H = @HAVE_WINSOCK2_H@ HAVE_WINT_T = @HAVE_WINT_T@ HAVE_WS2TCPIP_H = @HAVE_WS2TCPIP_H@ +HAVE_XLOCALE_H = @HAVE_XLOCALE_H@ HAVE__BOOL = @HAVE__BOOL@ HELP2MAN = @HELP2MAN@ HOSTENT_LIB = @HOSTENT_LIB@ ICONV_H = @ICONV_H@ INCLUDE_NEXT = @INCLUDE_NEXT@ INCLUDE_NEXT_AS_FIRST_DIRECTIVE = @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ +INET_NTOP_LIB = @INET_NTOP_LIB@ +INET_PTON_LIB = @INET_PTON_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ @@ -693,17 +779,20 @@ INT32_MAX_LT_INTMAX_MAX = @INT32_MAX_LT_INTMAX_MAX@ INT64_MAX_EQ_LONG_MAX = @INT64_MAX_EQ_LONG_MAX@ INTLLIBS = @INTLLIBS@ INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTTYPES_H = @INTTYPES_H@ KMEM_GROUP = @KMEM_GROUP@ LDFLAGS = @LDFLAGS@ LIBCOREUTILS_LIBDEPS = @LIBCOREUTILS_LIBDEPS@ LIBCOREUTILS_LTLIBDEPS = @LIBCOREUTILS_LTLIBDEPS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ +LIBMULTITHREAD = @LIBMULTITHREAD@ LIBOBJS = @LIBOBJS@ +LIBPTH = @LIBPTH@ +LIBPTH_PREFIX = @LIBPTH_PREFIX@ LIBS = @LIBS@ LIBSOCKET = @LIBSOCKET@ LIBTESTS_LIBDEPS = @LIBTESTS_LIBDEPS@ +LIBTHREAD = @LIBTHREAD@ LIB_ACL = @LIB_ACL@ LIB_CAP = @LIB_CAP@ LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@ @@ -724,7 +813,10 @@ LOCALE_TR_UTF8 = @LOCALE_TR_UTF8@ LOCALE_ZH_CN = @LOCALE_ZH_CN@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ +LTLIBMULTITHREAD = @LTLIBMULTITHREAD@ LTLIBOBJS = @LTLIBOBJS@ +LTLIBPTH = @LTLIBPTH@ +LTLIBTHREAD = @LTLIBTHREAD@ MAKEINFO = @MAKEINFO@ MAN = @MAN@ MKDIR_P = @MKDIR_P@ @@ -736,15 +828,20 @@ NETDB_H = @NETDB_H@ NETINET_IN_H = @NETINET_IN_H@ NEXT_ARPA_INET_H = @NEXT_ARPA_INET_H@ NEXT_AS_FIRST_DIRECTIVE_ARPA_INET_H = @NEXT_AS_FIRST_DIRECTIVE_ARPA_INET_H@ +NEXT_AS_FIRST_DIRECTIVE_CTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_CTYPE_H@ NEXT_AS_FIRST_DIRECTIVE_DIRENT_H = @NEXT_AS_FIRST_DIRECTIVE_DIRENT_H@ NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@ NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@ NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@ +NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@ NEXT_AS_FIRST_DIRECTIVE_ICONV_H = @NEXT_AS_FIRST_DIRECTIVE_ICONV_H@ NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H = @NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H@ +NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H = @NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H@ +NEXT_AS_FIRST_DIRECTIVE_LOCALE_H = @NEXT_AS_FIRST_DIRECTIVE_LOCALE_H@ NEXT_AS_FIRST_DIRECTIVE_MATH_H = @NEXT_AS_FIRST_DIRECTIVE_MATH_H@ NEXT_AS_FIRST_DIRECTIVE_NETDB_H = @NEXT_AS_FIRST_DIRECTIVE_NETDB_H@ NEXT_AS_FIRST_DIRECTIVE_NETINET_IN_H = @NEXT_AS_FIRST_DIRECTIVE_NETINET_IN_H@ +NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H = @NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H@ NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H = @NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H@ NEXT_AS_FIRST_DIRECTIVE_STDARG_H = @NEXT_AS_FIRST_DIRECTIVE_STDARG_H@ NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@ @@ -757,19 +854,25 @@ NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H@ +NEXT_AS_FIRST_DIRECTIVE_SYS_UTSNAME_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_UTSNAME_H@ NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@ NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@ NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@ NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@ +NEXT_CTYPE_H = @NEXT_CTYPE_H@ NEXT_DIRENT_H = @NEXT_DIRENT_H@ NEXT_ERRNO_H = @NEXT_ERRNO_H@ NEXT_FCNTL_H = @NEXT_FCNTL_H@ NEXT_FLOAT_H = @NEXT_FLOAT_H@ +NEXT_GETOPT_H = @NEXT_GETOPT_H@ NEXT_ICONV_H = @NEXT_ICONV_H@ NEXT_INTTYPES_H = @NEXT_INTTYPES_H@ +NEXT_LANGINFO_H = @NEXT_LANGINFO_H@ +NEXT_LOCALE_H = @NEXT_LOCALE_H@ NEXT_MATH_H = @NEXT_MATH_H@ NEXT_NETDB_H = @NEXT_NETDB_H@ NEXT_NETINET_IN_H = @NEXT_NETINET_IN_H@ +NEXT_SELINUX_SELINUX_H = @NEXT_SELINUX_SELINUX_H@ NEXT_SIGNAL_H = @NEXT_SIGNAL_H@ NEXT_STDARG_H = @NEXT_STDARG_H@ NEXT_STDDEF_H = @NEXT_STDDEF_H@ @@ -782,6 +885,7 @@ NEXT_SYS_SELECT_H = @NEXT_SYS_SELECT_H@ NEXT_SYS_SOCKET_H = @NEXT_SYS_SOCKET_H@ NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@ NEXT_SYS_TIME_H = @NEXT_SYS_TIME_H@ +NEXT_SYS_UTSNAME_H = @NEXT_SYS_UTSNAME_H@ NEXT_TIME_H = @NEXT_TIME_H@ NEXT_UNISTD_H = @NEXT_UNISTD_H@ NEXT_WCHAR_H = @NEXT_WCHAR_H@ @@ -809,15 +913,21 @@ PRI_MACROS_BROKEN = @PRI_MACROS_BROKEN@ PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@ RANLIB = @RANLIB@ REPLACE_BTOWC = @REPLACE_BTOWC@ +REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@ REPLACE_CEILF = @REPLACE_CEILF@ REPLACE_CEILL = @REPLACE_CEILL@ REPLACE_CHOWN = @REPLACE_CHOWN@ REPLACE_CLOSE = @REPLACE_CLOSE@ +REPLACE_CLOSEDIR = @REPLACE_CLOSEDIR@ REPLACE_DPRINTF = @REPLACE_DPRINTF@ +REPLACE_DUP = @REPLACE_DUP@ REPLACE_DUP2 = @REPLACE_DUP2@ +REPLACE_DUPLOCALE = @REPLACE_DUPLOCALE@ REPLACE_FCHDIR = @REPLACE_FCHDIR@ REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@ REPLACE_FCLOSE = @REPLACE_FCLOSE@ +REPLACE_FCNTL = @REPLACE_FCNTL@ +REPLACE_FDOPENDIR = @REPLACE_FDOPENDIR@ REPLACE_FFLUSH = @REPLACE_FFLUSH@ REPLACE_FLOORF = @REPLACE_FLOORF@ REPLACE_FLOORL = @REPLACE_FLOORL@ @@ -829,10 +939,13 @@ REPLACE_FREXP = @REPLACE_FREXP@ REPLACE_FREXPL = @REPLACE_FREXPL@ REPLACE_FSEEK = @REPLACE_FSEEK@ REPLACE_FSEEKO = @REPLACE_FSEEKO@ +REPLACE_FSTAT = @REPLACE_FSTAT@ REPLACE_FSTATAT = @REPLACE_FSTATAT@ REPLACE_FTELL = @REPLACE_FTELL@ REPLACE_FTELLO = @REPLACE_FTELLO@ +REPLACE_FUTIMENS = @REPLACE_FUTIMENS@ REPLACE_GETCWD = @REPLACE_GETCWD@ +REPLACE_GETGROUPS = @REPLACE_GETGROUPS@ REPLACE_GETLINE = @REPLACE_GETLINE@ REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@ REPLACE_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@ @@ -847,6 +960,7 @@ REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@ REPLACE_LCHOWN = @REPLACE_LCHOWN@ REPLACE_LDEXPL = @REPLACE_LDEXPL@ REPLACE_LINK = @REPLACE_LINK@ +REPLACE_LINKAT = @REPLACE_LINKAT@ REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@ REPLACE_LSEEK = @REPLACE_LSEEK@ REPLACE_LSTAT = @REPLACE_LSTAT@ @@ -859,26 +973,40 @@ REPLACE_MBSTATE_T = @REPLACE_MBSTATE_T@ REPLACE_MEMCHR = @REPLACE_MEMCHR@ REPLACE_MEMMEM = @REPLACE_MEMMEM@ REPLACE_MKDIR = @REPLACE_MKDIR@ +REPLACE_MKFIFO = @REPLACE_MKFIFO@ +REPLACE_MKNOD = @REPLACE_MKNOD@ REPLACE_MKSTEMP = @REPLACE_MKSTEMP@ REPLACE_MKTIME = @REPLACE_MKTIME@ REPLACE_NAN = @REPLACE_NAN@ REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@ +REPLACE_NL_LANGINFO = @REPLACE_NL_LANGINFO@ REPLACE_NULL = @REPLACE_NULL@ REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@ REPLACE_OPEN = @REPLACE_OPEN@ +REPLACE_OPENAT = @REPLACE_OPENAT@ +REPLACE_OPENDIR = @REPLACE_OPENDIR@ REPLACE_PERROR = @REPLACE_PERROR@ REPLACE_POPEN = @REPLACE_POPEN@ +REPLACE_PREAD = @REPLACE_PREAD@ REPLACE_PRINTF = @REPLACE_PRINTF@ REPLACE_PUTENV = @REPLACE_PUTENV@ +REPLACE_READLINK = @REPLACE_READLINK@ +REPLACE_REALPATH = @REPLACE_REALPATH@ +REPLACE_REMOVE = @REPLACE_REMOVE@ REPLACE_RENAME = @REPLACE_RENAME@ +REPLACE_RENAMEAT = @REPLACE_RENAMEAT@ +REPLACE_RMDIR = @REPLACE_RMDIR@ REPLACE_ROUND = @REPLACE_ROUND@ REPLACE_ROUNDF = @REPLACE_ROUNDF@ REPLACE_ROUNDL = @REPLACE_ROUNDL@ REPLACE_SELECT = @REPLACE_SELECT@ +REPLACE_SETENV = @REPLACE_SETENV@ REPLACE_SIGNBIT = @REPLACE_SIGNBIT@ REPLACE_SIGNBIT_USING_GCC = @REPLACE_SIGNBIT_USING_GCC@ +REPLACE_SLEEP = @REPLACE_SLEEP@ REPLACE_SNPRINTF = @REPLACE_SNPRINTF@ REPLACE_SPRINTF = @REPLACE_SPRINTF@ +REPLACE_STAT = @REPLACE_STAT@ REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@ REPLACE_STRCASESTR = @REPLACE_STRCASESTR@ REPLACE_STRDUP = @REPLACE_STRDUP@ @@ -889,8 +1017,14 @@ REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@ REPLACE_STRSTR = @REPLACE_STRSTR@ REPLACE_STRTOD = @REPLACE_STRTOD@ REPLACE_STRTOK_R = @REPLACE_STRTOK_R@ +REPLACE_SYMLINK = @REPLACE_SYMLINK@ REPLACE_TIMEGM = @REPLACE_TIMEGM@ REPLACE_TRUNCL = @REPLACE_TRUNCL@ +REPLACE_UNLINK = @REPLACE_UNLINK@ +REPLACE_UNLINKAT = @REPLACE_UNLINKAT@ +REPLACE_UNSETENV = @REPLACE_UNSETENV@ +REPLACE_USLEEP = @REPLACE_USLEEP@ +REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@ REPLACE_VASPRINTF = @REPLACE_VASPRINTF@ REPLACE_VDPRINTF = @REPLACE_VDPRINTF@ REPLACE_VFPRINTF = @REPLACE_VFPRINTF@ @@ -904,7 +1038,6 @@ REPLACE_WCTOB = @REPLACE_WCTOB@ REPLACE_WCWIDTH = @REPLACE_WCWIDTH@ REPLACE_WRITE = @REPLACE_WRITE@ SELINUX_CONTEXT_H = @SELINUX_CONTEXT_H@ -SELINUX_SELINUX_H = @SELINUX_SELINUX_H@ SEQ_LIBM = @SEQ_LIBM@ SERVENT_LIB = @SERVENT_LIB@ SET_MAKE = @SET_MAKE@ @@ -916,10 +1049,8 @@ STDBOOL_H = @STDBOOL_H@ STDDEF_H = @STDDEF_H@ STDINT_H = @STDINT_H@ STRIP = @STRIP@ -SYS_IOCTL_H = @SYS_IOCTL_H@ SYS_IOCTL_H_HAVE_WINSOCK2_H = @SYS_IOCTL_H_HAVE_WINSOCK2_H@ SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ -SYS_SELECT_H = @SYS_SELECT_H@ SYS_SOCKET_H = @SYS_SOCKET_H@ SYS_TIME_H = @SYS_TIME_H@ SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ @@ -933,9 +1064,7 @@ UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOC USE_ACL = @USE_ACL@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ -VOID_UNSETENV = @VOID_UNSETENV@ WARN_CFLAGS = @WARN_CFLAGS@ -WCHAR_H = @WCHAR_H@ WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@ WCTYPE_H = @WCTYPE_H@ WERROR_CFLAGS = @WERROR_CFLAGS@ @@ -945,6 +1074,7 @@ XGETTEXT_015 = @XGETTEXT_015@ XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ YACC = @YACC@ YFLAGS = @YFLAGS@ +YIELD_LIB = @YIELD_LIB@ abs_aux_dir = @abs_aux_dir@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ @@ -1018,8 +1148,10 @@ MAINTAINERCLEANFILES = constants.texi _W = (^|[^A-Za-z0-9_]) W_ = ([^A-Za-z0-9_]|$$) syntax_checks = \ + sc-avoid-builtin \ sc-avoid-io \ sc-avoid-non-zero \ + sc-avoid-path \ sc-avoid-timezone \ sc-avoid-zeroes \ sc-exponent-grouping \ @@ -1078,7 +1210,7 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__aclocal_m4_deps): .texi.info: - restore=: && backupdir="$(am__leading_dot)am$$$$" && \ + $(AM_V_MAKEINFO)restore=: && backupdir="$(am__leading_dot)am$$$$" && \ am__cwd=`pwd` && $(am__cd) $(srcdir) && \ rm -rf $$backupdir && mkdir $$backupdir && \ if ($(MAKEINFO) --version) >/dev/null 2>&1; then \ @@ -1100,18 +1232,18 @@ $(am__aclocal_m4_deps): rm -rf $$backupdir; exit $$rc .texi.dvi: - TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ + $(AM_V_TEXI2DVI)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \ - $(TEXI2DVI) $< + $(TEXI2DVI) $(AM_V_texinfo) $< $(AM_V_texidevnull) .texi.pdf: - TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ + $(AM_V_TEXI2PDF)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \ - $(TEXI2PDF) $< + $(TEXI2PDF) $(AM_V_texinfo) $< $(AM_V_texidevnull) .texi.html: - rm -rf $(@:.html=.htp) - if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \ + $(AM_V_MAKEINFO)rm -rf $(@:.html=.htp) + $(AM_V_at)if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \ -o $(@:.html=.htp) $<; \ then \ rm -rf $@; \ @@ -1146,8 +1278,8 @@ mostlyclean-vti: maintainer-clean-vti: -rm -f $(srcdir)/stamp-vti $(srcdir)/version.texi .dvi.ps: - TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ - $(DVIPS) -o $@ $< + $(AM_V_DVIPS)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ + $(DVIPS) $(AM_V_texinfo) -o $@ $< uninstall-dvi-am: @$(NORMAL_UNINSTALL) @@ -1249,6 +1381,8 @@ TAGS: ctags: CTAGS CTAGS: +cscope cscopelist: + distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ @@ -1478,13 +1612,12 @@ uninstall-am: uninstall-dvi-am uninstall-html-am uninstall-info-am \ constants.texi: $(top_srcdir)/src/tail.c $(top_srcdir)/src/shred.c - LC_ALL=C \ - sed -n -e 's/^#define \(DEFAULT_MAX[_A-Z]*\) \(.*\)/@set \1 \2/p' \ - $(top_srcdir)/src/tail.c > t-$@ - LC_ALL=C \ - sed -n -e 's/.*\(DEFAULT_PASSES\)[ =]* \([0-9]*\).*/@set SHRED_\1 \2/p'\ - $(top_srcdir)/src/shred.c >> t-$@ - mv t-$@ $@ + $(AM_V_GEN)LC_ALL=C; export LC_ALL; \ + { sed -n -e 's/^#define \(DEFAULT_MAX[_A-Z]*\) \(.*\)/@set \1 \2/p' \ + $(top_srcdir)/src/tail.c && \ + sed -n -e 's/.*\(DEFAULT_PASSES\)[ =]* \([0-9]*\).*/@set SHRED_\1 \2/p'\ + $(top_srcdir)/src/shred.c; } > t-$@ \ + && mv t-$@ $@ $(DVIS): $(EXTRA_DIST) $(INFO_DEPS): $(EXTRA_DIST) @@ -1503,9 +1636,18 @@ check-texinfo: $(syntax_checks) $(PERL) -e 1 2> /dev/null && { $(PERL) -ne \ '/\bPOSIX\b/ && !/\@acronym{POSIX}/ && !/^\* / || /{posix}/ and print,exit 1' \ $(srcdir)/*.texi 2> /dev/null || fail=1; }; \ - $(EGREP) -i '$(_W)builtins?$(W_)' $(srcdir)/*.texi && fail=1; \ + exit $$fail + +sc-avoid-builtin: + $(AM_V_GEN)$(EGREP) -i '$(_W)builtins?$(W_)' $(srcdir)/*.texi \ + && exit 1 || : + +sc-avoid-path: + $(AM_V_GEN)fail=0; \ $(EGREP) -i '$(_W)path(name)?s?$(W_)' $(srcdir)/*.texi \ - | $(EGREP) -v 'search path|@vindex PATH$$|@env[{]PATH[}]' && fail=1; \ + | $(EGREP) -v \ + 'PATH=|path search|search path|@vindex PATH$$|@env[{]PATH[}]' \ + && fail=1; \ exit $$fail # Use `time zone', not `timezone'. diff --git a/src/bin/coreutils/doc/coreutils.info b/src/bin/coreutils/doc/coreutils.info index 708729178c..7dd58db42c 100644 --- a/src/bin/coreutils/doc/coreutils.info +++ b/src/bin/coreutils/doc/coreutils.info @@ -56,10 +56,12 @@ START-INFO-DIR-ENTRY * mkdir: (coreutils)mkdir invocation. Create directories. * mkfifo: (coreutils)mkfifo invocation. Create FIFOs (named pipes). * mknod: (coreutils)mknod invocation. Create special files. +* mktemp: (coreutils)mktemp invocation. Create temporary files. * mv: (coreutils)mv invocation. Rename files. * nice: (coreutils)nice invocation. Modify niceness. * nl: (coreutils)nl invocation. Number lines and write files. * nohup: (coreutils)nohup invocation. Immunize to hangups. +* nproc: (coreutils)nproc invocation. Print the number of processors. * od: (coreutils)od invocation. Dump files in octal, etc. * paste: (coreutils)paste invocation. Merge lines of files. * pathchk: (coreutils)pathchk invocation. Check file name portability. @@ -110,10 +112,10 @@ START-INFO-DIR-ENTRY * yes: (coreutils)yes invocation. Print a string indefinitely. END-INFO-DIR-ENTRY - This manual documents version 7.6 of the GNU core utilities, + This manual documents version 8.4 of the GNU core utilities, including the standard programs for text and file manipulation. - Copyright (C) 1994-1996, 2000-2009 Free Software Foundation, Inc. + Copyright (C) 1994-1996, 2000-2010 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, @@ -128,10 +130,10 @@ File: coreutils.info, Node: Top, Next: Introduction, Up: (dir) GNU Coreutils ************* -This manual documents version 7.6 of the GNU core utilities, including +This manual documents version 8.4 of the GNU core utilities, including the standard programs for text and file manipulation. - Copyright (C) 1994-1996, 2000-2009 Free Software Foundation, Inc. + Copyright (C) 1994-1996, 2000-2010 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, @@ -142,197 +144,197 @@ the standard programs for text and file manipulation. * Menu: -* Introduction:: Caveats, overview, and authors. -* Common options:: Common options. -* Output of entire files:: cat tac nl od -* Formatting file contents:: fmt pr fold -* Output of parts of files:: head tail split csplit -* Summarizing files:: wc sum cksum md5sum sha1sum sha2 -* Operating on sorted files:: sort shuf uniq comm ptx tsort -* Operating on fields within a line:: cut paste join -* Operating on characters:: tr expand unexpand -* Directory listing:: ls dir vdir dircolors -* Basic operations:: cp dd install mv rm shred -* Special file types:: ln mkdir rmdir mkfifo mknod -* Changing file attributes:: chgrp chmod chown touch -* Disk usage:: df du stat sync truncate -* Printing text:: echo printf yes -* Conditions:: false true test expr -* Redirection:: tee -* File name manipulation:: dirname basename pathchk -* Working context:: pwd stty printenv tty -* User information:: id logname whoami groups users who -* System context:: date uname hostname hostid uptime -* SELinux context:: chcon runcon -* Modified command invocation:: chroot env nice nohup stdbuf su timeout -* Process control:: kill -* Delaying:: sleep -* Numeric operations:: factor seq -* File permissions:: Access modes. -* Date input formats:: Specifying date strings. -* Opening the software toolbox:: The software tools philosophy. -* GNU Free Documentation License:: Copying and sharing this manual. -* Concept index:: General index. +* Introduction:: Caveats, overview, and authors +* Common options:: Common options +* Output of entire files:: cat tac nl od base64 +* Formatting file contents:: fmt pr fold +* Output of parts of files:: head tail split csplit +* Summarizing files:: wc sum cksum md5sum sha1sum sha2 +* Operating on sorted files:: sort shuf uniq comm ptx tsort +* Operating on fields:: cut paste join +* Operating on characters:: tr expand unexpand +* Directory listing:: ls dir vdir dircolors +* Basic operations:: cp dd install mv rm shred +* Special file types:: mkdir rmdir unlink mkfifo mknod ln link readlink +* Changing file attributes:: chgrp chmod chown touch +* Disk usage:: df du stat sync truncate +* Printing text:: echo printf yes +* Conditions:: false true test expr +* Redirection:: tee +* File name manipulation:: dirname basename pathchk mktemp +* Working context:: pwd stty printenv tty +* User information:: id logname whoami groups users who +* System context:: date arch uname hostname hostid uptime +* SELinux context:: chcon runcon +* Modified command invocation:: chroot env nice nohup stdbuf su timeout +* Process control:: kill +* Delaying:: sleep +* Numeric operations:: factor seq +* File permissions:: Access modes +* Date input formats:: Specifying date strings +* Opening the software toolbox:: The software tools philosophy +* GNU Free Documentation License:: Copying and sharing this manual +* Concept index:: General index --- The Detailed Node Listing --- Common Options -* Exit status:: Indicating program success or failure. -* Backup options:: Backup options -* Block size:: Block size -* Signal specifications:: Specifying signals +* Exit status:: Indicating program success or failure +* Backup options:: Backup options +* Block size:: Block size +* Signal specifications:: Specifying signals * Disambiguating names and IDs:: chgrp and chown owner and group syntax -* Random sources:: Sources of random data -* Target directory:: Target directory -* Trailing slashes:: Trailing slashes -* Traversing symlinks:: Traversing symlinks to directories -* Treating / specially:: Treating / specially -* Standards conformance:: Standards conformance +* Random sources:: Sources of random data +* Target directory:: Target directory +* Trailing slashes:: Trailing slashes +* Traversing symlinks:: Traversing symlinks to directories +* Treating / specially:: Treating / specially +* Standards conformance:: Standards conformance Output of entire files -* cat invocation:: Concatenate and write files. -* tac invocation:: Concatenate and write files in reverse. -* nl invocation:: Number lines and write files. -* od invocation:: Write files in octal or other formats. -* base64 invocation:: Transform data into printable data. +* cat invocation:: Concatenate and write files +* tac invocation:: Concatenate and write files in reverse +* nl invocation:: Number lines and write files +* od invocation:: Write files in octal or other formats +* base64 invocation:: Transform data into printable data Formatting file contents -* fmt invocation:: Reformat paragraph text. -* pr invocation:: Paginate or columnate files for printing. -* fold invocation:: Wrap input lines to fit in specified width. +* fmt invocation:: Reformat paragraph text +* pr invocation:: Paginate or columnate files for printing +* fold invocation:: Wrap input lines to fit in specified width Output of parts of files -* head invocation:: Output the first part of files. -* tail invocation:: Output the last part of files. -* split invocation:: Split a file into fixed-size pieces. -* csplit invocation:: Split a file into context-determined pieces. +* head invocation:: Output the first part of files +* tail invocation:: Output the last part of files +* split invocation:: Split a file into fixed-size pieces +* csplit invocation:: Split a file into context-determined pieces Summarizing files -* wc invocation:: Print newline, word, and byte counts. -* sum invocation:: Print checksum and block counts. -* cksum invocation:: Print CRC checksum and byte counts. -* md5sum invocation:: Print or check MD5 digests. -* sha1sum invocation:: Print or check SHA-1 digests. -* sha2 utilities:: Print or check SHA-2 digests. +* wc invocation:: Print newline, word, and byte counts +* sum invocation:: Print checksum and block counts +* cksum invocation:: Print CRC checksum and byte counts +* md5sum invocation:: Print or check MD5 digests +* sha1sum invocation:: Print or check SHA-1 digests +* sha2 utilities:: Print or check SHA-2 digests Operating on sorted files -* sort invocation:: Sort text files. -* shuf invocation:: Shuffle text files. -* uniq invocation:: Uniquify files. -* comm invocation:: Compare two sorted files line by line. -* ptx invocation:: Produce a permuted index of file contents. -* tsort invocation:: Topological sort. +* sort invocation:: Sort text files +* shuf invocation:: Shuffle text files +* uniq invocation:: Uniquify files +* comm invocation:: Compare two sorted files line by line +* ptx invocation:: Produce a permuted index of file contents +* tsort invocation:: Topological sort `ptx': Produce permuted indexes -* General options in ptx:: Options which affect general program behavior. -* Charset selection in ptx:: Underlying character set considerations. -* Input processing in ptx:: Input fields, contexts, and keyword selection. -* Output formatting in ptx:: Types of output format, and sizing the fields. -* Compatibility in ptx:: The GNU extensions to `ptx' +* General options in ptx:: Options which affect general program behavior +* Charset selection in ptx:: Underlying character set considerations +* Input processing in ptx:: Input fields, contexts, and keyword selection +* Output formatting in ptx:: Types of output format, and sizing the fields +* Compatibility in ptx:: The GNU extensions to `ptx' -Operating on fields within a line +Operating on fields -* cut invocation:: Print selected parts of lines. -* paste invocation:: Merge lines of files. -* join invocation:: Join lines on a common field. +* cut invocation:: Print selected parts of lines +* paste invocation:: Merge lines of files +* join invocation:: Join lines on a common field Operating on characters -* tr invocation:: Translate, squeeze, and/or delete characters. -* expand invocation:: Convert tabs to spaces. -* unexpand invocation:: Convert spaces to tabs. +* tr invocation:: Translate, squeeze, and/or delete characters +* expand invocation:: Convert tabs to spaces +* unexpand invocation:: Convert spaces to tabs `tr': Translate, squeeze, and/or delete characters -* Character sets:: Specifying sets of characters. -* Translating:: Changing one set of characters to another. -* Squeezing:: Squeezing repeats and deleting. +* Character sets:: Specifying sets of characters +* Translating:: Changing one set of characters to another +* Squeezing:: Squeezing repeats and deleting Directory listing -* ls invocation:: List directory contents -* dir invocation:: Briefly list directory contents -* vdir invocation:: Verbosely list directory contents -* dircolors invocation:: Color setup for `ls' +* ls invocation:: List directory contents +* dir invocation:: Briefly list directory contents +* vdir invocation:: Verbosely list directory contents +* dircolors invocation:: Color setup for `ls' `ls': List directory contents -* Which files are listed:: Which files are listed -* What information is listed:: What information is listed -* Sorting the output:: Sorting the output -* More details about version sort:: More details about version sort -* General output formatting:: General output formatting -* Formatting the file names:: Formatting the file names +* Which files are listed:: Which files are listed +* What information is listed:: What information is listed +* Sorting the output:: Sorting the output +* Details about version sort:: More details about version sort +* General output formatting:: General output formatting +* Formatting the file names:: Formatting the file names Basic operations -* cp invocation:: Copy files and directories -* dd invocation:: Convert and copy a file -* install invocation:: Copy files and set attributes -* mv invocation:: Move (rename) files -* rm invocation:: Remove files or directories -* shred invocation:: Remove files more securely +* cp invocation:: Copy files and directories +* dd invocation:: Convert and copy a file +* install invocation:: Copy files and set attributes +* mv invocation:: Move (rename) files +* rm invocation:: Remove files or directories +* shred invocation:: Remove files more securely Special file types -* link invocation:: Make a hard link via the link syscall -* ln invocation:: Make links between files -* mkdir invocation:: Make directories -* mkfifo invocation:: Make FIFOs (named pipes) -* mknod invocation:: Make block or character special files -* readlink invocation:: Print value of a symlink or canonical file name -* rmdir invocation:: Remove empty directories -* unlink invocation:: Remove files via unlink syscall +* link invocation:: Make a hard link via the link syscall +* ln invocation:: Make links between files +* mkdir invocation:: Make directories +* mkfifo invocation:: Make FIFOs (named pipes) +* mknod invocation:: Make block or character special files +* readlink invocation:: Print value of a symlink or canonical file name +* rmdir invocation:: Remove empty directories +* unlink invocation:: Remove files via unlink syscall Changing file attributes -* chown invocation:: Change file owner and group -* chgrp invocation:: Change group ownership -* chmod invocation:: Change access permissions -* touch invocation:: Change file timestamps +* chown invocation:: Change file owner and group +* chgrp invocation:: Change group ownership +* chmod invocation:: Change access permissions +* touch invocation:: Change file timestamps Disk usage -* df invocation:: Report file system disk space usage -* du invocation:: Estimate file space usage -* stat invocation:: Report file or file system status -* sync invocation:: Synchronize data on disk with memory -* truncate invocation:: Shrink or extend the size of a file +* df invocation:: Report file system disk space usage +* du invocation:: Estimate file space usage +* stat invocation:: Report file or file system status +* sync invocation:: Synchronize data on disk with memory +* truncate invocation:: Shrink or extend the size of a file Printing text -* echo invocation:: Print a line of text -* printf invocation:: Format and print data -* yes invocation:: Print a string until interrupted +* echo invocation:: Print a line of text +* printf invocation:: Format and print data +* yes invocation:: Print a string until interrupted Conditions -* false invocation:: Do nothing, unsuccessfully -* true invocation:: Do nothing, successfully -* test invocation:: Check file types and compare values -* expr invocation:: Evaluate expressions +* false invocation:: Do nothing, unsuccessfully +* true invocation:: Do nothing, successfully +* test invocation:: Check file types and compare values +* expr invocation:: Evaluate expressions `test': Check file types and compare values -* File type tests:: File type tests -* Access permission tests:: Access permission tests -* File characteristic tests:: File characteristic tests -* String tests:: String tests -* Numeric tests:: Numeric tests +* File type tests:: File type tests +* Access permission tests:: Access permission tests +* File characteristic tests:: File characteristic tests +* String tests:: String tests +* Numeric tests:: Numeric tests `expr': Evaluate expression -* String expressions:: + : match substr index length -* Numeric expressions:: + - * / % -* Relations for expr:: | & < <= = == != >= > -* Examples of expr:: Examples of using `expr' +* String expressions:: + : match substr index length +* Numeric expressions:: + - * / % +* Relations for expr:: | & < <= = == != >= > +* Examples of expr:: Examples of using `expr' Redirection @@ -343,6 +345,7 @@ File name manipulation * basename invocation:: Strip directory and suffix from a file name * dirname invocation:: Strip non-directory suffix from a file name * pathchk invocation:: Check file name validity and portability +* mktemp invocation:: Create temporary file or directory Working context @@ -353,13 +356,13 @@ Working context `stty': Print or change terminal characteristics -* Control:: Control settings -* Input:: Input settings -* Output:: Output settings -* Local:: Local settings -* Combination:: Combination settings -* Characters:: Special characters -* Special:: Special settings +* Control:: Control settings +* Input:: Input settings +* Output:: Output settings +* Local:: Local settings +* Combination:: Combination settings +* Characters:: Special characters +* Special:: Special settings User information @@ -374,6 +377,7 @@ System context * arch invocation:: Print machine hardware name * date invocation:: Print or set system date and time +* nproc invocation:: Print the number of processors * uname invocation:: Print system information * hostname invocation:: Print or set system name * hostid invocation:: Print numeric host identifier @@ -385,10 +389,10 @@ System context * Date conversion specifiers:: %[aAbBcCdDeFgGhjmuUVwWxyY] * Literal conversion specifiers:: %[%nt] * Padding and other flags:: Pad with zeros, spaces, etc. -* Setting the time:: Changing the system clock. -* Options for date:: Instead of the current time. -* Date input formats:: Specifying date strings. -* Examples of date:: Examples. +* Setting the time:: Changing the system clock +* Options for date:: Instead of the current time +* Date input formats:: Specifying date strings +* Examples of date:: Examples SELinux context @@ -420,23 +424,23 @@ Numeric operations File permissions -* Mode Structure:: Structure of file mode bits. -* Symbolic Modes:: Mnemonic representation of file mode bits. -* Numeric Modes:: File mode bits as octal numbers. -* Directory Setuid and Setgid:: Set-user-ID and set-group-ID on directories. +* Mode Structure:: Structure of file mode bits +* Symbolic Modes:: Mnemonic representation of file mode bits +* Numeric Modes:: File mode bits as octal numbers +* Directory Setuid and Setgid:: Set-user-ID and set-group-ID on directories Date input formats -* General date syntax:: Common rules. -* Calendar date items:: 19 Dec 1994. -* Time of day items:: 9:20pm. -* Time zone items:: EST, PDT, GMT. -* Day of week items:: Monday and others. -* Relative items in date strings:: next tuesday, 2 years ago. -* Pure numbers in date strings:: 19931219, 1440. -* Seconds since the Epoch:: @1078100502. -* Specifying time zone rules:: TZ="America/New_York", TZ="UTC0". -* Authors of get_date:: Bellovin, Eggert, Salz, Berets, et al. +* General date syntax:: Common rules +* Calendar date items:: 19 Dec 1994 +* Time of day items:: 9:20pm +* Time zone items:: EST, PDT, GMT +* Day of week items:: Monday and others +* Relative items in date strings:: next tuesday, 2 years ago +* Pure numbers in date strings:: 19931219, 1440 +* Seconds since the Epoch:: @1078100502 +* Specifying time zone rules:: TZ="America/New_York", TZ="UTC0" +* Authors of get_date:: Bellovin, Eggert, Salz, Berets, et al Opening the software toolbox @@ -450,7 +454,7 @@ Opening the software toolbox Copying This Manual -* GNU Free Documentation License:: Copying and sharing this manual. +* GNU Free Documentation License:: Copying and sharing this manual  File: coreutils.info, Node: Introduction, Next: Common options, Prev: Top, Up: Top @@ -569,7 +573,8 @@ unusual platforms as POSIX requires only that it be nonzero. However, some of the programs documented here do produce other exit status values and a few associate different meanings with the values `0' and `1'. Here are some of the exceptions: `chroot', `env', `expr', -`nice', `nohup', `printenv', `sort', `su', `test', `timeout', `tty'. +`nice', `nohup', `printenv', `sort', `stdbuf', `su', `test', `timeout', +`tty'.  File: coreutils.info, Node: Backup options, Next: Block size, Prev: Exit status, Up: Common options @@ -2233,9 +2238,10 @@ options::. use `--follow=descriptor'. This is the default behavior, but it is not useful if you're tracking a log file that may be rotated (removed or renamed, then reopened). In that case, use - `--follow=name' to track the named file by reopening it + `--follow=name' to track the named file, perhaps by reopening it periodically to see if it has been removed and recreated by some - other program. + other program. Note that the inotify-based implementation handles + this case without the need for any periodic reopening. No matter which method you use, if the tracked file is determined to have shrunk, `tail' prints a message saying the file has been @@ -2882,7 +2888,7 @@ options of these commands are precisely the same as for `md5sum'. compute, especially on 32-bit computers, than SHA224 or SHA256.  -File: coreutils.info, Node: Operating on sorted files, Next: Operating on fields within a line, Prev: Summarizing files, Up: Top +File: coreutils.info, Node: Operating on sorted files, Next: Operating on fields, Prev: Summarizing files, Up: Top 7 Operating on sorted files *************************** @@ -3074,9 +3080,9 @@ scripts should specify global options first. `-V' `--version-sort' - Sort per `strverscmp(3)'. This is a normal string comparison, - except that embedded decimal numbers are sorted by numeric value - (see `--numeric-sort' above). + Sort by version name and number. It behaves like a standard sort, + except that each sequence of decimal digits is treated numerically + as an index/version number. (*Note Details about version sort::.) `-r' `--reverse' @@ -4269,10 +4275,10 @@ the way the linker handled archive files, which has since been solved in different ways.  -File: coreutils.info, Node: Operating on fields within a line, Next: Operating on characters, Prev: Operating on sorted files, Up: Top +File: coreutils.info, Node: Operating on fields, Next: Operating on characters, Prev: Operating on sorted files, Up: Top -8 Operating on fields within a line -*********************************** +8 Operating on fields +********************* * Menu: @@ -4281,7 +4287,7 @@ File: coreutils.info, Node: Operating on fields within a line, Next: Operating * join invocation:: Join lines on a common field.  -File: coreutils.info, Node: cut invocation, Next: paste invocation, Up: Operating on fields within a line +File: coreutils.info, Node: cut invocation, Next: paste invocation, Up: Operating on fields 8.1 `cut': Print selected parts of lines ======================================== @@ -4363,7 +4369,7 @@ options::. indicates failure.  -File: coreutils.info, Node: paste invocation, Next: join invocation, Prev: cut invocation, Up: Operating on fields within a line +File: coreutils.info, Node: paste invocation, Next: join invocation, Prev: cut invocation, Up: Operating on fields 8.2 `paste': Merge lines of files ================================= @@ -4419,7 +4425,7 @@ options::. indicates failure.  -File: coreutils.info, Node: join invocation, Prev: paste invocation, Up: Operating on fields within a line +File: coreutils.info, Node: join invocation, Prev: paste invocation, Up: Operating on fields 8.3 `join': Join lines on a common field ======================================== @@ -4558,7 +4564,7 @@ options::. indicates failure.  -File: coreutils.info, Node: Operating on characters, Next: Directory listing, Prev: Operating on fields within a line, Up: Top +File: coreutils.info, Node: Operating on characters, Next: Directory listing, Prev: Operating on fields, Up: Top 9 Operating on characters ************************* @@ -5030,8 +5036,9 @@ options affect more than one aspect of `ls''s operation. 1 minor problems (e.g., failure to access a file or directory not specified as a command line argument. This happens when listing a directory in which entries are actively being removed or renamed.) - 2 serious trouble (e.g., memory exhausted, invalid option or failure - to access file or directory specified as a command line argument) + 2 serious trouble (e.g., memory exhausted, invalid option, failure + to access a file or directory specified as a command line argument + or a directory loop) Also see *note Common options::. @@ -5040,7 +5047,7 @@ options affect more than one aspect of `ls''s operation. * Which files are listed:: * What information is listed:: * Sorting the output:: -* More details about version sort:: +* Details about version sort:: * General output formatting:: * Formatting file timestamps:: * Formatting the file names:: @@ -5420,7 +5427,7 @@ only file names are shown.  -File: coreutils.info, Node: Sorting the output, Next: More details about version sort, Prev: What information is listed, Up: ls invocation +File: coreutils.info, Node: Sorting the output, Next: Details about version sort, Prev: What information is listed, Up: ls invocation 10.1.3 Sorting the output ------------------------- @@ -5477,8 +5484,8 @@ order). `--sort=version' Sort by version name and number, lowest first. It behaves like a default sort, except that each sequence of decimal digits is - treated numerically as an index/version number. (*Note More - details about version sort::.) + treated numerically as an index/version number. (*Note Details + about version sort::.) `-X' `--sort=extension' @@ -5488,26 +5495,22 @@ order).  -File: coreutils.info, Node: More details about version sort, Next: General output formatting, Prev: Sorting the output, Up: ls invocation +File: coreutils.info, Node: Details about version sort, Next: General output formatting, Prev: Sorting the output, Up: ls invocation -10.1.4 More details about version sort --------------------------------------- +10.1.4 Details about version sort +--------------------------------- -The version sort takes into account the fact that file names frequently -include indices or version numbers. Standard sorting functions usually -do not produce the ordering that people expect because comparisons are -made on a character-by-character basis. The version sort addresses -this problem, and is especially useful when browsing directories that -contain many files with indices/version numbers in their names: +Version sorting handles the fact that file names frequently include +indices or version numbers. Standard sorting usually does not produce +the order that one expects because comparisons are made on a +character-by-character basis. Version sorting is especially useful +when browsing directories that contain many files with indices/version +numbers in their names: $ ls -1 $ ls -1v - foo.zml-1.gz foo.zml-1.gz - foo.zml-100.gz foo.zml-2.gz - foo.zml-12.gz foo.zml-6.gz - foo.zml-13.gz foo.zml-12.gz - foo.zml-2.gz foo.zml-13.gz - foo.zml-25.gz foo.zml-25.gz - foo.zml-6.gz foo.zml-100.gz + abc.zml-1.gz abc.zml-1.gz + abc.zml-12.gz abc.zml-2.gz + abc.zml-2.gz abc.zml-12.gz Version-sorted strings are compared such that if VER1 and VER2 are version numbers and PREFIX and SUFFIX (SUFFIX matching the regular @@ -5523,12 +5526,24 @@ implies that the name composed of "PREFIX VER1 SUFFIX" sorts before abc-1.01a.tgz abc-1.012b.tgz This functionality is implemented using gnulib's `filevercmp' -function. One result of that implementation decision is that `ls -v' -and `sort -V' do not use the locale category, `LC_COLLATE', which means -non-numeric prefixes are sorted as if `LC_COLLATE' were set to `C'. +function, which has some caveats worth noting. + + * `LC_COLLATE' is ignored, which means `ls -v' and `sort -V' will + sort non-numeric prefixes as if the `LC_COLLATE' locale category + was set to `C'. + + * Some suffixes will not be matched by the regular expression + mentioned above. Consequently these examples may not sort as you + expect: + + abc-1.2.3.4.7z + abc-1.2.3.7z + + abc-1.2.3.4.x86_64.rpm + abc-1.2.3.x86_64.rpm  -File: coreutils.info, Node: General output formatting, Next: Formatting file timestamps, Prev: More details about version sort, Up: ls invocation +File: coreutils.info, Node: General output formatting, Next: Formatting file timestamps, Prev: Details about version sort, Up: ls invocation 10.1.5 General output formatting -------------------------------- @@ -7170,6 +7185,11 @@ nonexistent entry in an existing directory. `link' simply calls `link and `--no-target-directory' options are not specified by POSIX, and the `link' command is more portable in practice. + If FILENAME is a symbolic link, it is unspecified whether LINKNAME +will be a hard link to the symbolic link or to the target of the +symbolic link. Use `ln -P' or `ln -L' to specify which behavior is +desired. + An exit status of zero indicates success, and a nonzero value indicates failure. @@ -7209,9 +7229,11 @@ option to rename them. original are indistinguishable. Technically speaking, they share the same inode, and the inode contains all the information about a file--indeed, it is not incorrect to say that the inode _is_ the file. -On all existing implementations, you cannot make a hard link to a -directory, and hard links cannot cross file system boundaries. (These -restrictions are not mandated by POSIX, however.) +Most systems prohibit making a hard link to a directory; on those where +it is allowed, only the super-user can do so (and with caution, since +creating a cycle will cause problems to many other utilities). Hard +links cannot cross file system boundaries. (These restrictions are not +mandated by POSIX, however.) "Symbolic links" ("symlinks" for short), on the other hand, are a special file type (which not all kernels support: System V release 3 @@ -7220,9 +7242,14 @@ refers to a different file, by name. When most operations (opening, reading, writing, and so on) are passed the symbolic link file, the kernel automatically "dereferences" the link and operates on the target of the link. But some operations (e.g., removing) work on the link -file itself, rather than on its target. The owner, group, and mode of -a symlink are not significant to file access performed through the -link. *Note Symbolic Links: (libc)Symbolic Links. +file itself, rather than on its target. The owner and group of a +symlink are not significant to file access performed through the link, +but do have implications on deleting a symbolic link from a directory +with the restricted deletion bit set. On the GNU system, the mode of a +symlink has no significance and cannot be changed, but on some BSD +systems, the mode can be changed and will affect whether the symlink +will be traversed in file name resolution. *Note Symbolic Links: +(libc)Symbolic Links. Symbolic links can contain arbitrary strings; a "dangling symlink" occurs when the string in the symlink does not resolve to a file. @@ -7268,6 +7295,12 @@ options::. `--interactive' Prompt whether to remove existing destination files. +`-L' +`--logical' + If `-s' is not in effect, and the source file is a symbolic link, + create the hard link to the file referred to by the symbolic link, + rather than the symbolic link itself. + `-n' `--no-dereference' Do not treat the last operand specially when it is a symbolic link @@ -7287,6 +7320,15 @@ options::. This option is weaker than the `--no-target-directory' (`-T') option, so it has no effect if both options are given. +`-P' +`--physical' + If `-s' is not in effect, and the source file is a symbolic link, + create the hard link to the symbolic link itself. On platforms + where this is not supported by the kernel, this option creates a + symbolic link with identical contents; since symbolic link contents + cannot be edited, any file name resolution performed through either + link will be the same as if a hard link had been created. + `-s' `--symbolic' Make symbolic links instead of hard links. This option merely @@ -7312,6 +7354,12 @@ options::. Print the name of each file after linking it successfully. + If `-L' and `-P' are both given, the last one takes precedence. If +`-s' is also given, `-L' and `-P' are silently ignored. If neither +option is given, then this implementation defaults to `-P' if the +system `link' supports hard links to symbolic links (such as the GNU +system), and `-L' if `link' follows symbolic links (such as on BSD). + An exit status of zero indicates success, and a nonzero value indicates failure. @@ -7531,13 +7579,15 @@ options::. `--canonicalize' Activate canonicalize mode. If any component of the file name except the last one is missing or unavailable, `readlink' produces - no output and exits with a nonzero exit code. + no output and exits with a nonzero exit code. A trailing slash is + ignored. `-e' `--canonicalize-existing' Activate canonicalize mode. If any component is missing or unavailable, `readlink' produces no output and exits with a - nonzero exit code. + nonzero exit code. A trailing slash requires that the name + resolve to a directory. `-m' `--canonicalize-missing' @@ -8005,7 +8055,8 @@ files. Synopsis: touch [OPTION]... FILE... - Any FILE argument that does not exist is created empty. + Any FILE argument that does not exist is created empty, unless +option `--no-create' (`-c') or `--no-dereference' (`-h') was in effect. A FILE argument string of `-' is handled specially and causes `touch' to change the times of the file associated with standard output. @@ -8017,19 +8068,21 @@ own the files. Although `touch' provides options for changing two of the times--the times of last access and modification--of a file, there is actually a -third one as well: the inode change time. This is often referred to as -a file's `ctime'. The inode change time represents the time when the -file's meta-information last changed. One common example of this is -when the permissions of a file change. Changing the permissions -doesn't access the file, so the atime doesn't change, nor does it -modify the file, so the mtime doesn't change. Yet, something about the -file itself has changed, and this must be noted somewhere. This is the -job of the ctime field. This is necessary, so that, for example, a -backup program can make a fresh copy of the file, including the new -permissions value. Another operation that modifies a file's ctime -without affecting the others is renaming. In any case, it is not +standard third one as well: the inode change time. This is often +referred to as a file's `ctime'. The inode change time represents the +time when the file's meta-information last changed. One common example +of this is when the permissions of a file change. Changing the +permissions doesn't access the file, so the atime doesn't change, nor +does it modify the file, so the mtime doesn't change. Yet, something +about the file itself has changed, and this must be noted somewhere. +This is the job of the ctime field. This is necessary, so that, for +example, a backup program can make a fresh copy of the file, including +the new permissions value. Another operation that modifies a file's +ctime without affecting the others is renaming. In any case, it is not possible, in normal operations, for a user to change the ctime field to -a user-specified value. +a user-specified value. Some operating systems and file systems +support a fourth time: the birth time, when the file was first created; +by definition, this timestamp never changes. Time stamps assume the time zone rules specified by the `TZ' environment variable, or by the system default rules if `TZ' is not @@ -8048,7 +8101,7 @@ options::. `-c' `--no-create' - Do not create files that do not exist. + Do not warn about or create files that do not exist. `-d' `--date=TIME' @@ -8064,6 +8117,20 @@ options::. `-f' Ignored; for compatibility with BSD versions of `touch'. +`-h' +`--no-dereference' + Attempt to change the timestamps of a symbolic link, rather than + what the link refers to. When using this option, empty files are + not created, but option `-c' must also be used to avoid warning + about files that do not exist. Not all systems support changing + the timestamps of symlinks, since underlying system support for + this action was not required until POSIX 2008. Also, on some + systems, the mere act of examining a symbolic link changes the + access time, such that only changes to the modification time will + persist long enough to be observable. When coupled with option + `-r', a reference timestamp is taken from a symbolic link rather + than the file it refers to. + `-m' `--time=mtime' `--time=modify' @@ -8076,7 +8143,9 @@ options::. option, the reference FILE's time is the origin for any relative TIMEs given, but is otherwise ignored. For example, `-r foo -d '-5 seconds'' specifies a time stamp equal to five seconds before - the corresponding time stamp for `foo'. + the corresponding time stamp for `foo'. If FILE is a symbolic + link, the reference timestamp is taken from the target of the + symlink, unless `-h' was also in effect. `-t [[CC]YY]MMDDHHMM[.SS]' Use the argument (optional four-digit or two-digit years, months, @@ -8084,7 +8153,8 @@ options::. time. If the year is specified with only two digits, then CC is 20 for years in the range 0 ... 68, and 19 for years in 69 ... 99. If no digits of the year are specified, the argument is - interpreted as a date in the current year. + interpreted as a date in the current year. Note that SS may be + `60', to accommodate leap seconds. On older systems, `touch' supports an obsolete syntax, as follows. @@ -8403,7 +8473,7 @@ options::. `--null' Output a zero byte (ASCII NUL) at the end of each line, rather than a newline. This option enables other programs to parse the - output of `du' even when that output would contain file names with + output of `du' even when that output would contain data with embedded newlines. `--si' @@ -8782,6 +8852,9 @@ STRING. `\c' produce no further output + `\e' + escape + `\f' form feed @@ -9621,6 +9694,7 @@ This section describes commands that manipulate file names. * basename invocation:: Strip directory and suffix from a file name. * dirname invocation:: Strip non-directory suffix from a file name. * pathchk invocation:: Check file name validity and portability. +* mktemp invocation:: Create temporary file or directory.  File: coreutils.info, Node: basename invocation, Next: dirname invocation, Up: File name manipulation @@ -9700,7 +9774,7 @@ indicates failure. dirname stdio.h  -File: coreutils.info, Node: pathchk invocation, Prev: dirname invocation, Up: File name manipulation +File: coreutils.info, Node: pathchk invocation, Next: mktemp invocation, Prev: dirname invocation, Up: File name manipulation 18.3 `pathchk': Check file name validity and portability ======================================================== @@ -9754,6 +9828,141 @@ options::. Options must precede operands. 0 if all specified file names passed all checks, 1 otherwise. + +File: coreutils.info, Node: mktemp invocation, Prev: pathchk invocation, Up: File name manipulation + +18.4 `mktemp': Create temporary file or directory +================================================= + +`mktemp' manages the creation of temporary files and directories. +Synopsis: + + mktemp [OPTION]... [TEMPLATE] + + Safely create a temporary file or directory based on TEMPLATE, and +print its name. If given, TEMPLATE must include at least three +consecutive `X's in the last component. If omitted, the template +`tmp.XXXXXXXXXX' is used, and option `--tmpdir' is implied. The final +run of `X's in the TEMPLATE will be replaced by alpha-numeric +characters; thus, on a case-sensitive file system, and with a TEMPLATE +including a run of N instances of `X', there are `62**N' potential file +names. + + Older scripts used to create temporary files by simply joining the +name of the program with the process id (`$$') as a suffix. However, +that naming scheme is easily predictable, and suffers from a race +condition where the attacker can create an appropriately named symbolic +link, such that when the script then opens a handle to what it thought +was an unused file, it is instead modifying an existing file. Using +the same scheme to create a directory is slightly safer, since the +`mkdir' will fail if the target already exists, but it is still +inferior because it allows for denial of service attacks. Therefore, +modern scripts should use the `mktemp' command to guarantee that the +generated name will be unpredictable, and that knowledge of the +temporary file name implies that the file was created by the current +script and cannot be modified by other users. + + When creating a file, the resulting file has read and write +permissions for the current user, but no permissions for the group or +others; these permissions are reduced if the current umask is more +restrictive. + + Here are some examples (although note that if you repeat them, you +will most likely get different file names): + + * Create a temporary file in the current directory. + $ mktemp file.XXXX + file.H47c + + * Create a temporary file with a known suffix. + $ mktemp --suffix=.txt file-XXXX + file-H08W.txt + $ mktemp file-XXXX-XXXX.txt + file-XXXX-eI9L.txt + + * Create a secure fifo relative to the user's choice of `TMPDIR', + but falling back to the current directory rather than `/tmp'. + Note that `mktemp' does not create fifos, but can create a secure + directory in which the fifo can live. Exit the shell if the + directory or fifo could not be created. + $ dir=$(mktemp -p "${TMPDIR:-.}" -d dir-XXXX) || exit 1 + $ fifo=$dir/fifo + $ mkfifo "$fifo" || { rmdir "$dir"; exit 1; } + + * Create and use a temporary file if possible, but ignore failure. + The file will reside in the directory named by `TMPDIR', if + specified, or else in `/tmp'. + $ file=$(mktemp -q) && { + > # Safe to use $file only within this block. Use quotes, + > # since $TMPDIR, and thus $file, may contain whitespace. + > echo ... > "$file" + > rm "$file" + > } + + * Act as a semi-random character generator (it is not fully random, + since it is impacted by the contents of the current directory). To + avoid security holes, do not use the resulting names to create a + file. + $ mktemp -u XXX + Gb9 + $ mktemp -u XXX + nzC + + + The program accepts the following options. Also see *note Common +options::. + +`-d' +`--directory' + Create a directory rather than a file. The directory will have + read, write, and search permissions for the current user, but no + permissions for the group or others; these permissions are reduced + if the current umask is more restrictive. + +`-q' +`--quiet' + Suppress diagnostics about failure to create a file or directory. + The exit status will still reflect whether a file was created. + +`-u' +`--dry-run' + Generate a temporary name that does not name an existing file, + without changing the file system contents. Using the output of + this command to create a new file is inherently unsafe, as there + is a window of time between generating the name and using it where + another process can create an object by the same name. + +`-p DIR' +`--tmpdir[=DIR]' + Treat TEMPLATE relative to the directory DIR. If DIR is not + specified (only possible with the long option `--tmpdir') or is + the empty string, use the value of `TMPDIR' if available, + otherwise use `/tmp'. If this is specified, TEMPLATE must not be + absolute. However, TEMPLATE can still contain slashes, although + intermediate directories must already exist. + +`--suffix=SUFFIX' + Append SUFFIX to the TEMPLATE. SUFFIX must not contain slash. If + `--suffix' is specified, TEMPLATE must end in `X'; if it is not + specified, then an appropriate `--suffix' is inferred by finding + the last `X' in TEMPLATE. This option exists for use with the + default TEMPLATE and for the creation of a SUFFIX that starts with + `X'. + +`-t' + Treat TEMPLATE as a single file relative to the value of `TMPDIR' + if available, or to the directory specified by `-p', otherwise to + `/tmp'. TEMPLATE must not contain slashes. This option is + deprecated; the use of `-p' without `-t' offers better defaults + (by favoring the command line over `TMPDIR') and more flexibility + (by allowing intermediate directories). + + + Exit status: + + 0 if the file was created, + 1 otherwise. +  File: coreutils.info, Node: Working context, Next: User information, Prev: File name manipulation, Up: Top @@ -10317,9 +10526,17 @@ File: coreutils.info, Node: printenv invocation, Next: tty invocation, Prev: environment variable. Otherwise, it prints the value of each VARIABLE that is set, and nothing for those that are not set. - The only options are a lone `--help' or `--version'. *Note Common + The program accepts the following option. Also see *note Common options::. +`-0' +`--null' + Output a zero byte (ASCII NUL) at the end of each line, rather + than a newline. This option enables other programs to parse the + output of `printenv' even when that output would contain data with + embedded newlines. + + Exit status: 0 if all variables specified were found @@ -10385,7 +10602,10 @@ if no user is specified. Synopsis: By default, it prints the real user ID, real group ID, effective user ID if different from the real user ID, effective group ID if -different from the real group ID, and supplemental group IDs. +different from the real group ID, and supplemental group IDs. In +addition, if SELinux is enabled and the `POSIXLY_CORRECT' environment +variable is not set, then print `context=C', where C is the security +context. Each of these numeric values is preceded by an identifying string and followed by the corresponding user or group name in parentheses. @@ -10636,6 +10856,7 @@ information. * date invocation:: Print or set system date and time. * arch invocation:: Print machine hardware name. +* nproc invocation:: Print the number of processors. * uname invocation:: Print system information. * hostname invocation:: Print or set system name. * hostid invocation:: Print numeric host identifier. @@ -11187,7 +11408,7 @@ option in the previous section.  -File: coreutils.info, Node: arch invocation, Next: uname invocation, Prev: date invocation, Up: System context +File: coreutils.info, Node: arch invocation, Next: nproc invocation, Prev: date invocation, Up: System context 21.2 `arch': Print machine hardware name ======================================== @@ -11203,9 +11424,40 @@ File: coreutils.info, Node: arch invocation, Next: uname invocation, Prev: da indicates failure.  -File: coreutils.info, Node: uname invocation, Next: hostname invocation, Prev: arch invocation, Up: System context +File: coreutils.info, Node: nproc invocation, Next: uname invocation, Prev: arch invocation, Up: System context -21.3 `uname': Print system information +21.3 `nproc': Print the number of available processors +====================================================== + +Print the number of processing units available to the current process, +which may be less than the number of online processors. If this +information is not accessible, then print the number of processors +installed. If the `OMP_NUM_THREADS' environment variable is set, then +it will determine the returned value. The result is guaranteed to be +greater than zero. Synopsis: + + nproc [OPTION] + + The program accepts the following options. Also see *note Common +options::. + +`--all' + Print the number of installed processors on the system, which may + be greater than the number online or available to the current + process. The `OMP_NUM_THREADS' environment variable is not + honored in this case. + +`--ignore=NUMBER' + If possible, exclude this NUMBER of processing units. + + + An exit status of zero indicates success, and a nonzero value +indicates failure. + + +File: coreutils.info, Node: uname invocation, Next: hostname invocation, Prev: nproc invocation, Up: System context + +21.4 `uname': Print system information ====================================== `uname' prints information about the machine and operating system it is @@ -11287,7 +11539,7 @@ indicates failure.  File: coreutils.info, Node: hostname invocation, Next: hostid invocation, Prev: uname invocation, Up: System context -21.4 `hostname': Print or set system name +21.5 `hostname': Print or set system name ========================================= With no arguments, `hostname' prints the name of the current host @@ -11306,7 +11558,7 @@ indicates failure.  File: coreutils.info, Node: hostid invocation, Next: uptime invocation, Prev: hostname invocation, Up: System context -21.5 `hostid': Print numeric host identifier +21.6 `hostid': Print numeric host identifier ============================================ `hostid' prints the numeric identifier of the current host in @@ -11327,7 +11579,7 @@ indicates failure.  File: coreutils.info, Node: uptime invocation, Prev: hostid invocation, Up: System context -21.6 `uptime': Print system uptime and load +21.7 `uptime': Print system uptime and load =========================================== `uptime' prints the current time, the system's uptime, the number of @@ -11566,7 +11818,7 @@ device files), copy them into place, too. Exit status: - 1 if `chroot' itself fails + 125 if `chroot' itself fails 126 if COMMAND is found but cannot be invoked 127 if COMMAND cannot be found the exit status of COMMAND otherwise @@ -11608,13 +11860,65 @@ environment variable. Any remaining arguments are passed as arguments to that program. The program should not be a special built-in utility (*note Special built-in utilities::). + Modifications to `PATH' take effect prior to searching for COMMAND. +Use caution when reducing `PATH'; behavior is not portable when `PATH' +is undefined or omits key directories such as `/bin'. + + In the rare case that a utility contains a `=' in the name, the only +way to disambiguate it from a variable assignment is to use an +intermediate command for COMMAND, and pass the problematic program name +via ARGS. For example, if `./prog=' is an executable in the current +`PATH': + + env prog= true # runs 'true', with prog= in environment + env ./prog= true # runs 'true', with ./prog= in environment + env -- prog= true # runs 'true', with prog= in environment + env sh -c '\prog= true' # runs 'prog=' with argument 'true' + env sh -c 'exec "$@"' sh prog= true # also runs 'prog=' + If no command name is specified following the environment specifications, the resulting environment is printed. This is like specifying the `printenv' program. + For some examples, suppose the environment passed to `env' contains +`LOGNAME=rms', `EDITOR=emacs', and `PATH=.:/gnubin:/hacks': + + * Output the current environment. + $ env | LC_ALL=C sort + EDITOR=emacs + LOGNAME=rms + PATH=.:/gnubin:/hacks + + * Run `foo' with a reduced environment, preserving only the original + `PATH' to avoid problems in locating `foo'. + env - PATH="$PATH" foo + + * Run `foo' with the environment containing `LOGNAME=rms', + `EDITOR=emacs', and `PATH=.:/gnubin:/hacks', and guarantees that + `foo' was found in the file system rather than as a shell built-in. + env foo + + * Run `nemacs' with the environment containing `LOGNAME=foo', + `EDITOR=emacs', `PATH=.:/gnubin:/hacks', and `DISPLAY=gnu:0'. + env DISPLAY=gnu:0 LOGNAME=foo nemacs + + * Attempt to run the program `/energy/--' (as that is the only + possible path search result); if the command exists, the + environment will contain `LOGNAME=rms' and `PATH=/energy', and the + arguments will be `e=mc2', `bar', and `baz'. + env -u EDITOR PATH=/energy -- e=mc2 bar baz + + The program accepts the following options. Also see *note Common options::. Options must precede operands. +`-0' +`--null' + Output a zero byte (ASCII NUL) at the end of each line, rather + than a newline. This option enables other programs to parse the + output of `env' even when that output would contain data with + embedded newlines. + `-u NAME' `--unset=NAME' Remove variable NAME from the environment, if it was in the @@ -11630,7 +11934,7 @@ options::. Options must precede operands. Exit status: 0 if no COMMAND is specified and the environment is output - 1 if `env' itself fails + 125 if `env' itself fails 126 if COMMAND is found but cannot be invoked 127 if COMMAND cannot be found the exit status of COMMAND otherwise @@ -11694,7 +11998,7 @@ options::. Options must precede operands. Exit status: 0 if no COMMAND is specified and the niceness is output - 1 if `nice' itself fails + 125 if `nice' itself fails 126 if COMMAND is found but cannot be invoked 127 if COMMAND cannot be found the exit status of COMMAND otherwise @@ -11786,10 +12090,14 @@ options::. Options must precede operands. Exit status: + 125 if `nohup' itself fails, and `POSIXLY_CORRECT' is not set 126 if COMMAND is found but cannot be invoked - 127 if `nohup' itself fails or if COMMAND cannot be found + 127 if COMMAND cannot be found the exit status of COMMAND otherwise + If `POSIXLY_CORRECT' is set, internal failures give status 127 +instead of 125. +  File: coreutils.info, Node: stdbuf invocation, Next: su invocation, Prev: nohup invocation, Up: Modified command invocation @@ -11940,7 +12248,7 @@ options::. Exit status: - 1 if `su' itself fails + 125 if `su' itself fails 126 if subshell is found but cannot be invoked 127 if subshell cannot be found the exit status of the subshell otherwise @@ -14320,7 +14628,7 @@ Index * +: String expressions. (line 53) * +PAGE_RANGE: pr invocation. (line 58) * - <1>: su invocation. (line 53) -* - <2>: env invocation. (line 44) +* - <2>: env invocation. (line 96) * -: Numeric expressions. (line 12) * - and Unix rm: rm invocation. (line 110) * -, removing files beginning with: rm invocation. (line 98) @@ -14329,11 +14637,12 @@ Index * --address-radix: od invocation. (line 36) * --adjustment: nice invocation. (line 47) * --all <1>: uname invocation. (line 30) -* --all <2>: who invocation. (line 36) -* --all <3>: stty invocation. (line 26) -* --all <4>: du invocation. (line 26) -* --all <5>: df invocation. (line 32) -* --all <6>: Which files are listed. +* --all <2>: nproc invocation. (line 19) +* --all <3>: who invocation. (line 36) +* --all <4>: stty invocation. (line 26) +* --all <5>: du invocation. (line 26) +* --all <6>: df invocation. (line 32) +* --all <7>: Which files are listed. (line 13) * --all: unexpand invocation. (line 37) * --all-repeated: uniq invocation. (line 69) @@ -14344,7 +14653,7 @@ Index * --archive: cp invocation. (line 65) * --author: What information is listed. (line 10) -* --backup <1>: ln invocation. (line 77) +* --backup <1>: ln invocation. (line 84) * --backup <2>: mv invocation. (line 56) * --backup <3>: install invocation. (line 42) * --backup <4>: cp invocation. (line 75) @@ -14371,8 +14680,8 @@ Index * --c-shell: dircolors invocation. (line 40) * --canonicalize: readlink invocation. (line 29) -* --canonicalize-existing: readlink invocation. (line 35) -* --canonicalize-missing: readlink invocation. (line 41) +* --canonicalize-existing: readlink invocation. (line 36) +* --canonicalize-missing: readlink invocation. (line 43) * --changes <1>: chmod invocation. (line 39) * --changes <2>: chgrp invocation. (line 20) * --changes: chown invocation. (line 70) @@ -14389,7 +14698,7 @@ Index * --compare: install invocation. (line 47) * --complement: cut invocation. (line 71) * --compute: runcon invocation. (line 27) -* --context <1>: id invocation. (line 45) +* --context <1>: id invocation. (line 48) * --context <2>: mknod invocation. (line 54) * --context <3>: mkfifo invocation. (line 28) * --context <4>: mkdir invocation. (line 56) @@ -14403,7 +14712,7 @@ Index * --csh: dircolors invocation. (line 40) * --date <1>: Options for date. (line 11) -* --date: touch invocation. (line 58) +* --date: touch invocation. (line 61) * --dead: who invocation. (line 44) * --decode: base64 invocation. (line 30) * --delimiter: cut invocation. (line 51) @@ -14422,13 +14731,15 @@ Index (line 41) * --dictionary-order: sort invocation. (line 87) * --digits: csplit invocation. (line 80) -* --directory <1>: ln invocation. (line 83) -* --directory <2>: install invocation. (line 62) +* --directory <1>: mktemp invocation. (line 86) +* --directory <2>: ln invocation. (line 90) +* --directory <3>: install invocation. (line 62) * --directory: Which files are listed. (line 28) * --dired: What information is listed. (line 16) * --double-space: pr invocation. (line 94) +* --dry-run: mktemp invocation. (line 98) * --echo: shuf invocation. (line 19) * --elide-empty-files: csplit invocation. (line 89) * --error: stdbuf invocation. (line 27) @@ -14453,7 +14764,7 @@ Index * --first-line-number: pr invocation. (line 194) * --follow: tail invocation. (line 48) * --footer-numbering: nl invocation. (line 75) -* --force <1>: ln invocation. (line 89) +* --force <1>: ln invocation. (line 96) * --force <2>: shred invocation. (line 101) * --force <3>: rm invocation. (line 35) * --force <4>: mv invocation. (line 61) @@ -14470,12 +14781,12 @@ Index * --full-time: What information is listed. (line 100) * --general-numeric-sort: sort invocation. (line 105) -* --group <1>: id invocation. (line 23) +* --group <1>: id invocation. (line 26) * --group: install invocation. (line 68) * --group-directories-first: Which files are listed. (line 50) * --groups <1>: chroot invocation. (line 29) -* --groups: id invocation. (line 27) +* --groups: id invocation. (line 30) * --hardware-platform: uname invocation. (line 35) * --head-count: shuf invocation. (line 32) * --header: pr invocation. (line 131) @@ -14492,12 +14803,13 @@ Index * --human-readable <3>: What information is listed. (line 116) * --human-readable: Block size. (line 138) +* --ignore: nproc invocation. (line 25) * --ignore-backups: Which files are listed. (line 23) * --ignore-case <1>: join invocation. (line 89) * --ignore-case <2>: uniq invocation. (line 59) * --ignore-case: sort invocation. (line 94) -* --ignore-environment: env invocation. (line 44) +* --ignore-environment: env invocation. (line 96) * --ignore-fail-on-non-empty: rmdir invocation. (line 17) * --ignore-garbage: base64 invocation. (line 36) * --ignore-interrupts: tee invocation. (line 30) @@ -14514,7 +14826,7 @@ Index * --inodes: df invocation. (line 58) * --input: stdbuf invocation. (line 19) * --input-range: shuf invocation. (line 23) -* --interactive <1>: ln invocation. (line 93) +* --interactive <1>: ln invocation. (line 100) * --interactive <2>: rm invocation. (line 50) * --interactive <3>: mv invocation. (line 67) * --interactive: cp invocation. (line 133) @@ -14532,20 +14844,21 @@ Index * --line-increment: nl invocation. (line 83) * --lines <1>: wc invocation. (line 55) * --lines <2>: split invocation. (line 26) -* --lines <3>: tail invocation. (line 139) +* --lines <3>: tail invocation. (line 140) * --lines: head invocation. (line 39) * --link: cp invocation. (line 139) * --literal: Formatting the file names. (line 17) * --local: df invocation. (line 69) -* --logical: pwd invocation. (line 15) +* --logical <1>: pwd invocation. (line 15) +* --logical: ln invocation. (line 104) * --login <1>: su invocation. (line 53) * --login: who invocation. (line 52) * --lookup: who invocation. (line 57) * --machine: uname invocation. (line 41) * --max-depth=DEPTH: du invocation. (line 116) * --max-line-length: wc invocation. (line 59) -* --max-unchanged-stats: tail invocation. (line 127) +* --max-unchanged-stats: tail invocation. (line 128) * --merge <1>: sort invocation. (line 32) * --merge: pr invocation. (line 160) * --mesg: who invocation. (line 95) @@ -14555,33 +14868,36 @@ Index * --mode <3>: mkdir invocation. (line 19) * --mode: install invocation. (line 74) * --month-sort: sort invocation. (line 149) -* --name: id invocation. (line 31) +* --name: id invocation. (line 34) * --no-clobber <1>: mv invocation. (line 74) * --no-clobber: cp invocation. (line 150) * --no-create <1>: truncate invocation. (line 22) -* --no-create: touch invocation. (line 54) +* --no-create: touch invocation. (line 57) * --no-dereference <1>: chcon invocation. (line 22) * --no-dereference <2>: du invocation. (line 112) -* --no-dereference <3>: chgrp invocation. (line 35) -* --no-dereference <4>: chown invocation. (line 108) -* --no-dereference <5>: ln invocation. (line 97) +* --no-dereference <3>: touch invocation. (line 75) +* --no-dereference <4>: chgrp invocation. (line 35) +* --no-dereference <5>: chown invocation. (line 108) +* --no-dereference <6>: ln invocation. (line 110) * --no-dereference: cp invocation. (line 156) * --no-file-warnings: pr invocation. (line 207) * --no-group: What information is listed. (line 110) -* --no-newline: readlink invocation. (line 46) +* --no-newline: readlink invocation. (line 48) * --no-preserve-root <1>: chmod invocation. (line 54) * --no-preserve-root <2>: chgrp invocation. (line 48) * --no-preserve-root <3>: chown invocation. (line 121) * --no-preserve-root: rm invocation. (line 84) * --no-renumber: nl invocation. (line 108) * --no-sync: df invocation. (line 73) -* --no-target-directory <1>: ln invocation. (line 131) +* --no-target-directory <1>: ln invocation. (line 153) * --no-target-directory <2>: mv invocation. (line 107) * --no-target-directory <3>: install invocation. (line 124) * --no-target-directory <4>: cp invocation. (line 340) * --no-target-directory: Target directory. (line 15) * --nodename: uname invocation. (line 46) +* --null <1>: env invocation. (line 83) +* --null <2>: printenv invocation. (line 19) * --null: du invocation. (line 122) * --number: cat invocation. (line 31) * --number-format: nl invocation. (line 95) @@ -14612,8 +14928,9 @@ Index * --parents <1>: rmdir invocation. (line 22) * --parents <2>: mkdir invocation. (line 34) * --parents: cp invocation. (line 235) -* --physical: pwd invocation. (line 22) -* --pid: tail invocation. (line 107) +* --physical <1>: pwd invocation. (line 22) +* --physical: ln invocation. (line 129) +* --pid: tail invocation. (line 108) * --portability <1>: pathchk invocation. (line 46) * --portability: df invocation. (line 80) * --prefix: csplit invocation. (line 62) @@ -14632,13 +14949,14 @@ Index * --process: who invocation. (line 66) * --processor: uname invocation. (line 50) * --quiet <1>: tty invocation. (line 18) -* --quiet <2>: chmod invocation. (line 45) -* --quiet <3>: chgrp invocation. (line 26) -* --quiet <4>: chown invocation. (line 76) -* --quiet <5>: readlink invocation. (line 52) -* --quiet <6>: md5sum invocation. (line 69) -* --quiet <7>: csplit invocation. (line 100) -* --quiet <8>: tail invocation. (line 147) +* --quiet <2>: mktemp invocation. (line 93) +* --quiet <3>: chmod invocation. (line 45) +* --quiet <4>: chgrp invocation. (line 26) +* --quiet <5>: chown invocation. (line 76) +* --quiet <6>: readlink invocation. (line 54) +* --quiet <7>: md5sum invocation. (line 69) +* --quiet <8>: csplit invocation. (line 100) +* --quiet <9>: tail invocation. (line 148) * --quiet: head invocation. (line 46) * --quote-name: Formatting the file names. (line 30) @@ -14651,7 +14969,7 @@ Index * --range <1>: runcon invocation. (line 43) * --range: chcon invocation. (line 63) * --read-bytes: od invocation. (line 71) -* --real: id invocation. (line 36) +* --real: id invocation. (line 39) * --recursive <1>: chcon invocation. (line 30) * --recursive <2>: chmod invocation. (line 69) * --recursive <3>: chgrp invocation. (line 66) @@ -14663,7 +14981,7 @@ Index * --reference <1>: chcon invocation. (line 25) * --reference <2>: Options for date. (line 34) * --reference <3>: truncate invocation. (line 30) -* --reference <4>: touch invocation. (line 77) +* --reference <4>: touch invocation. (line 94) * --reference <5>: chmod invocation. (line 62) * --reference <6>: chgrp invocation. (line 52) * --reference: chown invocation. (line 125) @@ -14672,7 +14990,7 @@ Index * --remove: shred invocation. (line 123) * --remove-destination: cp invocation. (line 280) * --repeated: uniq invocation. (line 63) -* --retry: tail invocation. (line 93) +* --retry: tail invocation. (line 94) * --reverse <1>: Sorting the output. (line 27) * --reverse: sort invocation. (line 182) * --rfc-2822: Options for date. (line 40) @@ -14710,9 +15028,9 @@ Index * --silent <2>: chmod invocation. (line 45) * --silent <3>: chgrp invocation. (line 26) * --silent <4>: chown invocation. (line 76) -* --silent <5>: readlink invocation. (line 52) +* --silent <5>: readlink invocation. (line 54) * --silent <6>: csplit invocation. (line 100) -* --silent <7>: tail invocation. (line 147) +* --silent <7>: tail invocation. (line 148) * --silent: head invocation. (line 46) * --size <1>: truncate invocation. (line 34) * --size: What information is listed. @@ -14721,7 +15039,7 @@ Index * --skip-bytes: od invocation. (line 55) * --skip-chars: uniq invocation. (line 41) * --skip-fields: uniq invocation. (line 31) -* --sleep-interval: tail invocation. (line 99) +* --sleep-interval: tail invocation. (line 100) * --sort <1>: Sorting the output. (line 32) * --sort: sort invocation. (line 105) * --spaces: fold invocation. (line 29) @@ -14736,15 +15054,16 @@ Index * --strip-program: install invocation. (line 111) * --strip-trailing-slashes <1>: mv invocation. (line 93) * --strip-trailing-slashes: cp invocation. (line 318) -* --suffix <1>: ln invocation. (line 122) -* --suffix <2>: mv invocation. (line 98) -* --suffix <3>: install invocation. (line 115) -* --suffix <4>: cp invocation. (line 331) -* --suffix <5>: csplit invocation. (line 66) +* --suffix <1>: mktemp invocation. (line 114) +* --suffix <2>: ln invocation. (line 144) +* --suffix <3>: mv invocation. (line 98) +* --suffix <4>: install invocation. (line 115) +* --suffix <5>: cp invocation. (line 331) +* --suffix <6>: csplit invocation. (line 66) * --suffix: Backup options. (line 50) * --suffix-length: split invocation. (line 54) * --summarize: du invocation. (line 136) -* --symbolic: ln invocation. (line 116) +* --symbolic: ln invocation. (line 138) * --symbolic-link: cp invocation. (line 323) * --sync: df invocation. (line 106) * --sysv: sum invocation. (line 31) @@ -14753,7 +15072,7 @@ Index * --tabsize: General output formatting. (line 92) * --tagged-paragraph: fmt invocation. (line 40) -* --target-directory <1>: ln invocation. (line 127) +* --target-directory <1>: ln invocation. (line 149) * --target-directory <2>: mv invocation. (line 103) * --target-directory <3>: install invocation. (line 120) * --target-directory <4>: cp invocation. (line 336) @@ -14763,11 +15082,12 @@ Index * --text: md5sum invocation. (line 87) * --time <1>: who invocation. (line 83) * --time <2>: du invocation. (line 148) -* --time <3>: touch invocation. (line 50) +* --time <3>: touch invocation. (line 53) * --time: Sorting the output. (line 13) * --time-style <1>: du invocation. (line 163) * --time-style: Formatting file timestamps. (line 26) +* --tmpdir: mktemp invocation. (line 106) * --total <1>: du invocation. (line 55) * --total: df invocation. (line 42) * --traditional: od invocation. (line 206) @@ -14778,12 +15098,12 @@ Index * --unique <1>: uniq invocation. (line 101) * --unique: sort invocation. (line 345) * --universal: Options for date. (line 87) -* --unset: env invocation. (line 38) +* --unset: env invocation. (line 90) * --update <1>: mv invocation. (line 80) * --update: cp invocation. (line 345) * --user <1>: runcon invocation. (line 31) * --user <2>: chcon invocation. (line 51) -* --user: id invocation. (line 41) +* --user: id invocation. (line 44) * --userspec: chroot invocation. (line 24) * --utc: Options for date. (line 87) * --verbose <1>: chcon invocation. (line 47) @@ -14791,16 +15111,16 @@ Index * --verbose <3>: chgrp invocation. (line 58) * --verbose <4>: chown invocation. (line 132) * --verbose <5>: rmdir invocation. (line 31) -* --verbose <6>: readlink invocation. (line 56) +* --verbose <6>: readlink invocation. (line 58) * --verbose <7>: mkdir invocation. (line 51) -* --verbose <8>: ln invocation. (line 136) +* --verbose <8>: ln invocation. (line 158) * --verbose <9>: shred invocation. (line 129) * --verbose <10>: rm invocation. (line 95) * --verbose <11>: mv invocation. (line 90) * --verbose <12>: install invocation. (line 129) * --verbose <13>: cp invocation. (line 355) * --verbose <14>: split invocation. (line 61) -* --verbose <15>: tail invocation. (line 151) +* --verbose <15>: tail invocation. (line 152) * --verbose: head invocation. (line 50) * --version: Common options. (line 41) * --version-sort: sort invocation. (line 176) @@ -14818,6 +15138,8 @@ Index * --zero-terminated <1>: uniq invocation. (line 112) * --zero-terminated <2>: shuf invocation. (line 48) * --zero-terminated: sort invocation. (line 359) +* -0 <1>: env invocation. (line 82) +* -0 <2>: printenv invocation. (line 18) * -0: du invocation. (line 121) * -1 <1>: General output formatting. (line 10) @@ -14834,7 +15156,7 @@ Index (line 12) * -a <6>: du invocation. (line 26) * -a <7>: df invocation. (line 32) -* -a <8>: touch invocation. (line 50) +* -a <8>: touch invocation. (line 53) * -a: cp invocation. (line 65) * -A: Which files are listed. (line 17) @@ -14852,7 +15174,7 @@ Index * -B: du invocation. (line 50) * -b: du invocation. (line 46) * -B: df invocation. (line 38) -* -b <1>: ln invocation. (line 77) +* -b <1>: ln invocation. (line 84) * -b <2>: mv invocation. (line 56) * -b <3>: install invocation. (line 42) * -b <4>: cp invocation. (line 75) @@ -14879,7 +15201,7 @@ Index * -c <4>: truncate invocation. (line 22) * -c <5>: stat invocation. (line 33) * -c <6>: du invocation. (line 55) -* -c <7>: touch invocation. (line 54) +* -c <7>: touch invocation. (line 57) * -c <8>: chmod invocation. (line 39) * -c <9>: chgrp invocation. (line 20) * -c <10>: chown invocation. (line 70) @@ -14904,10 +15226,11 @@ Index * -COLUMN: pr invocation. (line 68) * -d <1>: Options for date. (line 11) * -d <2>: who invocation. (line 44) +* -d <3>: mktemp invocation. (line 86) * -d: File type tests. (line 16) * -D: du invocation. (line 61) -* -d <1>: touch invocation. (line 58) -* -d <2>: ln invocation. (line 83) +* -d <1>: touch invocation. (line 61) +* -d <2>: ln invocation. (line 90) * -d: install invocation. (line 62) * -D: install invocation. (line 56) * -d: cp invocation. (line 103) @@ -14928,9 +15251,9 @@ Index * -e <1>: stdbuf invocation. (line 27) * -e: File characteristic tests. (line 9) -* -E: echo invocation. (line 68) +* -E: echo invocation. (line 71) * -e <1>: echo invocation. (line 25) -* -e <2>: readlink invocation. (line 35) +* -e <2>: readlink invocation. (line 36) * -e <3>: join invocation. (line 84) * -e: pr invocation. (line 118) * -E: cat invocation. (line 27) @@ -14943,13 +15266,13 @@ Index * -F: stty invocation. (line 31) * -f <1>: File type tests. (line 19) * -f <2>: stat invocation. (line 28) -* -f <3>: touch invocation. (line 68) +* -f <3>: touch invocation. (line 71) * -f <4>: chmod invocation. (line 45) * -f <5>: chgrp invocation. (line 26) * -f <6>: chown invocation. (line 76) * -f <7>: readlink invocation. (line 29) -* -f: ln invocation. (line 89) -* -F: ln invocation. (line 83) +* -f: ln invocation. (line 96) +* -F: ln invocation. (line 90) * -f <1>: shred invocation. (line 101) * -f <2>: rm invocation. (line 35) * -f <3>: mv invocation. (line 61) @@ -14961,15 +15284,15 @@ Index * -f <3>: uniq invocation. (line 31) * -f <4>: sort invocation. (line 94) * -f: csplit invocation. (line 62) -* -F: tail invocation. (line 88) +* -F: tail invocation. (line 89) * -f <1>: tail invocation. (line 48) * -f: pr invocation. (line 126) * -F: pr invocation. (line 126) * -f <1>: od invocation. (line 188) * -f: nl invocation. (line 75) * -f FORMAT: seq invocation. (line 24) -* -G: id invocation. (line 27) -* -g <1>: id invocation. (line 23) +* -G: id invocation. (line 30) +* -g <1>: id invocation. (line 26) * -g: stty invocation. (line 41) * -G: Access permission tests. (line 31) @@ -14990,7 +15313,8 @@ Index * -H: du invocation. (line 87) * -h: du invocation. (line 81) * -H: df invocation. (line 54) -* -h: df invocation. (line 48) +* -h <1>: df invocation. (line 48) +* -h: touch invocation. (line 75) * -H: chgrp invocation. (line 70) * -h: chgrp invocation. (line 35) * -H: chown invocation. (line 143) @@ -15006,11 +15330,11 @@ Index * -H: Traversing symlinks. (line 18) * -h: Block size. (line 138) * -i <1>: stdbuf invocation. (line 19) -* -i <2>: env invocation. (line 44) +* -i <2>: env invocation. (line 96) * -i <3>: uname invocation. (line 35) * -i <4>: tee invocation. (line 30) * -i <5>: df invocation. (line 58) -* -i: ln invocation. (line 93) +* -i: ln invocation. (line 100) * -I: rm invocation. (line 44) * -i <1>: rm invocation. (line 39) * -i <2>: mv invocation. (line 67) @@ -15052,6 +15376,7 @@ Index * -l: df invocation. (line 69) * -L <1>: chgrp invocation. (line 75) * -L <2>: chown invocation. (line 148) +* -L <3>: ln invocation. (line 104) * -L: cp invocation. (line 143) * -l <1>: cp invocation. (line 139) * -l: What information is listed. @@ -15071,8 +15396,8 @@ Index * -m <2>: uname invocation. (line 41) * -m <3>: who invocation. (line 62) * -m <4>: du invocation. (line 106) -* -m <5>: touch invocation. (line 73) -* -m <6>: readlink invocation. (line 41) +* -m <5>: touch invocation. (line 90) +* -m <6>: readlink invocation. (line 43) * -m <7>: mknod invocation. (line 48) * -m <8>: mkfifo invocation. (line 21) * -m <9>: mkdir invocation. (line 19) @@ -15085,11 +15410,11 @@ Index * -m: pr invocation. (line 160) * -n <1>: nice invocation. (line 47) * -n <2>: uname invocation. (line 46) -* -n <3>: id invocation. (line 31) +* -n <3>: id invocation. (line 34) * -n <4>: String tests. (line 19) * -n <5>: echo invocation. (line 22) -* -n <6>: readlink invocation. (line 46) -* -n <7>: ln invocation. (line 97) +* -n <6>: readlink invocation. (line 48) +* -n <7>: ln invocation. (line 110) * -n <8>: mv invocation. (line 74) * -n: cp invocation. (line 150) * -N: Formatting the file names. @@ -15100,7 +15425,7 @@ Index * -n <3>: shuf invocation. (line 32) * -n <4>: sort invocation. (line 159) * -n <5>: csplit invocation. (line 80) -* -n <6>: tail invocation. (line 139) +* -n <6>: tail invocation. (line 140) * -n: head invocation. (line 39) * -N: pr invocation. (line 194) * -n: pr invocation. (line 173) @@ -15131,7 +15456,8 @@ Index * -P: chcon invocation. (line 42) * -p <1>: uname invocation. (line 50) * -p: who invocation. (line 66) -* -P <1>: pwd invocation. (line 22) +* -P: pwd invocation. (line 22) +* -p: mktemp invocation. (line 106) * -P: pathchk invocation. (line 42) * -p <1>: pathchk invocation. (line 29) * -p: File type tests. (line 28) @@ -15140,8 +15466,9 @@ Index * -P <3>: chgrp invocation. (line 79) * -P: chown invocation. (line 152) * -p <1>: rmdir invocation. (line 22) -* -p <2>: mkdir invocation. (line 34) -* -p <3>: install invocation. (line 98) +* -p: mkdir invocation. (line 34) +* -P: ln invocation. (line 129) +* -p <1>: install invocation. (line 98) * -p: cp invocation. (line 163) * -P: cp invocation. (line 156) * -p <1>: dircolors invocation. @@ -15151,13 +15478,14 @@ Index * -p: nl invocation. (line 108) * -P: Traversing symlinks. (line 26) * -q <1>: who invocation. (line 70) -* -q: readlink invocation. (line 52) +* -q <2>: mktemp invocation. (line 93) +* -q: readlink invocation. (line 54) * -Q: Formatting the file names. (line 30) * -q <1>: Formatting the file names. (line 23) * -q <2>: csplit invocation. (line 100) -* -q <3>: tail invocation. (line 147) +* -q <3>: tail invocation. (line 148) * -q: head invocation. (line 46) * -r <1>: runcon invocation. (line 35) * -r: chcon invocation. (line 55) @@ -15166,11 +15494,11 @@ Index * -R: Options for date. (line 40) * -r <1>: Options for date. (line 34) * -r <2>: who invocation. (line 75) -* -r <3>: id invocation. (line 36) +* -r <3>: id invocation. (line 39) * -r <4>: Access permission tests. (line 15) * -r <5>: truncate invocation. (line 30) -* -r: touch invocation. (line 77) +* -r: touch invocation. (line 94) * -R <1>: chmod invocation. (line 69) * -R <2>: chgrp invocation. (line 66) * -R <3>: chown invocation. (line 140) @@ -15198,9 +15526,9 @@ Index * -s: truncate invocation. (line 34) * -S: du invocation. (line 140) * -s <1>: du invocation. (line 136) -* -s: readlink invocation. (line 52) -* -S: ln invocation. (line 122) -* -s: ln invocation. (line 116) +* -s: readlink invocation. (line 54) +* -S: ln invocation. (line 144) +* -s: ln invocation. (line 138) * -S <1>: mv invocation. (line 98) * -S: install invocation. (line 115) * -s: install invocation. (line 108) @@ -15232,12 +15560,13 @@ Index * -t: chcon invocation. (line 59) * -T: who invocation. (line 95) * -t <1>: who invocation. (line 83) -* -t <2>: File type tests. (line 34) +* -t <2>: mktemp invocation. (line 122) +* -t <3>: File type tests. (line 34) * -t: stat invocation. (line 53) * -T: df invocation. (line 119) * -t: df invocation. (line 113) -* -T: ln invocation. (line 131) -* -t: ln invocation. (line 127) +* -T: ln invocation. (line 153) +* -t: ln invocation. (line 149) * -T: mv invocation. (line 107) * -t: mv invocation. (line 103) * -T: install invocation. (line 124) @@ -15258,16 +15587,17 @@ Index * -t: od invocation. (line 85) * -T: cat invocation. (line 43) * -t: cat invocation. (line 39) -* -u <1>: env invocation. (line 38) +* -u <1>: env invocation. (line 90) * -u <2>: runcon invocation. (line 31) * -u <3>: chcon invocation. (line 51) * -u <4>: Options for date. (line 87) * -u <5>: who invocation. (line 86) -* -u <6>: id invocation. (line 41) -* -u <7>: Access permission tests. +* -u <6>: id invocation. (line 44) +* -u <7>: mktemp invocation. (line 98) +* -u <8>: Access permission tests. (line 18) -* -u <8>: shred invocation. (line 123) -* -u <9>: mv invocation. (line 80) +* -u <9>: shred invocation. (line 123) +* -u <10>: mv invocation. (line 80) * -u: cp invocation. (line 345) * -U: Sorting the output. (line 49) * -u <1>: Sorting the output. (line 42) @@ -15281,9 +15611,9 @@ Index * -v <4>: chgrp invocation. (line 58) * -v <5>: chown invocation. (line 132) * -v <6>: rmdir invocation. (line 31) -* -v <7>: readlink invocation. (line 56) +* -v <7>: readlink invocation. (line 58) * -v <8>: mkdir invocation. (line 51) -* -v <9>: ln invocation. (line 136) +* -v <9>: ln invocation. (line 158) * -v <10>: shred invocation. (line 129) * -v <11>: rm invocation. (line 95) * -v <12>: mv invocation. (line 90) @@ -15291,7 +15621,7 @@ Index * -v <14>: cp invocation. (line 355) * -v: Sorting the output. (line 56) * -V: sort invocation. (line 176) -* -v <1>: tail invocation. (line 151) +* -v <1>: tail invocation. (line 152) * -v <2>: head invocation. (line 50) * -v <3>: pr invocation. (line 247) * -v <4>: od invocation. (line 155) @@ -15324,7 +15654,7 @@ Index * -X: Sorting the output. (line 63) * -x: od invocation. (line 203) * -X FILE: du invocation. (line 211) -* -Z: id invocation. (line 45) +* -Z: id invocation. (line 48) * -z: String tests. (line 15) * -Z <1>: mknod invocation. (line 54) * -Z <2>: mkfifo invocation. (line 28) @@ -15366,10 +15696,10 @@ Index * \Uhhhhhhhh: printf invocation. (line 68) * \xHH: printf invocation. (line 63) * \| regexp operator: String expressions. (line 28) -* _POSIX2_VERSION <1>: touch invocation. (line 93) +* _POSIX2_VERSION <1>: touch invocation. (line 113) * _POSIX2_VERSION <2>: uniq invocation. (line 46) * _POSIX2_VERSION <3>: sort invocation. (line 392) -* _POSIX2_VERSION <4>: tail invocation. (line 162) +* _POSIX2_VERSION <4>: tail invocation. (line 163) * _POSIX2_VERSION: Standards conformance. (line 19) * abbreviations for months: Calendar date items. (line 38) @@ -15377,7 +15707,7 @@ Index (line 6) * access permissions, changing: chmod invocation. (line 6) * access time: dd invocation. (line 188) -* access time, changing: touch invocation. (line 50) +* access time, changing: touch invocation. (line 53) * access time, printing or sorting files by: Sorting the output. (line 42) * access time, show the most recent: du invocation. (line 159) @@ -15412,7 +15742,7 @@ Index * arithmetic tests: Numeric tests. (line 6) * ASCII dump of files: od invocation. (line 6) * ascii, converting to: dd invocation. (line 65) -* atime, changing: touch invocation. (line 50) +* atime, changing: touch invocation. (line 53) * atime, printing or sorting files by: Sorting the output. (line 42) * atime, show the most recent: du invocation. (line 159) * attributes, file: Changing file attributes. @@ -15431,7 +15761,7 @@ Index (line 23) * backup options: Backup options. (line 6) * backup suffix: Backup options. (line 50) -* backups, making <1>: ln invocation. (line 77) +* backups, making <1>: ln invocation. (line 84) * backups, making <2>: mv invocation. (line 56) * backups, making <3>: install invocation. (line 42) * backups, making <4>: cp invocation. (line 75) @@ -15477,7 +15807,7 @@ Index * bs: dd invocation. (line 33) * BSD sum: sum invocation. (line 25) * BSD tail: tail invocation. (line 19) -* BSD touch compatibility: touch invocation. (line 68) +* BSD touch compatibility: touch invocation. (line 71) * bsN: Output. (line 55) * bugs, reporting: Introduction. (line 12) * built-in shell commands, conflicts with <1>: sleep invocation. @@ -15681,9 +16011,9 @@ Index * delay for a specified time: sleep invocation. (line 6) * delaying commands: Delaying. (line 6) * deleting characters: Squeezing. (line 6) -* dereferencing symbolic links: ln invocation. (line 40) +* dereferencing symbolic links: ln invocation. (line 42) * descriptor follow option: tail invocation. (line 48) -* destination directory <1>: ln invocation. (line 127) +* destination directory <1>: ln invocation. (line 149) * destination directory <2>: mv invocation. (line 103) * destination directory <3>: install invocation. (line 120) * destination directory <4>: cp invocation. (line 336) @@ -15720,6 +16050,7 @@ Index (line 91) * directory listing, verbose: vdir invocation. (line 6) * directory order, listing by: Sorting the output. (line 20) +* directory, creating temporary: mktemp invocation. (line 6) * directory, stripping from file names: basename invocation. (line 6) * dired Emacs mode support: What information is listed. (line 16) @@ -15772,7 +16103,7 @@ Index * env: env invocation. (line 6) * environment variables, printing: printenv invocation. (line 6) * environment, preserving: su invocation. (line 64) -* environment, printing: env invocation. (line 29) +* environment, printing: env invocation. (line 45) * environment, running a program in a modified: env invocation. (line 6) * eof: Characters. (line 32) @@ -15809,14 +16140,15 @@ Index * existing backup method: Backup options. (line 39) * exit status commands: Conditions. (line 6) * exit status of chroot: chroot invocation. (line 58) -* exit status of env: env invocation. (line 48) +* exit status of env: env invocation. (line 100) * exit status of expr: expr invocation. (line 43) * exit status of false: false invocation. (line 6) * exit status of ls: ls invocation. (line 29) +* exit status of mktemp: mktemp invocation. (line 130) * exit status of nice: nice invocation. (line 56) * exit status of nohup: nohup invocation. (line 47) * exit status of pathchk: pathchk invocation. (line 50) -* exit status of printenv: printenv invocation. (line 17) +* exit status of printenv: printenv invocation. (line 25) * exit status of runcon: runcon invocation. (line 46) * exit status of sort: sort invocation. (line 58) * exit status of stdbuf: stdbuf invocation. (line 61) @@ -15858,6 +16190,7 @@ Index * file name pattern expansion, disabled: su invocation. (line 44) * file names, checking validity and portability: pathchk invocation. (line 6) +* file names, creating temporary: mktemp invocation. (line 6) * file names, stripping directory and suffix: basename invocation. (line 6) * file offset radix: od invocation. (line 36) @@ -15949,7 +16282,8 @@ Index (line 23) * hard link, defined: ln invocation. (line 32) * hard links: dd invocation. (line 202) -* hard links to directories: ln invocation. (line 83) +* hard links to directories: ln invocation. (line 90) +* hard links to symbolic links: ln invocation. (line 161) * hard links, counting in du: du invocation. (line 96) * hard links, creating <1>: ln invocation. (line 6) * hard links, creating: link invocation. (line 6) @@ -16129,6 +16463,7 @@ Index * LS_BLOCK_SIZE: Block size. (line 12) * LS_COLORS: dircolors invocation. (line 23) +* lutimes: touch invocation. (line 75) * machine type: uname invocation. (line 41) * machine-readable stty output: stty invocation. (line 41) * MacKenzie, D.: Introduction. (line 19) @@ -16165,6 +16500,7 @@ Index * mkdir: mkdir invocation. (line 6) * mkfifo: mkfifo invocation. (line 6) * mknod: mknod invocation. (line 6) +* mktemp: mktemp invocation. (line 6) * modem control: Control. (line 33) * modes and umask: Umask and Protection. (line 6) @@ -16175,14 +16511,14 @@ Index (line 6) * modified environment, running a program in a: env invocation. (line 6) -* modify time, changing: touch invocation. (line 73) +* modify time, changing: touch invocation. (line 90) * month in date strings: Relative items in date strings. (line 15) * month names in date strings: Calendar date items. (line 38) * months, sorting by: sort invocation. (line 149) * months, written-out: General date syntax. (line 36) * MS-DOS file system: df invocation. (line 139) -* mtime, changing: touch invocation. (line 73) +* mtime, changing: touch invocation. (line 90) * multicolumn output, generating: pr invocation. (line 6) * multiple changes to permissions: Multiple Changes. (line 6) * multiplication: Numeric expressions. (line 16) @@ -16243,6 +16579,7 @@ Index * notrunc: dd invocation. (line 119) * now in date strings: Relative items in date strings. (line 33) +* nproc: nproc invocation. (line 6) * number of inputs to merge, nmerge: sort invocation. (line 250) * numbered backup method: Backup options. (line 35) * numbering lines: nl invocation. (line 6) @@ -16300,7 +16637,9 @@ Index * output file name suffix: csplit invocation. (line 66) * output format: stat invocation. (line 33) * output format, portable: df invocation. (line 80) -* output null-byte-terminated lines: du invocation. (line 122) +* output NUL-byte-terminated lines <1>: env invocation. (line 83) +* output NUL-byte-terminated lines <2>: printenv invocation. (line 19) +* output NUL-byte-terminated lines: du invocation. (line 122) * output of entire files: Output of entire files. (line 6) * output of parts of files: Output of parts of files. @@ -16354,7 +16693,7 @@ Index * permissions, changing access: chmod invocation. (line 6) * permissions, copying existing: Copying Permissions. (line 6) * permissions, for changing file timestamps: touch invocation. - (line 16) + (line 17) * permissions, output by ls: What information is listed. (line 191) * petabyte, definition of: Block size. (line 109) @@ -16370,12 +16709,13 @@ Index * portable output format: df invocation. (line 80) * POSIX: Introduction. (line 11) * POSIX output format: df invocation. (line 80) -* POSIXLY_CORRECT <1>: printf invocation. (line 48) -* POSIXLY_CORRECT <2>: echo invocation. (line 73) -* POSIXLY_CORRECT <3>: dd invocation. (line 261) -* POSIXLY_CORRECT <4>: sort invocation. (line 284) -* POSIXLY_CORRECT <5>: pr invocation. (line 105) -* POSIXLY_CORRECT <6>: Standards conformance. +* POSIXLY_CORRECT <1>: id invocation. (line 11) +* POSIXLY_CORRECT <2>: printf invocation. (line 48) +* POSIXLY_CORRECT <3>: echo invocation. (line 76) +* POSIXLY_CORRECT <4>: dd invocation. (line 261) +* POSIXLY_CORRECT <5>: sort invocation. (line 284) +* POSIXLY_CORRECT <6>: pr invocation. (line 105) +* POSIXLY_CORRECT <7>: Standards conformance. (line 6) * POSIXLY_CORRECT: Common options. (line 11) * POSIXLY_CORRECT, and block size: Block size. (line 12) @@ -16386,6 +16726,7 @@ Index * print name of current directory: pwd invocation. (line 6) * print system information: uname invocation. (line 6) * print terminal file name: tty invocation. (line 6) +* Print the number of processors: nproc invocation. (line 6) * printenv: printenv invocation. (line 6) * printf: printf invocation. (line 6) * printing all or some environment variables: printenv invocation. @@ -16410,7 +16751,7 @@ Index * process zero-terminated items <2>: shuf invocation. (line 48) * process zero-terminated items: sort invocation. (line 359) * processes, commands for controlling: Process control. (line 6) -* prompting, and ln: ln invocation. (line 93) +* prompting, and ln: ln invocation. (line 100) * prompting, and mv: mv invocation. (line 36) * prompting, and rm: rm invocation. (line 11) * prompts, forcing: mv invocation. (line 67) @@ -16519,7 +16860,7 @@ Index * seconds since the epoch: Time conversion specifiers. (line 41) * section delimiters of pages: nl invocation. (line 68) -* security context <1>: id invocation. (line 45) +* security context <1>: id invocation. (line 48) * security context <2>: mknod invocation. (line 54) * security context <3>: mkfifo invocation. (line 28) * security context <4>: mkdir invocation. (line 56) @@ -16528,7 +16869,7 @@ Index (line 268) * seek: dd invocation. (line 48) * self-backups: cp invocation. (line 53) -* SELinux <1>: id invocation. (line 45) +* SELinux <1>: id invocation. (line 48) * SELinux <2>: mknod invocation. (line 54) * SELinux <3>: mkfifo invocation. (line 28) * SELinux <4>: mkdir invocation. (line 56) @@ -16687,11 +17028,13 @@ Index (line 143) * symbolic link to directory, traverse each that is specified on the command line: Traversing symlinks. (line 18) -* symbolic link, defined: ln invocation. (line 40) +* symbolic link, defined: ln invocation. (line 42) +* symbolic links and ln: ln invocation. (line 161) * symbolic links and pwd: pwd invocation. (line 26) * symbolic links, changing group: chgrp invocation. (line 35) * symbolic links, changing owner <1>: chgrp invocation. (line 30) * symbolic links, changing owner: chown invocation. (line 80) +* symbolic links, changing time: touch invocation. (line 75) * symbolic links, copying: cp invocation. (line 103) * symbolic links, copying with: cp invocation. (line 323) * symbolic links, dereferencing: Which files are listed. @@ -16713,6 +17056,7 @@ Index * syslog: su invocation. (line 29) * system context: System context. (line 6) * system information, printing <1>: uname invocation. (line 6) +* system information, printing <2>: nproc invocation. (line 6) * system information, printing: arch invocation. (line 6) * system name, printing: hostname invocation. (line 6) * System V sum: sum invocation. (line 31) @@ -16724,7 +17068,7 @@ Index * tagged paragraphs: fmt invocation. (line 40) * tail: tail invocation. (line 6) * tandem: Input. (line 45) -* target directory <1>: ln invocation. (line 127) +* target directory <1>: ln invocation. (line 149) * target directory <2>: mv invocation. (line 103) * target directory <3>: install invocation. (line 120) * target directory <4>: cp invocation. (line 336) @@ -16733,6 +17077,7 @@ Index * tee: tee invocation. (line 6) * telephone directory order: sort invocation. (line 87) * temporary directory: sort invocation. (line 336) +* temporary files and directories: mktemp invocation. (line 6) * terabyte, definition of: Block size. (line 102) * TERM: su invocation. (line 53) * terminal check: File type tests. (line 34) @@ -16753,7 +17098,7 @@ Index * this in date strings: Relative items in date strings. (line 33) * time <1>: Special. (line 11) -* time: touch invocation. (line 58) +* time: touch invocation. (line 61) * time conversion specifiers: Time conversion specifiers. (line 6) * time formats <1>: date invocation. (line 20) @@ -16805,7 +17150,7 @@ Index * TZ <3>: date invocation. (line 16) * TZ <4>: who invocation. (line 26) * TZ <5>: stat invocation. (line 139) -* TZ <6>: touch invocation. (line 37) +* TZ <6>: touch invocation. (line 40) * TZ <7>: Formatting file timestamps. (line 18) * TZ: pr invocation. (line 111) @@ -16828,7 +17173,7 @@ Index * upper: Character sets. (line 121) * uppercase, translating to lowercase: Input. (line 50) * uptime: uptime invocation. (line 6) -* use time, changing: touch invocation. (line 50) +* use time, changing: touch invocation. (line 53) * use time, printing or sorting files by: Sorting the output. (line 13) * use time, show the most recent: du invocation. (line 154) * USER: su invocation. (line 18) @@ -16857,7 +17202,7 @@ Index * version of kernel: uname invocation. (line 76) * version, sorting option for ls: Sorting the output. (line 56) * version-control Emacs variable: Backup options. (line 24) -* VERSION_CONTROL <1>: ln invocation. (line 77) +* VERSION_CONTROL <1>: ln invocation. (line 84) * VERSION_CONTROL <2>: mv invocation. (line 56) * VERSION_CONTROL <3>: install invocation. (line 42) * VERSION_CONTROL <4>: cp invocation. (line 75) @@ -16903,219 +17248,221 @@ Index  Tag Table: -Node: Top8203 -Node: Introduction21984 -Node: Common options23543 -Node: Exit status26757 -Node: Backup options27498 -Node: Block size29422 -Node: Signal specifications34331 -Node: Disambiguating names and IDs36381 -Ref: Disambiguating names and IDs-Footnote-137950 -Node: Random sources38020 -Node: Target directory39637 -Node: Trailing slashes43122 -Node: Traversing symlinks44143 -Node: Treating / specially45214 -Node: Special built-in utilities46761 -Node: Standards conformance47896 -Node: Output of entire files49412 -Node: cat invocation50013 -Node: tac invocation51769 -Node: nl invocation53031 -Node: od invocation56910 -Node: base64 invocation63758 -Node: Formatting file contents65137 -Node: fmt invocation65588 -Node: pr invocation68401 -Node: fold invocation80858 -Node: Output of parts of files82318 -Node: head invocation82826 -Node: tail invocation85011 -Node: split invocation93489 -Node: csplit invocation95850 -Node: Summarizing files100601 -Node: wc invocation101249 -Node: sum invocation104323 -Node: cksum invocation105728 -Node: md5sum invocation106868 -Node: sha1sum invocation111929 -Node: sha2 utilities112709 -Node: Operating on sorted files113333 -Node: sort invocation113934 -Ref: sort invocation-Footnote-1136785 -Node: shuf invocation137337 -Node: uniq invocation139916 -Node: comm invocation144608 -Node: ptx invocation147029 -Node: General options in ptx149833 -Node: Charset selection in ptx150414 -Node: Input processing in ptx151316 -Node: Output formatting in ptx156737 -Node: Compatibility in ptx163303 -Node: tsort invocation166536 -Node: tsort background169695 -Node: Operating on fields within a line171343 -Node: cut invocation171747 -Node: paste invocation175064 -Node: join invocation176392 -Node: Operating on characters181527 -Node: tr invocation181963 -Node: Character sets183681 -Node: Translating188112 -Node: Squeezing190203 -Node: expand invocation193270 -Node: unexpand invocation194752 -Node: Directory listing196570 -Node: ls invocation197056 -Ref: ls invocation-Footnote-1199130 -Node: Which files are listed199352 -Node: What information is listed203092 -Node: Sorting the output212339 -Node: More details about version sort214659 -Node: General output formatting216386 -Node: Formatting file timestamps220294 -Node: Formatting the file names225635 -Node: dir invocation228551 -Node: vdir invocation228962 -Node: dircolors invocation229340 -Node: Basic operations231038 -Node: cp invocation231658 -Node: dd invocation246936 -Node: install invocation256654 -Node: mv invocation261929 -Node: rm invocation266365 -Node: shred invocation270669 -Node: Special file types278182 -Node: link invocation279688 -Node: ln invocation280694 -Node: mkdir invocation287061 -Node: mkfifo invocation289432 -Node: mknod invocation290552 -Node: readlink invocation292682 -Node: rmdir invocation294548 -Node: unlink invocation295822 -Node: Changing file attributes296781 -Node: chown invocation297595 -Node: chgrp invocation303781 -Node: chmod invocation306831 -Node: touch invocation309586 -Node: Disk usage314232 -Node: df invocation314893 -Node: du invocation320835 -Node: stat invocation329361 -Node: sync invocation333343 -Node: truncate invocation334298 -Node: Printing text336057 -Node: echo invocation336431 -Node: printf invocation338860 -Node: yes invocation344096 -Node: Conditions344708 -Node: false invocation345299 -Node: true invocation346334 -Node: test invocation347613 -Node: File type tests349653 -Node: Access permission tests350535 -Node: File characteristic tests351420 -Node: String tests352185 -Node: Numeric tests352850 -Node: Connectives for test353656 -Node: expr invocation354009 -Node: String expressions356450 -Node: Numeric expressions359034 -Node: Relations for expr359731 -Node: Examples of expr360925 -Node: Redirection361649 -Node: tee invocation362107 -Node: File name manipulation366897 -Node: basename invocation367358 -Node: dirname invocation368805 -Node: pathchk invocation370011 -Node: Working context371749 -Node: pwd invocation372393 -Node: stty invocation373737 -Node: Control376497 -Node: Input377257 -Node: Output378930 -Node: Local380250 -Node: Combination381832 -Node: Characters384053 -Node: Special385607 -Node: printenv invocation387264 -Node: tty invocation388027 -Node: User information388733 -Node: id invocation389368 -Node: logname invocation391139 -Node: whoami invocation391766 -Node: groups invocation392253 -Node: users invocation393458 -Node: who invocation394405 -Node: System context397341 -Node: date invocation397942 -Node: Time conversion specifiers399659 -Node: Date conversion specifiers402059 -Node: Literal conversion specifiers405183 -Node: Padding and other flags405541 -Node: Setting the time407732 -Node: Options for date408738 -Node: Examples of date412214 -Ref: %s-examples413632 -Node: arch invocation415817 -Node: uname invocation416266 -Node: hostname invocation418839 -Node: hostid invocation419452 -Node: uptime invocation420163 -Node: SELinux context421286 -Node: chcon invocation421661 -Node: runcon invocation423483 -Node: Modified command invocation424949 -Node: chroot invocation425699 -Ref: chroot invocation-Footnote-1428267 -Node: env invocation428569 -Node: nice invocation430627 -Node: nohup invocation434341 -Node: stdbuf invocation436501 -Node: su invocation438702 -Node: timeout invocation443203 -Node: Process control444362 -Node: kill invocation444585 -Node: Delaying447656 -Node: sleep invocation447853 -Node: Numeric operations448973 -Node: factor invocation449305 -Node: seq invocation451056 -Node: File permissions454676 -Node: Mode Structure455294 -Node: Symbolic Modes458989 -Node: Setting Permissions460087 -Node: Copying Permissions462700 -Node: Changing Special Mode Bits463519 -Node: Conditional Executability465341 -Node: Multiple Changes465885 -Node: Umask and Protection467552 -Node: Numeric Modes468657 -Node: Directory Setuid and Setgid470557 -Node: Date input formats472819 -Node: General date syntax475172 -Node: Calendar date items478131 -Node: Time of day items480136 -Node: Time zone items482340 -Node: Day of week items483582 -Node: Relative items in date strings484579 -Node: Pure numbers in date strings487389 -Node: Seconds since the Epoch488378 -Node: Specifying time zone rules490007 -Node: Authors of get_date492379 -Node: Opening the software toolbox493139 -Node: Toolbox introduction493811 -Node: I/O redirection496534 -Node: The who command499368 -Node: The cut command500265 -Node: The sort command501328 -Node: The uniq command502032 -Node: Putting the tools together502722 -Ref: Putting the tools together-Footnote-1514674 -Node: GNU Free Documentation License514748 -Node: Concept index539941 +Node: Top8355 +Node: Introduction22129 +Node: Common options23688 +Node: Exit status26902 +Node: Backup options27653 +Node: Block size29577 +Node: Signal specifications34486 +Node: Disambiguating names and IDs36536 +Ref: Disambiguating names and IDs-Footnote-138105 +Node: Random sources38175 +Node: Target directory39792 +Node: Trailing slashes43277 +Node: Traversing symlinks44298 +Node: Treating / specially45369 +Node: Special built-in utilities46916 +Node: Standards conformance48051 +Node: Output of entire files49567 +Node: cat invocation50168 +Node: tac invocation51924 +Node: nl invocation53186 +Node: od invocation57065 +Node: base64 invocation63913 +Node: Formatting file contents65292 +Node: fmt invocation65743 +Node: pr invocation68556 +Node: fold invocation81013 +Node: Output of parts of files82473 +Node: head invocation82981 +Node: tail invocation85166 +Node: split invocation93765 +Node: csplit invocation96126 +Node: Summarizing files100877 +Node: wc invocation101525 +Node: sum invocation104599 +Node: cksum invocation106004 +Node: md5sum invocation107144 +Node: sha1sum invocation112205 +Node: sha2 utilities112985 +Node: Operating on sorted files113609 +Node: sort invocation114196 +Ref: sort invocation-Footnote-1137090 +Node: shuf invocation137642 +Node: uniq invocation140221 +Node: comm invocation144913 +Node: ptx invocation147334 +Node: General options in ptx150138 +Node: Charset selection in ptx150719 +Node: Input processing in ptx151621 +Node: Output formatting in ptx157042 +Node: Compatibility in ptx163608 +Node: tsort invocation166841 +Node: tsort background170000 +Node: Operating on fields171648 +Node: cut invocation172010 +Node: paste invocation175313 +Node: join invocation176627 +Node: Operating on characters181748 +Node: tr invocation182170 +Node: Character sets183888 +Node: Translating188319 +Node: Squeezing190410 +Node: expand invocation193477 +Node: unexpand invocation194959 +Node: Directory listing196777 +Node: ls invocation197263 +Ref: ls invocation-Footnote-1199359 +Node: Which files are listed199581 +Node: What information is listed203321 +Node: Sorting the output212568 +Node: Details about version sort214878 +Node: General output formatting216646 +Node: Formatting file timestamps220549 +Node: Formatting the file names225890 +Node: dir invocation228806 +Node: vdir invocation229217 +Node: dircolors invocation229595 +Node: Basic operations231293 +Node: cp invocation231913 +Node: dd invocation247191 +Node: install invocation256909 +Node: mv invocation262184 +Node: rm invocation266620 +Node: shred invocation270924 +Node: Special file types278437 +Node: link invocation279943 +Node: ln invocation281162 +Node: mkdir invocation288954 +Node: mkfifo invocation291325 +Node: mknod invocation292445 +Node: readlink invocation294575 +Node: rmdir invocation296546 +Node: unlink invocation297820 +Node: Changing file attributes298779 +Node: chown invocation299593 +Node: chgrp invocation305779 +Node: chmod invocation308829 +Node: touch invocation311584 +Node: Disk usage317438 +Node: df invocation318099 +Node: du invocation324041 +Node: stat invocation332561 +Node: sync invocation336543 +Node: truncate invocation337498 +Node: Printing text339257 +Node: echo invocation339631 +Node: printf invocation342087 +Node: yes invocation347323 +Node: Conditions347935 +Node: false invocation348526 +Node: true invocation349561 +Node: test invocation350840 +Node: File type tests352880 +Node: Access permission tests353762 +Node: File characteristic tests354647 +Node: String tests355412 +Node: Numeric tests356077 +Node: Connectives for test356883 +Node: expr invocation357236 +Node: String expressions359677 +Node: Numeric expressions362261 +Node: Relations for expr362958 +Node: Examples of expr364152 +Node: Redirection364876 +Node: tee invocation365334 +Node: File name manipulation370124 +Node: basename invocation370653 +Node: dirname invocation372100 +Node: pathchk invocation373306 +Node: mktemp invocation375070 +Node: Working context380690 +Node: pwd invocation381334 +Node: stty invocation382678 +Node: Control385438 +Node: Input386198 +Node: Output387871 +Node: Local389191 +Node: Combination390773 +Node: Characters392994 +Node: Special394548 +Node: printenv invocation396205 +Node: tty invocation397215 +Node: User information397921 +Node: id invocation398556 +Node: logname invocation400479 +Node: whoami invocation401106 +Node: groups invocation401593 +Node: users invocation402798 +Node: who invocation403745 +Node: System context406681 +Node: date invocation407346 +Node: Time conversion specifiers409063 +Node: Date conversion specifiers411463 +Node: Literal conversion specifiers414587 +Node: Padding and other flags414945 +Node: Setting the time417136 +Node: Options for date418142 +Node: Examples of date421618 +Ref: %s-examples423036 +Node: arch invocation425221 +Node: nproc invocation425670 +Node: uname invocation426780 +Node: hostname invocation429354 +Node: hostid invocation429967 +Node: uptime invocation430678 +Node: SELinux context431801 +Node: chcon invocation432176 +Node: runcon invocation433998 +Node: Modified command invocation435464 +Node: chroot invocation436214 +Ref: chroot invocation-Footnote-1438782 +Node: env invocation439084 +Node: nice invocation443328 +Node: nohup invocation447042 +Node: stdbuf invocation449325 +Node: su invocation451526 +Node: timeout invocation456027 +Node: Process control457186 +Node: kill invocation457409 +Node: Delaying460480 +Node: sleep invocation460677 +Node: Numeric operations461797 +Node: factor invocation462129 +Node: seq invocation463880 +Node: File permissions467500 +Node: Mode Structure468118 +Node: Symbolic Modes471813 +Node: Setting Permissions472911 +Node: Copying Permissions475524 +Node: Changing Special Mode Bits476343 +Node: Conditional Executability478165 +Node: Multiple Changes478709 +Node: Umask and Protection480376 +Node: Numeric Modes481481 +Node: Directory Setuid and Setgid483381 +Node: Date input formats485643 +Node: General date syntax487996 +Node: Calendar date items490955 +Node: Time of day items492960 +Node: Time zone items495164 +Node: Day of week items496406 +Node: Relative items in date strings497403 +Node: Pure numbers in date strings500213 +Node: Seconds since the Epoch501202 +Node: Specifying time zone rules502831 +Node: Authors of get_date505203 +Node: Opening the software toolbox505963 +Node: Toolbox introduction506635 +Node: I/O redirection509358 +Node: The who command512192 +Node: The cut command513089 +Node: The sort command514152 +Node: The uniq command514856 +Node: Putting the tools together515546 +Ref: Putting the tools together-Footnote-1527498 +Node: GNU Free Documentation License527572 +Node: Concept index552765  End Tag Table diff --git a/src/bin/coreutils/doc/coreutils.texi b/src/bin/coreutils/doc/coreutils.texi index 22d307a998..444dbc7fb8 100644 --- a/src/bin/coreutils/doc/coreutils.texi +++ b/src/bin/coreutils/doc/coreutils.texi @@ -31,7 +31,6 @@ @c FIXME: the following need documentation @c * [: (coreutils)[ invocation. File/string tests. @c * pinky: (coreutils)pinky invocation. FIXME. -@c * mktemp: (coreutils)mktemp invocation. FIXME. @dircategory Individual utilities @direntry @@ -80,10 +79,12 @@ * mkdir: (coreutils)mkdir invocation. Create directories. * mkfifo: (coreutils)mkfifo invocation. Create FIFOs (named pipes). * mknod: (coreutils)mknod invocation. Create special files. +* mktemp: (coreutils)mktemp invocation. Create temporary files. * mv: (coreutils)mv invocation. Rename files. * nice: (coreutils)nice invocation. Modify niceness. * nl: (coreutils)nl invocation. Number lines and write files. * nohup: (coreutils)nohup invocation. Immunize to hangups. +* nproc: (coreutils)nproc invocation. Print the number of processors. * od: (coreutils)od invocation. Dump files in octal, etc. * paste: (coreutils)paste invocation. Merge lines of files. * pathchk: (coreutils)pathchk invocation. Check file name portability. @@ -138,7 +139,7 @@ This manual documents version @value{VERSION} of the @sc{gnu} core utilities, including the standard programs for text and file manipulation. -Copyright @copyright{} 1994-1996, 2000-2009 Free Software Foundation, Inc. +Copyright @copyright{} 1994-1996, 2000-2010 Free Software Foundation, Inc. @quotation Permission is granted to copy, distribute and/or modify this document @@ -176,198 +177,198 @@ Free Documentation License''. @cindex file utilities @menu -* Introduction:: Caveats, overview, and authors. -* Common options:: Common options. -* Output of entire files:: cat tac nl od -* Formatting file contents:: fmt pr fold -* Output of parts of files:: head tail split csplit -* Summarizing files:: wc sum cksum md5sum sha1sum sha2 -* Operating on sorted files:: sort shuf uniq comm ptx tsort -* Operating on fields within a line:: cut paste join -* Operating on characters:: tr expand unexpand -* Directory listing:: ls dir vdir dircolors -* Basic operations:: cp dd install mv rm shred -* Special file types:: ln mkdir rmdir mkfifo mknod -* Changing file attributes:: chgrp chmod chown touch -* Disk usage:: df du stat sync truncate -* Printing text:: echo printf yes -* Conditions:: false true test expr -* Redirection:: tee -* File name manipulation:: dirname basename pathchk -* Working context:: pwd stty printenv tty -* User information:: id logname whoami groups users who -* System context:: date uname hostname hostid uptime -* SELinux context:: chcon runcon -* Modified command invocation:: chroot env nice nohup stdbuf su timeout -* Process control:: kill -* Delaying:: sleep -* Numeric operations:: factor seq -* File permissions:: Access modes. -* Date input formats:: Specifying date strings. -* Opening the software toolbox:: The software tools philosophy. -* GNU Free Documentation License:: Copying and sharing this manual. -* Concept index:: General index. +* Introduction:: Caveats, overview, and authors +* Common options:: Common options +* Output of entire files:: cat tac nl od base64 +* Formatting file contents:: fmt pr fold +* Output of parts of files:: head tail split csplit +* Summarizing files:: wc sum cksum md5sum sha1sum sha2 +* Operating on sorted files:: sort shuf uniq comm ptx tsort +* Operating on fields:: cut paste join +* Operating on characters:: tr expand unexpand +* Directory listing:: ls dir vdir dircolors +* Basic operations:: cp dd install mv rm shred +* Special file types:: mkdir rmdir unlink mkfifo mknod ln link readlink +* Changing file attributes:: chgrp chmod chown touch +* Disk usage:: df du stat sync truncate +* Printing text:: echo printf yes +* Conditions:: false true test expr +* Redirection:: tee +* File name manipulation:: dirname basename pathchk mktemp +* Working context:: pwd stty printenv tty +* User information:: id logname whoami groups users who +* System context:: date arch uname hostname hostid uptime +* SELinux context:: chcon runcon +* Modified command invocation:: chroot env nice nohup stdbuf su timeout +* Process control:: kill +* Delaying:: sleep +* Numeric operations:: factor seq +* File permissions:: Access modes +* Date input formats:: Specifying date strings +* Opening the software toolbox:: The software tools philosophy +* GNU Free Documentation License:: Copying and sharing this manual +* Concept index:: General index @detailmenu --- The Detailed Node Listing --- Common Options -* Exit status:: Indicating program success or failure. -* Backup options:: Backup options -* Block size:: Block size -* Signal specifications:: Specifying signals +* Exit status:: Indicating program success or failure +* Backup options:: Backup options +* Block size:: Block size +* Signal specifications:: Specifying signals * Disambiguating names and IDs:: chgrp and chown owner and group syntax -* Random sources:: Sources of random data -* Target directory:: Target directory -* Trailing slashes:: Trailing slashes -* Traversing symlinks:: Traversing symlinks to directories -* Treating / specially:: Treating / specially -* Standards conformance:: Standards conformance +* Random sources:: Sources of random data +* Target directory:: Target directory +* Trailing slashes:: Trailing slashes +* Traversing symlinks:: Traversing symlinks to directories +* Treating / specially:: Treating / specially +* Standards conformance:: Standards conformance Output of entire files -* cat invocation:: Concatenate and write files. -* tac invocation:: Concatenate and write files in reverse. -* nl invocation:: Number lines and write files. -* od invocation:: Write files in octal or other formats. -* base64 invocation:: Transform data into printable data. +* cat invocation:: Concatenate and write files +* tac invocation:: Concatenate and write files in reverse +* nl invocation:: Number lines and write files +* od invocation:: Write files in octal or other formats +* base64 invocation:: Transform data into printable data Formatting file contents -* fmt invocation:: Reformat paragraph text. -* pr invocation:: Paginate or columnate files for printing. -* fold invocation:: Wrap input lines to fit in specified width. +* fmt invocation:: Reformat paragraph text +* pr invocation:: Paginate or columnate files for printing +* fold invocation:: Wrap input lines to fit in specified width Output of parts of files -* head invocation:: Output the first part of files. -* tail invocation:: Output the last part of files. -* split invocation:: Split a file into fixed-size pieces. -* csplit invocation:: Split a file into context-determined pieces. +* head invocation:: Output the first part of files +* tail invocation:: Output the last part of files +* split invocation:: Split a file into fixed-size pieces +* csplit invocation:: Split a file into context-determined pieces Summarizing files -* wc invocation:: Print newline, word, and byte counts. -* sum invocation:: Print checksum and block counts. -* cksum invocation:: Print CRC checksum and byte counts. -* md5sum invocation:: Print or check MD5 digests. -* sha1sum invocation:: Print or check SHA-1 digests. -* sha2 utilities:: Print or check SHA-2 digests. +* wc invocation:: Print newline, word, and byte counts +* sum invocation:: Print checksum and block counts +* cksum invocation:: Print CRC checksum and byte counts +* md5sum invocation:: Print or check MD5 digests +* sha1sum invocation:: Print or check SHA-1 digests +* sha2 utilities:: Print or check SHA-2 digests Operating on sorted files -* sort invocation:: Sort text files. -* shuf invocation:: Shuffle text files. -* uniq invocation:: Uniquify files. -* comm invocation:: Compare two sorted files line by line. -* ptx invocation:: Produce a permuted index of file contents. -* tsort invocation:: Topological sort. +* sort invocation:: Sort text files +* shuf invocation:: Shuffle text files +* uniq invocation:: Uniquify files +* comm invocation:: Compare two sorted files line by line +* ptx invocation:: Produce a permuted index of file contents +* tsort invocation:: Topological sort @command{ptx}: Produce permuted indexes -* General options in ptx:: Options which affect general program behavior. -* Charset selection in ptx:: Underlying character set considerations. -* Input processing in ptx:: Input fields, contexts, and keyword selection. -* Output formatting in ptx:: Types of output format, and sizing the fields. -* Compatibility in ptx:: The @acronym{GNU} extensions to @command{ptx} +* General options in ptx:: Options which affect general program behavior +* Charset selection in ptx:: Underlying character set considerations +* Input processing in ptx:: Input fields, contexts, and keyword selection +* Output formatting in ptx:: Types of output format, and sizing the fields +* Compatibility in ptx:: The @acronym{GNU} extensions to @command{ptx} -Operating on fields within a line +Operating on fields -* cut invocation:: Print selected parts of lines. -* paste invocation:: Merge lines of files. -* join invocation:: Join lines on a common field. +* cut invocation:: Print selected parts of lines +* paste invocation:: Merge lines of files +* join invocation:: Join lines on a common field Operating on characters -* tr invocation:: Translate, squeeze, and/or delete characters. -* expand invocation:: Convert tabs to spaces. -* unexpand invocation:: Convert spaces to tabs. +* tr invocation:: Translate, squeeze, and/or delete characters +* expand invocation:: Convert tabs to spaces +* unexpand invocation:: Convert spaces to tabs @command{tr}: Translate, squeeze, and/or delete characters -* Character sets:: Specifying sets of characters. -* Translating:: Changing one set of characters to another. -* Squeezing:: Squeezing repeats and deleting. +* Character sets:: Specifying sets of characters +* Translating:: Changing one set of characters to another +* Squeezing:: Squeezing repeats and deleting Directory listing -* ls invocation:: List directory contents -* dir invocation:: Briefly list directory contents -* vdir invocation:: Verbosely list directory contents -* dircolors invocation:: Color setup for @command{ls} +* ls invocation:: List directory contents +* dir invocation:: Briefly list directory contents +* vdir invocation:: Verbosely list directory contents +* dircolors invocation:: Color setup for @command{ls} @command{ls}: List directory contents -* Which files are listed:: Which files are listed -* What information is listed:: What information is listed -* Sorting the output:: Sorting the output -* More details about version sort:: More details about version sort -* General output formatting:: General output formatting -* Formatting the file names:: Formatting the file names +* Which files are listed:: Which files are listed +* What information is listed:: What information is listed +* Sorting the output:: Sorting the output +* Details about version sort:: More details about version sort +* General output formatting:: General output formatting +* Formatting the file names:: Formatting the file names Basic operations -* cp invocation:: Copy files and directories -* dd invocation:: Convert and copy a file -* install invocation:: Copy files and set attributes -* mv invocation:: Move (rename) files -* rm invocation:: Remove files or directories -* shred invocation:: Remove files more securely +* cp invocation:: Copy files and directories +* dd invocation:: Convert and copy a file +* install invocation:: Copy files and set attributes +* mv invocation:: Move (rename) files +* rm invocation:: Remove files or directories +* shred invocation:: Remove files more securely Special file types -* link invocation:: Make a hard link via the link syscall -* ln invocation:: Make links between files -* mkdir invocation:: Make directories -* mkfifo invocation:: Make FIFOs (named pipes) -* mknod invocation:: Make block or character special files -* readlink invocation:: Print value of a symlink or canonical file name -* rmdir invocation:: Remove empty directories -* unlink invocation:: Remove files via unlink syscall +* link invocation:: Make a hard link via the link syscall +* ln invocation:: Make links between files +* mkdir invocation:: Make directories +* mkfifo invocation:: Make FIFOs (named pipes) +* mknod invocation:: Make block or character special files +* readlink invocation:: Print value of a symlink or canonical file name +* rmdir invocation:: Remove empty directories +* unlink invocation:: Remove files via unlink syscall Changing file attributes -* chown invocation:: Change file owner and group -* chgrp invocation:: Change group ownership -* chmod invocation:: Change access permissions -* touch invocation:: Change file timestamps +* chown invocation:: Change file owner and group +* chgrp invocation:: Change group ownership +* chmod invocation:: Change access permissions +* touch invocation:: Change file timestamps Disk usage -* df invocation:: Report file system disk space usage -* du invocation:: Estimate file space usage -* stat invocation:: Report file or file system status -* sync invocation:: Synchronize data on disk with memory -* truncate invocation:: Shrink or extend the size of a file +* df invocation:: Report file system disk space usage +* du invocation:: Estimate file space usage +* stat invocation:: Report file or file system status +* sync invocation:: Synchronize data on disk with memory +* truncate invocation:: Shrink or extend the size of a file Printing text -* echo invocation:: Print a line of text -* printf invocation:: Format and print data -* yes invocation:: Print a string until interrupted +* echo invocation:: Print a line of text +* printf invocation:: Format and print data +* yes invocation:: Print a string until interrupted Conditions -* false invocation:: Do nothing, unsuccessfully -* true invocation:: Do nothing, successfully -* test invocation:: Check file types and compare values -* expr invocation:: Evaluate expressions +* false invocation:: Do nothing, unsuccessfully +* true invocation:: Do nothing, successfully +* test invocation:: Check file types and compare values +* expr invocation:: Evaluate expressions @command{test}: Check file types and compare values -* File type tests:: File type tests -* Access permission tests:: Access permission tests -* File characteristic tests:: File characteristic tests -* String tests:: String tests -* Numeric tests:: Numeric tests +* File type tests:: File type tests +* Access permission tests:: Access permission tests +* File characteristic tests:: File characteristic tests +* String tests:: String tests +* Numeric tests:: Numeric tests @command{expr}: Evaluate expression -* String expressions:: + : match substr index length -* Numeric expressions:: + - * / % -* Relations for expr:: | & < <= = == != >= > -* Examples of expr:: Examples of using @command{expr} +* String expressions:: + : match substr index length +* Numeric expressions:: + - * / % +* Relations for expr:: | & < <= = == != >= > +* Examples of expr:: Examples of using @command{expr} Redirection @@ -378,6 +379,7 @@ File name manipulation * basename invocation:: Strip directory and suffix from a file name * dirname invocation:: Strip non-directory suffix from a file name * pathchk invocation:: Check file name validity and portability +* mktemp invocation:: Create temporary file or directory Working context @@ -388,13 +390,13 @@ Working context @command{stty}: Print or change terminal characteristics -* Control:: Control settings -* Input:: Input settings -* Output:: Output settings -* Local:: Local settings -* Combination:: Combination settings -* Characters:: Special characters -* Special:: Special settings +* Control:: Control settings +* Input:: Input settings +* Output:: Output settings +* Local:: Local settings +* Combination:: Combination settings +* Characters:: Special characters +* Special:: Special settings User information @@ -409,6 +411,7 @@ System context * arch invocation:: Print machine hardware name * date invocation:: Print or set system date and time +* nproc invocation:: Print the number of processors * uname invocation:: Print system information * hostname invocation:: Print or set system name * hostid invocation:: Print numeric host identifier @@ -420,10 +423,10 @@ System context * Date conversion specifiers:: %[aAbBcCdDeFgGhjmuUVwWxyY] * Literal conversion specifiers:: %[%nt] * Padding and other flags:: Pad with zeros, spaces, etc. -* Setting the time:: Changing the system clock. -* Options for date:: Instead of the current time. -* Date input formats:: Specifying date strings. -* Examples of date:: Examples. +* Setting the time:: Changing the system clock +* Options for date:: Instead of the current time +* Date input formats:: Specifying date strings +* Examples of date:: Examples SELinux context @@ -455,23 +458,23 @@ Numeric operations File permissions -* Mode Structure:: Structure of file mode bits. -* Symbolic Modes:: Mnemonic representation of file mode bits. -* Numeric Modes:: File mode bits as octal numbers. -* Directory Setuid and Setgid:: Set-user-ID and set-group-ID on directories. +* Mode Structure:: Structure of file mode bits +* Symbolic Modes:: Mnemonic representation of file mode bits +* Numeric Modes:: File mode bits as octal numbers +* Directory Setuid and Setgid:: Set-user-ID and set-group-ID on directories Date input formats -* General date syntax:: Common rules. -* Calendar date items:: 19 Dec 1994. -* Time of day items:: 9:20pm. -* Time zone items:: @sc{est}, @sc{pdt}, @sc{gmt}. -* Day of week items:: Monday and others. -* Relative items in date strings:: next tuesday, 2 years ago. -* Pure numbers in date strings:: 19931219, 1440. -* Seconds since the Epoch:: @@1078100502. -* Specifying time zone rules:: TZ="America/New_York", TZ="UTC0". -* Authors of get_date:: Bellovin, Eggert, Salz, Berets, et al. +* General date syntax:: Common rules +* Calendar date items:: 19 Dec 1994 +* Time of day items:: 9:20pm +* Time zone items:: @sc{est}, @sc{pdt}, @sc{gmt} +* Day of week items:: Monday and others +* Relative items in date strings:: next tuesday, 2 years ago +* Pure numbers in date strings:: 19931219, 1440 +* Seconds since the Epoch:: @@1078100502 +* Specifying time zone rules:: TZ="America/New_York", TZ="UTC0" +* Authors of get_date:: Bellovin, Eggert, Salz, Berets, et al Opening the software toolbox @@ -485,7 +488,7 @@ Opening the software toolbox Copying This Manual -* GNU Free Documentation License:: Copying and sharing this manual. +* GNU Free Documentation License:: Copying and sharing this manual @end detailmenu @end menu @@ -574,6 +577,18 @@ Do not treat the last operand specially when it is a directory or a symbolic link to a directory. @xref{Target directory}. @end macro +@macro optNull{cmd} +@item -0 +@opindex -0 +@itemx --null +@opindex --null +@cindex output @sc{nul}-byte-terminated lines +Output a zero byte (@acronym{ASCII} @sc{nul}) at the end of each line, +rather than a newline. This option enables other programs to parse the +output of @command{\cmd\} even when that output would contain data +with embedded newlines. +@end macro + @macro optSi @itemx --si @opindex --si @@ -745,8 +760,8 @@ However, some of the programs documented here do produce other exit status values and a few associate different meanings with the values @samp{0} and @samp{1}. Here are some of the exceptions: -@command{chroot}, @command{env}, @command{expr}, -@command{nice}, @command{nohup}, @command{printenv}, @command{sort}, +@command{chroot}, @command{env}, @command{expr}, @command{nice}, +@command{nohup}, @command{printenv}, @command{sort}, @command{stdbuf}, @command{su}, @command{test}, @command{timeout}, @command{tty}. @@ -2755,8 +2770,10 @@ If you'd like to continue to track the end of a growing file even after it has been unlinked, use @option{--follow=descriptor}. This is the default behavior, but it is not useful if you're tracking a log file that may be rotated (removed or renamed, then reopened). In that case, use -@option{--follow=name} to track the named file by reopening it periodically -to see if it has been removed and recreated by some other program. +@option{--follow=name} to track the named file, perhaps by reopening it +periodically to see if it has been removed and recreated by some other program. +Note that the inotify-based implementation handles this case without +the need for any periodic reopening. No matter which method you use, if the tracked file is determined to have shrunk, @command{tail} prints a message saying the file has been truncated @@ -3847,10 +3864,9 @@ To compare such strings numerically, use the @opindex -V @opindex --version-sort @cindex version number sort -@vindex LC_NUMERIC -Sort per @code{strverscmp(3)}. This is a normal string comparison, except -that embedded decimal numbers are sorted by numeric value -(see @option{--numeric-sort} above). +Sort by version name and number. It behaves like a standard sort, +except that each sequence of decimal digits is treated numerically +as an index/version number. (@xref{Details about version sort}.) @item -r @itemx --reverse @@ -5236,8 +5252,8 @@ the way the linker handled archive files, which has since been solved in different ways. -@node Operating on fields within a line -@chapter Operating on fields within a line +@node Operating on fields +@chapter Operating on fields @menu * cut invocation:: Print selected parts of lines. @@ -6113,8 +6129,9 @@ Exit status: 1 minor problems (e.g., failure to access a file or directory not specified as a command line argument. This happens when listing a directory in which entries are actively being removed or renamed.) -2 serious trouble (e.g., memory exhausted, invalid option or failure - to access file or directory specified as a command line argument) +2 serious trouble (e.g., memory exhausted, invalid option, failure + to access a file or directory specified as a command line argument + or a directory loop) @end display Also see @ref{Common options}. @@ -6123,7 +6140,7 @@ Also see @ref{Common options}. * Which files are listed:: * What information is listed:: * Sorting the output:: -* More details about version sort:: +* Details about version sort:: * General output formatting:: * Formatting file timestamps:: * Formatting the file names:: @@ -6653,7 +6670,7 @@ directories, since not doing any sorting can be noticeably faster. @opindex version@r{, sorting option for @command{ls}} Sort by version name and number, lowest first. It behaves like a default sort, except that each sequence of decimal digits is treated numerically -as an index/version number. (@xref{More details about version sort}.) +as an index/version number. (@xref{Details about version sort}.) @item -X @itemx --sort=extension @@ -6666,26 +6683,20 @@ after the last @samp{.}); files with no extension are sorted first. @end table -@node More details about version sort -@subsection More details about version sort +@node Details about version sort +@subsection Details about version sort -The version sort takes into account the fact that file names frequently include -indices or version numbers. Standard sorting functions usually do not produce -the ordering that people expect because comparisons are made on a -character-by-character basis. The version -sort addresses this problem, and is especially useful when browsing -directories that contain many files with indices/version numbers in their -names: +Version sorting handles the fact that file names frequently include indices or +version numbers. Standard sorting usually does not produce the order that one +expects because comparisons are made on a character-by-character basis. +Version sorting is especially useful when browsing directories that contain +many files with indices/version numbers in their names: @example $ ls -1 $ ls -1v -foo.zml-1.gz foo.zml-1.gz -foo.zml-100.gz foo.zml-2.gz -foo.zml-12.gz foo.zml-6.gz -foo.zml-13.gz foo.zml-12.gz -foo.zml-2.gz foo.zml-13.gz -foo.zml-25.gz foo.zml-25.gz -foo.zml-6.gz foo.zml-100.gz +abc.zml-1.gz abc.zml-1.gz +abc.zml-12.gz abc.zml-2.gz +abc.zml-2.gz abc.zml-12.gz @end example Version-sorted strings are compared such that if @var{ver1} and @var{ver2} @@ -6704,11 +6715,27 @@ abc-1.012b.tgz abc-1.007.tgz abc-1.01a.tgz abc-1.012b.tgz @end example -This functionality is implemented using gnulib's @code{filevercmp} function. -One result of that implementation decision is that @samp{ls -v} -and @samp{sort -V} do not use the locale category, @env{LC_COLLATE}, -which means non-numeric prefixes are sorted as if @env{LC_COLLATE} were set -to @samp{C}. +This functionality is implemented using gnulib's @code{filevercmp} function, +which has some caveats worth noting. + +@itemize @bullet +@item @env{LC_COLLATE} is ignored, which means @samp{ls -v} and @samp{sort -V} +will sort non-numeric prefixes as if the @env{LC_COLLATE} locale category +was set to @samp{C}. +@item Some suffixes will not be matched by the regular +expression mentioned above. Consequently these examples may +not sort as you expect: + +@example +abc-1.2.3.4.7z +abc-1.2.3.7z +@end example + +@example +abc-1.2.3.4.x86_64.rpm +abc-1.2.3.x86_64.rpm +@end example +@end itemize @node General output formatting @subsection General output formatting @@ -8753,6 +8780,11 @@ On a @acronym{GNU} system, this command acts like @samp{ln --directory not specified by @acronym{POSIX}, and the @command{link} command is more portable in practice. +If @var{filename} is a symbolic link, it is unspecified whether +@var{linkname} will be a hard link to the symbolic link or to the +target of the symbolic link. Use @command{ln -P} or @command{ln -L} +to specify which behavior is desired. + @exitstatus @@ -8808,8 +8840,10 @@ A @dfn{hard link} is another name for an existing file; the link and the original are indistinguishable. Technically speaking, they share the same inode, and the inode contains all the information about a file---indeed, it is not incorrect to say that the inode @emph{is} the -file. On all existing implementations, you cannot make a hard link to -a directory, and hard links cannot cross file system boundaries. (These +file. Most systems prohibit making a hard link to +a directory; on those where it is allowed, only the super-user can do +so (and with caution, since creating a cycle will cause problems to many +other utilities). Hard links cannot cross file system boundaries. (These restrictions are not mandated by @acronym{POSIX}, however.) @cindex dereferencing symbolic links @@ -8821,9 +8855,13 @@ refers to a different file, by name. When most operations (opening, reading, writing, and so on) are passed the symbolic link file, the kernel automatically @dfn{dereferences} the link and operates on the target of the link. But some operations (e.g., removing) work on the -link file itself, rather than on its target. The owner, group, and -mode of a symlink are not significant to file access performed through -the link. @xref{Symbolic Links,,, +link file itself, rather than on its target. The owner and group of a +symlink are not significant to file access performed through +the link, but do have implications on deleting a symbolic link from a +directory with the restricted deletion bit set. On the GNU system, +the mode of a symlink has no significance and cannot be changed, but +on some BSD systems, the mode can be changed and will affect whether +the symlink will be traversed in file name resolution. @xref{Symbolic Links,,, libc, The GNU C Library Reference Manual}. Symbolic links can contain arbitrary strings; a @dfn{dangling symlink} @@ -8878,6 +8916,14 @@ Remove existing destination files. @cindex prompting, and @command{ln} Prompt whether to remove existing destination files. +@item -L +@itemx --logical +@opindex -L +@opindex --logical +If @option{-s} is not in effect, and the source file is a symbolic +link, create the hard link to the file referred to by the symbolic +link, rather than the symbolic link itself. + @item -n @itemx --no-dereference @opindex -n @@ -8899,6 +8945,17 @@ just like a directory. This option is weaker than the @option{--no-target-directory} (@option{-T}) option, so it has no effect if both options are given. +@item -P +@itemx --physical +@opindex -P +@opindex --physical +If @option{-s} is not in effect, and the source file is a symbolic +link, create the hard link to the symbolic link itself. On platforms +where this is not supported by the kernel, this option creates a +symbolic link with identical contents; since symbolic link contents +cannot be edited, any file name resolution performed through either +link will be the same as if a hard link had been created. + @item -s @itemx --symbolic @opindex -s @@ -8920,6 +8977,15 @@ Print the name of each file after linking it successfully. @end table +@cindex hard links to symbolic links +@cindex symbolic links and @command{ln} +If @option{-L} and @option{-P} are both given, the last one takes +precedence. If @option{-s} is also given, @option{-L} and @option{-P} +are silently ignored. If neither option is given, then this +implementation defaults to @option{-P} if the system @code{link} supports +hard links to symbolic links (such as the GNU system), and @option{-L} +if @code{link} follows symbolic links (such as on BSD). + @exitstatus Examples: @@ -9204,7 +9270,8 @@ The program accepts the following options. Also see @ref{Common options}. @opindex --canonicalize Activate canonicalize mode. If any component of the file name except the last one is missing or unavailable, -@command{readlink} produces no output and exits with a nonzero exit code. +@command{readlink} produces no output and exits with a nonzero exit +code. A trailing slash is ignored. @item -e @itemx --canonicalize-existing @@ -9212,7 +9279,8 @@ If any component of the file name except the last one is missing or unavailable, @opindex --canonicalize-existing Activate canonicalize mode. If any component is missing or unavailable, @command{readlink} produces -no output and exits with a nonzero exit code. +no output and exits with a nonzero exit code. A trailing slash +requires that the name resolve to a directory. @item -m @itemx --canonicalize-missing @@ -9813,7 +9881,9 @@ touch [@var{option}]@dots{} @var{file}@dots{} @end example @cindex empty files, creating -Any @var{file} argument that does not exist is created empty. +Any @var{file} argument that does not exist is created empty, unless +option @option{--no-create} (@option{-c}) or @option{--no-dereference} +(@option{-h}) was in effect. A @var{file} argument string of @samp{-} is handled specially and causes @command{touch} to change the times of the file associated with @@ -9827,8 +9897,8 @@ user must own the files. Although @command{touch} provides options for changing two of the times---the times of last access and modification---of a file, there is actually -a third one as well: the inode change time. This is often referred to -as a file's @code{ctime}. +a standard third one as well: the inode change time. This is often +referred to as a file's @code{ctime}. The inode change time represents the time when the file's meta-information last changed. One common example of this is when the permissions of a file change. Changing the permissions doesn't access the file, so @@ -9840,6 +9910,9 @@ fresh copy of the file, including the new permissions value. Another operation that modifies a file's ctime without affecting the others is renaming. In any case, it is not possible, in normal operations, for a user to change the ctime field to a user-specified value. +Some operating systems and file systems support a fourth time: the +birth time, when the file was first created; by definition, this +timestamp never changes. @vindex TZ Time stamps assume the time zone rules specified by the @env{TZ} @@ -9868,7 +9941,7 @@ Change the access time only. @itemx --no-create @opindex -c @opindex --no-create -Do not create files that do not exist. +Do not warn about or create files that do not exist. @item -d @itemx --date=@var{time} @@ -9889,6 +9962,24 @@ silently ignore any excess precision here. @cindex BSD @command{touch} compatibility Ignored; for compatibility with BSD versions of @command{touch}. +@item -h +@itemx --no-dereference +@opindex -h +@opindex --no-dereference +@cindex symbolic links, changing time +@findex lutimes +Attempt to change the timestamps of a symbolic link, rather than what +the link refers to. When using this option, empty files are not +created, but option @option{-c} must also be used to avoid warning +about files that do not exist. Not all systems support changing the +timestamps of symlinks, since underlying system support for this +action was not required until @acronym{POSIX} 2008. Also, on some +systems, the mere act of examining a symbolic link changes the access +time, such that only changes to the modification time will persist +long enough to be observable. When coupled with option @option{-r}, a +reference timestamp is taken from a symbolic link rather than the file +it refers to. + @item -m @itemx --time=mtime @itemx --time=modify @@ -9908,6 +9999,8 @@ If this option is combined with the @option{--date=@var{time}} the origin for any relative @var{time}s given, but is otherwise ignored. For example, @samp{-r foo -d '-5 seconds'} specifies a time stamp equal to five seconds before the corresponding time stamp for @file{foo}. +If @var{file} is a symbolic link, the reference timestamp is taken +from the target of the symlink, unless @option{-h} was also in effect. @item -t [[@var{cc}]@var{yy}]@var{mmddhhmm}[.@var{ss}] Use the argument (optional four-digit or two-digit years, months, @@ -9916,6 +10009,7 @@ If the year is specified with only two digits, then @var{cc} is 20 for years in the range 0 @dots{} 68, and 19 for years in 69 @dots{} 99. If no digits of the year are specified, the argument is interpreted as a date in the current year. +Note that @var{ss} may be @samp{60}, to accommodate leap seconds. @end table @@ -10308,15 +10402,7 @@ Show the total for each directory (and file if --all) that is at most MAX_DEPTH levels down from the root of the hierarchy. The root is at level 0, so @code{du --max-depth=0} is equivalent to @code{du -s}. -@item -0 -@opindex -0 -@itemx --null -@opindex --null -@cindex output null-byte-terminated lines -Output a zero byte (@acronym{ASCII} @sc{nul}) at the end of each line, -rather than a newline. This option enables other programs to parse the -output of @command{du} even when that output would contain file names -with embedded newlines. +@optNull{du} @optSi @@ -10728,6 +10814,8 @@ alert (bell) backspace @item \c produce no further output +@item \e +escape @item \f form feed @item \n @@ -11802,6 +11890,7 @@ This section describes commands that manipulate file names. * basename invocation:: Strip directory and suffix from a file name. * dirname invocation:: Strip non-directory suffix from a file name. * pathchk invocation:: Check file name validity and portability. +* mktemp invocation:: Create temporary file or directory. @end menu @@ -11976,6 +12065,180 @@ Exit status: 1 otherwise. @end display +@node mktemp invocation +@section @command{mktemp}: Create temporary file or directory + +@pindex mktemp +@cindex file names, creating temporary +@cindex directory, creating temporary +@cindex temporary files and directories + +@command{mktemp} manages the creation of temporary files and +directories. Synopsis: + +@example +mktemp [@var{option}]@dots{} [@var{template}] +@end example + +Safely create a temporary file or directory based on @var{template}, +and print its name. If given, @var{template} must include at least +three consecutive @samp{X}s in the last component. If omitted, the template +@samp{tmp.XXXXXXXXXX} is used, and option @option{--tmpdir} is +implied. The final run of @samp{X}s in the @var{template} will be replaced +by alpha-numeric characters; thus, on a case-sensitive file system, +and with a @var{template} including a run of @var{n} instances of @samp{X}, +there are @samp{62**@var{n}} potential file names. + +Older scripts used to create temporary files by simply joining the +name of the program with the process id (@samp{$$}) as a suffix. +However, that naming scheme is easily predictable, and suffers from a +race condition where the attacker can create an appropriately named +symbolic link, such that when the script then opens a handle to what +it thought was an unused file, it is instead modifying an existing +file. Using the same scheme to create a directory is slightly safer, +since the @command{mkdir} will fail if the target already exists, but +it is still inferior because it allows for denial of service attacks. +Therefore, modern scripts should use the @command{mktemp} command to +guarantee that the generated name will be unpredictable, and that +knowledge of the temporary file name implies that the file was created +by the current script and cannot be modified by other users. + +When creating a file, the resulting file has read and write +permissions for the current user, but no permissions for the group or +others; these permissions are reduced if the current umask is more +restrictive. + +Here are some examples (although note that if you repeat them, you +will most likely get different file names): + +@itemize @bullet + +@item +Create a temporary file in the current directory. +@example +$ mktemp file.XXXX +file.H47c +@end example + +@item +Create a temporary file with a known suffix. +@example +$ mktemp --suffix=.txt file-XXXX +file-H08W.txt +$ mktemp file-XXXX-XXXX.txt +file-XXXX-eI9L.txt +@end example + +@item +Create a secure fifo relative to the user's choice of @env{TMPDIR}, +but falling back to the current directory rather than @file{/tmp}. +Note that @command{mktemp} does not create fifos, but can create a +secure directory in which the fifo can live. Exit the shell if the +directory or fifo could not be created. +@example +$ dir=$(mktemp -p "$@{TMPDIR:-.@}" -d dir-XXXX) || exit 1 +$ fifo=$dir/fifo +$ mkfifo "$fifo" || @{ rmdir "$dir"; exit 1; @} +@end example + +@item +Create and use a temporary file if possible, but ignore failure. The +file will reside in the directory named by @env{TMPDIR}, if specified, +or else in @file{/tmp}. +@example +$ file=$(mktemp -q) && @{ +> # Safe to use $file only within this block. Use quotes, +> # since $TMPDIR, and thus $file, may contain whitespace. +> echo ... > "$file" +> rm "$file" +> @} +@end example + +@item +Act as a semi-random character generator (it is not fully random, +since it is impacted by the contents of the current directory). To +avoid security holes, do not use the resulting names to create a file. +@example +$ mktemp -u XXX +Gb9 +$ mktemp -u XXX +nzC +@end example + +@end itemize + +The program accepts the following options. Also see @ref{Common options}. + +@table @samp + +@item -d +@itemx --directory +@opindex -d +@opindex --directory +Create a directory rather than a file. The directory will have read, +write, and search permissions for the current user, but no permissions +for the group or others; these permissions are reduced if the current +umask is more restrictive. + +@item -q +@itemx --quiet +@opindex -q +@opindex --quiet +Suppress diagnostics about failure to create a file or directory. The +exit status will still reflect whether a file was created. + +@item -u +@itemx --dry-run +@opindex -u +@opindex --dry-run +Generate a temporary name that does not name an existing file, without +changing the file system contents. Using the output of this command +to create a new file is inherently unsafe, as there is a window of +time between generating the name and using it where another process +can create an object by the same name. + +@item -p @var{dir} +@itemx --tmpdir[=@var{dir}] +@opindex -p +@opindex --tmpdir +Treat @var{template} relative to the directory @var{dir}. If +@var{dir} is not specified (only possible with the long option +@option{--tmpdir}) or is the empty string, use the value of +@env{TMPDIR} if available, otherwise use @samp{/tmp}. If this is +specified, @var{template} must not be absolute. However, +@var{template} can still contain slashes, although intermediate +directories must already exist. + +@item --suffix=@var{suffix} +@opindex --suffix +Append @var{suffix} to the @var{template}. @var{suffix} must not +contain slash. If @option{--suffix} is specified, @var{template} must +end in @samp{X}; if it is not specified, then an appropriate +@option{--suffix} is inferred by finding the last @samp{X} in +@var{template}. This option exists for use with the default +@var{template} and for the creation of a @var{suffix} that starts with +@samp{X}. + +@item -t +@opindex -t +Treat @var{template} as a single file relative to the value of +@env{TMPDIR} if available, or to the directory specified by +@option{-p}, otherwise to @samp{/tmp}. @var{template} must not +contain slashes. This option is deprecated; the use of @option{-p} +without @option{-t} offers better defaults (by favoring the command +line over @env{TMPDIR}) and more flexibility (by allowing intermediate +directories). + +@end table + +@cindex exit status of @command{mktemp} +Exit status: + +@display +0 if the file was created, +1 otherwise. +@end display + @node Working context @chapter Working context @@ -12738,8 +13001,13 @@ If no @var{variable}s are specified, @command{printenv} prints the value of every environment variable. Otherwise, it prints the value of each @var{variable} that is set, and nothing for those that are not set. -The only options are a lone @option{--help} or @option{--version}. -@xref{Common options}. +The program accepts the following option. Also see @ref{Common options}. + +@table @samp + +@optNull{printenv} + +@end table @cindex exit status of @command{printenv} Exit status: @@ -12825,9 +13093,13 @@ running it if no user is specified. Synopsis: id [@var{option}]@dots{} [@var{username}] @end example +@vindex POSIXLY_CORRECT By default, it prints the real user ID, real group ID, effective user ID if different from the real user ID, effective group ID if different from the real group ID, and supplemental group IDs. +In addition, if SELinux +is enabled and the @env{POSIXLY_CORRECT} environment variable is not set, +then print @samp{context=@var{c}}, where @var{c} is the security context. Each of these numeric values is preceded by an identifying string and followed by the corresponding user or group name in parentheses. @@ -13149,6 +13421,7 @@ information. @menu * date invocation:: Print or set system date and time. * arch invocation:: Print machine hardware name. +* nproc invocation:: Print the number of processors. * uname invocation:: Print system information. * hostname invocation:: Print or set system name. * hostid invocation:: Print numeric host identifier. @@ -13808,6 +14081,43 @@ The program accepts the @ref{Common options} only. @exitstatus +@node nproc invocation +@section @command{nproc}: Print the number of available processors + +@pindex nproc +@cindex Print the number of processors +@cindex system information, printing + +Print the number of processing units available to the current process, +which may be less than the number of online processors. +If this information is not accessible, then print the number of +processors installed. If the @env{OMP_NUM_THREADS} environment variable is +set, then it will determine the returned value. The result is guaranteed to be +greater than zero. Synopsis: + +@example +nproc [@var{option}] +@end example + +The program accepts the following options. Also see @ref{Common options}. + +@table @samp + +@item --all +@opindex --all +Print the number of installed processors on the system, which may +be greater than the number online or available to the current process. +The @env{OMP_NUM_THREADS} environment variable is not honored in this case. + +@item --ignore=@var{number} +@opindex --ignore +If possible, exclude this @var{number} of processing units. + +@end table + +@exitstatus + + @node uname invocation @section @command{uname}: Print system information @@ -14291,7 +14601,7 @@ device files), copy them into place, too. Exit status: @display -1 if @command{chroot} itself fails +125 if @command{chroot} itself fails 126 if @var{command} is found but cannot be invoked 127 if @var{command} cannot be found the exit status of @var{command} otherwise @@ -14336,17 +14646,89 @@ remaining arguments are passed as arguments to that program. The program should not be a special built-in utility (@pxref{Special built-in utilities}). +Modifications to @env{PATH} take effect prior to searching for +@var{command}. Use caution when reducing @env{PATH}; behavior is +not portable when @env{PATH} is undefined or omits key directories +such as @file{/bin}. + +In the rare case that a utility contains a @samp{=} in the name, the +only way to disambiguate it from a variable assignment is to use an +intermediate command for @var{command}, and pass the problematic +program name via @var{args}. For example, if @file{./prog=} is an +executable in the current @env{PATH}: + +@example +env prog= true # runs 'true', with prog= in environment +env ./prog= true # runs 'true', with ./prog= in environment +env -- prog= true # runs 'true', with prog= in environment +env sh -c '\prog= true' # runs 'prog=' with argument 'true' +env sh -c 'exec "$@@"' sh prog= true # also runs 'prog=' +@end example + @cindex environment, printing If no command name is specified following the environment specifications, the resulting environment is printed. This is like specifying the @command{printenv} program. +For some examples, suppose the environment passed to @command{env} +contains @samp{LOGNAME=rms}, @samp{EDITOR=emacs}, and +@samp{PATH=.:/gnubin:/hacks}: + +@itemize @bullet + +@item +Output the current environment. +@example +$ env | LC_ALL=C sort +EDITOR=emacs +LOGNAME=rms +PATH=.:/gnubin:/hacks +@end example + +@item +Run @command{foo} with a reduced environment, preserving only the +original @env{PATH} to avoid problems in locating @command{foo}. +@example +env - PATH="$PATH" foo +@end example + +@item +Run @command{foo} with the environment containing @samp{LOGNAME=rms}, +@samp{EDITOR=emacs}, and @samp{PATH=.:/gnubin:/hacks}, and guarantees +that @command{foo} was found in the file system rather than as a shell +built-in. +@example +env foo +@end example + +@item +Run @command{nemacs} with the environment containing @samp{LOGNAME=foo}, +@samp{EDITOR=emacs}, @samp{PATH=.:/gnubin:/hacks}, and +@samp{DISPLAY=gnu:0}. +@example +env DISPLAY=gnu:0 LOGNAME=foo nemacs +@end example + +@item +Attempt to run the program @command{/energy/--} (as that is the only +possible path search result); if the command exists, the environment +will contain @samp{LOGNAME=rms} and @samp{PATH=/energy}, and the +arguments will be @samp{e=mc2}, @samp{bar}, and @samp{baz}. +@example +env -u EDITOR PATH=/energy -- e=mc2 bar baz +@end example + +@end itemize + + The program accepts the following options. Also see @ref{Common options}. Options must precede operands. @table @samp +@optNull{env} + @item -u @var{name} @itemx --unset=@var{name} @opindex -u @@ -14369,7 +14751,7 @@ Exit status: @display 0 if no @var{command} is specified and the environment is output -1 if @command{env} itself fails +125 if @command{env} itself fails 126 if @var{command} is found but cannot be invoked 127 if @var{command} cannot be found the exit status of @var{command} otherwise @@ -14444,7 +14826,7 @@ Exit status: @display 0 if no @var{command} is specified and the niceness is output -1 if @command{nice} itself fails +125 if @command{nice} itself fails 126 if @var{command} is found but cannot be invoked 127 if @var{command} cannot be found the exit status of @var{command} otherwise @@ -14562,11 +14944,15 @@ options}. Options must precede operands. Exit status: @display +125 if @command{nohup} itself fails, and @env{POSIXLY_CORRECT} is not set 126 if @var{command} is found but cannot be invoked -127 if @command{nohup} itself fails or if @var{command} cannot be found +127 if @var{command} cannot be found the exit status of @var{command} otherwise @end display +If @env{POSIXLY_CORRECT} is set, internal failures give status 127 +instead of 125. + @node stdbuf invocation @section @command{stdbuf}: Run a command with modified I/O stream buffering @@ -14771,7 +15157,7 @@ shell is restricted (see @option{-m} just above). Exit status: @display -1 if @command{su} itself fails +125 if @command{su} itself fails 126 if subshell is found but cannot be invoked 127 if subshell cannot be found the exit status of the subshell otherwise diff --git a/src/bin/coreutils/doc/getdate.texi b/src/bin/coreutils/doc/getdate.texi index e7947800d3..48e8b68343 100644 --- a/src/bin/coreutils/doc/getdate.texi +++ b/src/bin/coreutils/doc/getdate.texi @@ -1,7 +1,7 @@ @c GNU date syntax documentation -@c Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -@c 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +@c Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, +@c 2004, 2005, 2006, 2009, 2010 Free Software Foundation, Inc. @c Permission is granted to copy, distribute and/or modify this document @c under the terms of the GNU Free Documentation License, Version 1.3 or diff --git a/src/bin/coreutils/doc/perm.texi b/src/bin/coreutils/doc/perm.texi index 221505ded7..5ee677fb37 100644 --- a/src/bin/coreutils/doc/perm.texi +++ b/src/bin/coreutils/doc/perm.texi @@ -1,7 +1,7 @@ @c File mode bits -@c Copyright (C) 1994, 1996, 1999-2001, 2003-2006, -@c 2008-2009 Free Software Foundation, Inc. +@c Copyright (C) 1994, 1996, 1999-2001, 2003-2006, 2008-2010 Free Software +@c Foundation, Inc. @c Permission is granted to copy, distribute and/or modify this document @c under the terms of the GNU Free Documentation License, Version 1.3 or diff --git a/src/bin/coreutils/doc/stamp-vti b/src/bin/coreutils/doc/stamp-vti index 39a3ddb05d..1dfc08ce94 100644 --- a/src/bin/coreutils/doc/stamp-vti +++ b/src/bin/coreutils/doc/stamp-vti @@ -1,4 +1,4 @@ -@set UPDATED 10 September 2009 -@set UPDATED-MONTH September 2009 -@set EDITION 7.6 -@set VERSION 7.6 +@set UPDATED 3 January 2010 +@set UPDATED-MONTH January 2010 +@set EDITION 8.4 +@set VERSION 8.4 diff --git a/src/bin/coreutils/doc/version.texi b/src/bin/coreutils/doc/version.texi index 39a3ddb05d..1dfc08ce94 100644 --- a/src/bin/coreutils/doc/version.texi +++ b/src/bin/coreutils/doc/version.texi @@ -1,4 +1,4 @@ -@set UPDATED 10 September 2009 -@set UPDATED-MONTH September 2009 -@set EDITION 7.6 -@set VERSION 7.6 +@set UPDATED 3 January 2010 +@set UPDATED-MONTH January 2010 +@set EDITION 8.4 +@set VERSION 8.4 diff --git a/src/bin/coreutils/lib/ChangeLog-2007 b/src/bin/coreutils/lib/ChangeLog-2007 index 21a454f4c3..e97df02fe0 100644 --- a/src/bin/coreutils/lib/ChangeLog-2007 +++ b/src/bin/coreutils/lib/ChangeLog-2007 @@ -8746,7 +8746,7 @@ ----- - Copyright (C) 2000-2009 Free Software Foundation, Inc. + Copyright (C) 2000-2010 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted provided the copyright notice diff --git a/src/bin/coreutils/lib/Jamfile b/src/bin/coreutils/lib/Jamfile index 69d4a6b98d..329515191e 100644 --- a/src/bin/coreutils/lib/Jamfile +++ b/src/bin/coreutils/lib/Jamfile @@ -22,6 +22,7 @@ StaticLibrary libfetish.a : backupfile.c base64.c basename.c + basename-lgpl.c buffer-lcm.c c-strcasecmp.c c-strtod.c @@ -40,6 +41,7 @@ StaticLibrary libfetish.a : diacrit.c dirchownmod.c dirname.c + dirname-lgpl.c dup-safer.c # dup2.c error.c @@ -51,6 +53,7 @@ StaticLibrary libfetish.a : fchmodat.c fchownat.c # fchown-stub.c + fcntl.c fd-reopen.c fd-safer.c file-has-acl.c @@ -59,14 +62,17 @@ StaticLibrary libfetish.a : # fileblocks.c filemode.c filenamecat.c + filenamecat-lgpl.c filevercmp.c fnmatch.c + fopen.c fopen-safer.c fpending.c fprintftime.c freadahead.c freadptr.c freadseek.c + freopen-safer.c # fsusage.c # ftruncate.c fts.c @@ -133,11 +139,14 @@ StaticLibrary libfetish.a : modechange.c # mountlist.c nanosleep.c + nproc.c # obstack.c offtostr.c + open.c open-safer.c openat-die.c openat-proc.c + openat-safer.c openat.c opendir-safer.c physmem.c @@ -158,7 +167,6 @@ StaticLibrary libfetish.a : readtokens0.c # realloc.c # regex.c - rename-dest-slash.c rename.c root-dev-ino.c # rmdir.c @@ -196,7 +204,6 @@ StaticLibrary libfetish.a : # strtoul.c # strtoull.c # strtoumax.c - strverscmp.c # tempname.c time_r.c trim.c @@ -205,7 +212,6 @@ StaticLibrary libfetish.a : uinttostr.c umaxtostr.c unicodeio.c - unlinkdir.c unsetenv.c userspec.c # utime.c diff --git a/src/bin/coreutils/lib/Makefile.am b/src/bin/coreutils/lib/Makefile.am index 074cc9cfc7..c89ef751d9 100644 --- a/src/bin/coreutils/lib/Makefile.am +++ b/src/bin/coreutils/lib/Makefile.am @@ -1,6 +1,6 @@ ## Makefile for gnulib/lib -*-Makefile-*- -# Copyright (C) 1995-2007, 2009 Free Software Foundation, Inc. +# Copyright (C) 1995-2007, 2009-2010 Free Software Foundation, Inc. ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -17,7 +17,7 @@ include gnulib.mk -AM_CFLAGS += $(WARN_CFLAGS) # $(WERROR_CFLAGS) +AM_CFLAGS += $(GNULIB_WARN_CFLAGS) $(WERROR_CFLAGS) libcoreutils_a_SOURCES += \ buffer-lcm.c buffer-lcm.h \ diff --git a/src/bin/coreutils/lib/Makefile.in b/src/bin/coreutils/lib/Makefile.in index 8181cd0ad4..4323321536 100644 --- a/src/bin/coreutils/lib/Makefile.in +++ b/src/bin/coreutils/lib/Makefile.in @@ -15,9 +15,9 @@ @SET_MAKE@ -# Copyright (C) 1995-2007, 2009 Free Software Foundation, Inc. +# Copyright (C) 1995-2007, 2009-2010 Free Software Foundation, Inc. -# Copyright (C) 2002-2009 Free Software Foundation, Inc. +# Copyright (C) 2002-2010 Free Software Foundation, Inc. # # This file is free software, distributed under the terms of the GNU # General Public License. As a special exception to the GNU General @@ -26,7 +26,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl --lib=libcoreutils --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=gnulib-tests --aux-dir=build-aux --with-tests --avoid=canonicalize-lgpl --avoid=dummy --avoid=lock --no-libtool --macro-prefix=gl acl alloca announce-gen areadlink-with-size argmatch argv-iter assert atexit autobuild backupfile base64 c-strcase c-strtod c-strtold calloc canon-host canonicalize chown cloexec closein closeout config-h configmake crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 cycle-check d-ino d-type diacrit dirfd dirname dup2 error euidaccess exclude exitfail fchdir fcntl fcntl-safer fdl file-type fileblocks filemode filenamecat filevercmp fnmatch-gnu fopen-safer fprintftime fseeko fsusage ftello ftruncate fts gendocs getdate getgroups gethrxtime getline getloadavg getndelim2 getopt-gnu getpagesize getpass-gnu gettext gettime gettimeofday getugroups getusershell git-version-gen gitlog-to-changelog gnu-make gnumakefile gnupload group-member hard-locale hash hash-pjw host-os human idcache ignore-value inttostr inttypes isapipe lchmod lchown lib-ignore linebuffer link link-follow long-options lstat maintainer-makefile malloc manywarnings mbrtowc mbsalign mbswidth memcasecmp memchr memcmp memcmp2 memcpy memmove mempcpy memrchr memset mgetgroups mkancesdirs mkdir mkdir-p mkstemp mktime modechange mountlist mpsort obstack pathmax perl physmem posix-shell posixtm posixver priv-set progname propername putenv quote quotearg raise randint randperm readlink readtokens readtokens0 readutmp realloc regex rename rename-dest-slash rmdir rmdir-errno root-dev-ino rpmatch safe-read same save-cwd savedir savewd selinux-at settime sig2str sigaction ssize_t stat-macros stat-time stdbool stdlib-safer stpcpy stpncpy strcspn strdup strftime strpbrk strtod strtoimax strtol strtoumax strverscmp sys_stat timespec tzset unicodeio unistd-safer unlink-busy unlinkdir unlocked-io update-copyright uptime useless-if-before-free userspec utimecmp utimens vasprintf-posix vc-list-files verify verror version-etc-fsf warnings wcwidth winsz-ioctl winsz-termios write-any-file xalloc xfreopen xgetcwd xgethostname xmemcoll xnanosleep xprintf xprintf-posix xstrtod xstrtoimax xstrtol xstrtold xstrtoumax yesno +# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl --lib=libcoreutils --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=gnulib-tests --aux-dir=build-aux --with-tests --avoid=canonicalize-lgpl --avoid=dummy --no-libtool --macro-prefix=gl acl alloca announce-gen areadlink-with-size argmatch argv-iter assert atexit autobuild backupfile base64 c-strcase c-strtod c-strtold calloc canon-host canonicalize chown cloexec closein closeout config-h configmake crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 cycle-check d-ino d-type diacrit dirfd dirname do-release-commit-and-tag dup2 environ error euidaccess exclude exitfail faccessat fchdir fcntl fcntl-safer fdl file-type fileblocks filemode filenamecat filevercmp fnmatch-gnu fopen-safer fprintftime freopen freopen-safer fseeko fsusage fsync ftello ftruncate fts getdate getgroups gethrxtime getline getloadavg getndelim2 getopt-gnu getpagesize getpass-gnu gettext gettime gettimeofday getugroups getusershell git-version-gen gitlog-to-changelog gnu-make gnu-web-doc-update gnumakefile gnupload group-member hard-locale hash hash-pjw host-os human idcache ignore-value inttostr inttypes isapipe isblank lchmod lchown lib-ignore linebuffer link link-follow linkat long-options lstat maintainer-makefile malloc manywarnings mbrtowc mbsalign mbswidth memcasecmp memchr memcmp memcmp2 memcpy memmove mempcpy memrchr memset mgetgroups mkancesdirs mkdir mkdir-p mkstemp mktime modechange mountlist mpsort nproc obstack pathmax perl physmem posix-shell posixtm posixver priv-set progname propername putenv quote quotearg raise randint randperm readlink readtokens readtokens0 readutmp realloc regex remove rename rmdir root-dev-ino rpmatch safe-read same save-cwd savedir savewd selinux-at settime sig2str sigaction ssize_t stat-macros stat-time stdbool stdlib-safer stpcpy stpncpy strcspn strdup-posix strftime strpbrk strsignal strtod strtoimax strtol strtoumax symlink sys_stat timespec tzset uname unicodeio unistd-safer unlink-busy unlocked-io unsetenv update-copyright uptime useless-if-before-free userspec utimecmp utimens vasprintf-posix vc-list-files verify verror version-etc-fsf wcwidth winsz-ioctl winsz-termios write-any-file xalloc xfreopen xgetcwd xgethostname xmemcoll xnanosleep xprintf xprintf-posix xreadlink xstrtod xstrtoimax xstrtol xstrtold xstrtoumax yesno @@ -71,35 +71,40 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/cloexec.m4 $(top_srcdir)/m4/close-stream.m4 \ $(top_srcdir)/m4/close.m4 $(top_srcdir)/m4/closein.m4 \ $(top_srcdir)/m4/closeout.m4 $(top_srcdir)/m4/codeset.m4 \ - $(top_srcdir)/m4/config-h.m4 $(top_srcdir)/m4/cycle-check.m4 \ - $(top_srcdir)/m4/d-ino.m4 $(top_srcdir)/m4/d-type.m4 \ - $(top_srcdir)/m4/dirent-safer.m4 $(top_srcdir)/m4/dirent_h.m4 \ - $(top_srcdir)/m4/dirfd.m4 $(top_srcdir)/m4/dirname.m4 \ - $(top_srcdir)/m4/dos.m4 $(top_srcdir)/m4/double-slash-root.m4 \ - $(top_srcdir)/m4/dup2.m4 $(top_srcdir)/m4/eealloc.m4 \ - $(top_srcdir)/m4/environ.m4 $(top_srcdir)/m4/errno_h.m4 \ - $(top_srcdir)/m4/error.m4 $(top_srcdir)/m4/euidaccess-stat.m4 \ + $(top_srcdir)/m4/config-h.m4 $(top_srcdir)/m4/ctype.m4 \ + $(top_srcdir)/m4/cycle-check.m4 $(top_srcdir)/m4/d-ino.m4 \ + $(top_srcdir)/m4/d-type.m4 $(top_srcdir)/m4/dirent-safer.m4 \ + $(top_srcdir)/m4/dirent_h.m4 $(top_srcdir)/m4/dirfd.m4 \ + $(top_srcdir)/m4/dirname.m4 $(top_srcdir)/m4/dos.m4 \ + $(top_srcdir)/m4/double-slash-root.m4 $(top_srcdir)/m4/dup2.m4 \ + $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/environ.m4 \ + $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/error.m4 \ + $(top_srcdir)/m4/euidaccess-stat.m4 \ $(top_srcdir)/m4/euidaccess.m4 $(top_srcdir)/m4/exclude.m4 \ $(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/exponentd.m4 \ $(top_srcdir)/m4/exponentf.m4 $(top_srcdir)/m4/exponentl.m4 \ - $(top_srcdir)/m4/extensions.m4 $(top_srcdir)/m4/fchdir.m4 \ - $(top_srcdir)/m4/fclose.m4 $(top_srcdir)/m4/fcntl-safer.m4 \ - $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/fd-reopen.m4 \ - $(top_srcdir)/m4/fdopendir.m4 $(top_srcdir)/m4/fflush.m4 \ - $(top_srcdir)/m4/file-type.m4 $(top_srcdir)/m4/fileblocks.m4 \ - $(top_srcdir)/m4/filemode.m4 $(top_srcdir)/m4/filenamecat.m4 \ - $(top_srcdir)/m4/flexmember.m4 $(top_srcdir)/m4/float_h.m4 \ - $(top_srcdir)/m4/fnmatch.m4 $(top_srcdir)/m4/fopen.m4 \ - $(top_srcdir)/m4/fpending.m4 $(top_srcdir)/m4/fpieee.m4 \ - $(top_srcdir)/m4/fprintftime.m4 $(top_srcdir)/m4/fpurge.m4 \ - $(top_srcdir)/m4/freading.m4 $(top_srcdir)/m4/frexp.m4 \ + $(top_srcdir)/m4/extensions.m4 $(top_srcdir)/m4/faccessat.m4 \ + $(top_srcdir)/m4/fchdir.m4 $(top_srcdir)/m4/fclose.m4 \ + $(top_srcdir)/m4/fcntl-o.m4 $(top_srcdir)/m4/fcntl-safer.m4 \ + $(top_srcdir)/m4/fcntl.m4 $(top_srcdir)/m4/fcntl_h.m4 \ + $(top_srcdir)/m4/fd-reopen.m4 $(top_srcdir)/m4/fdopendir.m4 \ + $(top_srcdir)/m4/fflush.m4 $(top_srcdir)/m4/file-type.m4 \ + $(top_srcdir)/m4/fileblocks.m4 $(top_srcdir)/m4/filemode.m4 \ + $(top_srcdir)/m4/filenamecat.m4 $(top_srcdir)/m4/flexmember.m4 \ + $(top_srcdir)/m4/float_h.m4 $(top_srcdir)/m4/fnmatch.m4 \ + $(top_srcdir)/m4/fopen.m4 $(top_srcdir)/m4/fpending.m4 \ + $(top_srcdir)/m4/fpieee.m4 $(top_srcdir)/m4/fprintftime.m4 \ + $(top_srcdir)/m4/fpurge.m4 $(top_srcdir)/m4/freading.m4 \ + $(top_srcdir)/m4/freopen.m4 $(top_srcdir)/m4/frexp.m4 \ $(top_srcdir)/m4/frexpl.m4 $(top_srcdir)/m4/fseeko.m4 \ $(top_srcdir)/m4/fstypename.m4 $(top_srcdir)/m4/fsusage.m4 \ - $(top_srcdir)/m4/ftello.m4 $(top_srcdir)/m4/ftruncate.m4 \ - $(top_srcdir)/m4/fts.m4 $(top_srcdir)/m4/getaddrinfo.m4 \ + $(top_srcdir)/m4/fsync.m4 $(top_srcdir)/m4/ftello.m4 \ + $(top_srcdir)/m4/ftruncate.m4 $(top_srcdir)/m4/fts.m4 \ + $(top_srcdir)/m4/getaddrinfo.m4 \ $(top_srcdir)/m4/getcwd-abort-bug.m4 \ $(top_srcdir)/m4/getcwd-path-max.m4 $(top_srcdir)/m4/getcwd.m4 \ $(top_srcdir)/m4/getdate.m4 $(top_srcdir)/m4/getdelim.m4 \ + $(top_srcdir)/m4/getdtablesize.m4 \ $(top_srcdir)/m4/getgroups.m4 $(top_srcdir)/m4/gethostname.m4 \ $(top_srcdir)/m4/gethrxtime.m4 $(top_srcdir)/m4/getline.m4 \ $(top_srcdir)/m4/getloadavg.m4 $(top_srcdir)/m4/getndelim2.m4 \ @@ -123,24 +128,27 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intmax_t.m4 \ $(top_srcdir)/m4/inttostr.m4 $(top_srcdir)/m4/inttypes-pri.m4 \ $(top_srcdir)/m4/inttypes.m4 $(top_srcdir)/m4/inttypes_h.m4 \ - $(top_srcdir)/m4/isapipe.m4 $(top_srcdir)/m4/isnand.m4 \ - $(top_srcdir)/m4/isnanf.m4 $(top_srcdir)/m4/isnanl.m4 \ - $(top_srcdir)/m4/jm-macros.m4 $(top_srcdir)/m4/jm-winsz1.m4 \ - $(top_srcdir)/m4/jm-winsz2.m4 $(top_srcdir)/m4/lchmod.m4 \ + $(top_srcdir)/m4/isapipe.m4 $(top_srcdir)/m4/isblank.m4 \ + $(top_srcdir)/m4/isnand.m4 $(top_srcdir)/m4/isnanf.m4 \ + $(top_srcdir)/m4/isnanl.m4 $(top_srcdir)/m4/jm-macros.m4 \ + $(top_srcdir)/m4/jm-winsz1.m4 $(top_srcdir)/m4/jm-winsz2.m4 \ + $(top_srcdir)/m4/langinfo_h.m4 $(top_srcdir)/m4/lchmod.m4 \ $(top_srcdir)/m4/lchown.m4 $(top_srcdir)/m4/ldexpl.m4 \ $(top_srcdir)/m4/lib-check.m4 $(top_srcdir)/m4/lib-ignore.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/link-follow.m4 \ - $(top_srcdir)/m4/link.m4 $(top_srcdir)/m4/localcharset.m4 \ - $(top_srcdir)/m4/locale-fr.m4 $(top_srcdir)/m4/locale-ja.m4 \ - $(top_srcdir)/m4/locale-tr.m4 $(top_srcdir)/m4/locale-zh.m4 \ - $(top_srcdir)/m4/long-options.m4 $(top_srcdir)/m4/longlong.m4 \ - $(top_srcdir)/m4/ls-mntd-fs.m4 $(top_srcdir)/m4/lseek.m4 \ - $(top_srcdir)/m4/lstat.m4 $(top_srcdir)/m4/malloc.m4 \ - $(top_srcdir)/m4/malloca.m4 $(top_srcdir)/m4/manywarnings.m4 \ - $(top_srcdir)/m4/math_h.m4 $(top_srcdir)/m4/mbchar.m4 \ - $(top_srcdir)/m4/mbiter.m4 $(top_srcdir)/m4/mbrlen.m4 \ - $(top_srcdir)/m4/mbrtowc.m4 $(top_srcdir)/m4/mbsinit.m4 \ + $(top_srcdir)/m4/link.m4 $(top_srcdir)/m4/linkat.m4 \ + $(top_srcdir)/m4/localcharset.m4 $(top_srcdir)/m4/locale-fr.m4 \ + $(top_srcdir)/m4/locale-ja.m4 $(top_srcdir)/m4/locale-tr.m4 \ + $(top_srcdir)/m4/locale-zh.m4 $(top_srcdir)/m4/locale_h.m4 \ + $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/long-options.m4 \ + $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ls-mntd-fs.m4 \ + $(top_srcdir)/m4/lseek.m4 $(top_srcdir)/m4/lstat.m4 \ + $(top_srcdir)/m4/malloc.m4 $(top_srcdir)/m4/malloca.m4 \ + $(top_srcdir)/m4/manywarnings.m4 $(top_srcdir)/m4/math_h.m4 \ + $(top_srcdir)/m4/mbchar.m4 $(top_srcdir)/m4/mbiter.m4 \ + $(top_srcdir)/m4/mbrlen.m4 $(top_srcdir)/m4/mbrtowc.m4 \ + $(top_srcdir)/m4/mbsinit.m4 $(top_srcdir)/m4/mbslen.m4 \ $(top_srcdir)/m4/mbsrtowcs.m4 $(top_srcdir)/m4/mbstate_t.m4 \ $(top_srcdir)/m4/mbswidth.m4 $(top_srcdir)/m4/md5.m4 \ $(top_srcdir)/m4/memcasecmp.m4 $(top_srcdir)/m4/memchr.m4 \ @@ -149,34 +157,34 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/mempcpy.m4 $(top_srcdir)/m4/memrchr.m4 \ $(top_srcdir)/m4/memset.m4 $(top_srcdir)/m4/memxfrm.m4 \ $(top_srcdir)/m4/mgetgroups.m4 $(top_srcdir)/m4/mkancesdirs.m4 \ - $(top_srcdir)/m4/mkdir-p.m4 $(top_srcdir)/m4/mkdir-slash.m4 \ + $(top_srcdir)/m4/mkdir-p.m4 $(top_srcdir)/m4/mkdir.m4 \ $(top_srcdir)/m4/mkstemp.m4 $(top_srcdir)/m4/mktime.m4 \ $(top_srcdir)/m4/mmap-anon.m4 $(top_srcdir)/m4/mode_t.m4 \ $(top_srcdir)/m4/modechange.m4 $(top_srcdir)/m4/mountlist.m4 \ $(top_srcdir)/m4/mpsort.m4 $(top_srcdir)/m4/multiarch.m4 \ $(top_srcdir)/m4/nanosleep.m4 $(top_srcdir)/m4/netdb_h.m4 \ - $(top_srcdir)/m4/netinet_in_h.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/open.m4 \ - $(top_srcdir)/m4/openat.m4 $(top_srcdir)/m4/pathmax.m4 \ - $(top_srcdir)/m4/perl.m4 $(top_srcdir)/m4/perror.m4 \ - $(top_srcdir)/m4/physmem.m4 $(top_srcdir)/m4/po.m4 \ - $(top_srcdir)/m4/posix-shell.m4 $(top_srcdir)/m4/posixtm.m4 \ - $(top_srcdir)/m4/posixver.m4 $(top_srcdir)/m4/prereq.m4 \ - $(top_srcdir)/m4/printf-frexp.m4 \ + $(top_srcdir)/m4/netinet_in_h.m4 \ + $(top_srcdir)/m4/nl_langinfo.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/nproc.m4 \ + $(top_srcdir)/m4/open.m4 $(top_srcdir)/m4/openat.m4 \ + $(top_srcdir)/m4/pathmax.m4 $(top_srcdir)/m4/perl.m4 \ + $(top_srcdir)/m4/perror.m4 $(top_srcdir)/m4/physmem.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/posix-shell.m4 \ + $(top_srcdir)/m4/posixtm.m4 $(top_srcdir)/m4/posixver.m4 \ + $(top_srcdir)/m4/prereq.m4 $(top_srcdir)/m4/printf-frexp.m4 \ $(top_srcdir)/m4/printf-frexpl.m4 $(top_srcdir)/m4/printf.m4 \ $(top_srcdir)/m4/priv-set.m4 $(top_srcdir)/m4/progtest.m4 \ $(top_srcdir)/m4/putenv.m4 $(top_srcdir)/m4/quote.m4 \ $(top_srcdir)/m4/quotearg.m4 $(top_srcdir)/m4/read-file.m4 \ $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/readtokens.m4 \ $(top_srcdir)/m4/readutmp.m4 $(top_srcdir)/m4/realloc.m4 \ - $(top_srcdir)/m4/regex.m4 \ - $(top_srcdir)/m4/rename-dest-slash.m4 \ - $(top_srcdir)/m4/rename.m4 $(top_srcdir)/m4/rmdir-errno.m4 \ - $(top_srcdir)/m4/rmdir.m4 $(top_srcdir)/m4/root-dev-ino.m4 \ - $(top_srcdir)/m4/rpmatch.m4 $(top_srcdir)/m4/safe-read.m4 \ - $(top_srcdir)/m4/safe-write.m4 $(top_srcdir)/m4/same.m4 \ - $(top_srcdir)/m4/save-cwd.m4 $(top_srcdir)/m4/savedir.m4 \ - $(top_srcdir)/m4/savewd.m4 $(top_srcdir)/m4/select.m4 \ + $(top_srcdir)/m4/regex.m4 $(top_srcdir)/m4/remove.m4 \ + $(top_srcdir)/m4/rename.m4 $(top_srcdir)/m4/rmdir.m4 \ + $(top_srcdir)/m4/root-dev-ino.m4 $(top_srcdir)/m4/rpmatch.m4 \ + $(top_srcdir)/m4/safe-read.m4 $(top_srcdir)/m4/safe-write.m4 \ + $(top_srcdir)/m4/same.m4 $(top_srcdir)/m4/save-cwd.m4 \ + $(top_srcdir)/m4/savedir.m4 $(top_srcdir)/m4/savewd.m4 \ + $(top_srcdir)/m4/select.m4 \ $(top_srcdir)/m4/selinux-context-h.m4 \ $(top_srcdir)/m4/selinux-selinux-h.m4 \ $(top_srcdir)/m4/servent.m4 $(top_srcdir)/m4/setenv.m4 \ @@ -190,38 +198,45 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/socklen.m4 $(top_srcdir)/m4/sockpfaf.m4 \ $(top_srcdir)/m4/ssize_t.m4 $(top_srcdir)/m4/st_dm_mode.m4 \ $(top_srcdir)/m4/stat-prog.m4 $(top_srcdir)/m4/stat-time.m4 \ - $(top_srcdir)/m4/stdarg.m4 $(top_srcdir)/m4/stdbool.m4 \ - $(top_srcdir)/m4/stddef_h.m4 $(top_srcdir)/m4/stdint.m4 \ - $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/stdio-safer.m4 \ - $(top_srcdir)/m4/stdio_h.m4 $(top_srcdir)/m4/stdlib-safer.m4 \ - $(top_srcdir)/m4/stdlib_h.m4 $(top_srcdir)/m4/stpcpy.m4 \ - $(top_srcdir)/m4/stpncpy.m4 $(top_srcdir)/m4/strcspn.m4 \ - $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \ - $(top_srcdir)/m4/strftime.m4 $(top_srcdir)/m4/string_h.m4 \ - $(top_srcdir)/m4/strndup.m4 $(top_srcdir)/m4/strnlen.m4 \ - $(top_srcdir)/m4/strnumcmp.m4 $(top_srcdir)/m4/strpbrk.m4 \ + $(top_srcdir)/m4/stat.m4 $(top_srcdir)/m4/stdarg.m4 \ + $(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stddef_h.m4 \ + $(top_srcdir)/m4/stdint.m4 $(top_srcdir)/m4/stdint_h.m4 \ + $(top_srcdir)/m4/stdio-safer.m4 $(top_srcdir)/m4/stdio_h.m4 \ + $(top_srcdir)/m4/stdlib-safer.m4 $(top_srcdir)/m4/stdlib_h.m4 \ + $(top_srcdir)/m4/stpcpy.m4 $(top_srcdir)/m4/stpncpy.m4 \ + $(top_srcdir)/m4/strcspn.m4 $(top_srcdir)/m4/strdup.m4 \ + $(top_srcdir)/m4/strerror.m4 $(top_srcdir)/m4/strftime.m4 \ + $(top_srcdir)/m4/string_h.m4 $(top_srcdir)/m4/strndup.m4 \ + $(top_srcdir)/m4/strnlen.m4 $(top_srcdir)/m4/strnumcmp.m4 \ + $(top_srcdir)/m4/strpbrk.m4 $(top_srcdir)/m4/strsignal.m4 \ $(top_srcdir)/m4/strstr.m4 $(top_srcdir)/m4/strtod.m4 \ $(top_srcdir)/m4/strtoimax.m4 $(top_srcdir)/m4/strtol.m4 \ $(top_srcdir)/m4/strtoll.m4 $(top_srcdir)/m4/strtoul.m4 \ $(top_srcdir)/m4/strtoull.m4 $(top_srcdir)/m4/strtoumax.m4 \ - $(top_srcdir)/m4/strverscmp.m4 $(top_srcdir)/m4/sys_ioctl_h.m4 \ + $(top_srcdir)/m4/symlink.m4 $(top_srcdir)/m4/symlinkat.m4 \ + $(top_srcdir)/m4/sys_ioctl_h.m4 \ $(top_srcdir)/m4/sys_select_h.m4 \ $(top_srcdir)/m4/sys_socket_h.m4 \ $(top_srcdir)/m4/sys_stat_h.m4 $(top_srcdir)/m4/sys_time_h.m4 \ - $(top_srcdir)/m4/tempname.m4 $(top_srcdir)/m4/time_h.m4 \ - $(top_srcdir)/m4/time_r.m4 $(top_srcdir)/m4/timespec.m4 \ + $(top_srcdir)/m4/sys_utsname_h.m4 $(top_srcdir)/m4/tempname.m4 \ + $(top_srcdir)/m4/thread.m4 $(top_srcdir)/m4/threadlib.m4 \ + $(top_srcdir)/m4/time_h.m4 $(top_srcdir)/m4/time_r.m4 \ + $(top_srcdir)/m4/timespec.m4 $(top_srcdir)/m4/tls.m4 \ $(top_srcdir)/m4/tm_gmtoff.m4 $(top_srcdir)/m4/tzset.m4 \ - $(top_srcdir)/m4/ungetc.m4 $(top_srcdir)/m4/unicodeio.m4 \ - $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/unistd_h.m4 \ - $(top_srcdir)/m4/unlink-busy.m4 $(top_srcdir)/m4/unlinkdir.m4 \ + $(top_srcdir)/m4/uname.m4 $(top_srcdir)/m4/ungetc.m4 \ + $(top_srcdir)/m4/unicodeio.m4 $(top_srcdir)/m4/unistd-safer.m4 \ + $(top_srcdir)/m4/unistd_h.m4 $(top_srcdir)/m4/unlink-busy.m4 \ + $(top_srcdir)/m4/unlink.m4 $(top_srcdir)/m4/unlinkdir.m4 \ $(top_srcdir)/m4/unlocked-io.m4 $(top_srcdir)/m4/uptime.m4 \ - $(top_srcdir)/m4/userspec.m4 $(top_srcdir)/m4/utimbuf.m4 \ - $(top_srcdir)/m4/utimecmp.m4 $(top_srcdir)/m4/utimens.m4 \ - $(top_srcdir)/m4/utimes.m4 $(top_srcdir)/m4/vasnprintf.m4 \ + $(top_srcdir)/m4/userspec.m4 $(top_srcdir)/m4/usleep.m4 \ + $(top_srcdir)/m4/utimbuf.m4 $(top_srcdir)/m4/utimecmp.m4 \ + $(top_srcdir)/m4/utimens.m4 $(top_srcdir)/m4/utimes.m4 \ + $(top_srcdir)/m4/vasnprintf.m4 \ $(top_srcdir)/m4/vasprintf-posix.m4 \ $(top_srcdir)/m4/vasprintf.m4 $(top_srcdir)/m4/version-etc.m4 \ $(top_srcdir)/m4/vfprintf-posix.m4 \ - $(top_srcdir)/m4/vprintf-posix.m4 $(top_srcdir)/m4/warnings.m4 \ + $(top_srcdir)/m4/vprintf-posix.m4 \ + $(top_srcdir)/m4/warn-on-use.m4 $(top_srcdir)/m4/warnings.m4 \ $(top_srcdir)/m4/wchar.m4 $(top_srcdir)/m4/wchar_t.m4 \ $(top_srcdir)/m4/wcrtomb.m4 $(top_srcdir)/m4/wctob.m4 \ $(top_srcdir)/m4/wctype.m4 $(top_srcdir)/m4/wcwidth.m4 \ @@ -232,7 +247,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/m4/xstrndup.m4 \ $(top_srcdir)/m4/xstrtod.m4 $(top_srcdir)/m4/xstrtol.m4 \ $(top_srcdir)/m4/xvasprintf.m4 $(top_srcdir)/m4/yesno.m4 \ - $(top_srcdir)/configure.ac + $(top_srcdir)/m4/yield.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d @@ -244,7 +259,7 @@ AR = ar ARFLAGS = cru AM_V_AR = $(am__v_AR_$(V)) am__v_AR_ = $(am__v_AR_$(AM_DEFAULT_VERBOSITY)) -am__v_AR_0 = @echo " AR " $@; +am__v_AR_0 = @echo " AR " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ @@ -252,31 +267,35 @@ libcoreutils_a_AR = $(AR) $(ARFLAGS) am__DEPENDENCIES_1 = am__dirstamp = $(am__leading_dot)dirstamp am_libcoreutils_a_OBJECTS = set-mode-acl.$(OBJEXT) copy-acl.$(OBJEXT) \ - file-has-acl.$(OBJEXT) areadlink-with-size.$(OBJEXT) \ + file-has-acl.$(OBJEXT) areadlink.$(OBJEXT) \ + areadlink-with-size.$(OBJEXT) areadlinkat.$(OBJEXT) \ argv-iter.$(OBJEXT) base64.$(OBJEXT) c-ctype.$(OBJEXT) \ c-strcasecmp.$(OBJEXT) c-strncasecmp.$(OBJEXT) \ - close-hook.$(OBJEXT) diacrit.$(OBJEXT) file-set.$(OBJEXT) \ + close-hook.$(OBJEXT) diacrit.$(OBJEXT) fd-safer-flag.$(OBJEXT) \ + dup-safer-flag.$(OBJEXT) file-set.$(OBJEXT) \ filevercmp.$(OBJEXT) freadahead.$(OBJEXT) freading.$(OBJEXT) \ freadptr.$(OBJEXT) freadseek.$(OBJEXT) fseterr.$(OBJEXT) \ full-read.$(OBJEXT) full-write.$(OBJEXT) getdate.$(OBJEXT) \ hash-pjw.$(OBJEXT) hash-triple.$(OBJEXT) linebuffer.$(OBJEXT) \ - localcharset.$(OBJEXT) malloca.$(OBJEXT) mbchar.$(OBJEXT) \ - mbsalign.$(OBJEXT) mbscasecmp.$(OBJEXT) mbslen.$(OBJEXT) \ - mbsstr.$(OBJEXT) mbswidth.$(OBJEXT) memchr2.$(OBJEXT) \ - memcmp2.$(OBJEXT) openat-die.$(OBJEXT) printf-frexp.$(OBJEXT) \ + localcharset.$(OBJEXT) glthread/lock.$(OBJEXT) \ + malloca.$(OBJEXT) mbchar.$(OBJEXT) mbsalign.$(OBJEXT) \ + mbscasecmp.$(OBJEXT) mbslen.$(OBJEXT) mbsstr.$(OBJEXT) \ + mbswidth.$(OBJEXT) memchr2.$(OBJEXT) memcmp2.$(OBJEXT) \ + nproc.$(OBJEXT) openat-die.$(OBJEXT) printf-frexp.$(OBJEXT) \ printf-frexpl.$(OBJEXT) priv-set.$(OBJEXT) progname.$(OBJEXT) \ propername.$(OBJEXT) randint.$(OBJEXT) randperm.$(OBJEXT) \ randread.$(OBJEXT) rand-isaac.$(OBJEXT) readtokens0.$(OBJEXT) \ savewd.$(OBJEXT) sockets.$(OBJEXT) striconv.$(OBJEXT) \ - strnlen1.$(OBJEXT) trim.$(OBJEXT) unicodeio.$(OBJEXT) \ + strnlen1.$(OBJEXT) glthread/threadlib.$(OBJEXT) \ + glthread/tls.$(OBJEXT) trim.$(OBJEXT) unicodeio.$(OBJEXT) \ unistr/u8-uctomb.$(OBJEXT) unistr/u8-uctomb-aux.$(OBJEXT) \ uniwidth/width.$(OBJEXT) verror.$(OBJEXT) \ version-etc.$(OBJEXT) version-etc-fsf.$(OBJEXT) \ xalloc-die.$(OBJEXT) xfreopen.$(OBJEXT) xgethostname.$(OBJEXT) \ - xmemcoll.$(OBJEXT) xprintf.$(OBJEXT) xstriconv.$(OBJEXT) \ - xstrndup.$(OBJEXT) xstrtoimax.$(OBJEXT) xstrtoumax.$(OBJEXT) \ - xvasprintf.$(OBJEXT) xasprintf.$(OBJEXT) buffer-lcm.$(OBJEXT) \ - xmemxfrm.$(OBJEXT) + xmemcoll.$(OBJEXT) xprintf.$(OBJEXT) xreadlink.$(OBJEXT) \ + xstriconv.$(OBJEXT) xstrndup.$(OBJEXT) xstrtoimax.$(OBJEXT) \ + xstrtoumax.$(OBJEXT) xvasprintf.$(OBJEXT) xasprintf.$(OBJEXT) \ + buffer-lcm.$(OBJEXT) xmemxfrm.$(OBJEXT) libcoreutils_a_OBJECTS = $(am_libcoreutils_a_OBJECTS) LTLIBRARIES = $(noinst_LTLIBRARIES) DEFAULT_INCLUDES = -I.@am__isrc@ @@ -287,20 +306,20 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_$(V)) am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) -am__v_CC_0 = @echo " CC " $@; +am__v_CC_0 = @echo " CC " $@; CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_$(V)) am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) -am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_0 = @echo " CCLD " $@; YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS) AM_V_YACC = $(am__v_YACC_$(V)) am__v_YACC_ = $(am__v_YACC_$(AM_DEFAULT_VERBOSITY)) -am__v_YACC_0 = @echo " YACC " $@; +am__v_YACC_0 = @echo " YACC " $@; YLWRAP = $(top_srcdir)/build-aux/ylwrap AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) -am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(libcoreutils_a_SOURCES) $(EXTRA_libcoreutils_a_SOURCES) DIST_SOURCES = $(libcoreutils_a_SOURCES) \ $(EXTRA_libcoreutils_a_SOURCES) @@ -352,7 +371,6 @@ ALLOCA_H = @ALLOCA_H@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@ -ARPA_INET_H = @ARPA_INET_H@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -372,7 +390,6 @@ CYGPATH_W = @CYGPATH_W@ DEFAULT_POSIX2_VERSION = @DEFAULT_POSIX2_VERSION@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ -DIRENT_H = @DIRENT_H@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ @@ -385,7 +402,6 @@ EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@ EOVERFLOW_VALUE = @EOVERFLOW_VALUE@ ERRNO_H = @ERRNO_H@ EXEEXT = @EXEEXT@ -FCNTL_H = @FCNTL_H@ FLOAT_H = @FLOAT_H@ FNMATCH_H = @FNMATCH_H@ GETADDRINFO_LIB = @GETADDRINFO_LIB@ @@ -403,6 +419,7 @@ GNULIB_ATOLL = @GNULIB_ATOLL@ GNULIB_BIND = @GNULIB_BIND@ GNULIB_BTOWC = @GNULIB_BTOWC@ GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@ +GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@ GNULIB_CEILF = @GNULIB_CEILF@ GNULIB_CEILL = @GNULIB_CEILL@ GNULIB_CHOWN = @GNULIB_CHOWN@ @@ -412,6 +429,7 @@ GNULIB_DIRFD = @GNULIB_DIRFD@ GNULIB_DPRINTF = @GNULIB_DPRINTF@ GNULIB_DUP2 = @GNULIB_DUP2@ GNULIB_DUP3 = @GNULIB_DUP3@ +GNULIB_DUPLOCALE = @GNULIB_DUPLOCALE@ GNULIB_ENVIRON = @GNULIB_ENVIRON@ GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@ GNULIB_FACCESSAT = @GNULIB_FACCESSAT@ @@ -419,6 +437,7 @@ GNULIB_FCHDIR = @GNULIB_FCHDIR@ GNULIB_FCHMODAT = @GNULIB_FCHMODAT@ GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@ GNULIB_FCLOSE = @GNULIB_FCLOSE@ +GNULIB_FCNTL = @GNULIB_FCNTL@ GNULIB_FDOPENDIR = @GNULIB_FDOPENDIR@ GNULIB_FFLUSH = @GNULIB_FFLUSH@ GNULIB_FLOORF = @GNULIB_FLOORF@ @@ -439,15 +458,18 @@ GNULIB_FSYNC = @GNULIB_FSYNC@ GNULIB_FTELL = @GNULIB_FTELL@ GNULIB_FTELLO = @GNULIB_FTELLO@ GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@ +GNULIB_FUTIMENS = @GNULIB_FUTIMENS@ GNULIB_FWRITE = @GNULIB_FWRITE@ GNULIB_GETADDRINFO = @GNULIB_GETADDRINFO@ GNULIB_GETCWD = @GNULIB_GETCWD@ GNULIB_GETDELIM = @GNULIB_GETDELIM@ GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@ GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@ +GNULIB_GETGROUPS = @GNULIB_GETGROUPS@ GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@ GNULIB_GETLINE = @GNULIB_GETLINE@ GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@ +GNULIB_GETLOGIN = @GNULIB_GETLOGIN@ GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@ GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@ GNULIB_GETPEERNAME = @GNULIB_GETPEERNAME@ @@ -460,6 +482,7 @@ GNULIB_IMAXDIV = @GNULIB_IMAXDIV@ GNULIB_INET_NTOP = @GNULIB_INET_NTOP@ GNULIB_INET_PTON = @GNULIB_INET_PTON@ GNULIB_IOCTL = @GNULIB_IOCTL@ +GNULIB_ISBLANK = @GNULIB_ISBLANK@ GNULIB_ISFINITE = @GNULIB_ISFINITE@ GNULIB_ISINF = @GNULIB_ISINF@ GNULIB_ISNAN = @GNULIB_ISNAN@ @@ -470,6 +493,7 @@ GNULIB_LCHMOD = @GNULIB_LCHMOD@ GNULIB_LCHOWN = @GNULIB_LCHOWN@ GNULIB_LDEXPL = @GNULIB_LDEXPL@ GNULIB_LINK = @GNULIB_LINK@ +GNULIB_LINKAT = @GNULIB_LINKAT@ GNULIB_LISTEN = @GNULIB_LISTEN@ GNULIB_LSEEK = @GNULIB_LSEEK@ GNULIB_LSTAT = @GNULIB_LSTAT@ @@ -500,10 +524,15 @@ GNULIB_MEMPCPY = @GNULIB_MEMPCPY@ GNULIB_MEMRCHR = @GNULIB_MEMRCHR@ GNULIB_MKDIRAT = @GNULIB_MKDIRAT@ GNULIB_MKDTEMP = @GNULIB_MKDTEMP@ +GNULIB_MKFIFO = @GNULIB_MKFIFO@ GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@ +GNULIB_MKNOD = @GNULIB_MKNOD@ GNULIB_MKNODAT = @GNULIB_MKNODAT@ GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@ +GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@ GNULIB_MKSTEMP = @GNULIB_MKSTEMP@ +GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@ +GNULIB_NL_LANGINFO = @GNULIB_NL_LANGINFO@ GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@ GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@ GNULIB_OPEN = @GNULIB_OPEN@ @@ -511,6 +540,7 @@ GNULIB_OPENAT = @GNULIB_OPENAT@ GNULIB_PERROR = @GNULIB_PERROR@ GNULIB_PIPE2 = @GNULIB_PIPE2@ GNULIB_POPEN = @GNULIB_POPEN@ +GNULIB_PREAD = @GNULIB_PREAD@ GNULIB_PRINTF = @GNULIB_PRINTF@ GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@ GNULIB_PUTC = @GNULIB_PUTC@ @@ -522,9 +552,13 @@ GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@ GNULIB_READLINK = @GNULIB_READLINK@ GNULIB_READLINKAT = @GNULIB_READLINKAT@ GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@ +GNULIB_REALPATH = @GNULIB_REALPATH@ GNULIB_RECV = @GNULIB_RECV@ GNULIB_RECVFROM = @GNULIB_RECVFROM@ +GNULIB_REMOVE = @GNULIB_REMOVE@ GNULIB_RENAME = @GNULIB_RENAME@ +GNULIB_RENAMEAT = @GNULIB_RENAMEAT@ +GNULIB_RMDIR = @GNULIB_RMDIR@ GNULIB_ROUND = @GNULIB_ROUND@ GNULIB_ROUNDF = @GNULIB_ROUNDF@ GNULIB_ROUNDL = @GNULIB_ROUNDL@ @@ -544,6 +578,7 @@ GNULIB_SLEEP = @GNULIB_SLEEP@ GNULIB_SNPRINTF = @GNULIB_SNPRINTF@ GNULIB_SOCKET = @GNULIB_SOCKET@ GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@ +GNULIB_STAT = @GNULIB_STAT@ GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@ GNULIB_STPCPY = @GNULIB_STPCPY@ GNULIB_STPNCPY = @GNULIB_STPNCPY@ @@ -564,14 +599,19 @@ GNULIB_STRTOLL = @GNULIB_STRTOLL@ GNULIB_STRTOULL = @GNULIB_STRTOULL@ GNULIB_STRTOUMAX = @GNULIB_STRTOUMAX@ GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@ +GNULIB_SYMLINK = @GNULIB_SYMLINK@ GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@ GNULIB_TRUNC = @GNULIB_TRUNC@ GNULIB_TRUNCF = @GNULIB_TRUNCF@ GNULIB_TRUNCL = @GNULIB_TRUNCL@ +GNULIB_UNAME = @GNULIB_UNAME@ GNULIB_UNISTD_H_GETOPT = @GNULIB_UNISTD_H_GETOPT@ GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@ +GNULIB_UNLINK = @GNULIB_UNLINK@ GNULIB_UNLINKAT = @GNULIB_UNLINKAT@ GNULIB_UNSETENV = @GNULIB_UNSETENV@ +GNULIB_USLEEP = @GNULIB_USLEEP@ +GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@ GNULIB_VASPRINTF = @GNULIB_VASPRINTF@ GNULIB_VDPRINTF = @GNULIB_VDPRINTF@ GNULIB_VFPRINTF = @GNULIB_VFPRINTF@ @@ -580,6 +620,7 @@ GNULIB_VPRINTF = @GNULIB_VPRINTF@ GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@ GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@ GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@ +GNULIB_WARN_CFLAGS = @GNULIB_WARN_CFLAGS@ GNULIB_WCRTOMB = @GNULIB_WCRTOMB@ GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@ GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@ @@ -593,6 +634,8 @@ HAVE_ARPA_INET_H = @HAVE_ARPA_INET_H@ HAVE_ATOLL = @HAVE_ATOLL@ HAVE_BTOWC = @HAVE_BTOWC@ HAVE_CALLOC_POSIX = @HAVE_CALLOC_POSIX@ +HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@ +HAVE_CHOWN = @HAVE_CHOWN@ HAVE_DECL_ACOSL = @HAVE_DECL_ACOSL@ HAVE_DECL_ASINL = @HAVE_DECL_ASINL@ HAVE_DECL_ATANL = @HAVE_DECL_ATANL@ @@ -643,51 +686,69 @@ HAVE_EUIDACCESS = @HAVE_EUIDACCESS@ HAVE_FACCESSAT = @HAVE_FACCESSAT@ HAVE_FCHMODAT = @HAVE_FCHMODAT@ HAVE_FCHOWNAT = @HAVE_FCHOWNAT@ +HAVE_FCNTL = @HAVE_FCNTL@ HAVE_FDOPENDIR = @HAVE_FDOPENDIR@ -HAVE_FSEEKO = @HAVE_FSEEKO@ HAVE_FSTATAT = @HAVE_FSTATAT@ HAVE_FSYNC = @HAVE_FSYNC@ -HAVE_FTELLO = @HAVE_FTELLO@ HAVE_FTRUNCATE = @HAVE_FTRUNCATE@ +HAVE_FUTIMENS = @HAVE_FUTIMENS@ HAVE_GETDOMAINNAME = @HAVE_GETDOMAINNAME@ HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@ +HAVE_GETGROUPS = @HAVE_GETGROUPS@ HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@ +HAVE_GETLOGIN = @HAVE_GETLOGIN@ +HAVE_GETOPT_H = @HAVE_GETOPT_H@ HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@ HAVE_GETSUBOPT = @HAVE_GETSUBOPT@ HAVE_GETUSERSHELL = @HAVE_GETUSERSHELL@ HAVE_INTTYPES_H = @HAVE_INTTYPES_H@ +HAVE_ISBLANK = @HAVE_ISBLANK@ HAVE_ISNAND = @HAVE_ISNAND@ HAVE_ISNANF = @HAVE_ISNANF@ HAVE_ISNANL = @HAVE_ISNANL@ HAVE_ISWCNTRL = @HAVE_ISWCNTRL@ +HAVE_LANGINFO_CODESET = @HAVE_LANGINFO_CODESET@ +HAVE_LANGINFO_ERA = @HAVE_LANGINFO_ERA@ +HAVE_LANGINFO_H = @HAVE_LANGINFO_H@ HAVE_LCHMOD = @HAVE_LCHMOD@ +HAVE_LCHOWN = @HAVE_LCHOWN@ HAVE_LINK = @HAVE_LINK@ +HAVE_LINKAT = @HAVE_LINKAT@ HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@ HAVE_LSTAT = @HAVE_LSTAT@ HAVE_MALLOC_POSIX = @HAVE_MALLOC_POSIX@ HAVE_MBRLEN = @HAVE_MBRLEN@ HAVE_MBRTOWC = @HAVE_MBRTOWC@ HAVE_MBSINIT = @HAVE_MBSINIT@ +HAVE_MBSLEN = @HAVE_MBSLEN@ HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@ HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@ HAVE_MEMPCPY = @HAVE_MEMPCPY@ HAVE_MKDIRAT = @HAVE_MKDIRAT@ HAVE_MKDTEMP = @HAVE_MKDTEMP@ +HAVE_MKFIFO = @HAVE_MKFIFO@ HAVE_MKFIFOAT = @HAVE_MKFIFOAT@ +HAVE_MKNOD = @HAVE_MKNOD@ HAVE_MKNODAT = @HAVE_MKNODAT@ HAVE_MKOSTEMP = @HAVE_MKOSTEMP@ +HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@ +HAVE_MKSTEMPS = @HAVE_MKSTEMPS@ HAVE_NETDB_H = @HAVE_NETDB_H@ HAVE_NETINET_IN_H = @HAVE_NETINET_IN_H@ +HAVE_NL_LANGINFO = @HAVE_NL_LANGINFO@ HAVE_OPENAT = @HAVE_OPENAT@ HAVE_OS_H = @HAVE_OS_H@ HAVE_PIPE2 = @HAVE_PIPE2@ HAVE_POSIX_SIGNALBLOCKING = @HAVE_POSIX_SIGNALBLOCKING@ +HAVE_PREAD = @HAVE_PREAD@ HAVE_RANDOM_H = @HAVE_RANDOM_H@ HAVE_RANDOM_R = @HAVE_RANDOM_R@ HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@ HAVE_READLINK = @HAVE_READLINK@ HAVE_READLINKAT = @HAVE_READLINKAT@ HAVE_REALLOC_POSIX = @HAVE_REALLOC_POSIX@ +HAVE_REALPATH = @HAVE_REALPATH@ +HAVE_RENAMEAT = @HAVE_RENAMEAT@ HAVE_RPMATCH = @HAVE_RPMATCH@ HAVE_SA_FAMILY_T = @HAVE_SA_FAMILY_T@ HAVE_SCANDIR = @HAVE_SCANDIR@ @@ -714,6 +775,7 @@ HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@ HAVE_STRUCT_SIGACTION_SA_SIGACTION = @HAVE_STRUCT_SIGACTION_SA_SIGACTION@ HAVE_STRUCT_SOCKADDR_STORAGE = @HAVE_STRUCT_SOCKADDR_STORAGE@ HAVE_STRUCT_TIMEVAL = @HAVE_STRUCT_TIMEVAL@ +HAVE_STRUCT_UTSNAME = @HAVE_STRUCT_UTSNAME@ HAVE_STRVERSCMP = @HAVE_STRVERSCMP@ HAVE_SYMLINK = @HAVE_SYMLINK@ HAVE_SYMLINKAT = @HAVE_SYMLINKAT@ @@ -726,11 +788,15 @@ HAVE_SYS_SELECT_H = @HAVE_SYS_SELECT_H@ HAVE_SYS_SOCKET_H = @HAVE_SYS_SOCKET_H@ HAVE_SYS_TIME_H = @HAVE_SYS_TIME_H@ HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@ +HAVE_SYS_UTSNAME_H = @HAVE_SYS_UTSNAME_H@ HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@ +HAVE_UNAME = @HAVE_UNAME@ HAVE_UNISTD_H = @HAVE_UNISTD_H@ HAVE_UNLINKAT = @HAVE_UNLINKAT@ HAVE_UNSETENV = @HAVE_UNSETENV@ HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@ +HAVE_USLEEP = @HAVE_USLEEP@ +HAVE_UTIMENSAT = @HAVE_UTIMENSAT@ HAVE_VASPRINTF = @HAVE_VASPRINTF@ HAVE_VDPRINTF = @HAVE_VDPRINTF@ HAVE_WCHAR_H = @HAVE_WCHAR_H@ @@ -742,12 +808,15 @@ HAVE_WCTYPE_H = @HAVE_WCTYPE_H@ HAVE_WINSOCK2_H = @HAVE_WINSOCK2_H@ HAVE_WINT_T = @HAVE_WINT_T@ HAVE_WS2TCPIP_H = @HAVE_WS2TCPIP_H@ +HAVE_XLOCALE_H = @HAVE_XLOCALE_H@ HAVE__BOOL = @HAVE__BOOL@ HELP2MAN = @HELP2MAN@ HOSTENT_LIB = @HOSTENT_LIB@ ICONV_H = @ICONV_H@ INCLUDE_NEXT = @INCLUDE_NEXT@ INCLUDE_NEXT_AS_FIRST_DIRECTIVE = @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ +INET_NTOP_LIB = @INET_NTOP_LIB@ +INET_PTON_LIB = @INET_PTON_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ @@ -758,17 +827,20 @@ INT32_MAX_LT_INTMAX_MAX = @INT32_MAX_LT_INTMAX_MAX@ INT64_MAX_EQ_LONG_MAX = @INT64_MAX_EQ_LONG_MAX@ INTLLIBS = @INTLLIBS@ INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTTYPES_H = @INTTYPES_H@ KMEM_GROUP = @KMEM_GROUP@ LDFLAGS = @LDFLAGS@ LIBCOREUTILS_LIBDEPS = @LIBCOREUTILS_LIBDEPS@ LIBCOREUTILS_LTLIBDEPS = @LIBCOREUTILS_LTLIBDEPS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ +LIBMULTITHREAD = @LIBMULTITHREAD@ LIBOBJS = @LIBOBJS@ +LIBPTH = @LIBPTH@ +LIBPTH_PREFIX = @LIBPTH_PREFIX@ LIBS = @LIBS@ $(POW_LIB) LIBSOCKET = @LIBSOCKET@ LIBTESTS_LIBDEPS = @LIBTESTS_LIBDEPS@ +LIBTHREAD = @LIBTHREAD@ LIB_ACL = @LIB_ACL@ LIB_CAP = @LIB_CAP@ LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@ @@ -789,7 +861,10 @@ LOCALE_TR_UTF8 = @LOCALE_TR_UTF8@ LOCALE_ZH_CN = @LOCALE_ZH_CN@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ +LTLIBMULTITHREAD = @LTLIBMULTITHREAD@ LTLIBOBJS = @LTLIBOBJS@ +LTLIBPTH = @LTLIBPTH@ +LTLIBTHREAD = @LTLIBTHREAD@ MAKEINFO = @MAKEINFO@ MAN = @MAN@ MKDIR_P = @MKDIR_P@ @@ -801,15 +876,20 @@ NETDB_H = @NETDB_H@ NETINET_IN_H = @NETINET_IN_H@ NEXT_ARPA_INET_H = @NEXT_ARPA_INET_H@ NEXT_AS_FIRST_DIRECTIVE_ARPA_INET_H = @NEXT_AS_FIRST_DIRECTIVE_ARPA_INET_H@ +NEXT_AS_FIRST_DIRECTIVE_CTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_CTYPE_H@ NEXT_AS_FIRST_DIRECTIVE_DIRENT_H = @NEXT_AS_FIRST_DIRECTIVE_DIRENT_H@ NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@ NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@ NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@ +NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@ NEXT_AS_FIRST_DIRECTIVE_ICONV_H = @NEXT_AS_FIRST_DIRECTIVE_ICONV_H@ NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H = @NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H@ +NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H = @NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H@ +NEXT_AS_FIRST_DIRECTIVE_LOCALE_H = @NEXT_AS_FIRST_DIRECTIVE_LOCALE_H@ NEXT_AS_FIRST_DIRECTIVE_MATH_H = @NEXT_AS_FIRST_DIRECTIVE_MATH_H@ NEXT_AS_FIRST_DIRECTIVE_NETDB_H = @NEXT_AS_FIRST_DIRECTIVE_NETDB_H@ NEXT_AS_FIRST_DIRECTIVE_NETINET_IN_H = @NEXT_AS_FIRST_DIRECTIVE_NETINET_IN_H@ +NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H = @NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H@ NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H = @NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H@ NEXT_AS_FIRST_DIRECTIVE_STDARG_H = @NEXT_AS_FIRST_DIRECTIVE_STDARG_H@ NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@ @@ -822,19 +902,25 @@ NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H@ +NEXT_AS_FIRST_DIRECTIVE_SYS_UTSNAME_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_UTSNAME_H@ NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@ NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@ NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@ NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@ +NEXT_CTYPE_H = @NEXT_CTYPE_H@ NEXT_DIRENT_H = @NEXT_DIRENT_H@ NEXT_ERRNO_H = @NEXT_ERRNO_H@ NEXT_FCNTL_H = @NEXT_FCNTL_H@ NEXT_FLOAT_H = @NEXT_FLOAT_H@ +NEXT_GETOPT_H = @NEXT_GETOPT_H@ NEXT_ICONV_H = @NEXT_ICONV_H@ NEXT_INTTYPES_H = @NEXT_INTTYPES_H@ +NEXT_LANGINFO_H = @NEXT_LANGINFO_H@ +NEXT_LOCALE_H = @NEXT_LOCALE_H@ NEXT_MATH_H = @NEXT_MATH_H@ NEXT_NETDB_H = @NEXT_NETDB_H@ NEXT_NETINET_IN_H = @NEXT_NETINET_IN_H@ +NEXT_SELINUX_SELINUX_H = @NEXT_SELINUX_SELINUX_H@ NEXT_SIGNAL_H = @NEXT_SIGNAL_H@ NEXT_STDARG_H = @NEXT_STDARG_H@ NEXT_STDDEF_H = @NEXT_STDDEF_H@ @@ -847,6 +933,7 @@ NEXT_SYS_SELECT_H = @NEXT_SYS_SELECT_H@ NEXT_SYS_SOCKET_H = @NEXT_SYS_SOCKET_H@ NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@ NEXT_SYS_TIME_H = @NEXT_SYS_TIME_H@ +NEXT_SYS_UTSNAME_H = @NEXT_SYS_UTSNAME_H@ NEXT_TIME_H = @NEXT_TIME_H@ NEXT_UNISTD_H = @NEXT_UNISTD_H@ NEXT_WCHAR_H = @NEXT_WCHAR_H@ @@ -874,15 +961,21 @@ PRI_MACROS_BROKEN = @PRI_MACROS_BROKEN@ PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@ RANLIB = @RANLIB@ REPLACE_BTOWC = @REPLACE_BTOWC@ +REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@ REPLACE_CEILF = @REPLACE_CEILF@ REPLACE_CEILL = @REPLACE_CEILL@ REPLACE_CHOWN = @REPLACE_CHOWN@ REPLACE_CLOSE = @REPLACE_CLOSE@ +REPLACE_CLOSEDIR = @REPLACE_CLOSEDIR@ REPLACE_DPRINTF = @REPLACE_DPRINTF@ +REPLACE_DUP = @REPLACE_DUP@ REPLACE_DUP2 = @REPLACE_DUP2@ +REPLACE_DUPLOCALE = @REPLACE_DUPLOCALE@ REPLACE_FCHDIR = @REPLACE_FCHDIR@ REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@ REPLACE_FCLOSE = @REPLACE_FCLOSE@ +REPLACE_FCNTL = @REPLACE_FCNTL@ +REPLACE_FDOPENDIR = @REPLACE_FDOPENDIR@ REPLACE_FFLUSH = @REPLACE_FFLUSH@ REPLACE_FLOORF = @REPLACE_FLOORF@ REPLACE_FLOORL = @REPLACE_FLOORL@ @@ -894,10 +987,13 @@ REPLACE_FREXP = @REPLACE_FREXP@ REPLACE_FREXPL = @REPLACE_FREXPL@ REPLACE_FSEEK = @REPLACE_FSEEK@ REPLACE_FSEEKO = @REPLACE_FSEEKO@ +REPLACE_FSTAT = @REPLACE_FSTAT@ REPLACE_FSTATAT = @REPLACE_FSTATAT@ REPLACE_FTELL = @REPLACE_FTELL@ REPLACE_FTELLO = @REPLACE_FTELLO@ +REPLACE_FUTIMENS = @REPLACE_FUTIMENS@ REPLACE_GETCWD = @REPLACE_GETCWD@ +REPLACE_GETGROUPS = @REPLACE_GETGROUPS@ REPLACE_GETLINE = @REPLACE_GETLINE@ REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@ REPLACE_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@ @@ -912,6 +1008,7 @@ REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@ REPLACE_LCHOWN = @REPLACE_LCHOWN@ REPLACE_LDEXPL = @REPLACE_LDEXPL@ REPLACE_LINK = @REPLACE_LINK@ +REPLACE_LINKAT = @REPLACE_LINKAT@ REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@ REPLACE_LSEEK = @REPLACE_LSEEK@ REPLACE_LSTAT = @REPLACE_LSTAT@ @@ -924,26 +1021,40 @@ REPLACE_MBSTATE_T = @REPLACE_MBSTATE_T@ REPLACE_MEMCHR = @REPLACE_MEMCHR@ REPLACE_MEMMEM = @REPLACE_MEMMEM@ REPLACE_MKDIR = @REPLACE_MKDIR@ +REPLACE_MKFIFO = @REPLACE_MKFIFO@ +REPLACE_MKNOD = @REPLACE_MKNOD@ REPLACE_MKSTEMP = @REPLACE_MKSTEMP@ REPLACE_MKTIME = @REPLACE_MKTIME@ REPLACE_NAN = @REPLACE_NAN@ REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@ +REPLACE_NL_LANGINFO = @REPLACE_NL_LANGINFO@ REPLACE_NULL = @REPLACE_NULL@ REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@ REPLACE_OPEN = @REPLACE_OPEN@ +REPLACE_OPENAT = @REPLACE_OPENAT@ +REPLACE_OPENDIR = @REPLACE_OPENDIR@ REPLACE_PERROR = @REPLACE_PERROR@ REPLACE_POPEN = @REPLACE_POPEN@ +REPLACE_PREAD = @REPLACE_PREAD@ REPLACE_PRINTF = @REPLACE_PRINTF@ REPLACE_PUTENV = @REPLACE_PUTENV@ +REPLACE_READLINK = @REPLACE_READLINK@ +REPLACE_REALPATH = @REPLACE_REALPATH@ +REPLACE_REMOVE = @REPLACE_REMOVE@ REPLACE_RENAME = @REPLACE_RENAME@ +REPLACE_RENAMEAT = @REPLACE_RENAMEAT@ +REPLACE_RMDIR = @REPLACE_RMDIR@ REPLACE_ROUND = @REPLACE_ROUND@ REPLACE_ROUNDF = @REPLACE_ROUNDF@ REPLACE_ROUNDL = @REPLACE_ROUNDL@ REPLACE_SELECT = @REPLACE_SELECT@ +REPLACE_SETENV = @REPLACE_SETENV@ REPLACE_SIGNBIT = @REPLACE_SIGNBIT@ REPLACE_SIGNBIT_USING_GCC = @REPLACE_SIGNBIT_USING_GCC@ +REPLACE_SLEEP = @REPLACE_SLEEP@ REPLACE_SNPRINTF = @REPLACE_SNPRINTF@ REPLACE_SPRINTF = @REPLACE_SPRINTF@ +REPLACE_STAT = @REPLACE_STAT@ REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@ REPLACE_STRCASESTR = @REPLACE_STRCASESTR@ REPLACE_STRDUP = @REPLACE_STRDUP@ @@ -954,8 +1065,14 @@ REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@ REPLACE_STRSTR = @REPLACE_STRSTR@ REPLACE_STRTOD = @REPLACE_STRTOD@ REPLACE_STRTOK_R = @REPLACE_STRTOK_R@ +REPLACE_SYMLINK = @REPLACE_SYMLINK@ REPLACE_TIMEGM = @REPLACE_TIMEGM@ REPLACE_TRUNCL = @REPLACE_TRUNCL@ +REPLACE_UNLINK = @REPLACE_UNLINK@ +REPLACE_UNLINKAT = @REPLACE_UNLINKAT@ +REPLACE_UNSETENV = @REPLACE_UNSETENV@ +REPLACE_USLEEP = @REPLACE_USLEEP@ +REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@ REPLACE_VASPRINTF = @REPLACE_VASPRINTF@ REPLACE_VDPRINTF = @REPLACE_VDPRINTF@ REPLACE_VFPRINTF = @REPLACE_VFPRINTF@ @@ -969,7 +1086,6 @@ REPLACE_WCTOB = @REPLACE_WCTOB@ REPLACE_WCWIDTH = @REPLACE_WCWIDTH@ REPLACE_WRITE = @REPLACE_WRITE@ SELINUX_CONTEXT_H = @SELINUX_CONTEXT_H@ -SELINUX_SELINUX_H = @SELINUX_SELINUX_H@ SEQ_LIBM = @SEQ_LIBM@ SERVENT_LIB = @SERVENT_LIB@ SET_MAKE = @SET_MAKE@ @@ -981,10 +1097,8 @@ STDBOOL_H = @STDBOOL_H@ STDDEF_H = @STDDEF_H@ STDINT_H = @STDINT_H@ STRIP = @STRIP@ -SYS_IOCTL_H = @SYS_IOCTL_H@ SYS_IOCTL_H_HAVE_WINSOCK2_H = @SYS_IOCTL_H_HAVE_WINSOCK2_H@ SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ -SYS_SELECT_H = @SYS_SELECT_H@ SYS_SOCKET_H = @SYS_SOCKET_H@ SYS_TIME_H = @SYS_TIME_H@ SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ @@ -998,9 +1112,7 @@ UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOC USE_ACL = @USE_ACL@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ -VOID_UNSETENV = @VOID_UNSETENV@ WARN_CFLAGS = @WARN_CFLAGS@ -WCHAR_H = @WCHAR_H@ WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@ WCTYPE_H = @WCTYPE_H@ WERROR_CFLAGS = @WERROR_CFLAGS@ @@ -1010,6 +1122,7 @@ XGETTEXT_015 = @XGETTEXT_015@ XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ YACC = @YACC@ YFLAGS = @YFLAGS@ +YIELD_LIB = @YIELD_LIB@ abs_aux_dir = @abs_aux_dir@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ @@ -1081,6 +1194,14 @@ noinst_LTLIBRARIES = # "gettextize --intl". #AM_CPPFLAGS += -I$(top_builddir)/intl +#if GNU_MAKE +# [nicer features that work only with GNU Make] +#else +# [fallback features that work in any 'make' implementation; see +# http://www.opengroup.org/susv3/utilities/make.html +# for the 2004 POSIX specification] +#endif + #script: script.in # rm -f $@-t $@ # sed -e 's#@''PREFERABLY_POSIX_SHELL''@#$(PREFERABLY_POSIX_SHELL)#g' \ @@ -1092,30 +1213,34 @@ noinst_LTLIBRARIES = #MOSTLYCLEANFILES += script script-t EXTRA_DIST = acl-internal.h acl.h acl_entries.c alignof.h alloca.c \ alloca.in.h $(top_srcdir)/build-aux/announce-gen areadlink.h \ + areadlink.h areadlink.h $(top_srcdir)/build-aux/arg-nonnull.h \ argmatch.c argmatch.h arpa_inet.in.h atexit.c backupfile.c \ backupfile.h btowc.c c-strtod.c c-strtod.h c-strtod.c \ c-strtod.h c-strtold.c calloc.c calloc.c canon-host.c \ - canon-host.h canonicalize.c canonicalize.h pathmax.h \ - chdir-long.c chdir-long.h chown.c fchown-stub.c cloexec.c \ - cloexec.h close.c close-hook.h close-stream.c close-stream.h \ - closein.c closein.h closeout.c closeout.h md5.c md5.h sha1.c \ - sha1.h sha256.c sha256.h sha512.c sha512.h cycle-check.c \ + canon-host.h canonicalize.c canonicalize.h chdir-long.c \ + chdir-long.h chown.c fchown-stub.c cloexec.c cloexec.h close.c \ + close-hook.h close-stream.c close-stream.h closein.c closein.h \ + closeout.c closeout.h md5.c md5.h sha1.c sha1.h sha256.c \ + sha256.h sha512.c sha512.h ctype.in.h cycle-check.c \ cycle-check.h dev-ino.h dirent.in.h dirent--.h dirent-safer.h \ - opendir-safer.c dirfd.c basename.c dirname.c dirname.h \ - stripslash.c dup2.c errno.in.h error.c error.h euidaccess.c \ - exclude.c exclude.h exitfail.c exitfail.h fchdir.c fclose.c \ + opendir-safer.c dirfd.c basename.c dirname.c stripslash.c \ + basename-lgpl.c dirname-lgpl.c dirname.h stripslash.c \ + $(top_srcdir)/build-aux/do-release-commit-and-tag dup2.c \ + errno.in.h error.c error.h euidaccess.c exclude.c exclude.h \ + exitfail.c exitfail.h faccessat.c fchdir.c fclose.c fcntl.c \ fcntl.in.h creat-safer.c fcntl--.h fcntl-safer.h open-safer.c \ fdopendir.c openat-priv.h openat-proc.c fflush.c stdio-impl.h \ file-set.h file-type.c file-type.h fileblocks.c filemode.c \ - filemode.h filenamecat.c filenamecat.h filevercmp.h float.in.h \ - fnmatch.c fnmatch.in.h fnmatch_loop.c fopen.c fopen-safer.c \ - stdio--.h stdio-safer.h fpending.c fpending.h fprintftime.c \ - fprintftime.h fpucw.h fpurge.c stdio-impl.h freadahead.h \ - stdio-impl.h freading.h stdio-impl.h freadptr.h stdio-impl.h \ - freadseek.h stdio-impl.h frexp.c frexp.c frexpl.c fseeko.c \ - stdio-impl.h fseterr.h stdio-impl.h fsusage.c fsusage.h \ - ftello.c ftruncate.c fts-cycle.c fts.c fts_.h \ - $(top_srcdir)/build-aux/gendocs.sh gai_strerror.c \ + filemode.h filenamecat.c filenamecat-lgpl.c filenamecat.h \ + filevercmp.h float.in.h fnmatch.c fnmatch.in.h fnmatch_loop.c \ + fopen.c fopen-safer.c stdio--.h stdio-safer.h fpending.c \ + fpending.h fprintftime.c fprintftime.h fpucw.h fpurge.c \ + stdio-impl.h freadahead.h stdio-impl.h freading.h stdio-impl.h \ + freadptr.h stdio-impl.h freadseek.h stdio-impl.h freopen.c \ + freopen-safer.c stdio--.h stdio-safer.h frexp.c frexp.c \ + frexpl.c fseeko.c stdio-impl.h fseterr.h stdio-impl.h \ + fsusage.c fsusage.h fsync.c ftello.c ftruncate.c fts-cycle.c \ + fts.c fts_.h $(top_srcdir)/build-aux/gendocs.sh gai_strerror.c \ getaddrinfo.c getcwd.c getdate.c getdate.h getdelim.c \ getgroups.c gethostname.c w32sock.h gethrxtime.c gethrxtime.h \ xtime.h getline.c getloadavg.c getndelim2.c getndelim2.h \ @@ -1124,6 +1249,7 @@ EXTRA_DIST = acl-internal.h acl.h acl_entries.c alignof.h alloca.c \ gettime.c gettimeofday.c getugroups.c getugroups.h \ getusershell.c $(top_srcdir)/build-aux/git-version-gen \ $(top_srcdir)/build-aux/gitlog-to-changelog \ + $(top_srcdir)/build-aux/gnu-web-doc-update \ $(top_srcdir)/GNUmakefile $(top_srcdir)/build-aux/gnupload \ group-member.c group-member.h hard-locale.c hard-locale.h \ hash.c hash.h hash-triple.h \ @@ -1135,119 +1261,145 @@ EXTRA_DIST = acl-internal.h acl.h acl_entries.c alignof.h alloca.c \ iconv_open-solaris.gperf iconv_open.c idcache.c idcache.h \ inet_ntop.c intprops.h imaxtostr.c inttostr.c inttostr.h \ offtostr.c uinttostr.c umaxtostr.c inttypes.in.h isapipe.c \ - isapipe.h float+.h isnan.c isnand-nolibm.h isnand.c float+.h \ - isnan.c isnanf-nolibm.h isnanf.c float+.h isnan.c \ - isnanl-nolibm.h isnanl.c lchown.c link.c \ - $(top_srcdir)/build-aux/link-warning.h config.charset \ - ref-add.sin ref-del.sin long-options.c long-options.h lseek.c \ - lstat.c $(top_srcdir)/maint.mk malloc.c malloc.c malloca.h \ + isapipe.h isblank.c float+.h isnan.c isnand-nolibm.h isnand.c \ + float+.h isnan.c isnanf-nolibm.h isnanf.c float+.h isnan.c \ + isnanl-nolibm.h isnanl.c langinfo.in.h lchown.c link.c \ + $(top_srcdir)/build-aux/link-warning.h at-func2.c linkat.c \ + config.charset ref-add.sin ref-del.sin locale.in.h \ + long-options.c long-options.h lseek.c lstat.c \ + $(top_srcdir)/maint.mk malloc.c malloc.c malloca.h \ malloca.valgrind math.in.h mbchar.h mbrlen.c mbrtowc.c \ mbsinit.c mbsrtowcs-state.c mbsrtowcs.c str-kmp.h memcasecmp.c \ memcasecmp.h memchr.c memchr.valgrind memchr2.valgrind \ memcmp.c memcmp2.h memcoll.c memcoll.h memcpy.c memmove.c \ mempcpy.c memrchr.c memset.c mgetgroups.c mgetgroups.h \ mkancesdirs.c mkancesdirs.h mkdir.c dirchownmod.c \ - dirchownmod.h mkdir-p.c mkdir-p.h mkstemp.c mktime.c \ - modechange.c modechange.h mountlist.c mountlist.h mpsort.c \ - mpsort.h nanosleep.c netdb.in.h netinet_in.in.h obstack.c \ - obstack.h open.c at-func.c fchmodat.c fchownat.c fstatat.c \ - mkdirat.c openat-priv.h openat-proc.c openat.c openat.h \ - fcntl--.h fcntl-safer.h openat-safer.c pathmax.h physmem.c \ - physmem.h posixtm.c posixtm.h posixver.c posixver.h \ - printf-frexp.h printf-frexp.c printf-frexpl.h priv-set.h \ - putenv.c quote.c quote.h quotearg.c quotearg.h raise.c \ - readlink.c readtokens.c readtokens.h readutmp.c readutmp.h \ - realloc.c realloc.c regcomp.c regex.c regex.h regex_internal.c \ - regex_internal.h regexec.c rename.c rename-dest-slash.c \ - rmdir.c root-dev-ino.c root-dev-ino.h rpmatch.c safe-read.c \ - safe-read.h safe-write.c safe-write.h same.c same.h \ - same-inode.h save-cwd.c save-cwd.h savedir.c savedir.h \ - select.c selinux-at.c selinux-at.h setenv.c settime.c \ - sig2str.c sig2str.h sig-handler.h sigaction.c signal.in.h \ - float+.h signbitd.c signbitf.c signbitl.c sigprocmask.c \ - snprintf.c w32sock.h stat-macros.h stat-time.h stdarg.in.h \ - stdbool.in.h stddef.in.h stdint.in.h stdio-write.c stdio.in.h \ - stdlib.in.h mkstemp-safer.c stdlib--.h stdlib-safer.h stpcpy.c \ - stpncpy.c strcspn.c strdup.c strdup.c streq.h strerror.c \ - strftime.c strftime.h string.in.h strndup.c strnlen.c \ - strpbrk.c str-two-way.h strstr.c strtod.c strtoimax.c strtol.c \ - strtoll.c strtoul.c strtoull.c strtoumax.c strverscmp.c \ - sys_select.in.h sys_socket.in.h sys_stat.in.h sys_time.in.h \ - tempname.c tempname.h time.in.h time_r.c timespec.h trim.h \ - u64.h unistd.in.h dup-safer.c fd-safer.c pipe-safer.c \ - unistd--.h unistd-safer.h unistr.h unitypes.h localcharset.h \ - uniwidth.h uniwidth/cjk.h unlinkdir.c unlinkdir.h \ + dirchownmod.h mkdir-p.c mkdir-p.h mkstemp.c mktime-internal.h \ + mktime.c modechange.c modechange.h mountlist.c mountlist.h \ + mpsort.c mpsort.h nanosleep.c netdb.in.h netinet_in.in.h \ + nl_langinfo.c nproc.h obstack.c obstack.h open.c at-func.c \ + fchmodat.c fchownat.c fstatat.c mkdirat.c openat-priv.h \ + openat-proc.c openat.c openat.h unlinkat.c fcntl--.h \ + fcntl-safer.h openat-safer.c pathmax.h physmem.c physmem.h \ + posixtm.c posixtm.h posixver.c posixver.h printf-frexp.h \ + printf-frexp.c printf-frexpl.h priv-set.h putenv.c quote.c \ + quote.h quotearg.c quotearg.h raise.c readlink.c readtokens.c \ + readtokens.h readutmp.c readutmp.h realloc.c realloc.c \ + regcomp.c regex.c regex.h regex_internal.c regex_internal.h \ + regexec.c remove.c rename.c rmdir.c root-dev-ino.c \ + root-dev-ino.h rpmatch.c safe-read.c safe-read.h safe-write.c \ + safe-write.h same.c same.h same-inode.h save-cwd.c save-cwd.h \ + savedir.c savedir.h select.c selinux-at.c selinux-at.h \ + getfilecon.c setenv.c settime.c sig2str.c sig2str.h \ + sig-handler.h sigaction.c signal.in.h float+.h signbitd.c \ + signbitf.c signbitl.c sigprocmask.c snprintf.c w32sock.h \ + stat.c stat-macros.h stat-time.h stdarg.in.h stdbool.in.h \ + stddef.in.h stdint.in.h stdio-write.c stdio.in.h stdlib.in.h \ + mkstemp-safer.c stdlib--.h stdlib-safer.h stpcpy.c stpncpy.c \ + strcspn.c strdup.c streq.h strerror.c strftime.c strftime.h \ + string.in.h strndup.c strnlen.c strpbrk.c siglist.h \ + strsignal.c str-two-way.h strstr.c strtod.c strtoimax.c \ + strtol.c strtoll.c strtoul.c strtoull.c strtoumax.c symlink.c \ + symlinkat.c sys_select.in.h sys_socket.in.h sys_stat.in.h \ + sys_time.in.h sys_utsname.in.h tempname.c tempname.h \ + $(top_srcdir)/build-aux/config.rpath time.in.h time_r.c \ + timespec.h trim.h u64.h uname.c unistd.in.h dup-safer.c \ + fd-safer.c pipe-safer.c unistd--.h unistd-safer.h unistr.h \ + unitypes.h localcharset.h uniwidth.h uniwidth/cjk.h unlink.c \ unlocked-io.h unsetenv.c \ + $(top_srcdir)/build-aux/unused-parameter.h \ $(top_srcdir)/build-aux/update-copyright \ $(top_srcdir)/build-aux/useless-if-before-free inttostr.h \ userspec.c userspec.h utimecmp.c utimecmp.h utimens.c \ utimens.h asnprintf.c float+.h printf-args.c printf-args.h \ printf-parse.c printf-parse.h vasnprintf.c vasnprintf.h \ asprintf.c vasprintf.c $(top_srcdir)/build-aux/vc-list-files \ - vfprintf.c vprintf.c wchar.in.h wcrtomb.c wctype.in.h \ - wcwidth.c write.c write-any-file.c write-any-file.h xalloc.h \ - xmalloc.c xgetcwd.c xgetcwd.h xnanosleep.c xnanosleep.h \ - xstrtod.c xstrtod.h xstrtol-error.c xstrtol.c xstrtol.h \ - xstrtoul.c xstrtod.c xstrtod.h xstrtold.c xalloc.h yesno.c \ - yesno.h -BUILT_SOURCES = $(ALLOCA_H) $(ARPA_INET_H) configmake.h $(DIRENT_H) \ - $(ERRNO_H) $(FCNTL_H) $(FLOAT_H) $(FNMATCH_H) getdate.c \ - $(GETOPT_H) $(ICONV_H) iconv_open-aix.h iconv_open-hpux.h \ - iconv_open-irix.h iconv_open-osf.h iconv_open-solaris.h \ - $(INTTYPES_H) math.h $(NETDB_H) $(NETINET_IN_H) \ - $(SELINUX_SELINUX_H) $(SELINUX_CONTEXT_H) signal.h $(STDARG_H) \ - $(STDBOOL_H) $(STDDEF_H) $(STDINT_H) stdio.h stdlib.h string.h \ - $(SYS_SELECT_H) $(SYS_SOCKET_H) sys/stat.h $(SYS_TIME_H) \ - time.h unistd.h $(WCHAR_H) $(WCTYPE_H) + vfprintf.c vprintf.c $(top_srcdir)/build-aux/warn-on-use.h \ + wchar.in.h wcrtomb.c wctype.in.h wcwidth.c write.c \ + write-any-file.c write-any-file.h xalloc.h xmalloc.c xgetcwd.c \ + xgetcwd.h xnanosleep.c xnanosleep.h xreadlink.h xstrtod.c \ + xstrtod.h xstrtol-error.c xstrtol.c xstrtol.h xstrtoul.c \ + xstrtod.c xstrtod.h xstrtold.c xalloc.h yesno.c yesno.h + +# The BUILT_SOURCES created by this Makefile snippet are not used via #include +# statements but through direct file reference. Therefore this snippet must be +# present in all Makefile.am that need it. This is ensured by the applicability +# 'all' defined above. + +# The BUILT_SOURCES created by this Makefile snippet are not used via #include +# statements but through direct file reference. Therefore this snippet must be +# present in all Makefile.am that need it. This is ensured by the applicability +# 'all' defined above. + +# The BUILT_SOURCES created by this Makefile snippet are not used via #include +# statements but through direct file reference. Therefore this snippet must be +# present in all Makefile.am that need it. This is ensured by the applicability +# 'all' defined above. +BUILT_SOURCES = $(ALLOCA_H) arg-nonnull.h arpa/inet.h configmake.h \ + ctype.h dirent.h $(ERRNO_H) fcntl.h $(FLOAT_H) $(FNMATCH_H) \ + getdate.c $(GETOPT_H) $(ICONV_H) iconv_open-aix.h \ + iconv_open-hpux.h iconv_open-irix.h iconv_open-osf.h \ + iconv_open-solaris.h inttypes.h langinfo.h link-warning.h \ + locale.h math.h $(NETDB_H) $(NETINET_IN_H) selinux/selinux.h \ + $(SELINUX_CONTEXT_H) signal.h $(STDARG_H) $(STDBOOL_H) \ + $(STDDEF_H) $(STDINT_H) stdio.h stdlib.h string.h sys/select.h \ + sys/socket.h sys/stat.h $(SYS_TIME_H) sys/utsname.h time.h \ + unistd.h unused-parameter.h warn-on-use.h wchar.h $(WCTYPE_H) SUFFIXES = .sed .sin -MOSTLYCLEANFILES = core *.stackdump alloca.h alloca.h-t arpa/inet.h \ - arpa/inet.h-t dirent.h dirent.h-t errno.h errno.h-t fcntl.h \ - fcntl.h-t float.h float.h-t fnmatch.h fnmatch.h-t getopt.h \ - getopt.h-t iconv.h iconv.h-t iconv_open-aix.h-t \ - iconv_open-hpux.h-t iconv_open-irix.h-t iconv_open-osf.h-t \ - iconv_open-solaris.h-t inttypes.h inttypes.h-t math.h math.h-t \ - netdb.h netdb.h-t netinet/in.h netinet/in.h-t \ - selinux/selinux.h selinux/selinux.h-t selinux/context.h \ - selinux/context.h-t signal.h signal.h-t stdarg.h stdarg.h-t \ - stdbool.h stdbool.h-t stddef.h stddef.h-t stdint.h stdint.h-t \ - stdio.h stdio.h-t stdlib.h stdlib.h-t string.h string.h-t \ - sys/select.h sys/select.h-t sys/socket.h sys/socket.h-t \ - sys/stat.h sys/stat.h-t sys/time.h sys/time.h-t time.h \ - time.h-t unistd.h unistd.h-t wchar.h wchar.h-t wctype.h \ - wctype.h-t -MOSTLYCLEANDIRS = arpa netinet selinux sys sys sys +MOSTLYCLEANFILES = core *.stackdump alloca.h alloca.h-t arg-nonnull.h \ + arg-nonnull.h-t arpa/inet.h arpa/inet.h-t ctype.h ctype.h-t \ + dirent.h dirent.h-t errno.h errno.h-t fcntl.h fcntl.h-t \ + float.h float.h-t fnmatch.h fnmatch.h-t getopt.h getopt.h-t \ + iconv.h iconv.h-t iconv_open-aix.h-t iconv_open-hpux.h-t \ + iconv_open-irix.h-t iconv_open-osf.h-t iconv_open-solaris.h-t \ + inttypes.h inttypes.h-t langinfo.h langinfo.h-t link-warning.h \ + link-warning.h-t locale.h locale.h-t math.h math.h-t netdb.h \ + netdb.h-t netinet/in.h netinet/in.h-t selinux/selinux.h \ + selinux/selinux.h-t selinux/context.h selinux/context.h-t \ + signal.h signal.h-t stdarg.h stdarg.h-t stdbool.h stdbool.h-t \ + stddef.h stddef.h-t stdint.h stdint.h-t stdio.h stdio.h-t \ + stdlib.h stdlib.h-t string.h string.h-t sys/select.h \ + sys/select.h-t sys/socket.h sys/socket.h-t sys/stat.h \ + sys/stat.h-t sys/time.h sys/time.h-t sys/utsname.h \ + sys/utsname.h-t time.h time.h-t unistd.h unistd.h-t \ + unused-parameter.h unused-parameter.h-t warn-on-use.h \ + warn-on-use.h-t wchar.h wchar.h-t wctype.h wctype.h-t +MOSTLYCLEANDIRS = arpa netinet selinux sys sys sys sys CLEANFILES = configmake.h configmake.h-t charset.alias ref-add.sed \ ref-del.sed DISTCLEANFILES = MAINTAINERCLEANFILES = getdate.c iconv_open-aix.h iconv_open-hpux.h \ iconv_open-irix.h iconv_open-osf.h iconv_open-solaris.h AM_CPPFLAGS = -AM_CFLAGS = $(WARN_CFLAGS) # $(WERROR_CFLAGS) +AM_CFLAGS = $(GNULIB_WARN_CFLAGS) $(WERROR_CFLAGS) libcoreutils_a_SOURCES = set-mode-acl.c copy-acl.c file-has-acl.c \ - areadlink-with-size.c argv-iter.c argv-iter.h base64.h \ - base64.c bitrotate.h c-ctype.h c-ctype.c c-strcase.h \ - c-strcasecmp.c c-strncasecmp.c close-hook.c diacrit.h \ - diacrit.c file-set.c filevercmp.c freadahead.c freading.c \ - freadptr.c freadseek.c fseterr.c full-read.h full-read.c \ - full-write.h full-write.c getdate.y gettext.h hash-pjw.h \ - hash-pjw.c hash-triple.c ignore-value.h linebuffer.h \ - linebuffer.c localcharset.h localcharset.c malloca.c mbchar.c \ - mbiter.h mbsalign.c mbsalign.h mbscasecmp.c mbslen.c mbsstr.c \ - mbswidth.h mbswidth.c mbuiter.h memchr2.h memchr2.c memcmp2.c \ - openat-die.c printf-frexp.c printf-frexpl.c priv-set.c \ - progname.h progname.c propername.h propername.c randint.c \ - randint.h randperm.c randperm.h randread.c randread.h \ - rand-isaac.c rand-isaac.h readtokens0.h readtokens0.c savewd.h \ - savewd.c se-context.in.h se-selinux.in.h size_max.h sockets.h \ - sockets.c striconv.h striconv.c strnlen1.h strnlen1.c trim.c \ - unicodeio.h unicodeio.c unistr/u8-uctomb.c \ - unistr/u8-uctomb-aux.c uniwidth/width.c verify.h verror.h \ - verror.c version-etc.h version-etc.c version-etc-fsf.c \ - xalloc-die.c xfreopen.c xfreopen.h xgethostname.h \ - xgethostname.c xmemcoll.h xmemcoll.c xprintf.h xprintf.c \ - xsize.h xstriconv.h xstriconv.c xstrndup.h xstrndup.c \ - xstrtoimax.c xstrtoumax.c xvasprintf.h xvasprintf.c \ - xasprintf.c buffer-lcm.c buffer-lcm.h xmemxfrm.c xmemxfrm.h + areadlink.c areadlink-with-size.c areadlinkat.c argv-iter.c \ + argv-iter.h base64.h base64.c bitrotate.h c-ctype.h c-ctype.c \ + c-strcase.h c-strcasecmp.c c-strncasecmp.c close-hook.c \ + diacrit.h diacrit.c fd-safer-flag.c dup-safer-flag.c \ + file-set.c filevercmp.c freadahead.c freading.c freadptr.c \ + freadseek.c fseterr.c full-read.h full-read.c full-write.h \ + full-write.c getdate.y gettext.h hash-pjw.h hash-pjw.c \ + hash-triple.c ignore-value.h linebuffer.h linebuffer.c \ + localcharset.h localcharset.c glthread/lock.h glthread/lock.c \ + malloca.c mbchar.c mbiter.h mbsalign.c mbsalign.h mbscasecmp.c \ + mbslen.c mbsstr.c mbswidth.h mbswidth.c mbuiter.h memchr2.h \ + memchr2.c memcmp2.c nproc.c openat-die.c printf-frexp.c \ + printf-frexpl.c priv-set.c progname.h progname.c propername.h \ + propername.c randint.c randint.h randperm.c randperm.h \ + randread.c randread.h rand-isaac.c rand-isaac.h readtokens0.h \ + readtokens0.c savewd.h savewd.c se-context.in.h \ + se-selinux.in.h size_max.h sockets.h sockets.c striconv.h \ + striconv.c strnlen1.h strnlen1.c glthread/threadlib.c \ + glthread/tls.h glthread/tls.c trim.c unicodeio.h unicodeio.c \ + unistr/u8-uctomb.c unistr/u8-uctomb-aux.c uniwidth/width.c \ + verify.h verror.h verror.c version-etc.h version-etc.c \ + version-etc-fsf.c xalloc-die.c xfreopen.c xfreopen.h \ + xgethostname.h xgethostname.c xmemcoll.h xmemcoll.c xprintf.h \ + xprintf.c xreadlink.c xsize.h xstriconv.h xstriconv.c \ + xstrndup.h xstrndup.c xstrtoimax.c xstrtoumax.c xvasprintf.h \ + xvasprintf.c xasprintf.c buffer-lcm.c buffer-lcm.h xmemxfrm.c \ + xmemxfrm.h libcoreutils_a_LIBADD = $(gl_LIBOBJS) @ALLOCA@ $(LIBOBJS) libcoreutils_a_DEPENDENCIES = $(gl_LIBOBJS) @ALLOCA@ $(LIBOBJS) EXTRA_libcoreutils_a_SOURCES = acl_entries.c alloca.c argmatch.c \ @@ -1256,49 +1408,56 @@ EXTRA_libcoreutils_a_SOURCES = acl_entries.c alloca.c argmatch.c \ chdir-long.c chown.c fchown-stub.c cloexec.c close.c \ close-stream.c closein.c closeout.c md5.c sha1.c sha256.c \ sha512.c cycle-check.c opendir-safer.c dirfd.c basename.c \ - dirname.c stripslash.c dup2.c error.c euidaccess.c exclude.c \ - exitfail.c fchdir.c fclose.c creat-safer.c open-safer.c \ - fdopendir.c openat-proc.c fflush.c file-type.c fileblocks.c \ - filemode.c filenamecat.c fnmatch.c fnmatch_loop.c fopen.c \ - fopen-safer.c fpending.c fprintftime.c fpurge.c frexp.c \ - frexp.c frexpl.c fseeko.c fsusage.c ftello.c ftruncate.c \ - fts-cycle.c fts.c gai_strerror.c getaddrinfo.c getcwd.c \ - getdelim.c getgroups.c gethostname.c gethrxtime.c getline.c \ - getloadavg.c getndelim2.c getopt.c getopt1.c getpagesize.c \ - getpass.c gettime.c gettimeofday.c getugroups.c getusershell.c \ - group-member.c hard-locale.c hash.c human.c i-ring.c \ - iconv_open.c idcache.c inet_ntop.c imaxtostr.c inttostr.c \ - offtostr.c uinttostr.c umaxtostr.c isapipe.c isnan.c isnand.c \ - isnan.c isnanf.c isnan.c isnanl.c lchown.c link.c \ - long-options.c lseek.c lstat.c malloc.c malloc.c mbrlen.c \ - mbrtowc.c mbsinit.c mbsrtowcs-state.c mbsrtowcs.c memcasecmp.c \ - memchr.c memcmp.c memcoll.c memcpy.c memmove.c mempcpy.c \ - memrchr.c memset.c mgetgroups.c mkancesdirs.c mkdir.c \ - dirchownmod.c mkdir-p.c mkstemp.c mktime.c modechange.c \ - mountlist.c mpsort.c nanosleep.c obstack.c open.c at-func.c \ + dirname.c stripslash.c basename-lgpl.c dirname-lgpl.c \ + stripslash.c dup2.c error.c euidaccess.c exclude.c exitfail.c \ + faccessat.c fchdir.c fclose.c fcntl.c creat-safer.c \ + open-safer.c fdopendir.c openat-proc.c fflush.c file-type.c \ + fileblocks.c filemode.c filenamecat.c filenamecat-lgpl.c \ + fnmatch.c fnmatch_loop.c fopen.c fopen-safer.c fpending.c \ + fprintftime.c fpurge.c freopen.c freopen-safer.c frexp.c \ + frexp.c frexpl.c fseeko.c fsusage.c fsync.c ftello.c \ + ftruncate.c fts-cycle.c fts.c gai_strerror.c getaddrinfo.c \ + getcwd.c getdelim.c getgroups.c gethostname.c gethrxtime.c \ + getline.c getloadavg.c getndelim2.c getopt.c getopt1.c \ + getpagesize.c getpass.c gettime.c gettimeofday.c getugroups.c \ + getusershell.c group-member.c hard-locale.c hash.c human.c \ + i-ring.c iconv_open.c idcache.c inet_ntop.c imaxtostr.c \ + inttostr.c offtostr.c uinttostr.c umaxtostr.c isapipe.c \ + isblank.c isnan.c isnand.c isnan.c isnanf.c isnan.c isnanl.c \ + lchown.c link.c at-func2.c linkat.c long-options.c lseek.c \ + lstat.c malloc.c malloc.c mbrlen.c mbrtowc.c mbsinit.c \ + mbsrtowcs-state.c mbsrtowcs.c memcasecmp.c memchr.c memcmp.c \ + memcoll.c memcpy.c memmove.c mempcpy.c memrchr.c memset.c \ + mgetgroups.c mkancesdirs.c mkdir.c dirchownmod.c mkdir-p.c \ + mkstemp.c mktime.c modechange.c mountlist.c mpsort.c \ + nanosleep.c nl_langinfo.c obstack.c open.c at-func.c \ fchmodat.c fchownat.c fstatat.c mkdirat.c openat-proc.c \ - openat.c openat-safer.c physmem.c posixtm.c posixver.c \ - printf-frexp.c putenv.c quote.c quotearg.c raise.c readlink.c \ - readtokens.c readutmp.c realloc.c realloc.c regcomp.c regex.c \ - regex_internal.c regexec.c rename.c rename-dest-slash.c \ + openat.c unlinkat.c openat-safer.c physmem.c posixtm.c \ + posixver.c printf-frexp.c putenv.c quote.c quotearg.c raise.c \ + readlink.c readtokens.c readutmp.c realloc.c realloc.c \ + regcomp.c regex.c regex_internal.c regexec.c remove.c rename.c \ rmdir.c root-dev-ino.c rpmatch.c safe-read.c safe-write.c \ - same.c save-cwd.c savedir.c select.c selinux-at.c setenv.c \ - settime.c sig2str.c sigaction.c signbitd.c signbitf.c \ - signbitl.c sigprocmask.c snprintf.c stdio-write.c \ - mkstemp-safer.c stpcpy.c stpncpy.c strcspn.c strdup.c strdup.c \ - strerror.c strftime.c strndup.c strnlen.c strpbrk.c strstr.c \ - strtod.c strtoimax.c strtol.c strtoll.c strtoul.c strtoull.c \ - strtoumax.c strverscmp.c tempname.c time_r.c dup-safer.c \ - fd-safer.c pipe-safer.c unlinkdir.c unsetenv.c userspec.c \ - utimecmp.c utimens.c asnprintf.c printf-args.c printf-parse.c \ + same.c save-cwd.c savedir.c select.c selinux-at.c getfilecon.c \ + setenv.c settime.c sig2str.c sigaction.c signbitd.c signbitf.c \ + signbitl.c sigprocmask.c snprintf.c stat.c stdio-write.c \ + mkstemp-safer.c stpcpy.c stpncpy.c strcspn.c strdup.c \ + strerror.c strftime.c strndup.c strnlen.c strpbrk.c \ + strsignal.c strstr.c strtod.c strtoimax.c strtol.c strtoll.c \ + strtoul.c strtoull.c strtoumax.c symlink.c symlinkat.c \ + tempname.c time_r.c uname.c dup-safer.c fd-safer.c \ + pipe-safer.c unlink.c unsetenv.c userspec.c utimecmp.c \ + utimens.c asnprintf.c printf-args.c printf-parse.c \ vasnprintf.c asprintf.c vasprintf.c vfprintf.c vprintf.c \ wcrtomb.c wcwidth.c write.c write-any-file.c xmalloc.c \ xgetcwd.c xnanosleep.c xstrtod.c xstrtol-error.c xstrtol.c \ xstrtoul.c xstrtod.c xstrtold.c yesno.c +ARG_NONNULL_H = arg-nonnull.h GPERF = gperf -LINK_WARNING_H = $(top_srcdir)/build-aux/link-warning.h +LINK_WARNING_H = link-warning.h charset_alias = $(DESTDIR)$(libdir)/charset.alias charset_tmp = $(DESTDIR)$(libdir)/charset.tmp +UNUSED_PARAMETER_H = unused-parameter.h +WARN_ON_USE_H = warn-on-use.h all: $(BUILT_SOURCES) config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive @@ -1354,6 +1513,18 @@ distclean-hdr: clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +glthread/$(am__dirstamp): + @$(MKDIR_P) glthread + @: > glthread/$(am__dirstamp) +glthread/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) glthread/$(DEPDIR) + @: > glthread/$(DEPDIR)/$(am__dirstamp) +glthread/lock.$(OBJEXT): glthread/$(am__dirstamp) \ + glthread/$(DEPDIR)/$(am__dirstamp) +glthread/threadlib.$(OBJEXT): glthread/$(am__dirstamp) \ + glthread/$(DEPDIR)/$(am__dirstamp) +glthread/tls.$(OBJEXT): glthread/$(am__dirstamp) \ + glthread/$(DEPDIR)/$(am__dirstamp) unistr/$(am__dirstamp): @$(MKDIR_P) unistr @: > unistr/$(am__dirstamp) @@ -1388,6 +1559,9 @@ clean-noinstLTLIBRARIES: mostlyclean-compile: -rm -f *.$(OBJEXT) + -rm -f glthread/lock.$(OBJEXT) + -rm -f glthread/threadlib.$(OBJEXT) + -rm -f glthread/tls.$(OBJEXT) -rm -f unistr/u8-uctomb-aux.$(OBJEXT) -rm -f unistr/u8-uctomb.$(OBJEXT) -rm -f uniwidth/width.$(OBJEXT) @@ -1405,14 +1579,18 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/acl_entries.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alloca.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/areadlink-with-size.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/areadlink.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/areadlinkat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argmatch.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argv-iter.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asnprintf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asprintf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/at-func.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/at-func2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atexit.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/backupfile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base64.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/basename-lgpl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/basename.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/btowc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/buffer-lcm.Po@am__quote@ @@ -1438,18 +1616,23 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/diacrit.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dirchownmod.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dirfd.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dirname-lgpl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dirname.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dup-safer-flag.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dup-safer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dup2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/euidaccess.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exclude.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exitfail.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/faccessat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fchdir.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fchmodat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fchown-stub.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fchownat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fclose.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fcntl.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fd-safer-flag.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fd-safer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdopendir.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fflush.Po@am__quote@ @@ -1458,6 +1641,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file-type.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileblocks.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filemode.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filenamecat-lgpl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filenamecat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filevercmp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fnmatch.Po@am__quote@ @@ -1471,12 +1655,15 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/freading.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/freadptr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/freadseek.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/freopen-safer.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/freopen.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/frexp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/frexpl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fseeko.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fseterr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstatat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fsusage.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fsync.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftello.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftruncate.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fts-cycle.Po@am__quote@ @@ -1488,6 +1675,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getcwd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getdate.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getdelim.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getfilecon.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getgroups.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gethostname.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gethrxtime.Po@am__quote@ @@ -1515,6 +1703,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inet_ntop.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inttostr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isapipe.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isblank.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isnan.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isnand.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isnanf.Po@am__quote@ @@ -1522,6 +1711,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lchown.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linebuffer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/link.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linkat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localcharset.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/long-options.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lseek.Po@am__quote@ @@ -1563,6 +1753,8 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mountlist.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mpsort.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nanosleep.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nl_langinfo.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nproc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/obstack.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/offtostr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/open-safer.Po@am__quote@ @@ -1600,7 +1792,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regex.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regex_internal.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regexec.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rename-dest-slash.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/remove.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rename.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rmdir.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/root-dev-ino.Po@am__quote@ @@ -1627,6 +1819,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sigprocmask.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/snprintf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sockets.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdio-write.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stpcpy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stpncpy.Po@am__quote@ @@ -1640,6 +1833,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strnlen.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strnlen1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strpbrk.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strsignal.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strstr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strtod.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strtoimax.Po@am__quote@ @@ -1648,14 +1842,17 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strtoul.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strtoull.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strtoumax.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strverscmp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symlink.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symlinkat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tempname.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/time_r.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trim.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uinttostr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/umaxtostr.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uname.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unicodeio.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unlinkdir.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unlink.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unlinkat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unsetenv.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/userspec.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utimecmp.Po@am__quote@ @@ -1681,6 +1878,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmemxfrm.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xnanosleep.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xprintf.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xreadlink.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xstriconv.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xstrndup.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xstrtod.Po@am__quote@ @@ -1692,6 +1890,9 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xstrtoumax.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xvasprintf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yesno.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@glthread/$(DEPDIR)/lock.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@glthread/$(DEPDIR)/threadlib.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@glthread/$(DEPDIR)/tls.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@unistr/$(DEPDIR)/u8-uctomb-aux.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@unistr/$(DEPDIR)/u8-uctomb.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@uniwidth/$(DEPDIR)/width.Po@am__quote@ @@ -1724,7 +1925,7 @@ distclean-compile: # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): - @failcom='exit 1'; \ + @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ @@ -1749,7 +1950,7 @@ $(RECURSIVE_TARGETS): fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): - @failcom='exit 1'; \ + @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ @@ -1786,6 +1987,10 @@ ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done +cscopelist-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) cscopelist); \ + done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ @@ -1849,6 +2054,20 @@ GTAGS: && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-recursive $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags @@ -1941,6 +2160,8 @@ clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -rm -f glthread/$(DEPDIR)/$(am__dirstamp) + -rm -f glthread/$(am__dirstamp) -rm -f unistr/$(DEPDIR)/$(am__dirstamp) -rm -f unistr/$(am__dirstamp) -rm -f uniwidth/$(DEPDIR)/$(am__dirstamp) @@ -1959,7 +2180,7 @@ clean-am: clean-generic clean-noinstLIBRARIES clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-recursive - -rm -rf $(DEPDIR) ./$(DEPDIR) unistr/$(DEPDIR) uniwidth/$(DEPDIR) + -rm -rf $(DEPDIR) ./$(DEPDIR) glthread/$(DEPDIR) unistr/$(DEPDIR) uniwidth/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-local distclean-tags @@ -2005,7 +2226,7 @@ install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive - -rm -rf $(DEPDIR) ./$(DEPDIR) unistr/$(DEPDIR) uniwidth/$(DEPDIR) + -rm -rf $(DEPDIR) ./$(DEPDIR) glthread/$(DEPDIR) unistr/$(DEPDIR) uniwidth/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -2025,24 +2246,24 @@ ps-am: uninstall-am: uninstall-local .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check \ - ctags-recursive install install-am install-strip \ - tags-recursive + cscopelist-recursive ctags-recursive install install-am \ + install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am all-local check check-am clean clean-generic \ - clean-noinstLIBRARIES clean-noinstLTLIBRARIES ctags \ - ctags-recursive distclean distclean-compile distclean-generic \ - distclean-hdr distclean-local distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-exec-local install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-compile mostlyclean-generic \ - mostlyclean-local pdf pdf-am ps ps-am tags tags-recursive \ - uninstall uninstall-am uninstall-local + clean-noinstLIBRARIES clean-noinstLTLIBRARIES cscopelist \ + cscopelist-recursive ctags ctags-recursive distclean \ + distclean-compile distclean-generic distclean-hdr \ + distclean-local distclean-tags distdir dvi dvi-am html html-am \ + info info-am install install-am install-data install-data-am \ + install-dvi install-dvi-am install-exec install-exec-am \ + install-exec-local install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-local pdf pdf-am ps ps-am tags \ + tags-recursive uninstall uninstall-am uninstall-local # We need the following in order to create when the system @@ -2053,10 +2274,18 @@ alloca.h: alloca.in.h cat $(srcdir)/alloca.in.h; \ } > $@-t && \ mv -f $@-t $@ +# The arg-nonnull.h that gets inserted into generated .h files is the same as +# build-aux/arg-nonnull.h, except that it has the copyright header cut off. +arg-nonnull.h: $(top_srcdir)/build-aux/arg-nonnull.h + $(AM_V_GEN)rm -f $@-t $@ && \ + sed -n -e '/GL_ARG_NONNULL/,$$p' \ + < $(top_srcdir)/build-aux/arg-nonnull.h \ + > $@-t && \ + mv $@-t $@ # We need the following in order to create when the system # doesn't have one. -arpa/inet.h: arpa_inet.in.h +arpa/inet.h: arpa_inet.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) $(AM_V_at)$(MKDIR_P) arpa $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ @@ -2069,6 +2298,7 @@ arpa/inet.h: arpa_inet.in.h -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \ -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/arpa_inet.in.h; \ } > $@-t && \ mv $@-t $@ @@ -2127,9 +2357,24 @@ configmake.h: Makefile rm -f $@; mv $@-t $@; \ fi +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +ctype.h: ctype.in.h $(LINK_WARNING_H) + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''NEXT_CTYPE_H''@|$(NEXT_CTYPE_H)|g' \ + -e 's/@''GNULIB_ISBLANK''@/$(GNULIB_ISBLANK)/g' \ + -e 's/@''HAVE_ISBLANK''@/$(HAVE_ISBLANK)/g' \ + -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + < $(srcdir)/ctype.in.h; \ + } > $@-t && \ + mv $@-t $@ + # We need the following in order to create when the system # doesn't have one that works with the given compiler. -dirent.h: dirent.in.h +dirent.h: dirent.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -2143,8 +2388,11 @@ dirent.h: dirent.in.h -e 's|@''HAVE_FDOPENDIR''@|$(HAVE_FDOPENDIR)|g' \ -e 's|@''HAVE_SCANDIR''@|$(HAVE_SCANDIR)|g' \ -e 's|@''HAVE_ALPHASORT''@|$(HAVE_ALPHASORT)|g' \ - -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ + -e 's|@''REPLACE_CLOSEDIR''@|$(REPLACE_CLOSEDIR)|g' \ + -e 's|@''REPLACE_FDOPENDIR''@|$(REPLACE_FDOPENDIR)|g' \ + -e 's|@''REPLACE_OPENDIR''@|$(REPLACE_OPENDIR)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/dirent.in.h; \ } > $@-t && \ mv $@-t $@ @@ -2169,17 +2417,22 @@ errno.h: errno.in.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. -fcntl.h: fcntl.in.h +fcntl.h: fcntl.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \ + -e 's|@''GNULIB_FCNTL''@|$(GNULIB_FCNTL)|g' \ -e 's|@''GNULIB_OPEN''@|$(GNULIB_OPEN)|g' \ -e 's|@''GNULIB_OPENAT''@|$(GNULIB_OPENAT)|g' \ - -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \ + -e 's|@''HAVE_FCNTL''@|$(HAVE_FCNTL)|g' \ -e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \ + -e 's|@''REPLACE_FCNTL''@|$(REPLACE_FCNTL)|g' \ + -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \ + -e 's|@''REPLACE_OPENAT''@|$(REPLACE_OPENAT)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/fcntl.in.h; \ } > $@-t && \ mv $@-t $@ @@ -2198,37 +2451,35 @@ float.h: float.in.h # We need the following in order to create when the system # doesn't have one that supports the required API. -fnmatch.h: fnmatch.in.h +fnmatch.h: fnmatch.in.h $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - cat $(srcdir)/fnmatch.in.h; \ + sed -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + < $(srcdir)/fnmatch.in.h; \ } > $@-t && \ mv -f $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. -getopt.h: getopt.in.h +getopt.h: getopt.in.h $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - cat $(srcdir)/getopt.in.h; \ + sed -e 's|@''HAVE_GETOPT_H''@|$(HAVE_GETOPT_H)|g' \ + -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''NEXT_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + < $(srcdir)/getopt.in.h; \ } > $@-t && \ mv -f $@-t $@ -#if GNU_MAKE -# [nicer features that work only with GNU Make] -#else -# [fallback features that work in any 'make' implementation; see -# http://www.opengroup.org/susv3/utilities/make.html -# for the 2004 POSIX specification] -#endif - distclean-local: clean-GNUmakefile clean-GNUmakefile: test x'$(VPATH)' != x && rm -f $(top_builddir)/GNUmakefile || : # We need the following in order to create when the system # doesn't have one that works with the given compiler. -iconv.h: iconv.in.h +iconv.h: iconv.in.h $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -2238,6 +2489,7 @@ iconv.h: iconv.in.h -e 's|@''REPLACE_ICONV''@|$(REPLACE_ICONV)|g' \ -e 's|@''REPLACE_ICONV_OPEN''@|$(REPLACE_ICONV_OPEN)|g' \ -e 's|@''REPLACE_ICONV_UTF''@|$(REPLACE_ICONV_UTF)|g' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/iconv.in.h; \ } > $@-t && \ mv $@-t $@ @@ -2260,7 +2512,7 @@ iconv_open-solaris.h: iconv_open-solaris.gperf # We need the following in order to create when the system # doesn't have one that works with the given compiler. -inttypes.h: inttypes.in.h +inttypes.h: inttypes.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \ @@ -2285,10 +2537,38 @@ inttypes.h: inttypes.in.h -e 's/@''UINT32_MAX_LT_UINTMAX_MAX''@/$(UINT32_MAX_LT_UINTMAX_MAX)/g' \ -e 's/@''UINT64_MAX_EQ_ULONG_MAX''@/$(UINT64_MAX_EQ_ULONG_MAX)/g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/inttypes.in.h; \ } > $@-t && \ mv $@-t $@ +# We need the following in order to create an empty placeholder for +# when the system doesn't have one. +langinfo.h: langinfo.in.h $(LINK_WARNING_H) + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's|@''HAVE_LANGINFO_H''@|$(HAVE_LANGINFO_H)|g' \ + -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''NEXT_LANGINFO_H''@|$(NEXT_LANGINFO_H)|g' \ + -e 's|@''GNULIB_NL_LANGINFO''@|$(GNULIB_NL_LANGINFO)|g' \ + -e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \ + -e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \ + -e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \ + -e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \ + -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + < $(srcdir)/langinfo.in.h; \ + } > $@-t && \ + mv $@-t $@ +# The link-warning.h that gets inserted into generated .h files is the same as +# build-aux/link-warning.h, except that it has the copyright header cut off. +link-warning.h: $(top_srcdir)/build-aux/link-warning.h + $(AM_V_GEN)rm -f $@-t $@ && \ + sed -n -e '/GL_LINK_WARNING/,$$p' \ + < $(top_srcdir)/build-aux/link-warning.h \ + > $@-t && \ + mv $@-t $@ + # We need the following in order to install a simple file in $(libdir) # which is shared with other installed packages. We use a list of referencing # packages so that "make uninstall" will remove the file if and only if it @@ -2348,9 +2628,26 @@ charset.alias: config.charset sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > t-$@ && \ mv t-$@ $@ +# We need the following in order to create when the system +# doesn't have one that provides all definitions. +locale.h: locale.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ + sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''NEXT_LOCALE_H''@|$(NEXT_LOCALE_H)|g' \ + -e 's|@''GNULIB_DUPLOCALE''@|$(GNULIB_DUPLOCALE)|g' \ + -e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \ + -e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \ + -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + < $(srcdir)/locale.in.h; \ + } > $@-t && \ + mv $@-t $@ + # We need the following in order to create when the system # doesn't have one that works with the given compiler. -math.h: math.in.h +math.h: math.in.h $(LINK_WARNING_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \ @@ -2412,13 +2709,15 @@ math.h: math.in.h -e 's|@''REPLACE_SIGNBIT_USING_GCC''@|$(REPLACE_SIGNBIT_USING_GCC)|g' \ -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ < $(srcdir)/math.in.h; \ } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. -netdb.h: netdb.in.h +netdb.h: netdb.in.h $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -2431,6 +2730,7 @@ netdb.h: netdb.in.h -e 's|@''HAVE_DECL_GAI_STRERROR''@|$(HAVE_DECL_GAI_STRERROR)|g' \ -e 's|@''HAVE_DECL_GETADDRINFO''@|$(HAVE_DECL_GETADDRINFO)|g' \ -e 's|@''HAVE_DECL_GETNAMEINFO''@|$(HAVE_DECL_GETNAMEINFO)|g' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/netdb.in.h; \ } > $@-t && \ mv $@-t $@ @@ -2448,22 +2748,31 @@ netinet/in.h: netinet_in.in.h < $(srcdir)/netinet_in.in.h; \ } > $@-t && \ mv $@-t $@ -selinux/selinux.h: se-selinux.in.h +selinux/selinux.h: se-selinux.in.h $(UNUSED_PARAMETER_H) $(AM_V_at)$(MKDIR_P) selinux $(AM_V_GEN)rm -f $@-t $@ && \ - cp $(srcdir)/se-selinux.in.h $@-t && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ + sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''NEXT_SELINUX_SELINUX_H''@|$(NEXT_SELINUX_SELINUX_H)|g' \ + -e '/definition of _GL_UNUSED_PARAMETER/r $(UNUSED_PARAMETER_H)' \ + < $(srcdir)/se-selinux.in.h; \ + } > $@-t && \ chmod a-x $@-t && \ mv $@-t $@ -selinux/context.h: se-context.in.h +selinux/context.h: se-context.in.h $(UNUSED_PARAMETER_H) $(AM_V_at)$(MKDIR_P) selinux $(AM_V_GEN)rm -f $@-t $@ && \ - cp $(srcdir)/se-context.in.h $@-t && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ + sed -e '/definition of _GL_UNUSED_PARAMETER/r $(UNUSED_PARAMETER_H)' \ + < $(srcdir)/se-context.in.h; \ + } > $@-t && \ chmod a-x $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have a complete one. -signal.h: signal.in.h +signal.h: signal.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -2479,6 +2788,7 @@ signal.h: signal.in.h -e 's|@''HAVE_STRUCT_SIGACTION_SA_SIGACTION''@|$(HAVE_STRUCT_SIGACTION_SA_SIGACTION)|g' \ -e 's|@''HAVE_TYPE_VOLATILE_SIG_ATOMIC_T''@|$(HAVE_TYPE_VOLATILE_SIG_ATOMIC_T)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/signal.in.h; \ } > $@-t && \ mv $@-t $@ @@ -2553,7 +2863,7 @@ stdint.h: stdint.in.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. -stdio.h: stdio.in.h +stdio.h: stdio.in.h $(LINK_WARNING_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -2585,7 +2895,9 @@ stdio.h: stdio.in.h -e 's|@''GNULIB_PUTC''@|$(GNULIB_PUTC)|g' \ -e 's|@''GNULIB_PUTCHAR''@|$(GNULIB_PUTCHAR)|g' \ -e 's|@''GNULIB_PUTS''@|$(GNULIB_PUTS)|g' \ + -e 's|@''GNULIB_REMOVE''@|$(GNULIB_REMOVE)|g' \ -e 's|@''GNULIB_RENAME''@|$(GNULIB_RENAME)|g' \ + -e 's|@''GNULIB_RENAMEAT''@|$(GNULIB_RENAMEAT)|g' \ -e 's|@''GNULIB_SNPRINTF''@|$(GNULIB_SNPRINTF)|g' \ -e 's|@''GNULIB_SPRINTF_POSIX''@|$(GNULIB_SPRINTF_POSIX)|g' \ -e 's|@''GNULIB_STDIO_H_SIGPIPE''@|$(GNULIB_STDIO_H_SIGPIPE)|g' \ @@ -2604,6 +2916,7 @@ stdio.h: stdio.in.h -e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \ -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \ -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \ + -e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \ -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \ -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \ -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \ @@ -2622,7 +2935,9 @@ stdio.h: stdio.in.h -e 's|@''REPLACE_PERROR''@|$(REPLACE_PERROR)|g' \ -e 's|@''REPLACE_POPEN''@|$(REPLACE_POPEN)|g' \ -e 's|@''REPLACE_PRINTF''@|$(REPLACE_PRINTF)|g' \ + -e 's|@''REPLACE_REMOVE''@|$(REPLACE_REMOVE)|g' \ -e 's|@''REPLACE_RENAME''@|$(REPLACE_RENAME)|g' \ + -e 's|@''REPLACE_RENAMEAT''@|$(REPLACE_RENAMEAT)|g' \ -e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \ -e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \ -e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \ @@ -2633,30 +2948,35 @@ stdio.h: stdio.in.h -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \ -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ < $(srcdir)/stdio.in.h; \ } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. -stdlib.h: stdlib.in.h +stdlib.h: stdlib.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \ - -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \ - -e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \ - -e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \ - -e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \ -e 's|@''GNULIB_ATOLL''@|$(GNULIB_ATOLL)|g' \ + -e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \ + -e 's|@''GNULIB_CANONICALIZE_FILE_NAME''@|$(GNULIB_CANONICALIZE_FILE_NAME)|g' \ -e 's|@''GNULIB_GETLOADAVG''@|$(GNULIB_GETLOADAVG)|g' \ -e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \ + -e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \ -e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \ -e 's|@''GNULIB_MKOSTEMP''@|$(GNULIB_MKOSTEMP)|g' \ + -e 's|@''GNULIB_MKOSTEMPS''@|$(GNULIB_MKOSTEMPS)|g' \ -e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \ + -e 's|@''GNULIB_MKSTEMPS''@|$(GNULIB_MKSTEMPS)|g' \ -e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \ -e 's|@''GNULIB_RANDOM_R''@|$(GNULIB_RANDOM_R)|g' \ + -e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \ + -e 's|@''GNULIB_REALPATH''@|$(GNULIB_REALPATH)|g' \ -e 's|@''GNULIB_RPMATCH''@|$(GNULIB_RPMATCH)|g' \ -e 's|@''GNULIB_SETENV''@|$(GNULIB_SETENV)|g' \ -e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \ @@ -2665,12 +2985,18 @@ stdlib.h: stdlib.in.h -e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \ -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \ -e 's|@''HAVE_CALLOC_POSIX''@|$(HAVE_CALLOC_POSIX)|g' \ + -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \ + -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \ -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \ -e 's|@''HAVE_MALLOC_POSIX''@|$(HAVE_MALLOC_POSIX)|g' \ -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \ -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \ - -e 's|@''HAVE_REALLOC_POSIX''@|$(HAVE_REALLOC_POSIX)|g' \ + -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \ + -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \ + -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \ -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \ + -e 's|@''HAVE_REALLOC_POSIX''@|$(HAVE_REALLOC_POSIX)|g' \ + -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \ -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \ -e 's|@''HAVE_SETENV''@|$(HAVE_SETENV)|g' \ -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \ @@ -2679,19 +3005,22 @@ stdlib.h: stdlib.in.h -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \ -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \ -e 's|@''HAVE_UNSETENV''@|$(HAVE_UNSETENV)|g' \ - -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \ + -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \ -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \ -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \ + -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \ + -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \ -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \ - -e 's|@''VOID_UNSETENV''@|$(VOID_UNSETENV)|g' \ + -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/stdlib.in.h; \ } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. -string.h: string.in.h +string.h: string.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -2730,6 +3059,7 @@ string.h: string.in.h -e 's|@''GNULIB_STRERROR''@|$(GNULIB_STRERROR)|g' \ -e 's|@''GNULIB_STRSIGNAL''@|$(GNULIB_STRSIGNAL)|g' \ -e 's|@''GNULIB_STRVERSCMP''@|$(GNULIB_STRVERSCMP)|g' \ + -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \ -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \ -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \ -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \ @@ -2758,13 +3088,14 @@ string.h: string.in.h -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \ -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/string.in.h; \ } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. -sys/select.h: sys_select.in.h +sys/select.h: sys_select.in.h $(LINK_WARNING_H) $(AM_V_at)$(MKDIR_P) sys $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ @@ -2782,7 +3113,7 @@ sys/select.h: sys_select.in.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. -sys/socket.h: sys_socket.in.h +sys/socket.h: sys_socket.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) $(AM_V_at)$(MKDIR_P) sys $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ @@ -2812,13 +3143,14 @@ sys/socket.h: sys_socket.in.h -e 's|@''HAVE_SA_FAMILY_T''@|$(HAVE_SA_FAMILY_T)|g' \ -e 's|@''HAVE_ACCEPT4''@|$(HAVE_ACCEPT4)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/sys_socket.in.h; \ } > $@-t && \ mv -f $@-t $@ # We need the following in order to create when the system # has one that is incomplete. -sys/stat.h: sys_stat.in.h +sys/stat.h: sys_stat.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) $(AM_V_at)$(MKDIR_P) sys $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ @@ -2827,30 +3159,45 @@ sys/stat.h: sys_stat.in.h -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \ -e 's|@''GNULIB_FCHMODAT''@|$(GNULIB_FCHMODAT)|g' \ -e 's|@''GNULIB_FSTATAT''@|$(GNULIB_FSTATAT)|g' \ + -e 's|@''GNULIB_FUTIMENS''@|$(GNULIB_FUTIMENS)|g' \ -e 's|@''GNULIB_LCHMOD''@|$(GNULIB_LCHMOD)|g' \ -e 's|@''GNULIB_LSTAT''@|$(GNULIB_LSTAT)|g' \ -e 's|@''GNULIB_MKDIRAT''@|$(GNULIB_MKDIRAT)|g' \ + -e 's|@''GNULIB_MKFIFO''@|$(GNULIB_MKFIFO)|g' \ -e 's|@''GNULIB_MKFIFOAT''@|$(GNULIB_MKFIFOAT)|g' \ + -e 's|@''GNULIB_MKNOD''@|$(GNULIB_MKNOD)|g' \ -e 's|@''GNULIB_MKNODAT''@|$(GNULIB_MKNODAT)|g' \ + -e 's|@''GNULIB_STAT''@|$(GNULIB_STAT)|g' \ + -e 's|@''GNULIB_UTIMENSAT''@|$(GNULIB_UTIMENSAT)|g' \ -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \ -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \ + -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \ -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \ -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \ -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \ + -e 's|@''HAVE_MKFIFO''@|$(HAVE_MKFIFO)|g' \ -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \ + -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \ -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \ - -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ + -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \ + -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \ -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \ + -e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \ -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \ -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \ + -e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \ + -e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \ + -e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \ + -e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/sys_stat.in.h; \ } > $@-t && \ mv $@-t $@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. -sys/time.h: sys_time.in.h +sys/time.h: sys_time.in.h $(ARG_NONNULL_H) $(AM_V_at)$(MKDIR_P) sys $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ @@ -2860,13 +3207,33 @@ sys/time.h: sys_time.in.h -e 's|@''NEXT_SYS_TIME_H''@|$(NEXT_SYS_TIME_H)|g' \ -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \ -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/sys_time.in.h; \ } > $@-t && \ mv $@-t $@ +# We need the following in order to create when the system +# does not have one. +sys/utsname.h: sys_utsname.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) + $(AM_V_at)$(MKDIR_P) sys + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's/@''HAVE_SYS_UTSNAME_H''@/$(HAVE_SYS_UTSNAME_H)/g' \ + -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''NEXT_SYS_UTSNAME_H''@|$(NEXT_SYS_UTSNAME_H)|g' \ + -e 's|@''GNULIB_UNAME''@|$(GNULIB_UNAME)|g' \ + -e 's|@''HAVE_STRUCT_UTSNAME''@|$(HAVE_STRUCT_UTSNAME)|g' \ + -e 's|@''HAVE_UNAME''@|$(HAVE_UNAME)|g' \ + -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + < $(srcdir)/sys_utsname.in.h; \ + } > $@-t && \ + mv $@-t $@ + # We need the following in order to create when the system # doesn't have one that works with the given compiler. -time.h: time.in.h +time.h: time.in.h $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -2879,13 +3246,14 @@ time.h: time.in.h -e 's|@REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \ -e 's|@SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ -e 's|@TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/time.in.h; \ } > $@-t && \ mv $@-t $@ # We need the following in order to create an empty placeholder for # when the system doesn't have one. -unistd.h: unistd.in.h +unistd.h: unistd.in.h $(LINK_WARNING_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \ @@ -2906,22 +3274,31 @@ unistd.h: unistd.in.h -e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \ -e 's|@''GNULIB_GETDOMAINNAME''@|$(GNULIB_GETDOMAINNAME)|g' \ -e 's|@''GNULIB_GETDTABLESIZE''@|$(GNULIB_GETDTABLESIZE)|g' \ + -e 's|@''GNULIB_GETGROUPS''@|$(GNULIB_GETGROUPS)|g' \ -e 's|@''GNULIB_GETHOSTNAME''@|$(GNULIB_GETHOSTNAME)|g' \ + -e 's|@''GNULIB_GETLOGIN''@|$(GNULIB_GETLOGIN)|g' \ -e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \ -e 's|@''GNULIB_GETPAGESIZE''@|$(GNULIB_GETPAGESIZE)|g' \ -e 's|@''GNULIB_GETUSERSHELL''@|$(GNULIB_GETUSERSHELL)|g' \ -e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \ -e 's|@''GNULIB_LINK''@|$(GNULIB_LINK)|g' \ + -e 's|@''GNULIB_LINKAT''@|$(GNULIB_LINKAT)|g' \ -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \ -e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \ + -e 's|@''GNULIB_PREAD''@|$(GNULIB_PREAD)|g' \ -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \ -e 's|@''GNULIB_READLINKAT''@|$(GNULIB_READLINKAT)|g' \ + -e 's|@''GNULIB_RMDIR''@|$(GNULIB_RMDIR)|g' \ -e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \ + -e 's|@''GNULIB_SYMLINK''@|$(GNULIB_SYMLINK)|g' \ -e 's|@''GNULIB_SYMLINKAT''@|$(GNULIB_SYMLINKAT)|g' \ -e 's|@''GNULIB_UNISTD_H_GETOPT''@|$(GNULIB_UNISTD_H_GETOPT)|g' \ -e 's|@''GNULIB_UNISTD_H_SIGPIPE''@|$(GNULIB_UNISTD_H_SIGPIPE)|g' \ + -e 's|@''GNULIB_UNLINK''@|$(GNULIB_UNLINK)|g' \ -e 's|@''GNULIB_UNLINKAT''@|$(GNULIB_UNLINKAT)|g' \ + -e 's|@''GNULIB_USLEEP''@|$(GNULIB_USLEEP)|g' \ -e 's|@''GNULIB_WRITE''@|$(GNULIB_WRITE)|g' \ + -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \ -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \ -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \ -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \ @@ -2931,41 +3308,78 @@ unistd.h: unistd.in.h -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \ -e 's|@''HAVE_GETDOMAINNAME''@|$(HAVE_GETDOMAINNAME)|g' \ -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \ + -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \ -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \ + -e 's|@''HAVE_GETLOGIN''@|$(HAVE_GETLOGIN)|g' \ -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \ -e 's|@''HAVE_GETUSERSHELL''@|$(HAVE_GETUSERSHELL)|g' \ + -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \ -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \ + -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \ -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \ + -e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \ -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \ -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \ -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \ + -e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \ -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \ -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \ + -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \ -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \ -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \ -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \ -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \ -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \ -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \ + -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \ -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \ -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \ -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ + -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \ -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \ -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \ + -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \ -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \ + -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \ + -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \ + -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \ + -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \ + -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \ + -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \ + -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \ + -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \ -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \ -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \ -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ < $(srcdir)/unistd.in.h; \ } > $@-t && \ mv $@-t $@ +# The unused-parameter.h that gets inserted into generated .h files is the same +# as build-aux/unused-parameter.h, except that it has the copyright header cut +# off. +unused-parameter.h: $(top_srcdir)/build-aux/unused-parameter.h + $(AM_V_GEN)rm -f $@-t $@ && \ + sed -n -e '/GL_UNUSED_PARAMETER/,$$p' \ + < $(top_srcdir)/build-aux/unused-parameter.h \ + > $@-t && \ + mv $@-t $@ +# The warn-on-use.h that gets inserted into generated .h files is the same as +# build-aux/warn-on-use.h, except that it has the copyright header cut off. +warn-on-use.h: $(top_srcdir)/build-aux/warn-on-use.h + $(AM_V_GEN)rm -f $@-t $@ && \ + sed -n -e '/^.ifndef/,$$p' \ + < $(top_srcdir)/build-aux/warn-on-use.h \ + > $@-t && \ + mv $@-t $@ # We need the following in order to create when the system # version does not work standalone. -wchar.h: wchar.in.h +wchar.h: wchar.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -3008,6 +3422,7 @@ wchar.h: wchar.in.h -e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \ -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/wchar.in.h; \ } > $@-t && \ mv $@-t $@ diff --git a/src/bin/coreutils/lib/acl-internal.h b/src/bin/coreutils/lib/acl-internal.h index e4661e8173..676e57aba3 100644 --- a/src/bin/coreutils/lib/acl-internal.h +++ b/src/bin/coreutils/lib/acl-internal.h @@ -1,6 +1,6 @@ /* Internal implementation of access control lists. - Copyright (C) 2002-2003, 2005-2009 Free Software Foundation, Inc. + Copyright (C) 2002-2003, 2005-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/acl.h b/src/bin/coreutils/lib/acl.h index fcb00f5ae1..f0d9e83a19 100644 --- a/src/bin/coreutils/lib/acl.h +++ b/src/bin/coreutils/lib/acl.h @@ -1,6 +1,6 @@ /* acl.c - access control lists - Copyright (C) 2002, 2008 Free Software Foundation, Inc. + Copyright (C) 2002, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/acl_entries.c b/src/bin/coreutils/lib/acl_entries.c index 12e85e565d..baf3aab345 100644 --- a/src/bin/coreutils/lib/acl_entries.c +++ b/src/bin/coreutils/lib/acl_entries.c @@ -1,6 +1,6 @@ /* Return the number of entries in an ACL. - Copyright (C) 2002-2003, 2005-2009 Free Software Foundation, Inc. + Copyright (C) 2002-2003, 2005-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,26 +37,26 @@ acl_entries (acl_t acl) #if HAVE_ACL_FIRST_ENTRY /* Linux, FreeBSD, MacOS X */ # if HAVE_ACL_TYPE_EXTENDED /* MacOS X */ /* acl_get_entry returns 0 when it successfully fetches an entry, - and -1/EINVAL at the end. */ + and -1/EINVAL at the end. */ acl_entry_t ace; int got_one; for (got_one = acl_get_entry (acl, ACL_FIRST_ENTRY, &ace); - got_one >= 0; - got_one = acl_get_entry (acl, ACL_NEXT_ENTRY, &ace)) - count++; + got_one >= 0; + got_one = acl_get_entry (acl, ACL_NEXT_ENTRY, &ace)) + count++; # else /* Linux, FreeBSD */ /* acl_get_entry returns 1 when it successfully fetches an entry, - and 0 at the end. */ + and 0 at the end. */ acl_entry_t ace; int got_one; for (got_one = acl_get_entry (acl, ACL_FIRST_ENTRY, &ace); - got_one > 0; - got_one = acl_get_entry (acl, ACL_NEXT_ENTRY, &ace)) - count++; + got_one > 0; + got_one = acl_get_entry (acl, ACL_NEXT_ENTRY, &ace)) + count++; if (got_one < 0) - return -1; + return -1; # endif #else /* IRIX, Tru64 */ # if HAVE_ACL_TO_SHORT_TEXT /* IRIX */ @@ -65,7 +65,7 @@ acl_entries (acl_t acl) # endif # if HAVE_ACL_FREE_TEXT /* Tru64 */ /* Don't use acl_get_entry: it takes only one argument and does not - work. */ + work. */ count = acl->acl_num; # endif #endif diff --git a/src/bin/coreutils/lib/alignof.h b/src/bin/coreutils/lib/alignof.h index ad682ed7c6..0ded2f798d 100644 --- a/src/bin/coreutils/lib/alignof.h +++ b/src/bin/coreutils/lib/alignof.h @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Determine alignment of types. - Copyright (C) 2003-2004, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2003-2004, 2006, 2009-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/alloca.c b/src/bin/coreutils/lib/alloca.c index 4083ab1132..370d1f9f8e 100644 --- a/src/bin/coreutils/lib/alloca.c +++ b/src/bin/coreutils/lib/alloca.c @@ -84,37 +84,37 @@ long i00afunc (); STACK_DIRECTION = 0 => direction of growth unknown */ # ifndef STACK_DIRECTION -# define STACK_DIRECTION 0 /* Direction unknown. */ +# define STACK_DIRECTION 0 /* Direction unknown. */ # endif # if STACK_DIRECTION != 0 -# define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ +# define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ # else /* STACK_DIRECTION == 0; need run-time code. */ -static int stack_dir; /* 1 or -1 once known. */ -# define STACK_DIR stack_dir +static int stack_dir; /* 1 or -1 once known. */ +# define STACK_DIR stack_dir static void find_stack_direction (void) { - static char *addr = NULL; /* Address of first `dummy', once known. */ - auto char dummy; /* To get stack address. */ + static char *addr = NULL; /* Address of first `dummy', once known. */ + auto char dummy; /* To get stack address. */ if (addr == NULL) - { /* Initial entry. */ + { /* Initial entry. */ addr = ADDRESS_FUNCTION (dummy); - find_stack_direction (); /* Recurse once. */ + find_stack_direction (); /* Recurse once. */ } else { /* Second entry. */ if (ADDRESS_FUNCTION (dummy) > addr) - stack_dir = 1; /* Stack grew upward. */ + stack_dir = 1; /* Stack grew upward. */ else - stack_dir = -1; /* Stack grew downward. */ + stack_dir = -1; /* Stack grew downward. */ } } @@ -127,21 +127,21 @@ find_stack_direction (void) It is very important that sizeof(header) agree with malloc alignment chunk size. The following default should work okay. */ -# ifndef ALIGN_SIZE -# define ALIGN_SIZE sizeof(double) +# ifndef ALIGN_SIZE +# define ALIGN_SIZE sizeof(double) # endif typedef union hdr { - char align[ALIGN_SIZE]; /* To force sizeof(header). */ + char align[ALIGN_SIZE]; /* To force sizeof(header). */ struct { - union hdr *next; /* For chaining headers. */ - char *deep; /* For stack depth measure. */ + union hdr *next; /* For chaining headers. */ + char *deep; /* For stack depth measure. */ } h; } header; -static header *last_alloca_header = NULL; /* -> last alloca header. */ +static header *last_alloca_header = NULL; /* -> last alloca header. */ /* Return a pointer to at least SIZE bytes of storage, which will be automatically reclaimed upon exit from @@ -153,11 +153,11 @@ static header *last_alloca_header = NULL; /* -> last alloca header. */ void * alloca (size_t size) { - auto char probe; /* Probes stack depth: */ + auto char probe; /* Probes stack depth: */ register char *depth = ADDRESS_FUNCTION (probe); # if STACK_DIRECTION == 0 - if (STACK_DIR == 0) /* Unknown growth direction. */ + if (STACK_DIR == 0) /* Unknown growth direction. */ find_stack_direction (); # endif @@ -165,7 +165,7 @@ alloca (size_t size) was allocated from deeper in the stack than currently. */ { - register header *hp; /* Traverses linked list. */ + register header *hp; /* Traverses linked list. */ # ifdef emacs BLOCK_INPUT; @@ -173,18 +173,18 @@ alloca (size_t size) for (hp = last_alloca_header; hp != NULL;) if ((STACK_DIR > 0 && hp->h.deep > depth) - || (STACK_DIR < 0 && hp->h.deep < depth)) - { - register header *np = hp->h.next; + || (STACK_DIR < 0 && hp->h.deep < depth)) + { + register header *np = hp->h.next; - free (hp); /* Collect garbage. */ + free (hp); /* Collect garbage. */ - hp = np; /* -> next header. */ - } + hp = np; /* -> next header. */ + } else - break; /* Rest are not deeper. */ + break; /* Rest are not deeper. */ - last_alloca_header = hp; /* -> last valid storage. */ + last_alloca_header = hp; /* -> last valid storage. */ # ifdef emacs UNBLOCK_INPUT; @@ -192,7 +192,7 @@ alloca (size_t size) } if (size == 0) - return NULL; /* No allocation required. */ + return NULL; /* No allocation required. */ /* Allocate combined header + user data storage. */ @@ -232,10 +232,10 @@ alloca (size_t size) /* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */ struct stack_control_header { - long shgrow:32; /* Number of times stack has grown. */ - long shaseg:32; /* Size of increments to stack. */ - long shhwm:32; /* High water mark of stack. */ - long shsize:32; /* Current size of stack (all segments). */ + long shgrow:32; /* Number of times stack has grown. */ + long shaseg:32; /* Size of increments to stack. */ + long shhwm:32; /* High water mark of stack. */ + long shsize:32; /* Current size of stack (all segments). */ }; /* The stack segment linkage control information occurs at @@ -247,21 +247,21 @@ struct stack_control_header struct stack_segment_linkage { - long ss[0200]; /* 0200 overflow words. */ - long sssize:32; /* Number of words in this segment. */ - long ssbase:32; /* Offset to stack base. */ + long ss[0200]; /* 0200 overflow words. */ + long sssize:32; /* Number of words in this segment. */ + long ssbase:32; /* Offset to stack base. */ long:32; - long sspseg:32; /* Offset to linkage control of previous - segment of stack. */ + long sspseg:32; /* Offset to linkage control of previous + segment of stack. */ long:32; - long sstcpt:32; /* Pointer to task common address block. */ - long sscsnm; /* Private control structure number for - microtasking. */ - long ssusr1; /* Reserved for user. */ - long ssusr2; /* Reserved for user. */ - long sstpid; /* Process ID for pid based multi-tasking. */ - long ssgvup; /* Pointer to multitasking thread giveup. */ - long sscray[7]; /* Reserved for Cray Research. */ + long sstcpt:32; /* Pointer to task common address block. */ + long sscsnm; /* Private control structure number for + microtasking. */ + long ssusr1; /* Reserved for user. */ + long ssusr2; /* Reserved for user. */ + long sstpid; /* Process ID for pid based multi-tasking. */ + long ssgvup; /* Pointer to multitasking thread giveup. */ + long sscray[7]; /* Reserved for Cray Research. */ long ssa0; long ssa1; long ssa2; @@ -285,27 +285,27 @@ struct stack_segment_linkage returned by the STKSTAT library routine. */ struct stk_stat { - long now; /* Current total stack size. */ - long maxc; /* Amount of contiguous space which would - be required to satisfy the maximum - stack demand to date. */ - long high_water; /* Stack high-water mark. */ - long overflows; /* Number of stack overflow ($STKOFEN) calls. */ - long hits; /* Number of internal buffer hits. */ - long extends; /* Number of block extensions. */ - long stko_mallocs; /* Block allocations by $STKOFEN. */ - long underflows; /* Number of stack underflow calls ($STKRETN). */ - long stko_free; /* Number of deallocations by $STKRETN. */ - long stkm_free; /* Number of deallocations by $STKMRET. */ - long segments; /* Current number of stack segments. */ - long maxs; /* Maximum number of stack segments so far. */ - long pad_size; /* Stack pad size. */ - long current_address; /* Current stack segment address. */ - long current_size; /* Current stack segment size. This - number is actually corrupted by STKSTAT to - include the fifteen word trailer area. */ - long initial_address; /* Address of initial segment. */ - long initial_size; /* Size of initial segment. */ + long now; /* Current total stack size. */ + long maxc; /* Amount of contiguous space which would + be required to satisfy the maximum + stack demand to date. */ + long high_water; /* Stack high-water mark. */ + long overflows; /* Number of stack overflow ($STKOFEN) calls. */ + long hits; /* Number of internal buffer hits. */ + long extends; /* Number of block extensions. */ + long stko_mallocs; /* Block allocations by $STKOFEN. */ + long underflows; /* Number of stack underflow calls ($STKRETN). */ + long stko_free; /* Number of deallocations by $STKRETN. */ + long stkm_free; /* Number of deallocations by $STKMRET. */ + long segments; /* Current number of stack segments. */ + long maxs; /* Maximum number of stack segments so far. */ + long pad_size; /* Stack pad size. */ + long current_address; /* Current stack segment address. */ + long current_size; /* Current stack segment size. This + number is actually corrupted by STKSTAT to + include the fifteen word trailer area. */ + long initial_address; /* Address of initial segment. */ + long initial_size; /* Size of initial segment. */ }; /* The following structure describes the data structure which trails @@ -314,13 +314,13 @@ struct stk_stat struct stk_trailer { - long this_address; /* Address of this block. */ - long this_size; /* Size of this block (does not include - this trailer). */ + long this_address; /* Address of this block. */ + long this_size; /* Size of this block (does not include + this trailer). */ long unknown2; long unknown3; - long link; /* Address of trailer block of previous - segment. */ + long link; /* Address of trailer block of previous + segment. */ long unknown5; long unknown6; long unknown7; @@ -358,8 +358,8 @@ i00afunc (long *address) /* Set up the iteration. */ trailer = (struct stk_trailer *) (status.current_address - + status.current_size - - 15); + + status.current_size + - 15); /* There must be at least one stack segment. Therefore it is a fatal error if "trailer" is null. */ @@ -374,10 +374,10 @@ i00afunc (long *address) block = (long *) trailer->this_address; size = trailer->this_size; if (block == 0 || size == 0) - abort (); + abort (); trailer = (struct stk_trailer *) trailer->link; if ((block <= address) && (address < (block + size))) - break; + break; } /* Set the result to the offset in this segment and add the sizes @@ -393,7 +393,7 @@ i00afunc (long *address) do { if (trailer->this_size <= 0) - abort (); + abort (); result += trailer->this_size; trailer = (struct stk_trailer *) trailer->link; } @@ -456,7 +456,7 @@ i00afunc (long address) fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl); # endif if (pseg == 0) - break; + break; stkl = stkl - pseg; ssptr = (struct stack_segment_linkage *) stkl; size = ssptr->sssize; diff --git a/src/bin/coreutils/lib/alloca.h b/src/bin/coreutils/lib/alloca.h index abe08cbf94..f85f052778 100644 --- a/src/bin/coreutils/lib/alloca.h +++ b/src/bin/coreutils/lib/alloca.h @@ -1,12 +1,15 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +#line 1 /* Memory allocation on the stack. - Copyright (C) 1995, 1999, 2001, 2002, 2003, 2004, 2006 Free Software - Foundation, Inc. + Copyright (C) 1995, 1999, 2001-2004, 2006-2010 Free Software Foundation, + Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 2, or (at your option) + by the Free Software Foundation; either version 3, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -21,8 +24,8 @@ /* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H means there is a real alloca function. */ -#ifndef _GNULIB_ALLOCA_H -# define _GNULIB_ALLOCA_H +#ifndef _GL_ALLOCA_H +#define _GL_ALLOCA_H /* alloca (N) returns a pointer to N bytes of memory allocated on the stack, which will last until the function returns. @@ -43,6 +46,8 @@ # elif defined _MSC_VER # include # define alloca _alloca +# elif defined __DECC && defined __VMS +# define alloca __ALLOCA # else # include # ifdef __cplusplus @@ -52,4 +57,4 @@ void *alloca (size_t); # endif #endif -#endif /* _GNULIB_ALLOCA_H */ +#endif /* _GL_ALLOCA_H */ diff --git a/src/bin/coreutils/lib/alloca.in.h b/src/bin/coreutils/lib/alloca.in.h index ed33a8233f..5d7df8119a 100644 --- a/src/bin/coreutils/lib/alloca.in.h +++ b/src/bin/coreutils/lib/alloca.in.h @@ -3,8 +3,8 @@ #line 1 /* Memory allocation on the stack. - Copyright (C) 1995, 1999, 2001-2004, 2006-2008 Free Software - Foundation, Inc. + Copyright (C) 1995, 1999, 2001-2004, 2006-2010 Free Software Foundation, + Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published diff --git a/src/bin/coreutils/lib/areadlink-with-size.c b/src/bin/coreutils/lib/areadlink-with-size.c index d0bcb70ad5..9616ee04bd 100644 --- a/src/bin/coreutils/lib/areadlink-with-size.c +++ b/src/bin/coreutils/lib/areadlink-with-size.c @@ -1,7 +1,7 @@ /* readlink wrapper to return the link name in malloc'd storage. Unlike xreadlink and xreadlink_with_size, don't ever call exit. - Copyright (C) 2001, 2003-2007 Free Software Foundation, Inc. + Copyright (C) 2001, 2003-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,16 +22,12 @@ #include "areadlink.h" -#include #include #include -#include +#include #include #include -#ifndef SIZE_MAX -# define SIZE_MAX ((size_t) -1) -#endif #ifndef SSIZE_MAX # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) #endif @@ -61,8 +57,8 @@ areadlink_with_size (char const *file, size_t size) size_t symlink_max = SYMLINK_MAX; size_t INITIAL_LIMIT_BOUND = 8 * 1024; size_t initial_limit = (symlink_max < INITIAL_LIMIT_BOUND - ? symlink_max + 1 - : INITIAL_LIMIT_BOUND); + ? symlink_max + 1 + : INITIAL_LIMIT_BOUND); /* The initial buffer size for the link value. */ size_t buf_size = size < initial_limit ? size + 1 : initial_limit; @@ -74,35 +70,35 @@ areadlink_with_size (char const *file, size_t size) char *buffer = malloc (buf_size); if (buffer == NULL) - return NULL; + return NULL; r = readlink (file, buffer, buf_size); link_length = r; /* On AIX 5L v5.3 and HP-UX 11i v2 04/09, readlink returns -1 - with errno == ERANGE if the buffer is too small. */ + with errno == ERANGE if the buffer is too small. */ if (r < 0 && errno != ERANGE) - { - int saved_errno = errno; - free (buffer); - errno = saved_errno; - return NULL; - } + { + int saved_errno = errno; + free (buffer); + errno = saved_errno; + return NULL; + } if (link_length < buf_size) - { - buffer[link_length] = 0; - return buffer; - } + { + buffer[link_length] = 0; + return buffer; + } free (buffer); if (buf_size <= MAXSIZE / 2) - buf_size *= 2; + buf_size *= 2; else if (buf_size < MAXSIZE) - buf_size = MAXSIZE; + buf_size = MAXSIZE; else - { - errno = ENOMEM; - return NULL; - } + { + errno = ENOMEM; + return NULL; + } } } diff --git a/src/bin/coreutils/lib/areadlink.c b/src/bin/coreutils/lib/areadlink.c new file mode 100644 index 0000000000..b0db4200cb --- /dev/null +++ b/src/bin/coreutils/lib/areadlink.c @@ -0,0 +1,119 @@ +/* areadlink.c -- readlink wrapper to return the link name in malloc'd storage + Unlike xreadlink and xreadlink_with_size, don't ever call exit. + + Copyright (C) 2001, 2003-2007, 2009-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Jim Meyering + and Bruno Haible . */ + +#include + +/* Specification. */ +#include "areadlink.h" + +#include +#include +#include +#include +#include +#include + +#ifndef SSIZE_MAX +# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) +#endif + +/* The initial buffer size for the link value. A power of 2 + detects arithmetic overflow earlier, but is not required. */ +enum { + INITIAL_BUF_SIZE = 1024 +}; + +/* Call readlink to get the symbolic link value of FILENAME. + Return a pointer to that NUL-terminated string in malloc'd storage. + If readlink fails, return NULL and set errno. + If realloc fails, or if the link value is longer than SIZE_MAX :-), + return NULL and set errno to ENOMEM. */ + +char * +areadlink (char const *filename) +{ + /* Allocate the initial buffer on the stack. This way, in the common + case of a symlink of small size, we get away with a single small malloc() + instead of a big malloc() followed by a shrinking realloc(). */ + char initial_buf[INITIAL_BUF_SIZE]; + + char *buffer = initial_buf; + size_t buf_size = sizeof initial_buf; + + while (1) + { + /* Attempt to read the link into the current buffer. */ + ssize_t link_length = readlink (filename, buffer, buf_size); + + /* On AIX 5L v5.3 and HP-UX 11i v2 04/09, readlink returns -1 + with errno == ERANGE if the buffer is too small. */ + if (link_length < 0 && errno != ERANGE) + { + if (buffer != initial_buf) + { + int saved_errno = errno; + free (buffer); + errno = saved_errno; + } + return NULL; + } + + if ((size_t) link_length < buf_size) + { + buffer[link_length++] = '\0'; + + /* Return it in a chunk of memory as small as possible. */ + if (buffer == initial_buf) + { + buffer = (char *) malloc (link_length); + if (buffer == NULL) + /* errno is ENOMEM. */ + return NULL; + memcpy (buffer, initial_buf, link_length); + } + else + { + /* Shrink buffer before returning it. */ + if ((size_t) link_length < buf_size) + { + char *smaller_buffer = (char *) realloc (buffer, link_length); + + if (smaller_buffer != NULL) + buffer = smaller_buffer; + } + } + return buffer; + } + + if (buffer != initial_buf) + free (buffer); + buf_size *= 2; + if (SSIZE_MAX < buf_size || (SIZE_MAX / 2 < SSIZE_MAX && buf_size == 0)) + { + errno = ENOMEM; + return NULL; + } + buffer = (char *) malloc (buf_size); + if (buffer == NULL) + /* errno is ENOMEM. */ + return NULL; + } +} diff --git a/src/bin/coreutils/lib/areadlink.h b/src/bin/coreutils/lib/areadlink.h index 8720ed9a61..476559b9d3 100644 --- a/src/bin/coreutils/lib/areadlink.h +++ b/src/bin/coreutils/lib/areadlink.h @@ -1,6 +1,7 @@ /* Read symbolic links without size limitation. - Copyright (C) 2001, 2003, 2004, 2007 Free Software Foundation, Inc. + Copyright (C) 2001, 2003-2004, 2007, 2009-2010 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,3 +22,12 @@ extern char *areadlink (char const *filename); extern char *areadlink_with_size (char const *filename, size_t size_hint); + +#if GNULIB_AREADLINKAT +extern char *areadlinkat (int fd, char const *filename); +#endif + +#if GNULIB_AREADLINKAT_WITH_SIZE +extern char *areadlinkat_with_size (int fd, char const *filename, + size_t size_hint); +#endif diff --git a/src/bin/coreutils/lib/areadlinkat.c b/src/bin/coreutils/lib/areadlinkat.c new file mode 100644 index 0000000000..74c757240e --- /dev/null +++ b/src/bin/coreutils/lib/areadlinkat.c @@ -0,0 +1,145 @@ +/* areadlinkat.c -- readlinkat wrapper to return malloc'd link name + Unlike xreadlinkat, only call exit on failure to change directory. + + Copyright (C) 2001, 2003-2007, 2009-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Jim Meyering , + and Bruno Haible , + and Eric Blake . */ + +#include + +/* Specification. */ +#include "areadlink.h" + +#include +#include +#include +#include +#include +#include + +#ifndef SSIZE_MAX +# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) +#endif + +#if HAVE_READLINKAT + +/* The initial buffer size for the link value. A power of 2 + detects arithmetic overflow earlier, but is not required. */ +enum { + INITIAL_BUF_SIZE = 1024 +}; + +/* Call readlinkat to get the symbolic link value of FILENAME relative to FD. + Return a pointer to that NUL-terminated string in malloc'd storage. + If readlinkat fails, return NULL and set errno (although failure to + change directory will issue a diagnostic and exit). + If realloc fails, or if the link value is longer than SIZE_MAX :-), + return NULL and set errno to ENOMEM. */ + +char * +areadlinkat (int fd, char const *filename) +{ + /* Allocate the initial buffer on the stack. This way, in the common + case of a symlink of small size, we get away with a single small malloc() + instead of a big malloc() followed by a shrinking realloc(). */ + char initial_buf[INITIAL_BUF_SIZE]; + + char *buffer = initial_buf; + size_t buf_size = sizeof initial_buf; + + while (1) + { + /* Attempt to read the link into the current buffer. */ + ssize_t link_length = readlinkat (fd, filename, buffer, buf_size); + + /* On AIX 5L v5.3 and HP-UX 11i v2 04/09, readlink returns -1 + with errno == ERANGE if the buffer is too small. */ + if (link_length < 0 && errno != ERANGE) + { + if (buffer != initial_buf) + { + int saved_errno = errno; + free (buffer); + errno = saved_errno; + } + return NULL; + } + + if ((size_t) link_length < buf_size) + { + buffer[link_length++] = '\0'; + + /* Return it in a chunk of memory as small as possible. */ + if (buffer == initial_buf) + { + buffer = (char *) malloc (link_length); + if (buffer == NULL) + /* errno is ENOMEM. */ + return NULL; + memcpy (buffer, initial_buf, link_length); + } + else + { + /* Shrink buffer before returning it. */ + if ((size_t) link_length < buf_size) + { + char *smaller_buffer = (char *) realloc (buffer, link_length); + + if (smaller_buffer != NULL) + buffer = smaller_buffer; + } + } + return buffer; + } + + if (buffer != initial_buf) + free (buffer); + buf_size *= 2; + if (SSIZE_MAX < buf_size || (SIZE_MAX / 2 < SSIZE_MAX && buf_size == 0)) + { + errno = ENOMEM; + return NULL; + } + buffer = (char *) malloc (buf_size); + if (buffer == NULL) + /* errno is ENOMEM. */ + return NULL; + } +} + +#else /* !HAVE_READLINKAT */ + +/* It is more efficient to change directories only once and call + areadlink, rather than repeatedly call the replacement + readlinkat. */ + +# define AT_FUNC_NAME areadlinkat +# define AT_FUNC_F1 areadlink +# define AT_FUNC_POST_FILE_PARAM_DECLS /* empty */ +# define AT_FUNC_POST_FILE_ARGS /* empty */ +# define AT_FUNC_RESULT char * +# define AT_FUNC_FAIL NULL +# include "at-func.c" +# undef AT_FUNC_NAME +# undef AT_FUNC_F1 +# undef AT_FUNC_POST_FILE_PARAM_DECLS +# undef AT_FUNC_POST_FILE_ARGS +# undef AT_FUNC_RESULT +# undef AT_FUNC_FAIL + +#endif /* !HAVE_READLINKAT */ diff --git a/src/bin/coreutils/lib/arg-nonnull.h b/src/bin/coreutils/lib/arg-nonnull.h new file mode 100644 index 0000000000..f0dbac76e0 --- /dev/null +++ b/src/bin/coreutils/lib/arg-nonnull.h @@ -0,0 +1,10 @@ +/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools + that the values passed as arguments n, ..., m must be non-NULL pointers. + n = 1 stands for the first argument, n = 2 for the second argument etc. */ +#ifndef _GL_ARG_NONNULL +# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 +# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) +# else +# define _GL_ARG_NONNULL(params) +# endif +#endif diff --git a/src/bin/coreutils/lib/argmatch.c b/src/bin/coreutils/lib/argmatch.c index 925449bfd4..d1bffe0dad 100644 --- a/src/bin/coreutils/lib/argmatch.c +++ b/src/bin/coreutils/lib/argmatch.c @@ -1,7 +1,7 @@ /* argmatch.c -- find a match for a string in an array - Copyright (C) 1990, 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007 - Free Software Foundation, Inc. + Copyright (C) 1990, 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007, + 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -81,12 +81,12 @@ argmatch_exit_fn argmatch_die = __argmatch_die; ptrdiff_t argmatch (const char *arg, const char *const *arglist, - const char *vallist, size_t valsize) + const char *vallist, size_t valsize) { - size_t i; /* Temporary index in ARGLIST. */ - size_t arglen; /* Length of ARG. */ - ptrdiff_t matchind = -1; /* Index of first nonexact match. */ - bool ambiguous = false; /* If true, multiple nonexact match(es). */ + size_t i; /* Temporary index in ARGLIST. */ + size_t arglen; /* Length of ARG. */ + ptrdiff_t matchind = -1; /* Index of first nonexact match. */ + bool ambiguous = false; /* If true, multiple nonexact match(es). */ arglen = strlen (arg); @@ -94,26 +94,26 @@ argmatch (const char *arg, const char *const *arglist, for (i = 0; arglist[i]; i++) { if (!strncmp (arglist[i], arg, arglen)) - { - if (strlen (arglist[i]) == arglen) - /* Exact match found. */ - return i; - else if (matchind == -1) - /* First nonexact match found. */ - matchind = i; - else - { - /* Second nonexact match found. */ - if (vallist == NULL - || memcmp (vallist + valsize * matchind, - vallist + valsize * i, valsize)) - { - /* There is a real ambiguity, or we could not - disambiguate. */ - ambiguous = true; - } - } - } + { + if (strlen (arglist[i]) == arglen) + /* Exact match found. */ + return i; + else if (matchind == -1) + /* First nonexact match found. */ + matchind = i; + else + { + /* Second nonexact match found. */ + if (vallist == NULL + || memcmp (vallist + valsize * matchind, + vallist + valsize * i, valsize)) + { + /* There is a real ambiguity, or we could not + disambiguate. */ + ambiguous = true; + } + } + } } if (ambiguous) return -2; @@ -130,11 +130,11 @@ void argmatch_invalid (const char *context, const char *value, ptrdiff_t problem) { char const *format = (problem == -1 - ? _("invalid argument %s for %s") - : _("ambiguous argument %s for %s")); + ? _("invalid argument %s for %s") + : _("ambiguous argument %s for %s")); error (0, 0, format, quotearg_n_style (0, ARGMATCH_QUOTING_STYLE, value), - quote_n (1, context)); + quote_n (1, context)); } /* List the valid arguments for argmatch. @@ -143,7 +143,7 @@ argmatch_invalid (const char *context, const char *value, ptrdiff_t problem) VALSIZE is the size of the elements of VALLIST */ void argmatch_valid (const char *const *arglist, - const char *vallist, size_t valsize) + const char *vallist, size_t valsize) { size_t i; const char *last_val = NULL; @@ -153,14 +153,14 @@ argmatch_valid (const char *const *arglist, fprintf (stderr, _("Valid arguments are:")); for (i = 0; arglist[i]; i++) if ((i == 0) - || memcmp (last_val, vallist + valsize * i, valsize)) + || memcmp (last_val, vallist + valsize * i, valsize)) { - fprintf (stderr, "\n - `%s'", arglist[i]); - last_val = vallist + valsize * i; + fprintf (stderr, "\n - `%s'", arglist[i]); + last_val = vallist + valsize * i; } else { - fprintf (stderr, ", `%s'", arglist[i]); + fprintf (stderr, ", `%s'", arglist[i]); } putc ('\n', stderr); } @@ -173,9 +173,9 @@ argmatch_valid (const char *const *arglist, ptrdiff_t __xargmatch_internal (const char *context, - const char *arg, const char *const *arglist, - const char *vallist, size_t valsize, - argmatch_exit_fn exit_fn) + const char *arg, const char *const *arglist, + const char *vallist, size_t valsize, + argmatch_exit_fn exit_fn) { ptrdiff_t res = argmatch (arg, arglist, vallist, valsize); if (res >= 0) @@ -194,8 +194,8 @@ __xargmatch_internal (const char *context, return the first corresponding argument in ARGLIST */ const char * argmatch_to_argument (const char *value, - const char *const *arglist, - const char *vallist, size_t valsize) + const char *const *arglist, + const char *vallist, size_t valsize) { size_t i; @@ -263,14 +263,14 @@ main (int argc, const char *const *argv) if ((cp = getenv ("VERSION_CONTROL"))) backup_type = XARGMATCH ("$VERSION_CONTROL", cp, - backup_args, backup_vals); + backup_args, backup_vals); if (argc == 2) backup_type = XARGMATCH (program_name, argv[1], - backup_args, backup_vals); + backup_args, backup_vals); printf ("The version control is `%s'\n", - ARGMATCH_TO_ARGUMENT (backup_type, backup_args, backup_vals)); + ARGMATCH_TO_ARGUMENT (backup_type, backup_args, backup_vals)); return 0; } diff --git a/src/bin/coreutils/lib/argmatch.h b/src/bin/coreutils/lib/argmatch.h index cc403145ac..08d555bfa9 100644 --- a/src/bin/coreutils/lib/argmatch.h +++ b/src/bin/coreutils/lib/argmatch.h @@ -1,7 +1,7 @@ /* argmatch.h -- definitions and prototypes for argmatch.c - Copyright (C) 1990, 1998, 1999, 2001, 2002, 2004, 2005 Free Software - Foundation, Inc. + Copyright (C) 1990, 1998, 1999, 2001, 2002, 2004, 2005, 2009, 2010 Free + Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -40,7 +40,7 @@ to the same values in VALLIST). */ ptrdiff_t argmatch (char const *arg, char const *const *arglist, - char const *vallist, size_t valsize); + char const *vallist, size_t valsize); # define ARGMATCH(Arg, Arglist, Vallist) \ argmatch (Arg, Arglist, (char const *) (Vallist), sizeof *(Vallist)) @@ -54,7 +54,7 @@ extern argmatch_exit_fn argmatch_die; /* Report on stderr why argmatch failed. Report correct values. */ void argmatch_invalid (char const *context, char const *value, - ptrdiff_t problem); + ptrdiff_t problem); /* Left for compatibility with the old name invalid_arg */ @@ -66,7 +66,7 @@ void argmatch_invalid (char const *context, char const *value, /* Report on stderr the list of possible arguments. */ void argmatch_valid (char const *const *arglist, - char const *vallist, size_t valsize); + char const *vallist, size_t valsize); # define ARGMATCH_VALID(Arglist, Vallist) \ argmatch_valid (Arglist, (char const *) (Vallist), sizeof *(Vallist)) @@ -77,26 +77,26 @@ void argmatch_valid (char const *const *arglist, failure, and exits using the function EXIT_FN. */ ptrdiff_t __xargmatch_internal (char const *context, - char const *arg, char const *const *arglist, - char const *vallist, size_t valsize, - argmatch_exit_fn exit_fn); + char const *arg, char const *const *arglist, + char const *vallist, size_t valsize, + argmatch_exit_fn exit_fn); /* Programmer friendly interface to __xargmatch_internal. */ -# define XARGMATCH(Context, Arg, Arglist, Vallist) \ - ((Vallist) [__xargmatch_internal (Context, Arg, Arglist, \ - (char const *) (Vallist), \ - sizeof *(Vallist), \ - argmatch_die)]) +# define XARGMATCH(Context, Arg, Arglist, Vallist) \ + ((Vallist) [__xargmatch_internal (Context, Arg, Arglist, \ + (char const *) (Vallist), \ + sizeof *(Vallist), \ + argmatch_die)]) /* Convert a value into a corresponding argument. */ char const *argmatch_to_argument (char const *value, - char const *const *arglist, - char const *vallist, size_t valsize); + char const *const *arglist, + char const *vallist, size_t valsize); -# define ARGMATCH_TO_ARGUMENT(Value, Arglist, Vallist) \ - argmatch_to_argument (Value, Arglist, \ - (char const *) (Vallist), sizeof *(Vallist)) +# define ARGMATCH_TO_ARGUMENT(Value, Arglist, Vallist) \ + argmatch_to_argument (Value, Arglist, \ + (char const *) (Vallist), sizeof *(Vallist)) #endif /* ARGMATCH_H_ */ diff --git a/src/bin/coreutils/lib/argv-iter.c b/src/bin/coreutils/lib/argv-iter.c index 05b06efd82..c65a3cc42b 100644 --- a/src/bin/coreutils/lib/argv-iter.c +++ b/src/bin/coreutils/lib/argv-iter.c @@ -1,5 +1,5 @@ /* Iterate over arguments from argv or --files0-from=FILE - Copyright (C) 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/argv-iter.h b/src/bin/coreutils/lib/argv-iter.h index 537fb1ea29..685faa21e6 100644 --- a/src/bin/coreutils/lib/argv-iter.h +++ b/src/bin/coreutils/lib/argv-iter.h @@ -1,5 +1,5 @@ /* Iterate over arguments from argv or --files0-from=FILE - Copyright (C) 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,16 +17,12 @@ #include #include +/* Definition of _GL_ARG_NONNULL. */ +#include "arg-nonnull.h" + struct argv_iterator; enum argv_iter_err; -#undef _ATTRIBUTE_NONNULL_ -#if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || 3 < __GNUC__ -# define _ATTRIBUTE_NONNULL_(m) __attribute__ ((__nonnull__ (m))) -#else -# define _ATTRIBUTE_NONNULL_(m) -#endif - enum argv_iter_err { AI_ERR_OK = 1, @@ -36,12 +32,12 @@ enum argv_iter_err }; struct argv_iterator *argv_iter_init_argv (char **argv) - _ATTRIBUTE_NONNULL_ (1); + _GL_ARG_NONNULL ((1)); struct argv_iterator *argv_iter_init_stream (FILE *fp) - _ATTRIBUTE_NONNULL_ (1); + _GL_ARG_NONNULL ((1)); char *argv_iter (struct argv_iterator *, enum argv_iter_err *) - _ATTRIBUTE_NONNULL_ (1) _ATTRIBUTE_NONNULL_ (2); + _GL_ARG_NONNULL ((1, 2)); size_t argv_iter_n_args (struct argv_iterator const *) - _ATTRIBUTE_NONNULL_ (1); + _GL_ARG_NONNULL ((1)); void argv_iter_free (struct argv_iterator *) - _ATTRIBUTE_NONNULL_ (1); + _GL_ARG_NONNULL ((1)); diff --git a/src/bin/coreutils/lib/arpa_inet.in.h b/src/bin/coreutils/lib/arpa_inet.in.h index 090b117c57..b93ffec5ac 100644 --- a/src/bin/coreutils/lib/arpa_inet.in.h +++ b/src/bin/coreutils/lib/arpa_inet.in.h @@ -3,7 +3,7 @@ #line 1 /* A GNU-like . - Copyright (C) 2005-2006, 2008 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2008-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,8 +22,11 @@ #ifndef _GL_ARPA_INET_H /* Gnulib's sys/socket.h is responsible for pulling in winsock2.h etc - under MinGW. */ -#include + under MinGW. + But avoid namespace pollution on glibc systems. */ +#ifndef __GLIBC__ +# include +#endif #if @HAVE_ARPA_INET_H@ @@ -41,6 +44,8 @@ /* The definition of GL_LINK_WARNING is copied here. */ +/* The definition of _GL_ARG_NONNULL is copied here. */ + #ifdef __cplusplus extern "C" { #endif @@ -63,7 +68,8 @@ extern "C" { For more details, see the POSIX:2001 specification . */ extern const char *inet_ntop (int af, const void *restrict src, - char *restrict dst, socklen_t cnt); + char *restrict dst, socklen_t cnt) + _GL_ARG_NONNULL ((2, 3)); # endif #elif defined GNULIB_POSIXCHECK # undef inet_ntop @@ -75,13 +81,14 @@ extern const char *inet_ntop (int af, const void *restrict src, #if @GNULIB_INET_PTON@ # if !@HAVE_DECL_INET_PTON@ -extern int inet_pton (int af, const char *restrict src, void *restrict dst); +extern int inet_pton (int af, const char *restrict src, void *restrict dst) + _GL_ARG_NONNULL ((2, 3)); # endif #elif defined GNULIB_POSIXCHECK # undef inet_pton # define inet_pton(af,src,dst) \ (GL_LINK_WARNING ("inet_pton is unportable - " \ - "use gnulib module inet_pton for portability"), \ + "use gnulib module inet_pton for portability"), \ inet_pton (af, src, dst)) #endif diff --git a/src/bin/coreutils/lib/asnprintf.c b/src/bin/coreutils/lib/asnprintf.c index d2ad8db272..0fd2cd353e 100644 --- a/src/bin/coreutils/lib/asnprintf.c +++ b/src/bin/coreutils/lib/asnprintf.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Formatted output to strings. - Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009, 2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/asprintf.c b/src/bin/coreutils/lib/asprintf.c index 51ccf4973b..ce372d94aa 100644 --- a/src/bin/coreutils/lib/asprintf.c +++ b/src/bin/coreutils/lib/asprintf.c @@ -2,7 +2,8 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Formatted output to strings. - Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006-2007, 2009-2010 Free Software Foundation, + Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/at-func.c b/src/bin/coreutils/lib/at-func.c index 3188770c65..ea456edfb5 100644 --- a/src/bin/coreutils/lib/at-func.c +++ b/src/bin/coreutils/lib/at-func.c @@ -1,5 +1,5 @@ /* Define an at-style functions like fstatat, unlinkat, fchownat, etc. - Copyright (C) 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,16 +16,21 @@ /* written by Jim Meyering */ +#include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ +#include "openat.h" +#include "openat-priv.h" +#include "save-cwd.h" + #ifdef AT_FUNC_USE_F1_COND -# define CALL_FUNC(F) \ - (flag == AT_FUNC_USE_F1_COND \ - ? AT_FUNC_F1 (F AT_FUNC_POST_FILE_ARGS) \ +# define CALL_FUNC(F) \ + (flag == AT_FUNC_USE_F1_COND \ + ? AT_FUNC_F1 (F AT_FUNC_POST_FILE_ARGS) \ : AT_FUNC_F2 (F AT_FUNC_POST_FILE_ARGS)) -# define VALIDATE_FLAG(F) \ - if (flag & ~AT_FUNC_USE_F1_COND) \ - { \ - errno = EINVAL; \ - return -1; \ +# define VALIDATE_FLAG(F) \ + if (flag & ~AT_FUNC_USE_F1_COND) \ + { \ + errno = EINVAL; \ + return FUNC_FAIL; \ } #else # define CALL_FUNC(F) (AT_FUNC_F1 (F AT_FUNC_POST_FILE_ARGS)) @@ -38,11 +43,18 @@ # define FUNC_RESULT int #endif +#ifdef AT_FUNC_FAIL +# define FUNC_FAIL AT_FUNC_FAIL +#else +# define FUNC_FAIL -1 +#endif + /* Call AT_FUNC_F1 to operate on FILE, which is in the directory open on descriptor FD. If AT_FUNC_USE_F1_COND is defined to a value, AT_FUNC_POST_FILE_PARAM_DECLS must inlude a parameter named flag; call AT_FUNC_F2 if FLAG is 0 or fail if FLAG contains more bits than - AT_FUNC_USE_F1_COND. If possible, do it without changing the + AT_FUNC_USE_F1_COND. Return int and fail with -1 unless AT_FUNC_RESULT + or AT_FUNC_FAIL are defined. If possible, do it without changing the working directory. Otherwise, resort to using save_cwd/fchdir, then AT_FUNC_F?/restore_cwd. If either the save_cwd or the restore_cwd fails, then give a diagnostic and exit nonzero. */ @@ -65,36 +77,45 @@ AT_FUNC_NAME (int fd, char const *file AT_FUNC_POST_FILE_PARAM_DECLS) char *proc_file = openat_proc_name (proc_buf, fd, file); if (proc_file) { - FUNC_RESULT proc_result = CALL_FUNC (proc_file); - int proc_errno = errno; - if (proc_file != proc_buf) - free (proc_file); - /* If the syscall succeeds, or if it fails with an unexpected - errno value, then return right away. Otherwise, fall through - and resort to using save_cwd/restore_cwd. */ - if (0 <= proc_result) - return proc_result; - if (! EXPECTED_ERRNO (proc_errno)) - { - errno = proc_errno; - return proc_result; - } + FUNC_RESULT proc_result = CALL_FUNC (proc_file); + int proc_errno = errno; + if (proc_file != proc_buf) + free (proc_file); + /* If the syscall succeeds, or if it fails with an unexpected + errno value, then return right away. Otherwise, fall through + and resort to using save_cwd/restore_cwd. */ + if (FUNC_FAIL != proc_result) + return proc_result; + if (! EXPECTED_ERRNO (proc_errno)) + { + errno = proc_errno; + return proc_result; + } } } if (save_cwd (&saved_cwd) != 0) openat_save_fail (errno); + if (0 <= fd && fd == saved_cwd.desc) + { + /* If saving the working directory collides with the user's + requested fd, then the user's fd must have been closed to + begin with. */ + free_cwd (&saved_cwd); + errno = EBADF; + return FUNC_FAIL; + } if (fchdir (fd) != 0) { saved_errno = errno; free_cwd (&saved_cwd); errno = saved_errno; - return -1; + return FUNC_FAIL; } err = CALL_FUNC (file); - saved_errno = (err < 0 ? errno : 0); + saved_errno = (err == FUNC_FAIL ? errno : 0); if (restore_cwd (&saved_cwd) != 0) openat_restore_fail (errno); @@ -107,3 +128,4 @@ AT_FUNC_NAME (int fd, char const *file AT_FUNC_POST_FILE_PARAM_DECLS) } #undef CALL_FUNC #undef FUNC_RESULT +#undef FUNC_FAIL diff --git a/src/bin/coreutils/lib/at-func2.c b/src/bin/coreutils/lib/at-func2.c new file mode 100644 index 0000000000..f19d2ed478 --- /dev/null +++ b/src/bin/coreutils/lib/at-func2.c @@ -0,0 +1,282 @@ +/* Define an at-style functions like linkat or renameat. + Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* written by Jim Meyering and Eric Blake */ + +#include + +#include "openat-priv.h" + +#include +#include +#include +#include + +#include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ +#include "filenamecat.h" +#include "openat.h" +#include "same-inode.h" +#include "save-cwd.h" + +/* Call FUNC to operate on a pair of files, where FILE1 is relative to FD1, + and FILE2 is relative to FD2. If possible, do it without changing the + working directory. Otherwise, resort to using save_cwd/fchdir, + FUNC, restore_cwd (up to two times). If either the save_cwd or the + restore_cwd fails, then give a diagnostic and exit nonzero. */ +int +at_func2 (int fd1, char const *file1, + int fd2, char const *file2, + int (*func) (char const *file1, char const *file2)) +{ + struct saved_cwd saved_cwd; + int saved_errno; + int err; + char *file1_alt; + char *file2_alt; + struct stat st1; + struct stat st2; + + /* There are 16 possible scenarios, based on whether an fd is + AT_FDCWD or real, and whether a file is absolute or relative: + + fd1 file1 fd2 file2 action + 0 cwd abs cwd abs direct call + 1 cwd abs cwd rel direct call + 2 cwd abs fd abs direct call + 3 cwd abs fd rel chdir to fd2 + 4 cwd rel cwd abs direct call + 5 cwd rel cwd rel direct call + 6 cwd rel fd abs direct call + 7 cwd rel fd rel convert file1 to abs, then case 3 + 8 fd abs cwd abs direct call + 9 fd abs cwd rel direct call + 10 fd abs fd abs direct call + 11 fd abs fd rel chdir to fd2 + 12 fd rel cwd abs chdir to fd1 + 13 fd rel cwd rel convert file2 to abs, then case 12 + 14 fd rel fd abs chdir to fd1 + 15a fd1 rel fd1 rel chdir to fd1 + 15b fd1 rel fd2 rel chdir to fd1, then case 7 + + Try some optimizations to reduce fd to AT_FDCWD, or to at least + avoid converting an absolute name or doing a double chdir. */ + + if ((fd1 == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file1)) + && (fd2 == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file2))) + return func (file1, file2); /* Case 0-2, 4-6, 8-10. */ + + /* If /proc/self/fd works, we don't need any stat or chdir. */ + { + char proc_buf1[OPENAT_BUFFER_SIZE]; + char *proc_file1 = ((fd1 == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file1)) + ? (char *) file1 + : openat_proc_name (proc_buf1, fd1, file1)); + if (proc_file1) + { + char proc_buf2[OPENAT_BUFFER_SIZE]; + char *proc_file2 = ((fd2 == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file2)) + ? (char *) file2 + : openat_proc_name (proc_buf2, fd2, file2)); + if (proc_file2) + { + int proc_result = func (proc_file1, proc_file2); + int proc_errno = errno; + if (proc_file1 != proc_buf1 && proc_file1 != file1) + free (proc_file1); + if (proc_file2 != proc_buf2 && proc_file2 != file2) + free (proc_file2); + /* If the syscall succeeds, or if it fails with an unexpected + errno value, then return right away. Otherwise, fall through + and resort to using save_cwd/restore_cwd. */ + if (0 <= proc_result) + return proc_result; + if (! EXPECTED_ERRNO (proc_errno)) + { + errno = proc_errno; + return proc_result; + } + } + else if (proc_file1 != proc_buf1 && proc_file1 != file1) + free (proc_file1); + } + } + + /* Cases 3, 7, 11-15 remain. Time to normalize directory fds, if + possible. */ + if (IS_ABSOLUTE_FILE_NAME (file1)) + fd1 = AT_FDCWD; /* Case 11 reduced to 3. */ + else if (IS_ABSOLUTE_FILE_NAME (file2)) + fd2 = AT_FDCWD; /* Case 14 reduced to 12. */ + + /* Cases 3, 7, 12, 13, 15 remain. */ + + if (fd1 == AT_FDCWD) /* Cases 3, 7. */ + { + if (stat (".", &st1) == -1 || fstat (fd2, &st2) == -1) + return -1; + if (!S_ISDIR (st2.st_mode)) + { + errno = ENOTDIR; + return -1; + } + if (SAME_INODE (st1, st2)) /* Reduced to cases 1, 5. */ + return func (file1, file2); + } + else if (fd2 == AT_FDCWD) /* Cases 12, 13. */ + { + if (stat (".", &st2) == -1 || fstat (fd1, &st1) == -1) + return -1; + if (!S_ISDIR (st1.st_mode)) + { + errno = ENOTDIR; + return -1; + } + if (SAME_INODE (st1, st2)) /* Reduced to cases 4, 5. */ + return func (file1, file2); + } + else if (fd1 != fd2) /* Case 15b. */ + { + if (fstat (fd1, &st1) == -1 || fstat (fd2, &st2) == -1) + return -1; + if (!S_ISDIR (st1.st_mode) || !S_ISDIR (st2.st_mode)) + { + errno = ENOTDIR; + return -1; + } + if (SAME_INODE (st1, st2)) /* Reduced to case 15a. */ + { + fd2 = fd1; + if (stat (".", &st1) == 0 && SAME_INODE (st1, st2)) + return func (file1, file2); /* Further reduced to case 5. */ + } + } + else /* Case 15a. */ + { + if (fstat (fd1, &st1) == -1) + return -1; + if (!S_ISDIR (st1.st_mode)) + { + errno = ENOTDIR; + return -1; + } + if (stat (".", &st2) == 0 && SAME_INODE (st1, st2)) + return func (file1, file2); /* Reduced to case 5. */ + } + + /* Cases 3, 7, 12, 13, 15a, 15b remain. With all reductions in + place, it is time to start changing directories. */ + + if (save_cwd (&saved_cwd) != 0) + openat_save_fail (errno); + + if (fd1 != AT_FDCWD && fd2 != AT_FDCWD && fd1 != fd2) /* Case 15b. */ + { + if (fchdir (fd1) != 0) + { + saved_errno = errno; + free_cwd (&saved_cwd); + errno = saved_errno; + return -1; + } + fd1 = AT_FDCWD; /* Reduced to case 7. */ + } + + /* Cases 3, 7, 12, 13, 15a remain. Convert one relative name to + absolute, if necessary. */ + + file1_alt = (char *) file1; + file2_alt = (char *) file2; + + if (fd1 == AT_FDCWD && !IS_ABSOLUTE_FILE_NAME (file1)) /* Case 7. */ + { + /* It would be nicer to use: + file1_alt = file_name_concat (xgetcwd (), file1, NULL); + but libraries should not call xalloc_die. */ + char *cwd = getcwd (NULL, 0); + if (!cwd) + { + saved_errno = errno; + free_cwd (&saved_cwd); + errno = saved_errno; + return -1; + } + file1_alt = mfile_name_concat (cwd, file1, NULL); + if (!file1_alt) + { + saved_errno = errno; + free (cwd); + free_cwd (&saved_cwd); + errno = saved_errno; + return -1; + } + free (cwd); /* Reduced to case 3. */ + } + else if (fd2 == AT_FDCWD && !IS_ABSOLUTE_FILE_NAME (file2)) /* Case 13. */ + { + char *cwd = getcwd (NULL, 0); + if (!cwd) + { + saved_errno = errno; + free_cwd (&saved_cwd); + errno = saved_errno; + return -1; + } + file2_alt = mfile_name_concat (cwd, file2, NULL); + if (!file2_alt) + { + saved_errno = errno; + free (cwd); + free_cwd (&saved_cwd); + errno = saved_errno; + return -1; + } + free (cwd); /* Reduced to case 12. */ + } + + /* Cases 3, 12, 15a remain. Change to the correct directory. */ + if (fchdir (fd1 == AT_FDCWD ? fd2 : fd1) != 0) + { + saved_errno = errno; + free_cwd (&saved_cwd); + if (file1 != file1_alt) + free (file1_alt); + else if (file2 != file2_alt) + free (file2_alt); + errno = saved_errno; + return -1; + } + + /* Finally safe to perform the user's function, then clean up. */ + + err = func (file1_alt, file2_alt); + saved_errno = (err < 0 ? errno : 0); + + if (file1 != file1_alt) + free (file1_alt); + else if (file2 != file2_alt) + free (file2_alt); + + if (restore_cwd (&saved_cwd) != 0) + openat_restore_fail (errno); + + free_cwd (&saved_cwd); + + if (saved_errno) + errno = saved_errno; + return err; +} +#undef CALL_FUNC +#undef FUNC_RESULT diff --git a/src/bin/coreutils/lib/backupfile.c b/src/bin/coreutils/lib/backupfile.c index f6cf73779b..7a70f4030a 100644 --- a/src/bin/coreutils/lib/backupfile.c +++ b/src/bin/coreutils/lib/backupfile.c @@ -1,8 +1,6 @@ /* backupfile.c -- make Emacs style backup file names - Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 Free Software - Foundation, Inc. + Copyright (C) 1990-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -103,18 +101,18 @@ check_extension (char *file, size_t filelen, char e) long name_max; /* Temporarily modify the buffer into its parent directory name, - invoke pathconf on the directory, and then restore the buffer. */ + invoke pathconf on the directory, and then restore the buffer. */ char tmp[sizeof "."]; memcpy (tmp, base, sizeof "."); strcpy (base, "."); errno = 0; name_max = pathconf (file, _PC_NAME_MAX); if (0 <= name_max || errno == 0) - { - long size = baselen_max = name_max; - if (name_max != size) - baselen_max = SIZE_MAX; - } + { + long size = baselen_max = name_max; + if (name_max != size) + baselen_max = SIZE_MAX; + } memcpy (base, tmp, sizeof "."); } @@ -123,21 +121,21 @@ check_extension (char *file, size_t filelen, char e) /* Live within DOS's 8.3 limit. */ char *dot = strchr (base, '.'); if (!dot) - baselen_max = 8; + baselen_max = 8; else - { - char const *second_dot = strchr (dot + 1, '.'); - baselen_max = (second_dot - ? second_dot - base - : dot + 1 - base + 3); - } + { + char const *second_dot = strchr (dot + 1, '.'); + baselen_max = (second_dot + ? second_dot - base + : dot + 1 - base + 3); + } } if (baselen_max < baselen) { baselen = file + filelen - base; if (baselen_max <= baselen) - baselen = baselen_max - 1; + baselen = baselen_max - 1; base[baselen] = e; base[baselen + 1] = '\0'; } @@ -203,41 +201,41 @@ numbered_backup (char **buffer, size_t buffer_size, size_t filelen) size_t new_buflen; if (! REAL_DIR_ENTRY (dp) || _D_EXACT_NAMLEN (dp) < baselen + 4) - continue; + continue; if (memcmp (buf + base_offset, dp->d_name, baselen + 2) != 0) - continue; + continue; p = dp->d_name + baselen + 2; /* Check whether this file has a version number and if so, - whether it is larger. Use string operations rather than - integer arithmetic, to avoid problems with integer overflow. */ + whether it is larger. Use string operations rather than + integer arithmetic, to avoid problems with integer overflow. */ if (! ('1' <= *p && *p <= '9')) - continue; + continue; all_9s = (*p == '9'); for (versionlen = 1; ISDIGIT (p[versionlen]); versionlen++) - all_9s &= (p[versionlen] == '9'); + all_9s &= (p[versionlen] == '9'); if (! (p[versionlen] == '~' && !p[versionlen + 1] - && (versionlenmax < versionlen - || (versionlenmax == versionlen - && memcmp (buf + filelen + 2, p, versionlen) <= 0)))) - continue; + && (versionlenmax < versionlen + || (versionlenmax == versionlen + && memcmp (buf + filelen + 2, p, versionlen) <= 0)))) + continue; /* This directory has the largest version number seen so far. - Append this highest numbered extension to the file name, - prepending '0' to the number if it is all 9s. */ + Append this highest numbered extension to the file name, + prepending '0' to the number if it is all 9s. */ versionlenmax = all_9s + versionlen; result = (all_9s ? BACKUP_IS_LONGER : BACKUP_IS_SAME_LENGTH); new_buflen = filelen + 2 + versionlenmax + 1; if (buffer_size <= new_buflen) - { - buf = xnrealloc (buf, 2, new_buflen); - buffer_size = new_buflen * 2; - } + { + buf = xnrealloc (buf, 2, new_buflen); + buffer_size = new_buflen * 2; + } q = buf + filelen; *q++ = '.'; *q++ = '~'; @@ -249,7 +247,7 @@ numbered_backup (char **buffer, size_t buffer_size, size_t filelen) q += versionlen; while (*--q == '9') - *q = '0'; + *q = '0'; ++*q; } @@ -286,15 +284,15 @@ find_backup_file_name (char const *file, enum backup_type backup_type) switch (numbered_backup (&s, ssize, filelen)) { case BACKUP_IS_SAME_LENGTH: - return s; + return s; case BACKUP_IS_LONGER: - simple = false; - break; + simple = false; + break; case BACKUP_IS_NEW: - simple = (backup_type == numbered_existing_backups); - break; + simple = (backup_type == numbered_existing_backups); + break; } if (simple) diff --git a/src/bin/coreutils/lib/backupfile.h b/src/bin/coreutils/lib/backupfile.h index 3cfdd8c687..e2af28adef 100644 --- a/src/bin/coreutils/lib/backupfile.h +++ b/src/bin/coreutils/lib/backupfile.h @@ -1,7 +1,7 @@ /* backupfile.h -- declarations for making Emacs style backup file names - Copyright (C) 1990, 1991, 1992, 1997, 1998, 1999, 2003, 2004 Free - Software Foundation, Inc. + Copyright (C) 1990-1992, 1997-1999, 2003-2004, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -41,7 +41,7 @@ enum backup_type numbered_backups }; -# define VALID_BACKUP_TYPE(Type) \ +# define VALID_BACKUP_TYPE(Type) \ ((unsigned int) (Type) <= numbered_backups) extern char const *simple_backup_suffix; diff --git a/src/bin/coreutils/lib/base64.c b/src/bin/coreutils/lib/base64.c index 866a596c90..82ed8ae127 100644 --- a/src/bin/coreutils/lib/base64.c +++ b/src/bin/coreutils/lib/base64.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* base64.c -- Encode binary data using printable characters. - Copyright (C) 1999, 2000, 2001, 2004, 2005, 2006 Free Software + Copyright (C) 1999, 2000, 2001, 2004, 2005, 2006, 2009, 2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -70,7 +70,7 @@ to_uchar (char ch) terminate the output buffer. */ void base64_encode (const char *restrict in, size_t inlen, - char *restrict out, size_t outlen) + char *restrict out, size_t outlen) { static const char b64str[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; @@ -79,27 +79,27 @@ base64_encode (const char *restrict in, size_t inlen, { *out++ = b64str[(to_uchar (in[0]) >> 2) & 0x3f]; if (!--outlen) - break; + break; *out++ = b64str[((to_uchar (in[0]) << 4) - + (--inlen ? to_uchar (in[1]) >> 4 : 0)) - & 0x3f]; + + (--inlen ? to_uchar (in[1]) >> 4 : 0)) + & 0x3f]; if (!--outlen) - break; + break; *out++ = - (inlen - ? b64str[((to_uchar (in[1]) << 2) - + (--inlen ? to_uchar (in[2]) >> 6 : 0)) - & 0x3f] - : '='); + (inlen + ? b64str[((to_uchar (in[1]) << 2) + + (--inlen ? to_uchar (in[2]) >> 6 : 0)) + & 0x3f] + : '='); if (!--outlen) - break; + break; *out++ = inlen ? b64str[to_uchar (in[2]) & 0x3f] : '='; if (!--outlen) - break; + break; if (inlen) - inlen--; + inlen--; if (inlen) - in += 3; + in += 3; } if (outlen) @@ -156,71 +156,71 @@ base64_encode_alloc (const char *in, size_t inlen, char **out) IBM C V6 for AIX mishandles "#define B64(x) ...'x'...", so use "_" as the formal parameter rather than "x". */ -#define B64(_) \ - ((_) == 'A' ? 0 \ - : (_) == 'B' ? 1 \ - : (_) == 'C' ? 2 \ - : (_) == 'D' ? 3 \ - : (_) == 'E' ? 4 \ - : (_) == 'F' ? 5 \ - : (_) == 'G' ? 6 \ - : (_) == 'H' ? 7 \ - : (_) == 'I' ? 8 \ - : (_) == 'J' ? 9 \ - : (_) == 'K' ? 10 \ - : (_) == 'L' ? 11 \ - : (_) == 'M' ? 12 \ - : (_) == 'N' ? 13 \ - : (_) == 'O' ? 14 \ - : (_) == 'P' ? 15 \ - : (_) == 'Q' ? 16 \ - : (_) == 'R' ? 17 \ - : (_) == 'S' ? 18 \ - : (_) == 'T' ? 19 \ - : (_) == 'U' ? 20 \ - : (_) == 'V' ? 21 \ - : (_) == 'W' ? 22 \ - : (_) == 'X' ? 23 \ - : (_) == 'Y' ? 24 \ - : (_) == 'Z' ? 25 \ - : (_) == 'a' ? 26 \ - : (_) == 'b' ? 27 \ - : (_) == 'c' ? 28 \ - : (_) == 'd' ? 29 \ - : (_) == 'e' ? 30 \ - : (_) == 'f' ? 31 \ - : (_) == 'g' ? 32 \ - : (_) == 'h' ? 33 \ - : (_) == 'i' ? 34 \ - : (_) == 'j' ? 35 \ - : (_) == 'k' ? 36 \ - : (_) == 'l' ? 37 \ - : (_) == 'm' ? 38 \ - : (_) == 'n' ? 39 \ - : (_) == 'o' ? 40 \ - : (_) == 'p' ? 41 \ - : (_) == 'q' ? 42 \ - : (_) == 'r' ? 43 \ - : (_) == 's' ? 44 \ - : (_) == 't' ? 45 \ - : (_) == 'u' ? 46 \ - : (_) == 'v' ? 47 \ - : (_) == 'w' ? 48 \ - : (_) == 'x' ? 49 \ - : (_) == 'y' ? 50 \ - : (_) == 'z' ? 51 \ - : (_) == '0' ? 52 \ - : (_) == '1' ? 53 \ - : (_) == '2' ? 54 \ - : (_) == '3' ? 55 \ - : (_) == '4' ? 56 \ - : (_) == '5' ? 57 \ - : (_) == '6' ? 58 \ - : (_) == '7' ? 59 \ - : (_) == '8' ? 60 \ - : (_) == '9' ? 61 \ - : (_) == '+' ? 62 \ - : (_) == '/' ? 63 \ +#define B64(_) \ + ((_) == 'A' ? 0 \ + : (_) == 'B' ? 1 \ + : (_) == 'C' ? 2 \ + : (_) == 'D' ? 3 \ + : (_) == 'E' ? 4 \ + : (_) == 'F' ? 5 \ + : (_) == 'G' ? 6 \ + : (_) == 'H' ? 7 \ + : (_) == 'I' ? 8 \ + : (_) == 'J' ? 9 \ + : (_) == 'K' ? 10 \ + : (_) == 'L' ? 11 \ + : (_) == 'M' ? 12 \ + : (_) == 'N' ? 13 \ + : (_) == 'O' ? 14 \ + : (_) == 'P' ? 15 \ + : (_) == 'Q' ? 16 \ + : (_) == 'R' ? 17 \ + : (_) == 'S' ? 18 \ + : (_) == 'T' ? 19 \ + : (_) == 'U' ? 20 \ + : (_) == 'V' ? 21 \ + : (_) == 'W' ? 22 \ + : (_) == 'X' ? 23 \ + : (_) == 'Y' ? 24 \ + : (_) == 'Z' ? 25 \ + : (_) == 'a' ? 26 \ + : (_) == 'b' ? 27 \ + : (_) == 'c' ? 28 \ + : (_) == 'd' ? 29 \ + : (_) == 'e' ? 30 \ + : (_) == 'f' ? 31 \ + : (_) == 'g' ? 32 \ + : (_) == 'h' ? 33 \ + : (_) == 'i' ? 34 \ + : (_) == 'j' ? 35 \ + : (_) == 'k' ? 36 \ + : (_) == 'l' ? 37 \ + : (_) == 'm' ? 38 \ + : (_) == 'n' ? 39 \ + : (_) == 'o' ? 40 \ + : (_) == 'p' ? 41 \ + : (_) == 'q' ? 42 \ + : (_) == 'r' ? 43 \ + : (_) == 's' ? 44 \ + : (_) == 't' ? 45 \ + : (_) == 'u' ? 46 \ + : (_) == 'v' ? 47 \ + : (_) == 'w' ? 48 \ + : (_) == 'x' ? 49 \ + : (_) == 'y' ? 50 \ + : (_) == 'z' ? 51 \ + : (_) == '0' ? 52 \ + : (_) == '1' ? 53 \ + : (_) == '2' ? 54 \ + : (_) == '3' ? 55 \ + : (_) == '4' ? 56 \ + : (_) == '5' ? 57 \ + : (_) == '6' ? 58 \ + : (_) == '7' ? 59 \ + : (_) == '8' ? 60 \ + : (_) == '9' ? 61 \ + : (_) == '+' ? 62 \ + : (_) == '/' ? 63 \ : -1) static const signed char b64[0x100] = { @@ -331,12 +331,12 @@ get_4 (struct base64_decode_context *ctx, { char const *t = *in; if (4 <= in_end - *in && memchr (t, '\n', 4) == NULL) - { - /* This is the common case: no newline. */ - *in += 4; - *n_non_newline = 4; - return (char *) t; - } + { + /* This is the common case: no newline. */ + *in += 4; + *n_non_newline = 4; + return (char *) t; + } } { @@ -344,13 +344,13 @@ get_4 (struct base64_decode_context *ctx, char const *p = *in; while (p < in_end) { - char c = *p++; - if (c != '\n') - { - ctx->buf[ctx->i++] = c; - if (ctx->i == 4) - break; - } + char c = *p++; + if (c != '\n') + { + ctx->buf[ctx->i++] = c; + if (ctx->i == 4) + break; + } } *in = p; @@ -359,12 +359,12 @@ get_4 (struct base64_decode_context *ctx, } } -#define return_false \ - do \ - { \ - *outp = out; \ - return false; \ - } \ +#define return_false \ + do \ + { \ + *outp = out; \ + return false; \ + } \ while (false) /* Decode up to four bytes of base64-encoded data, IN, of length INLEN @@ -375,7 +375,7 @@ get_4 (struct base64_decode_context *ctx, *OUTLEN to reflect the number of bytes remaining in *OUT. */ static inline bool decode_4 (char const *restrict in, size_t inlen, - char *restrict *outp, size_t *outleft) + char *restrict *outp, size_t *outleft) { char *out = *outp; if (inlen < 2) @@ -387,7 +387,7 @@ decode_4 (char const *restrict in, size_t inlen, if (*outleft) { *out++ = ((b64[to_uchar (in[0])] << 2) - | (b64[to_uchar (in[1])] >> 4)); + | (b64[to_uchar (in[1])] >> 4)); --*outleft; } @@ -397,43 +397,43 @@ decode_4 (char const *restrict in, size_t inlen, if (in[2] == '=') { if (inlen != 4) - return_false; + return_false; if (in[3] != '=') - return_false; + return_false; } else { if (!isbase64 (in[2])) - return_false; + return_false; if (*outleft) - { - *out++ = (((b64[to_uchar (in[1])] << 4) & 0xf0) - | (b64[to_uchar (in[2])] >> 2)); - --*outleft; - } + { + *out++ = (((b64[to_uchar (in[1])] << 4) & 0xf0) + | (b64[to_uchar (in[2])] >> 2)); + --*outleft; + } if (inlen == 3) - return_false; + return_false; if (in[3] == '=') - { - if (inlen != 4) - return_false; - } + { + if (inlen != 4) + return_false; + } else - { - if (!isbase64 (in[3])) - return_false; + { + if (!isbase64 (in[3])) + return_false; - if (*outleft) - { - *out++ = (((b64[to_uchar (in[2])] << 6) & 0xc0) - | b64[to_uchar (in[3])]); - --*outleft; - } - } + if (*outleft) + { + *out++ = (((b64[to_uchar (in[2])] << 6) & 0xc0) + | b64[to_uchar (in[3])]); + --*outleft; + } + } } *outp = out; @@ -460,8 +460,8 @@ decode_4 (char const *restrict in, size_t inlen, bool base64_decode_ctx (struct base64_decode_context *ctx, - const char *restrict in, size_t inlen, - char *restrict out, size_t *outlen) + const char *restrict in, size_t inlen, + char *restrict out, size_t *outlen) { size_t outleft = *outlen; bool ignore_newlines = ctx != NULL; @@ -479,57 +479,57 @@ base64_decode_ctx (struct base64_decode_context *ctx, { size_t outleft_save = outleft; if (ctx_i == 0 && !flush_ctx) - { - while (true) - { - /* Save a copy of outleft, in case we need to re-parse this - block of four bytes. */ - outleft_save = outleft; - if (!decode_4 (in, inlen, &out, &outleft)) - break; + { + while (true) + { + /* Save a copy of outleft, in case we need to re-parse this + block of four bytes. */ + outleft_save = outleft; + if (!decode_4 (in, inlen, &out, &outleft)) + break; - in += 4; - inlen -= 4; - } - } + in += 4; + inlen -= 4; + } + } if (inlen == 0 && !flush_ctx) - break; + break; /* Handle the common case of 72-byte wrapped lines. - This also handles any other multiple-of-4-byte wrapping. */ + This also handles any other multiple-of-4-byte wrapping. */ if (inlen && *in == '\n' && ignore_newlines) - { - ++in; - --inlen; - continue; - } + { + ++in; + --inlen; + continue; + } /* Restore OUT and OUTLEFT. */ out -= outleft_save - outleft; outleft = outleft_save; { - char const *in_end = in + inlen; - char const *non_nl; + char const *in_end = in + inlen; + char const *non_nl; - if (ignore_newlines) - non_nl = get_4 (ctx, &in, in_end, &inlen); - else - non_nl = in; /* Might have nl in this case. */ + if (ignore_newlines) + non_nl = get_4 (ctx, &in, in_end, &inlen); + else + non_nl = in; /* Might have nl in this case. */ - /* If the input is empty or consists solely of newlines (0 non-newlines), - then we're done. Likewise if there are fewer than 4 bytes when not - flushing context and not treating newlines as garbage. */ - if (inlen == 0 || (inlen < 4 && !flush_ctx && ignore_newlines)) - { - inlen = 0; - break; - } - if (!decode_4 (non_nl, inlen, &out, &outleft)) - break; + /* If the input is empty or consists solely of newlines (0 non-newlines), + then we're done. Likewise if there are fewer than 4 bytes when not + flushing context and not treating newlines as garbage. */ + if (inlen == 0 || (inlen < 4 && !flush_ctx && ignore_newlines)) + { + inlen = 0; + break; + } + if (!decode_4 (non_nl, inlen, &out, &outleft)) + break; - inlen = in_end - in; + inlen = in_end - in; } } @@ -551,8 +551,8 @@ base64_decode_ctx (struct base64_decode_context *ctx, undefined. */ bool base64_decode_alloc_ctx (struct base64_decode_context *ctx, - const char *in, size_t inlen, char **out, - size_t *outlen) + const char *in, size_t inlen, char **out, + size_t *outlen) { /* This may allocate a few bytes too many, depending on input, but it's not worth the extra CPU time to compute the exact size. diff --git a/src/bin/coreutils/lib/base64.h b/src/bin/coreutils/lib/base64.h index a7e01598ac..1ff3e00d35 100644 --- a/src/bin/coreutils/lib/base64.h +++ b/src/bin/coreutils/lib/base64.h @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* base64.h -- Encode binary data using printable characters. - Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2006, 2009, 2010 Free Software Foundation, Inc. Written by Simon Josefsson. This program is free software; you can redistribute it and/or modify @@ -41,24 +41,24 @@ struct base64_decode_context extern bool isbase64 (char ch); extern void base64_encode (const char *restrict in, size_t inlen, - char *restrict out, size_t outlen); + char *restrict out, size_t outlen); extern size_t base64_encode_alloc (const char *in, size_t inlen, char **out); extern void base64_decode_ctx_init (struct base64_decode_context *ctx); extern bool base64_decode_ctx (struct base64_decode_context *ctx, - const char *restrict in, size_t inlen, - char *restrict out, size_t *outlen); + const char *restrict in, size_t inlen, + char *restrict out, size_t *outlen); extern bool base64_decode_alloc_ctx (struct base64_decode_context *ctx, - const char *in, size_t inlen, - char **out, size_t *outlen); + const char *in, size_t inlen, + char **out, size_t *outlen); #define base64_decode(in, inlen, out, outlen) \ - base64_decode_ctx (NULL, in, inlen, out, outlen) + base64_decode_ctx (NULL, in, inlen, out, outlen) #define base64_decode_alloc(in, inlen, out, outlen) \ - base64_decode_alloc_ctx (NULL, in, inlen, out, outlen) + base64_decode_alloc_ctx (NULL, in, inlen, out, outlen) #endif /* BASE64_H */ diff --git a/src/bin/coreutils/lib/basename-lgpl.c b/src/bin/coreutils/lib/basename-lgpl.c new file mode 100644 index 0000000000..a35ff01c2c --- /dev/null +++ b/src/bin/coreutils/lib/basename-lgpl.c @@ -0,0 +1,75 @@ +/* basename.c -- return the last element in a file name + + Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2010 Free Software + Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +#include "dirname.h" + +#include + +/* Return the address of the last file name component of NAME. If + NAME has no relative file name components because it is a file + system root, return the empty string. */ + +char * +last_component (char const *name) +{ + char const *base = name + FILE_SYSTEM_PREFIX_LEN (name); + char const *p; + bool saw_slash = false; + + while (ISSLASH (*base)) + base++; + + for (p = base; *p; p++) + { + if (ISSLASH (*p)) + saw_slash = true; + else if (saw_slash) + { + base = p; + saw_slash = false; + } + } + + return (char *) base; +} + +/* Return the length of the basename NAME. Typically NAME is the + value returned by base_name or last_component. Act like strlen + (NAME), except omit all trailing slashes. */ + +size_t +base_len (char const *name) +{ + size_t len; + size_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name); + + for (len = strlen (name); 1 < len && ISSLASH (name[len - 1]); len--) + continue; + + if (DOUBLE_SLASH_IS_DISTINCT_ROOT && len == 1 + && ISSLASH (name[0]) && ISSLASH (name[1]) && ! name[2]) + return 2; + + if (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE && prefix_len + && len == prefix_len && ISSLASH (name[prefix_len])) + return prefix_len + 1; + + return len; +} diff --git a/src/bin/coreutils/lib/basename.c b/src/bin/coreutils/lib/basename.c index 426ed40f1a..24da93ac47 100644 --- a/src/bin/coreutils/lib/basename.c +++ b/src/bin/coreutils/lib/basename.c @@ -1,7 +1,7 @@ /* basename.c -- return the last element in a file name - Copyright (C) 1990, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006 Free - Software Foundation, Inc. + Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,52 +24,6 @@ #include "xalloc.h" #include "xstrndup.h" -/* Return the address of the last file name component of NAME. If - NAME has no relative file name components because it is a file - system root, return the empty string. */ - -char * -last_component (char const *name) -{ - char const *base = name + FILE_SYSTEM_PREFIX_LEN (name); - char const *p; - bool saw_slash = false; - - while (ISSLASH (*base)) - base++; - - for (p = base; *p; p++) - { - if (ISSLASH (*p)) - saw_slash = true; - else if (saw_slash) - { - base = p; - saw_slash = false; - } - } - - return (char *) base; -} - - -/* In general, we can't use the builtin `basename' function if available, - since it has different meanings in different environments. - In some environments the builtin `basename' modifies its argument. - - Return the last file name component of NAME, allocated with - xmalloc. On systems with drive letters, a leading "./" - distinguishes relative names that would otherwise look like a drive - letter. Unlike POSIX basename(), NAME cannot be NULL, - base_name("") returns "", and the first trailing slash is not - stripped. - - If lstat (NAME) would succeed, then { chdir (dir_name (NAME)); - lstat (base_name (NAME)); } will access the same file. Likewise, - if the sequence { chdir (dir_name (NAME)); - rename (base_name (NAME), "foo"); } succeeds, you have renamed NAME - to "foo" in the same directory NAME was in. */ - char * base_name (char const *name) { @@ -102,27 +56,3 @@ base_name (char const *name) /* Finally, copy the basename. */ return xstrndup (base, length); } - -/* Return the length of the basename NAME. Typically NAME is the - value returned by base_name or last_component. Act like strlen - (NAME), except omit all trailing slashes. */ - -size_t -base_len (char const *name) -{ - size_t len; - size_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name); - - for (len = strlen (name); 1 < len && ISSLASH (name[len - 1]); len--) - continue; - - if (DOUBLE_SLASH_IS_DISTINCT_ROOT && len == 1 - && ISSLASH (name[0]) && ISSLASH (name[1]) && ! name[2]) - return 2; - - if (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE && prefix_len - && len == prefix_len && ISSLASH (name[prefix_len])) - return prefix_len + 1; - - return len; -} diff --git a/src/bin/coreutils/lib/bitrotate.h b/src/bin/coreutils/lib/bitrotate.h index 63f5d56cf6..80e6ef5000 100644 --- a/src/bin/coreutils/lib/bitrotate.h +++ b/src/bin/coreutils/lib/bitrotate.h @@ -1,5 +1,5 @@ /* bitrotate.h - Rotate bits in integers - Copyright (C) 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/btowc.c b/src/bin/coreutils/lib/btowc.c index 7f3b9663c4..a46f1b242d 100644 --- a/src/bin/coreutils/lib/btowc.c +++ b/src/bin/coreutils/lib/btowc.c @@ -1,5 +1,5 @@ /* Convert unibyte character to wide character. - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. Written by Bruno Haible , 2008. This program is free software: you can redistribute it and/or modify @@ -32,7 +32,7 @@ btowc (int c) buf[0] = c; if (mbtowc (&wc, buf, 1) >= 0) - return wc; + return wc; } return WEOF; } diff --git a/src/bin/coreutils/lib/buffer-lcm.c b/src/bin/coreutils/lib/buffer-lcm.c index ee901741da..a7969200b2 100644 --- a/src/bin/coreutils/lib/buffer-lcm.c +++ b/src/bin/coreutils/lib/buffer-lcm.c @@ -1,6 +1,6 @@ /* buffer-lcm.c - compute a good buffer size for dealing with two files - Copyright (C) 2002, 2005, 2009 Free Software Foundation, Inc. + Copyright (C) 2002, 2005, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/c-ctype.c b/src/bin/coreutils/lib/c-ctype.c index d1ca044531..6b3aed8780 100644 --- a/src/bin/coreutils/lib/c-ctype.c +++ b/src/bin/coreutils/lib/c-ctype.c @@ -3,7 +3,7 @@ #line 1 /* Character handling in C locale. - Copyright 2000-2003, 2006 Free Software Foundation, Inc. + Copyright 2000-2003, 2006, 2009-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/c-ctype.h b/src/bin/coreutils/lib/c-ctype.h index 825e6bb305..d4b5e1b692 100644 --- a/src/bin/coreutils/lib/c-ctype.h +++ b/src/bin/coreutils/lib/c-ctype.h @@ -8,7 +8,7 @@ functions' behaviour depends on the current locale set via setlocale. - Copyright (C) 2000-2003, 2006, 2008 Free Software Foundation, Inc. + Copyright (C) 2000-2003, 2006, 2008-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/c-strcase.h b/src/bin/coreutils/lib/c-strcase.h index 65c5ed5d2c..e725641664 100644 --- a/src/bin/coreutils/lib/c-strcase.h +++ b/src/bin/coreutils/lib/c-strcase.h @@ -2,7 +2,8 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Case-insensitive string comparison functions in C locale. - Copyright (C) 1995-1996, 2001, 2003, 2005 Free Software Foundation, Inc. + Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2010 Free Software + Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/c-strcasecmp.c b/src/bin/coreutils/lib/c-strcasecmp.c index acebbb5f35..a52f4c7ac7 100644 --- a/src/bin/coreutils/lib/c-strcasecmp.c +++ b/src/bin/coreutils/lib/c-strcasecmp.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* c-strcasecmp.c -- case insensitive string comparator in C locale - Copyright (C) 1998-1999, 2005-2006 Free Software Foundation, Inc. + Copyright (C) 1998-1999, 2005-2006, 2009-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -43,7 +43,7 @@ c_strcasecmp (const char *s1, const char *s2) c2 = c_tolower (*p2); if (c1 == '\0') - break; + break; ++p1; ++p2; diff --git a/src/bin/coreutils/lib/c-strncasecmp.c b/src/bin/coreutils/lib/c-strncasecmp.c index 1537069d18..1113fc0d06 100644 --- a/src/bin/coreutils/lib/c-strncasecmp.c +++ b/src/bin/coreutils/lib/c-strncasecmp.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* c-strncasecmp.c -- case insensitive string comparator in C locale - Copyright (C) 1998-1999, 2005-2006 Free Software Foundation, Inc. + Copyright (C) 1998-1999, 2005-2006, 2009-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -43,7 +43,7 @@ c_strncasecmp (const char *s1, const char *s2, size_t n) c2 = c_tolower (*p2); if (--n == 0 || c1 == '\0') - break; + break; ++p1; ++p2; diff --git a/src/bin/coreutils/lib/c-strtod.c b/src/bin/coreutils/lib/c-strtod.c index 51e996e5da..38d472bd25 100644 --- a/src/bin/coreutils/lib/c-strtod.c +++ b/src/bin/coreutils/lib/c-strtod.c @@ -1,6 +1,6 @@ /* Convert string to double, using the C locale. - Copyright (C) 2003, 2004, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2003-2004, 2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -73,7 +73,7 @@ C_STRTOD (char const *nptr, char **endptr) if (!locale) { if (endptr) - *endptr = (char *) nptr; + *endptr = (char *) nptr; return 0; /* errno is set here */ } @@ -87,11 +87,11 @@ C_STRTOD (char const *nptr, char **endptr) { saved_locale = strdup (saved_locale); if (saved_locale == NULL) - { - if (endptr) - *endptr = (char *) nptr; - return 0; /* errno is set here */ - } + { + if (endptr) + *endptr = (char *) nptr; + return 0; /* errno is set here */ + } setlocale (LC_NUMERIC, "C"); } diff --git a/src/bin/coreutils/lib/c-strtod.h b/src/bin/coreutils/lib/c-strtod.h index 2b3f84735a..c2adf1e4e5 100644 --- a/src/bin/coreutils/lib/c-strtod.h +++ b/src/bin/coreutils/lib/c-strtod.h @@ -1,6 +1,6 @@ /* Convert string to double, using the C locale. - Copyright (C) 2003-2004, 2009 Free Software Foundation, Inc. + Copyright (C) 2003-2004, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/calloc.c b/src/bin/coreutils/lib/calloc.c index 554a58da93..d28e1583c8 100644 --- a/src/bin/coreutils/lib/calloc.c +++ b/src/bin/coreutils/lib/calloc.c @@ -1,6 +1,6 @@ /* calloc() function that is glibc compatible. This wrapper function is required at least on Tru64 UNIX 5.1 and mingw. - Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2004-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -49,13 +49,13 @@ rpl_calloc (size_t n, size_t s) else { /* Defend against buggy calloc implementations that mishandle - size_t overflow. */ + size_t overflow. */ size_t bytes = n * s; if (bytes / s != n) - { - errno = ENOMEM; - return NULL; - } + { + errno = ENOMEM; + return NULL; + } } #endif diff --git a/src/bin/coreutils/lib/canon-host.c b/src/bin/coreutils/lib/canon-host.c index df9cbbfb2e..6083e79393 100644 --- a/src/bin/coreutils/lib/canon-host.c +++ b/src/bin/coreutils/lib/canon-host.c @@ -1,6 +1,6 @@ /* Host name canonicalization - Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 2005-2010 Free Software Foundation, Inc. Written by Derek Price . @@ -69,11 +69,11 @@ canon_host_r (char const *host, int *cherror) if (!status) { /* http://lists.gnu.org/archive/html/bug-coreutils/2006-09/msg00300.html - says Darwin 7.9.0 getaddrinfo returns 0 but sets - res->ai_canonname to NULL. */ + says Darwin 7.9.0 getaddrinfo returns 0 but sets + res->ai_canonname to NULL. */ retval = strdup (res->ai_canonname ? res->ai_canonname : host); if (!retval && cherror) - *cherror = EAI_MEMORY; + *cherror = EAI_MEMORY; freeaddrinfo (res); } else if (cherror) diff --git a/src/bin/coreutils/lib/canon-host.h b/src/bin/coreutils/lib/canon-host.h index 2037f3ebd1..4120b8a829 100644 --- a/src/bin/coreutils/lib/canon-host.h +++ b/src/bin/coreutils/lib/canon-host.h @@ -1,6 +1,6 @@ /* Host name canonicalization - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2009-2010 Free Software Foundation, Inc. Written by Derek Price diff --git a/src/bin/coreutils/lib/canonicalize.c b/src/bin/coreutils/lib/canonicalize.c index 523e08204c..18acd06132 100644 --- a/src/bin/coreutils/lib/canonicalize.c +++ b/src/bin/coreutils/lib/canonicalize.c @@ -1,5 +1,5 @@ /* Return the canonical absolute name of a given file. - Copyright (C) 1996-2009 Free Software Foundation, Inc. + Copyright (C) 1996-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,34 +18,25 @@ #include "canonicalize.h" +#include #include #include - -#if HAVE_SYS_PARAM_H -# include -#endif - #include - #include -#include -#include - +#include "areadlink.h" #include "file-set.h" -#include "filenamecat.h" #include "hash-triple.h" +#include "pathmax.h" #include "xalloc.h" #include "xgetcwd.h" -#ifndef __set_errno -# define __set_errno(Val) errno = (Val) +#ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT +# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0 #endif -#include "pathmax.h" -#include "areadlink.h" - -#if !(HAVE_CANONICALIZE_FILE_NAME || GNULIB_CANONICALIZE_LGPL) +#if !((HAVE_CANONICALIZE_FILE_NAME && FUNC_REALPATH_WORKS) \ + || GNULIB_CANONICALIZE_LGPL) /* Return the canonical absolute name of file NAME. A canonical name does not contain any `.', `..' components nor any repeated file name separators ('/') or symlinks. All components must exist. @@ -54,68 +45,7 @@ char * canonicalize_file_name (const char *name) { -# if HAVE_RESOLVEPATH - - char *resolved, *extra_buf = NULL; - size_t resolved_size; - ssize_t resolved_len; - - if (name == NULL) - { - __set_errno (EINVAL); - return NULL; - } - - if (name[0] == '\0') - { - __set_errno (ENOENT); - return NULL; - } - - /* All known hosts with resolvepath (e.g. Solaris 7) don't turn - relative names into absolute ones, so prepend the working - directory if the file name is not absolute. */ - if (name[0] != '/') - { - char *wd; - - if (!(wd = xgetcwd ())) - return NULL; - - extra_buf = file_name_concat (wd, name, NULL); - name = extra_buf; - free (wd); - } - - resolved_size = strlen (name); - while (1) - { - resolved_size = 2 * resolved_size + 1; - resolved = xmalloc (resolved_size); - resolved_len = resolvepath (name, resolved, resolved_size); - if (resolved_len < 0) - { - free (resolved); - free (extra_buf); - return NULL; - } - if (resolved_len < resolved_size) - break; - free (resolved); - } - - free (extra_buf); - - /* NUL-terminate the resulting name. */ - resolved[resolved_len] = '\0'; - - return resolved; - -# else - return canonicalize_filename_mode (name, CAN_EXISTING); - -# endif /* !HAVE_RESOLVEPATH */ } #endif /* !HAVE_CANONICALIZE_FILE_NAME */ @@ -128,12 +58,12 @@ seen_triple (Hash_table **ht, char const *filename, struct stat const *st) { size_t initial_capacity = 7; *ht = hash_initialize (initial_capacity, - NULL, - triple_hash, - triple_compare_ino_str, - triple_free); + NULL, + triple_hash, + triple_compare_ino_str, + triple_free); if (*ht == NULL) - xalloc_die (); + xalloc_die (); } if (seen_file (*ht, filename, st)) @@ -143,7 +73,8 @@ seen_triple (Hash_table **ht, char const *filename, struct stat const *st) return false; } -/* Return the canonical absolute name of file NAME. A canonical name +/* Return the canonical absolute name of file NAME, while treating + missing elements according to CAN_MODE. A canonical name does not contain any `.', `..' components nor any repeated file name separators ('/') or symlinks. Whether components must exist or not depends on canonicalize mode. The result is malloc'd. */ @@ -157,16 +88,17 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) char const *rname_limit; size_t extra_len = 0; Hash_table *ht = NULL; + int saved_errno; if (name == NULL) { - __set_errno (EINVAL); + errno = EINVAL; return NULL; } if (name[0] == '\0') { - __set_errno (ENOENT); + errno = ENOENT; return NULL; } @@ -174,19 +106,19 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) { rname = xgetcwd (); if (!rname) - return NULL; + return NULL; dest = strchr (rname, '\0'); if (dest - rname < PATH_MAX) - { - char *p = xrealloc (rname, PATH_MAX); - dest = p + (dest - rname); - rname = p; - rname_limit = rname + PATH_MAX; - } + { + char *p = xrealloc (rname, PATH_MAX); + dest = p + (dest - rname); + rname = p; + rname_limit = rname + PATH_MAX; + } else - { - rname_limit = dest; - } + { + rname_limit = dest; + } } else { @@ -194,131 +126,154 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode) rname_limit = rname + PATH_MAX; rname[0] = '/'; dest = rname + 1; + if (DOUBLE_SLASH_IS_DISTINCT_ROOT && name[1] == '/') + *dest++ = '/'; } for (start = name; *start; start = end) { /* Skip sequence of multiple file name separators. */ while (*start == '/') - ++start; + ++start; /* Find end of component. */ for (end = start; *end && *end != '/'; ++end) - /* Nothing. */; + /* Nothing. */; if (end - start == 0) - break; + break; else if (end - start == 1 && start[0] == '.') - /* nothing */; + /* nothing */; else if (end - start == 2 && start[0] == '.' && start[1] == '.') - { - /* Back up to previous component, ignore if at root already. */ - if (dest > rname + 1) - while ((--dest)[-1] != '/'); - } + { + /* Back up to previous component, ignore if at root already. */ + if (dest > rname + 1) + while ((--dest)[-1] != '/'); + if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1 + && *dest == '/') + dest++; + } else - { - struct stat st; + { + struct stat st; - if (dest[-1] != '/') - *dest++ = '/'; + if (dest[-1] != '/') + *dest++ = '/'; - if (dest + (end - start) >= rname_limit) - { - ptrdiff_t dest_offset = dest - rname; - size_t new_size = rname_limit - rname; + if (dest + (end - start) >= rname_limit) + { + ptrdiff_t dest_offset = dest - rname; + size_t new_size = rname_limit - rname; - if (end - start + 1 > PATH_MAX) - new_size += end - start + 1; - else - new_size += PATH_MAX; - rname = xrealloc (rname, new_size); - rname_limit = rname + new_size; + if (end - start + 1 > PATH_MAX) + new_size += end - start + 1; + else + new_size += PATH_MAX; + rname = xrealloc (rname, new_size); + rname_limit = rname + new_size; - dest = rname + dest_offset; - } + dest = rname + dest_offset; + } - dest = memcpy (dest, start, end - start); - dest += end - start; - *dest = '\0'; + dest = memcpy (dest, start, end - start); + dest += end - start; + *dest = '\0'; - if (lstat (rname, &st) != 0) - { - if (can_mode == CAN_EXISTING) - goto error; - if (can_mode == CAN_ALL_BUT_LAST && *end) - goto error; - st.st_mode = 0; - } + if (lstat (rname, &st) != 0) + { + saved_errno = errno; + if (can_mode == CAN_EXISTING) + goto error; + if (can_mode == CAN_ALL_BUT_LAST) + { + if (end[strspn (end, "/")] || saved_errno != ENOENT) + goto error; + continue; + } + st.st_mode = 0; + } - if (S_ISLNK (st.st_mode)) - { - char *buf; - size_t n, len; + if (S_ISLNK (st.st_mode)) + { + char *buf; + size_t n, len; - /* Detect loops. We cannot use the cycle-check module here, - since it's actually possible to encounter the same symlink - more than once in a given traversal. However, encountering - the same symlink,NAME pair twice does indicate a loop. */ - if (seen_triple (&ht, name, &st)) - { - __set_errno (ELOOP); - if (can_mode == CAN_MISSING) - continue; - else - goto error; - } + /* Detect loops. We cannot use the cycle-check module here, + since it's actually possible to encounter the same symlink + more than once in a given traversal. However, encountering + the same symlink,NAME pair twice does indicate a loop. */ + if (seen_triple (&ht, name, &st)) + { + if (can_mode == CAN_MISSING) + continue; + saved_errno = ELOOP; + goto error; + } - buf = areadlink_with_size (rname, st.st_size); - if (!buf) - { - if (can_mode == CAN_MISSING && errno != ENOMEM) - continue; - else - goto error; - } + buf = areadlink_with_size (rname, st.st_size); + if (!buf) + { + if (can_mode == CAN_MISSING && errno != ENOMEM) + continue; + saved_errno = errno; + goto error; + } - n = strlen (buf); - len = strlen (end); + n = strlen (buf); + len = strlen (end); - if (!extra_len) - { - extra_len = - ((n + len + 1) > PATH_MAX) ? (n + len + 1) : PATH_MAX; - extra_buf = xmalloc (extra_len); - } - else if ((n + len + 1) > extra_len) - { - extra_len = n + len + 1; - extra_buf = xrealloc (extra_buf, extra_len); - } + if (!extra_len) + { + extra_len = + ((n + len + 1) > PATH_MAX) ? (n + len + 1) : PATH_MAX; + extra_buf = xmalloc (extra_len); + } + else if ((n + len + 1) > extra_len) + { + extra_len = n + len + 1; + extra_buf = xrealloc (extra_buf, extra_len); + } - /* Careful here, end may be a pointer into extra_buf... */ - memmove (&extra_buf[n], end, len + 1); - name = end = memcpy (extra_buf, buf, n); + /* Careful here, end may be a pointer into extra_buf... */ + memmove (&extra_buf[n], end, len + 1); + name = end = memcpy (extra_buf, buf, n); - if (buf[0] == '/') - dest = rname + 1; /* It's an absolute symlink */ - else - /* Back up to previous component, ignore if at root already: */ - if (dest > rname + 1) - while ((--dest)[-1] != '/'); + if (buf[0] == '/') + { + dest = rname + 1; /* It's an absolute symlink */ + if (DOUBLE_SLASH_IS_DISTINCT_ROOT && buf[1] == '/') + *dest++ = '/'; + } + else + { + /* Back up to previous component, ignore if at root + already: */ + if (dest > rname + 1) + while ((--dest)[-1] != '/'); + if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1 + && *dest == '/') + dest++; + } - free (buf); - } - else - { - if (!S_ISDIR (st.st_mode) && *end && (can_mode != CAN_MISSING)) - { - errno = ENOTDIR; - goto error; - } - } - } + free (buf); + } + else + { + if (!S_ISDIR (st.st_mode) && *end && (can_mode != CAN_MISSING)) + { + saved_errno = ENOTDIR; + goto error; + } + } + } } if (dest > rname + 1 && dest[-1] == '/') --dest; + if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1 && *dest == '/') + dest++; *dest = '\0'; + if (rname_limit != dest + 1) + rname = xrealloc (rname, dest - rname + 1); free (extra_buf); if (ht) @@ -330,5 +285,6 @@ error: free (rname); if (ht) hash_free (ht); + errno = saved_errno; return NULL; } diff --git a/src/bin/coreutils/lib/canonicalize.h b/src/bin/coreutils/lib/canonicalize.h index 8ca4fb4226..9d78b93f2c 100644 --- a/src/bin/coreutils/lib/canonicalize.h +++ b/src/bin/coreutils/lib/canonicalize.h @@ -1,5 +1,5 @@ /* Return the canonical absolute name of a given file. - Copyright (C) 1996-2007 Free Software Foundation, Inc. + Copyright (C) 1996-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,7 +17,8 @@ #ifndef CANONICALIZE_H_ # define CANONICALIZE_H_ -# if GNULIB_CANONICALIZE +#include /* for canonicalize_file_name */ + enum canonicalize_mode_t { /* All components must exist. */ @@ -36,17 +37,5 @@ typedef enum canonicalize_mode_t canonicalize_mode_t; whether components must exist depends on the canonicalize_mode_t argument. */ char *canonicalize_filename_mode (const char *, canonicalize_mode_t); -# endif - -# if HAVE_DECL_CANONICALIZE_FILE_NAME -# include -# else -/* Return a malloc'd string containing the canonical absolute name of - the named file. If any file name component does not exist or is a - symlink to a nonexistent file, return NULL. A canonical name does - not contain any `.', `..' components nor any repeated file name - separators ('/') or symlinks. */ -char *canonicalize_file_name (const char *); -# endif #endif /* !CANONICALIZE_H_ */ diff --git a/src/bin/coreutils/lib/chdir-long.c b/src/bin/coreutils/lib/chdir-long.c index ba47d59973..28e24070e9 100644 --- a/src/bin/coreutils/lib/chdir-long.c +++ b/src/bin/coreutils/lib/chdir-long.c @@ -1,5 +1,5 @@ /* provide a chdir function that tries not to fail due to ENAMETOOLONG - Copyright (C) 2004-2009 Free Software Foundation, Inc. + Copyright (C) 2004-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,19 +20,23 @@ #include "chdir-long.h" +#include +#include +#include #include #include #include -#include #include -#include - -#include "fcntl--.h" #ifndef PATH_MAX # error "compile this file only if your system defines PATH_MAX" #endif +/* The results of openat() in this file are not leaked to any + single-threaded code that could use stdio. + FIXME - if the kernel ever adds support for multi-thread safety for + avoiding standard fds, then we should use openat_safer. */ + struct cd_buf { int fd; @@ -68,7 +72,7 @@ static int cdb_advance_fd (struct cd_buf *cdb, char const *dir) { int new_fd = openat (cdb->fd, dir, - O_RDONLY | O_DIRECTORY | O_NOCTTY | O_NONBLOCK); + O_RDONLY | O_DIRECTORY | O_NOCTTY | O_NONBLOCK); if (new_fd < 0) return -1; @@ -131,27 +135,27 @@ chdir_long (char *dir) code in the following loop cleaner. */ if (n_leading_slash == 2) { - int err; - /* Find next slash. - We already know that dir[2] is neither a slash nor '\0'. */ - char *slash = memchr (dir + 3, '/', dir_end - (dir + 3)); - if (slash == NULL) - { - errno = ENAMETOOLONG; - return -1; - } - *slash = '\0'; - err = cdb_advance_fd (&cdb, dir); - *slash = '/'; - if (err != 0) - goto Fail; - dir = find_non_slash (slash + 1); + int err; + /* Find next slash. + We already know that dir[2] is neither a slash nor '\0'. */ + char *slash = memchr (dir + 3, '/', dir_end - (dir + 3)); + if (slash == NULL) + { + errno = ENAMETOOLONG; + return -1; + } + *slash = '\0'; + err = cdb_advance_fd (&cdb, dir); + *slash = '/'; + if (err != 0) + goto Fail; + dir = find_non_slash (slash + 1); } else if (n_leading_slash) { - if (cdb_advance_fd (&cdb, "/") != 0) - goto Fail; - dir += n_leading_slash; + if (cdb_advance_fd (&cdb, "/") != 0) + goto Fail; + dir += n_leading_slash; } assert (*dir != '/'); @@ -159,31 +163,31 @@ chdir_long (char *dir) while (PATH_MAX <= dir_end - dir) { - int err; - /* Find a slash that is PATH_MAX or fewer bytes away from dir. - I.e. see if there is a slash that will give us a name of - length PATH_MAX-1 or less. */ - char *slash = memrchr (dir, '/', PATH_MAX); - if (slash == NULL) - { - errno = ENAMETOOLONG; - return -1; - } + int err; + /* Find a slash that is PATH_MAX or fewer bytes away from dir. + I.e. see if there is a slash that will give us a name of + length PATH_MAX-1 or less. */ + char *slash = memrchr (dir, '/', PATH_MAX); + if (slash == NULL) + { + errno = ENAMETOOLONG; + return -1; + } - *slash = '\0'; - assert (slash - dir < PATH_MAX); - err = cdb_advance_fd (&cdb, dir); - *slash = '/'; - if (err != 0) - goto Fail; + *slash = '\0'; + assert (slash - dir < PATH_MAX); + err = cdb_advance_fd (&cdb, dir); + *slash = '/'; + if (err != 0) + goto Fail; - dir = find_non_slash (slash + 1); + dir = find_non_slash (slash + 1); } if (dir < dir_end) { - if (cdb_advance_fd (&cdb, dir) != 0) - goto Fail; + if (cdb_advance_fd (&cdb, dir) != 0) + goto Fail; } if (cdb_fchdir (&cdb) != 0) @@ -224,10 +228,10 @@ main (int argc, char *argv[]) { int saved_errno = errno; if (feof (stdin)) - exit (0); + exit (0); error (EXIT_FAILURE, saved_errno, - "reading standard input"); + "reading standard input"); } else if (len == 0) exit (0); @@ -237,12 +241,12 @@ main (int argc, char *argv[]) if (chdir_long (line) != 0) error (EXIT_FAILURE, errno, - "chdir_long failed: %s", line); + "chdir_long failed: %s", line); if (argc <= 1) { /* Using `pwd' here makes sense only if it is a robust implementation, - like the one in coreutils after the 2004-04-19 changes. */ + like the one in coreutils after the 2004-04-19 changes. */ char const *cmd = "pwd"; execlp (cmd, (char *) NULL); error (EXIT_FAILURE, errno, "%s", cmd); diff --git a/src/bin/coreutils/lib/chdir-long.h b/src/bin/coreutils/lib/chdir-long.h index 5bf0bbc25c..a0a4432134 100644 --- a/src/bin/coreutils/lib/chdir-long.h +++ b/src/bin/coreutils/lib/chdir-long.h @@ -1,5 +1,5 @@ /* provide a chdir function that tries not to fail due to ENAMETOOLONG - Copyright (C) 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2004-2005, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,7 +20,7 @@ #include #ifndef PATH_MAX -# ifdef MAXPATHLEN +# ifdef MAXPATHLEN # define PATH_MAX MAXPATHLEN # endif #endif diff --git a/src/bin/coreutils/lib/chown.c b/src/bin/coreutils/lib/chown.c index b851cbc4c0..d8f6bfe0c4 100644 --- a/src/bin/coreutils/lib/chown.c +++ b/src/bin/coreutils/lib/chown.c @@ -1,7 +1,7 @@ /* provide consistent interface to chown for systems that don't interpret an ID of -1 as meaning `don't change the corresponding ID'. - Copyright (C) 1997, 2004-2007, 2009 Free Software Foundation, Inc. + Copyright (C) 1997, 2004-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,19 +23,32 @@ /* Specification. */ #include -#include -#include -#include -#include #include +#include +#include +#include +#include + +#if !HAVE_CHOWN + +/* Simple stub that always fails with ENOSYS, for mingw. */ +int +chown (const char *file _GL_UNUSED, uid_t uid _GL_UNUSED, + gid_t gid _GL_UNUSED) +{ + errno = ENOSYS; + return -1; +} + +#else /* HAVE_CHOWN */ /* Below we refer to the system's chown(). */ -#undef chown +# undef chown /* The results of open() in this file are not used with fchdir, therefore save some unnecessary work in fchdir.c. */ -#undef open -#undef close +# undef open +# undef close /* Provide a more-closely POSIX-conforming version of chown on systems with one or both of the following problems: @@ -46,21 +59,29 @@ int rpl_chown (const char *file, uid_t uid, gid_t gid) { -#if HAVE_CHOWN + struct stat st; + bool stat_valid = false; + int result; + +# if CHOWN_CHANGE_TIME_BUG + if (gid != (gid_t) -1 || uid != (uid_t) -1) + { + if (stat (file, &st)) + return -1; + stat_valid = true; + } +# endif + # if CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE if (gid == (gid_t) -1 || uid == (uid_t) -1) { - struct stat file_stats; - /* Stat file to get id(s) that should remain unchanged. */ - if (stat (file, &file_stats)) - return -1; - + if (!stat_valid && stat (file, &st)) + return -1; if (gid == (gid_t) -1) - gid = file_stats.st_gid; - + gid = st.st_gid; if (uid == (uid_t) -1) - uid = file_stats.st_uid; + uid = st.st_uid; } # endif @@ -74,36 +95,62 @@ rpl_chown (const char *file, uid_t uid, gid_t gid) int open_flags = O_NONBLOCK | O_NOCTTY; int fd = open (file, O_RDONLY | open_flags); if (0 <= fd - || (errno == EACCES - && 0 <= (fd = open (file, O_WRONLY | open_flags)))) + || (errno == EACCES + && 0 <= (fd = open (file, O_WRONLY | open_flags)))) { - int result = fchown (fd, uid, gid); - int saved_errno = errno; + int saved_errno; + bool fchown_socket_failure; - /* POSIX says fchown can fail with errno == EINVAL on sockets, - so fall back on chown in that case. */ - struct stat sb; - bool fchown_socket_failure = - (result != 0 && saved_errno == EINVAL - && fstat (fd, &sb) == 0 && S_ISFIFO (sb.st_mode)); + result = fchown (fd, uid, gid); + saved_errno = errno; - close (fd); + /* POSIX says fchown can fail with errno == EINVAL on sockets + and pipes, so fall back on chown in that case. */ + fchown_socket_failure = + (result != 0 && saved_errno == EINVAL + && fstat (fd, &st) == 0 + && (S_ISFIFO (st.st_mode) || S_ISSOCK (st.st_mode))); - if (! fchown_socket_failure) - { - errno = saved_errno; - return result; - } + close (fd); + + if (! fchown_socket_failure) + { + errno = saved_errno; + return result; + } } else if (errno != EACCES) return -1; } # endif - return chown (file, uid, gid); +# if CHOWN_TRAILING_SLASH_BUG + if (!stat_valid) + { + size_t len = strlen (file); + if (len && file[len - 1] == '/' && stat (file, &st)) + return -1; + } +# endif -#else /* !HAVE_CHOWN */ - errno = ENOSYS; - return -1; -#endif + result = chown (file, uid, gid); + +# if CHOWN_CHANGE_TIME_BUG + if (result == 0 && stat_valid + && (uid == st.st_uid || uid == (uid_t) -1) + && (gid == st.st_gid || gid == (gid_t) -1)) + { + /* No change in ownership, but at least one argument was not -1, + so we are required to update ctime. Since chown succeeded, + we assume that chmod will do likewise. Fortunately, on all + known systems where a 'no-op' chown skips the ctime update, a + 'no-op' chmod still does the trick. */ + result = chmod (file, st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO + | S_ISUID | S_ISGID | S_ISVTX)); + } +# endif + + return result; } + +#endif /* HAVE_CHOWN */ diff --git a/src/bin/coreutils/lib/cloexec.c b/src/bin/coreutils/lib/cloexec.c index 0fb227c0a2..2d12efef09 100644 --- a/src/bin/coreutils/lib/cloexec.c +++ b/src/bin/coreutils/lib/cloexec.c @@ -1,6 +1,6 @@ /* closexec.c - set or clear the close-on-exec descriptor flag - Copyright (C) 1991, 2004, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 1991, 2004-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,17 +21,24 @@ #include "cloexec.h" -#include +#include #include +#include /* Set the `FD_CLOEXEC' flag of DESC if VALUE is true, or clear the flag if VALUE is false. - Return 0 on success, or -1 on error with `errno' set. */ + Return 0 on success, or -1 on error with `errno' set. + + Note that on MingW, this function does NOT protect DESC from being + inherited into spawned children. Instead, either use dup_cloexec + followed by closing the original DESC, or use interfaces such as + open or pipe2 that accept flags like O_CLOEXEC to create DESC + non-inheritable in the first place. */ int set_cloexec_flag (int desc, bool value) { -#if defined F_GETFD && defined F_SETFD +#ifdef F_SETFD int flags = fcntl (desc, F_GETFD, 0); @@ -40,15 +47,37 @@ set_cloexec_flag (int desc, bool value) int newflags = (value ? flags | FD_CLOEXEC : flags & ~FD_CLOEXEC); if (flags == newflags - || fcntl (desc, F_SETFD, newflags) != -1) - return 0; + || fcntl (desc, F_SETFD, newflags) != -1) + return 0; } return -1; -#else +#else /* !F_SETFD */ + /* Use dup2 to reject invalid file descriptors; the cloexec flag + will be unaffected. */ + if (desc < 0) + { + errno = EBADF; + return -1; + } + if (dup2 (desc, desc) < 0) + /* errno is EBADF here. */ + return -1; + + /* There is nothing we can do on this kind of platform. Punt. */ return 0; - -#endif +#endif /* !F_SETFD */ +} + + +/* Duplicates a file handle FD, while marking the copy to be closed + prior to exec or spawn. Returns -1 and sets errno if FD could not + be duplicated. */ + +int +dup_cloexec (int fd) +{ + return fcntl (fd, F_DUPFD_CLOEXEC, 0); } diff --git a/src/bin/coreutils/lib/cloexec.h b/src/bin/coreutils/lib/cloexec.h index c25921d6b3..e3a2cb850a 100644 --- a/src/bin/coreutils/lib/cloexec.h +++ b/src/bin/coreutils/lib/cloexec.h @@ -1,2 +1,38 @@ +/* closexec.c - set or clear the close-on-exec descriptor flag + + Copyright (C) 2004, 2009-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +*/ + #include + +/* Set the `FD_CLOEXEC' flag of DESC if VALUE is true, + or clear the flag if VALUE is false. + Return 0 on success, or -1 on error with `errno' set. + + Note that on MingW, this function does NOT protect DESC from being + inherited into spawned children. Instead, either use dup_cloexec + followed by closing the original DESC, or use interfaces such as + open or pipe2 that accept flags like O_CLOEXEC to create DESC + non-inheritable in the first place. */ + int set_cloexec_flag (int desc, bool value); + +/* Duplicates a file handle FD, while marking the copy to be closed + prior to exec or spawn. Returns -1 and sets errno if FD could not + be duplicated. */ + +int dup_cloexec (int fd); diff --git a/src/bin/coreutils/lib/close-hook.c b/src/bin/coreutils/lib/close-hook.c index bd92925ef7..eb0e33ad68 100644 --- a/src/bin/coreutils/lib/close-hook.c +++ b/src/bin/coreutils/lib/close-hook.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Hook for making the close() function extensible. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009, 2010 Free Software Foundation, Inc. Written by Bruno Haible , 2009. This program is free software: you can redistribute it and/or modify it @@ -69,7 +69,7 @@ register_close_hook (close_hook_fn hook, struct close_hook *link) { /* The link is already in use. */ if (link->private_fn != hook) - abort (); + abort (); } } diff --git a/src/bin/coreutils/lib/close-hook.h b/src/bin/coreutils/lib/close-hook.h index 9e1e966d6f..2e4585c3e2 100644 --- a/src/bin/coreutils/lib/close-hook.h +++ b/src/bin/coreutils/lib/close-hook.h @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Hook for making the close() function extensible. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published diff --git a/src/bin/coreutils/lib/close-stream.c b/src/bin/coreutils/lib/close-stream.c index 59ab616b1e..cf0422f3d8 100644 --- a/src/bin/coreutils/lib/close-stream.c +++ b/src/bin/coreutils/lib/close-stream.c @@ -1,7 +1,6 @@ /* Close a stream, with nicer error checking than fclose's. - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2006, 2007, 2008 Free - Software Foundation, Inc. + Copyright (C) 1998-2002, 2004, 2006-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -71,7 +70,7 @@ close_stream (FILE *stream) if (prev_fail || (fclose_fail && (some_pending || errno != EBADF))) { if (! fclose_fail) - errno = 0; + errno = 0; return EOF; } diff --git a/src/bin/coreutils/lib/close.c b/src/bin/coreutils/lib/close.c index 5278f24bba..afa8f64058 100644 --- a/src/bin/coreutils/lib/close.c +++ b/src/bin/coreutils/lib/close.c @@ -1,5 +1,5 @@ /* close replacement. - Copyright (C) 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/closein.c b/src/bin/coreutils/lib/closein.c index c7fb581eaa..077a3247d6 100644 --- a/src/bin/coreutils/lib/closein.c +++ b/src/bin/coreutils/lib/closein.c @@ -1,6 +1,6 @@ /* Close standard input, rewinding seekable stdin if necessary. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -86,22 +86,22 @@ close_stdin (void) if (freadahead (stdin) > 0) { /* Only attempt flush if stdin is seekable, as fflush is entitled to - fail on non-seekable streams. */ + fail on non-seekable streams. */ if (fseeko (stdin, 0, SEEK_CUR) == 0 && fflush (stdin) != 0) - fail = true; + fail = true; } if (close_stream (stdin) != 0) fail = true; if (fail) { /* Report failure, but defer exit until after closing stdout, - since the failure report should still be flushed. */ + since the failure report should still be flushed. */ char const *close_error = _("error closing file"); if (file_name) - error (0, errno, "%s: %s", quotearg_colon (file_name), - close_error); + error (0, errno, "%s: %s", quotearg_colon (file_name), + close_error); else - error (0, errno, "%s", close_error); + error (0, errno, "%s", close_error); } close_stdout (); diff --git a/src/bin/coreutils/lib/closein.h b/src/bin/coreutils/lib/closein.h index 837ead641d..20e97521b9 100644 --- a/src/bin/coreutils/lib/closein.h +++ b/src/bin/coreutils/lib/closein.h @@ -1,6 +1,6 @@ /* Close standard input, rewinding seekable stdin if necessary. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/closeout.c b/src/bin/coreutils/lib/closeout.c index 6a0b82ffaf..18a8912dfd 100644 --- a/src/bin/coreutils/lib/closeout.c +++ b/src/bin/coreutils/lib/closeout.c @@ -1,7 +1,7 @@ /* Close standard output and standard error, exiting with a diagnostic on error. - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2006, 2008 Free - Software Foundation, Inc. + Copyright (C) 1998-2002, 2004, 2006, 2008-2010 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -111,10 +111,10 @@ close_stdout (void) { char const *write_error = _("write error"); if (file_name) - error (0, errno, "%s: %s", quotearg_colon (file_name), - write_error); + error (0, errno, "%s: %s", quotearg_colon (file_name), + write_error); else - error (0, errno, "%s", write_error); + error (0, errno, "%s", write_error); _exit (exit_failure); } diff --git a/src/bin/coreutils/lib/closeout.h b/src/bin/coreutils/lib/closeout.h index 34e61effbf..475f95e652 100644 --- a/src/bin/coreutils/lib/closeout.h +++ b/src/bin/coreutils/lib/closeout.h @@ -1,7 +1,7 @@ /* Close standard output and standard error. - Copyright (C) 1998, 2000, 2003, 2004, 2006, 2008 Free Software Foundation, - Inc. + Copyright (C) 1998, 2000, 2003-2004, 2006, 2008-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/config.charset b/src/bin/coreutils/lib/config.charset index 7f91212032..2959df89bf 100755 --- a/src/bin/coreutils/lib/config.charset +++ b/src/bin/coreutils/lib/config.charset @@ -1,7 +1,7 @@ #! /bin/sh # Output a system dependent table of character encoding aliases. # -# Copyright (C) 2000-2004, 2006-2009 Free Software Foundation, Inc. +# Copyright (C) 2000-2004, 2006-2010 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -123,561 +123,561 @@ echo "# It was automatically generated from config.charset." # List of references, updated during installation: echo "# Packages using this file: " case "$os" in - linux-gnulibc1*) - # Linux libc5 doesn't have nl_langinfo(CODESET); therefore - # localcharset.c falls back to using the full locale name - # from the environment variables. - echo "C ASCII" - echo "POSIX ASCII" - for l in af af_ZA ca ca_ES da da_DK de de_AT de_BE de_CH de_DE de_LU \ - en en_AU en_BW en_CA en_DK en_GB en_IE en_NZ en_US en_ZA \ - en_ZW es es_AR es_BO es_CL es_CO es_DO es_EC es_ES es_GT \ - es_HN es_MX es_PA es_PE es_PY es_SV es_US es_UY es_VE et \ - et_EE eu eu_ES fi fi_FI fo fo_FO fr fr_BE fr_CA fr_CH fr_FR \ - fr_LU ga ga_IE gl gl_ES id id_ID in in_ID is is_IS it it_CH \ - it_IT kl kl_GL nl nl_BE nl_NL no no_NO pt pt_BR pt_PT sv \ - sv_FI sv_SE; do - echo "$l ISO-8859-1" - echo "$l.iso-8859-1 ISO-8859-1" - echo "$l.iso-8859-15 ISO-8859-15" - echo "$l.iso-8859-15@euro ISO-8859-15" - echo "$l@euro ISO-8859-15" - echo "$l.cp-437 CP437" - echo "$l.cp-850 CP850" - echo "$l.cp-1252 CP1252" - echo "$l.cp-1252@euro CP1252" - #echo "$l.atari-st ATARI-ST" # not a commonly used encoding - echo "$l.utf-8 UTF-8" - echo "$l.utf-8@euro UTF-8" - done - for l in cs cs_CZ hr hr_HR hu hu_HU pl pl_PL ro ro_RO sk sk_SK sl \ - sl_SI sr sr_CS sr_YU; do - echo "$l ISO-8859-2" - echo "$l.iso-8859-2 ISO-8859-2" - echo "$l.cp-852 CP852" - echo "$l.cp-1250 CP1250" - echo "$l.utf-8 UTF-8" - done - for l in mk mk_MK ru ru_RU; do - echo "$l ISO-8859-5" - echo "$l.iso-8859-5 ISO-8859-5" - echo "$l.koi8-r KOI8-R" - echo "$l.cp-866 CP866" - echo "$l.cp-1251 CP1251" - echo "$l.utf-8 UTF-8" - done - for l in ar ar_SA; do - echo "$l ISO-8859-6" - echo "$l.iso-8859-6 ISO-8859-6" - echo "$l.cp-864 CP864" - #echo "$l.cp-868 CP868" # not a commonly used encoding - echo "$l.cp-1256 CP1256" - echo "$l.utf-8 UTF-8" - done - for l in el el_GR gr gr_GR; do - echo "$l ISO-8859-7" - echo "$l.iso-8859-7 ISO-8859-7" - echo "$l.cp-869 CP869" - echo "$l.cp-1253 CP1253" - echo "$l.cp-1253@euro CP1253" - echo "$l.utf-8 UTF-8" - echo "$l.utf-8@euro UTF-8" - done - for l in he he_IL iw iw_IL; do - echo "$l ISO-8859-8" - echo "$l.iso-8859-8 ISO-8859-8" - echo "$l.cp-862 CP862" - echo "$l.cp-1255 CP1255" - echo "$l.utf-8 UTF-8" - done - for l in tr tr_TR; do - echo "$l ISO-8859-9" - echo "$l.iso-8859-9 ISO-8859-9" - echo "$l.cp-857 CP857" - echo "$l.cp-1254 CP1254" - echo "$l.utf-8 UTF-8" - done - for l in lt lt_LT lv lv_LV; do - #echo "$l BALTIC" # not a commonly used encoding, wrong encoding name - echo "$l ISO-8859-13" - done - for l in ru_UA uk uk_UA; do - echo "$l KOI8-U" - done - for l in zh zh_CN; do - #echo "$l GB_2312-80" # not a commonly used encoding, wrong encoding name - echo "$l GB2312" - done - for l in ja ja_JP ja_JP.EUC; do - echo "$l EUC-JP" - done - for l in ko ko_KR; do - echo "$l EUC-KR" - done - for l in th th_TH; do - echo "$l TIS-620" - done - for l in fa fa_IR; do - #echo "$l ISIRI-3342" # a broken encoding - echo "$l.utf-8 UTF-8" - done - ;; - linux* | *-gnu*) - # With glibc-2.1 or newer, we don't need any canonicalization, - # because glibc has iconv and both glibc and libiconv support all - # GNU canonical names directly. Therefore, the Makefile does not - # need to install the alias file at all. - # The following applies only to glibc-2.0.x and older libcs. - echo "ISO_646.IRV:1983 ASCII" - ;; - aix*) - echo "ISO8859-1 ISO-8859-1" - echo "ISO8859-2 ISO-8859-2" - echo "ISO8859-5 ISO-8859-5" - echo "ISO8859-6 ISO-8859-6" - echo "ISO8859-7 ISO-8859-7" - echo "ISO8859-8 ISO-8859-8" - echo "ISO8859-9 ISO-8859-9" - echo "ISO8859-15 ISO-8859-15" - echo "IBM-850 CP850" - echo "IBM-856 CP856" - echo "IBM-921 ISO-8859-13" - echo "IBM-922 CP922" - echo "IBM-932 CP932" - echo "IBM-943 CP943" - echo "IBM-1046 CP1046" - echo "IBM-1124 CP1124" - echo "IBM-1129 CP1129" - echo "IBM-1252 CP1252" - echo "IBM-eucCN GB2312" - echo "IBM-eucJP EUC-JP" - echo "IBM-eucKR EUC-KR" - echo "IBM-eucTW EUC-TW" - echo "big5 BIG5" - echo "GBK GBK" - echo "TIS-620 TIS-620" - echo "UTF-8 UTF-8" - ;; - hpux*) - echo "iso88591 ISO-8859-1" - echo "iso88592 ISO-8859-2" - echo "iso88595 ISO-8859-5" - echo "iso88596 ISO-8859-6" - echo "iso88597 ISO-8859-7" - echo "iso88598 ISO-8859-8" - echo "iso88599 ISO-8859-9" - echo "iso885915 ISO-8859-15" - echo "roman8 HP-ROMAN8" - echo "arabic8 HP-ARABIC8" - echo "greek8 HP-GREEK8" - echo "hebrew8 HP-HEBREW8" - echo "turkish8 HP-TURKISH8" - echo "kana8 HP-KANA8" - echo "tis620 TIS-620" - echo "big5 BIG5" - echo "eucJP EUC-JP" - echo "eucKR EUC-KR" - echo "eucTW EUC-TW" - echo "hp15CN GB2312" - #echo "ccdc ?" # what is this? - echo "SJIS SHIFT_JIS" - echo "utf8 UTF-8" - ;; - irix*) - echo "ISO8859-1 ISO-8859-1" - echo "ISO8859-2 ISO-8859-2" - echo "ISO8859-5 ISO-8859-5" - echo "ISO8859-7 ISO-8859-7" - echo "ISO8859-9 ISO-8859-9" - echo "eucCN GB2312" - echo "eucJP EUC-JP" - echo "eucKR EUC-KR" - echo "eucTW EUC-TW" - ;; - osf*) - echo "ISO8859-1 ISO-8859-1" - echo "ISO8859-2 ISO-8859-2" - echo "ISO8859-4 ISO-8859-4" - echo "ISO8859-5 ISO-8859-5" - echo "ISO8859-7 ISO-8859-7" - echo "ISO8859-8 ISO-8859-8" - echo "ISO8859-9 ISO-8859-9" - echo "ISO8859-15 ISO-8859-15" - echo "cp850 CP850" - echo "big5 BIG5" - echo "dechanyu DEC-HANYU" - echo "dechanzi GB2312" - echo "deckanji DEC-KANJI" - echo "deckorean EUC-KR" - echo "eucJP EUC-JP" - echo "eucKR EUC-KR" - echo "eucTW EUC-TW" - echo "GBK GBK" - echo "KSC5601 CP949" - echo "sdeckanji EUC-JP" - echo "SJIS SHIFT_JIS" - echo "TACTIS TIS-620" - echo "UTF-8 UTF-8" - ;; - solaris*) - echo "646 ASCII" - echo "ISO8859-1 ISO-8859-1" - echo "ISO8859-2 ISO-8859-2" - echo "ISO8859-3 ISO-8859-3" - echo "ISO8859-4 ISO-8859-4" - echo "ISO8859-5 ISO-8859-5" - echo "ISO8859-6 ISO-8859-6" - echo "ISO8859-7 ISO-8859-7" - echo "ISO8859-8 ISO-8859-8" - echo "ISO8859-9 ISO-8859-9" - echo "ISO8859-15 ISO-8859-15" - echo "koi8-r KOI8-R" - echo "ansi-1251 CP1251" - echo "BIG5 BIG5" - echo "Big5-HKSCS BIG5-HKSCS" - echo "gb2312 GB2312" - echo "GBK GBK" - echo "GB18030 GB18030" - echo "cns11643 EUC-TW" - echo "5601 EUC-KR" - echo "ko_KR.johap92 JOHAB" - echo "eucJP EUC-JP" - echo "PCK SHIFT_JIS" - echo "TIS620.2533 TIS-620" - #echo "sun_eu_greek ?" # what is this? - echo "UTF-8 UTF-8" - ;; - freebsd* | os2*) - # FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore - # localcharset.c falls back to using the full locale name - # from the environment variables. - # Likewise for OS/2. OS/2 has XFree86 just like FreeBSD. Just - # reuse FreeBSD's locale data for OS/2. - echo "C ASCII" - echo "US-ASCII ASCII" - for l in la_LN lt_LN; do - echo "$l.ASCII ASCII" - done - for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \ - fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT la_LN \ - lt_LN nl_BE nl_NL no_NO pt_PT sv_SE; do - echo "$l.ISO_8859-1 ISO-8859-1" - echo "$l.DIS_8859-15 ISO-8859-15" - done - for l in cs_CZ hr_HR hu_HU la_LN lt_LN pl_PL sl_SI; do - echo "$l.ISO_8859-2 ISO-8859-2" - done - for l in la_LN lt_LT; do - echo "$l.ISO_8859-4 ISO-8859-4" - done - for l in ru_RU ru_SU; do - echo "$l.KOI8-R KOI8-R" - echo "$l.ISO_8859-5 ISO-8859-5" - echo "$l.CP866 CP866" - done - echo "uk_UA.KOI8-U KOI8-U" - echo "zh_TW.BIG5 BIG5" - echo "zh_TW.Big5 BIG5" - echo "zh_CN.EUC GB2312" - echo "ja_JP.EUC EUC-JP" - echo "ja_JP.SJIS SHIFT_JIS" - echo "ja_JP.Shift_JIS SHIFT_JIS" - echo "ko_KR.EUC EUC-KR" - ;; - netbsd*) - echo "646 ASCII" - echo "ISO8859-1 ISO-8859-1" - echo "ISO8859-2 ISO-8859-2" - echo "ISO8859-4 ISO-8859-4" - echo "ISO8859-5 ISO-8859-5" - echo "ISO8859-7 ISO-8859-7" - echo "ISO8859-13 ISO-8859-13" - echo "ISO8859-15 ISO-8859-15" - echo "eucCN GB2312" - echo "eucJP EUC-JP" - echo "eucKR EUC-KR" - echo "eucTW EUC-TW" - echo "BIG5 BIG5" - echo "SJIS SHIFT_JIS" - ;; - openbsd*) - echo "646 ASCII" - echo "ISO8859-1 ISO-8859-1" - echo "ISO8859-2 ISO-8859-2" - echo "ISO8859-4 ISO-8859-4" - echo "ISO8859-5 ISO-8859-5" - echo "ISO8859-7 ISO-8859-7" - echo "ISO8859-13 ISO-8859-13" - echo "ISO8859-15 ISO-8859-15" - ;; - darwin[56]*) - # Darwin 6.8 doesn't have nl_langinfo(CODESET); therefore - # localcharset.c falls back to using the full locale name - # from the environment variables. - echo "C ASCII" - for l in en_AU en_CA en_GB en_US la_LN; do - echo "$l.US-ASCII ASCII" - done - for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \ - fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT nl_BE \ - nl_NL no_NO pt_PT sv_SE; do - echo "$l ISO-8859-1" - echo "$l.ISO8859-1 ISO-8859-1" - echo "$l.ISO8859-15 ISO-8859-15" - done - for l in la_LN; do - echo "$l.ISO8859-1 ISO-8859-1" - echo "$l.ISO8859-15 ISO-8859-15" - done - for l in cs_CZ hr_HR hu_HU la_LN pl_PL sl_SI; do - echo "$l.ISO8859-2 ISO-8859-2" - done - for l in la_LN lt_LT; do - echo "$l.ISO8859-4 ISO-8859-4" - done - for l in ru_RU; do - echo "$l.KOI8-R KOI8-R" - echo "$l.ISO8859-5 ISO-8859-5" - echo "$l.CP866 CP866" - done - for l in bg_BG; do - echo "$l.CP1251 CP1251" - done - echo "uk_UA.KOI8-U KOI8-U" - echo "zh_TW.BIG5 BIG5" - echo "zh_TW.Big5 BIG5" - echo "zh_CN.EUC GB2312" - echo "ja_JP.EUC EUC-JP" - echo "ja_JP.SJIS SHIFT_JIS" - echo "ko_KR.EUC EUC-KR" - ;; - darwin*) - # Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is - # useless: - # - It returns the empty string when LANG is set to a locale of the - # form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8 - # LC_CTYPE file. - # - The environment variables LANG, LC_CTYPE, LC_ALL are not set by - # the system; nl_langinfo(CODESET) returns "US-ASCII" in this case. - # - The documentation says: - # "... all code that calls BSD system routines should ensure - # that the const *char parameters of these routines are in UTF-8 - # encoding. All BSD system functions expect their string - # parameters to be in UTF-8 encoding and nothing else." - # It also says - # "An additional caveat is that string parameters for files, - # paths, and other file-system entities must be in canonical - # UTF-8. In a canonical UTF-8 Unicode string, all decomposable - # characters are decomposed ..." - # but this is not true: You can pass non-decomposed UTF-8 strings - # to file system functions, and it is the OS which will convert - # them to decomposed UTF-8 before accessing the file system. - # - The Apple Terminal application displays UTF-8 by default. - # - However, other applications are free to use different encodings: - # - xterm uses ISO-8859-1 by default. - # - TextEdit uses MacRoman by default. - # We prefer UTF-8 over decomposed UTF-8-MAC because one should - # minimize the use of decomposed Unicode. Unfortunately, through the - # Darwin file system, decomposed UTF-8 strings are leaked into user - # space nevertheless. - # Then there are also the locales with encodings other than US-ASCII - # and UTF-8. These locales can be occasionally useful to users (e.g. - # when grepping through ISO-8859-1 encoded text files), when all their - # file names are in US-ASCII. - echo "ISO8859-1 ISO-8859-1" - echo "ISO8859-2 ISO-8859-2" - echo "ISO8859-4 ISO-8859-4" - echo "ISO8859-5 ISO-8859-5" - echo "ISO8859-7 ISO-8859-7" - echo "ISO8859-9 ISO-8859-9" - echo "ISO8859-13 ISO-8859-13" - echo "ISO8859-15 ISO-8859-15" - echo "KOI8-R KOI8-R" - echo "KOI8-U KOI8-U" - echo "CP866 CP866" - echo "CP949 CP949" - echo "CP1131 CP1131" - echo "CP1251 CP1251" - echo "eucCN GB2312" - echo "GB2312 GB2312" - echo "eucJP EUC-JP" - echo "eucKR EUC-KR" - echo "Big5 BIG5" - echo "Big5HKSCS BIG5-HKSCS" - echo "GBK GBK" - echo "GB18030 GB18030" - echo "SJIS SHIFT_JIS" - echo "ARMSCII-8 ARMSCII-8" - echo "PT154 PT154" - #echo "ISCII-DEV ?" - echo "* UTF-8" - ;; - beos* | haiku*) - # BeOS and Haiku have a single locale, and it has UTF-8 encoding. - echo "* UTF-8" - ;; - msdosdjgpp*) - # DJGPP 2.03 doesn't have nl_langinfo(CODESET); therefore - # localcharset.c falls back to using the full locale name - # from the environment variables. - echo "#" - echo "# The encodings given here may not all be correct." - echo "# If you find that the encoding given for your language and" - echo "# country is not the one your DOS machine actually uses, just" - echo "# correct it in this file, and send a mail to" - echo "# Juan Manuel Guerrero " - echo "# and Bruno Haible ." - echo "#" - echo "C ASCII" - # ISO-8859-1 languages - echo "ca CP850" - echo "ca_ES CP850" - echo "da CP865" # not CP850 ?? - echo "da_DK CP865" # not CP850 ?? - echo "de CP850" - echo "de_AT CP850" - echo "de_CH CP850" - echo "de_DE CP850" - echo "en CP850" - echo "en_AU CP850" # not CP437 ?? - echo "en_CA CP850" - echo "en_GB CP850" - echo "en_NZ CP437" - echo "en_US CP437" - echo "en_ZA CP850" # not CP437 ?? - echo "es CP850" - echo "es_AR CP850" - echo "es_BO CP850" - echo "es_CL CP850" - echo "es_CO CP850" - echo "es_CR CP850" - echo "es_CU CP850" - echo "es_DO CP850" - echo "es_EC CP850" - echo "es_ES CP850" - echo "es_GT CP850" - echo "es_HN CP850" - echo "es_MX CP850" - echo "es_NI CP850" - echo "es_PA CP850" - echo "es_PY CP850" - echo "es_PE CP850" - echo "es_SV CP850" - echo "es_UY CP850" - echo "es_VE CP850" - echo "et CP850" - echo "et_EE CP850" - echo "eu CP850" - echo "eu_ES CP850" - echo "fi CP850" - echo "fi_FI CP850" - echo "fr CP850" - echo "fr_BE CP850" - echo "fr_CA CP850" - echo "fr_CH CP850" - echo "fr_FR CP850" - echo "ga CP850" - echo "ga_IE CP850" - echo "gd CP850" - echo "gd_GB CP850" - echo "gl CP850" - echo "gl_ES CP850" - echo "id CP850" # not CP437 ?? - echo "id_ID CP850" # not CP437 ?? - echo "is CP861" # not CP850 ?? - echo "is_IS CP861" # not CP850 ?? - echo "it CP850" - echo "it_CH CP850" - echo "it_IT CP850" - echo "lt CP775" - echo "lt_LT CP775" - echo "lv CP775" - echo "lv_LV CP775" - echo "nb CP865" # not CP850 ?? - echo "nb_NO CP865" # not CP850 ?? - echo "nl CP850" - echo "nl_BE CP850" - echo "nl_NL CP850" - echo "nn CP865" # not CP850 ?? - echo "nn_NO CP865" # not CP850 ?? - echo "no CP865" # not CP850 ?? - echo "no_NO CP865" # not CP850 ?? - echo "pt CP850" - echo "pt_BR CP850" - echo "pt_PT CP850" - echo "sv CP850" - echo "sv_SE CP850" - # ISO-8859-2 languages - echo "cs CP852" - echo "cs_CZ CP852" - echo "hr CP852" - echo "hr_HR CP852" - echo "hu CP852" - echo "hu_HU CP852" - echo "pl CP852" - echo "pl_PL CP852" - echo "ro CP852" - echo "ro_RO CP852" - echo "sk CP852" - echo "sk_SK CP852" - echo "sl CP852" - echo "sl_SI CP852" - echo "sq CP852" - echo "sq_AL CP852" - echo "sr CP852" # CP852 or CP866 or CP855 ?? - echo "sr_CS CP852" # CP852 or CP866 or CP855 ?? - echo "sr_YU CP852" # CP852 or CP866 or CP855 ?? - # ISO-8859-3 languages - echo "mt CP850" - echo "mt_MT CP850" - # ISO-8859-5 languages - echo "be CP866" - echo "be_BE CP866" - echo "bg CP866" # not CP855 ?? - echo "bg_BG CP866" # not CP855 ?? - echo "mk CP866" # not CP855 ?? - echo "mk_MK CP866" # not CP855 ?? - echo "ru CP866" - echo "ru_RU CP866" - echo "uk CP1125" - echo "uk_UA CP1125" - # ISO-8859-6 languages - echo "ar CP864" - echo "ar_AE CP864" - echo "ar_DZ CP864" - echo "ar_EG CP864" - echo "ar_IQ CP864" - echo "ar_IR CP864" - echo "ar_JO CP864" - echo "ar_KW CP864" - echo "ar_MA CP864" - echo "ar_OM CP864" - echo "ar_QA CP864" - echo "ar_SA CP864" - echo "ar_SY CP864" - # ISO-8859-7 languages - echo "el CP869" - echo "el_GR CP869" - # ISO-8859-8 languages - echo "he CP862" - echo "he_IL CP862" - # ISO-8859-9 languages - echo "tr CP857" - echo "tr_TR CP857" - # Japanese - echo "ja CP932" - echo "ja_JP CP932" - # Chinese - echo "zh_CN GBK" - echo "zh_TW CP950" # not CP938 ?? - # Korean - echo "kr CP949" # not CP934 ?? - echo "kr_KR CP949" # not CP934 ?? - # Thai - echo "th CP874" - echo "th_TH CP874" - # Other - echo "eo CP850" - echo "eo_EO CP850" - ;; + linux-gnulibc1*) + # Linux libc5 doesn't have nl_langinfo(CODESET); therefore + # localcharset.c falls back to using the full locale name + # from the environment variables. + echo "C ASCII" + echo "POSIX ASCII" + for l in af af_ZA ca ca_ES da da_DK de de_AT de_BE de_CH de_DE de_LU \ + en en_AU en_BW en_CA en_DK en_GB en_IE en_NZ en_US en_ZA \ + en_ZW es es_AR es_BO es_CL es_CO es_DO es_EC es_ES es_GT \ + es_HN es_MX es_PA es_PE es_PY es_SV es_US es_UY es_VE et \ + et_EE eu eu_ES fi fi_FI fo fo_FO fr fr_BE fr_CA fr_CH fr_FR \ + fr_LU ga ga_IE gl gl_ES id id_ID in in_ID is is_IS it it_CH \ + it_IT kl kl_GL nl nl_BE nl_NL no no_NO pt pt_BR pt_PT sv \ + sv_FI sv_SE; do + echo "$l ISO-8859-1" + echo "$l.iso-8859-1 ISO-8859-1" + echo "$l.iso-8859-15 ISO-8859-15" + echo "$l.iso-8859-15@euro ISO-8859-15" + echo "$l@euro ISO-8859-15" + echo "$l.cp-437 CP437" + echo "$l.cp-850 CP850" + echo "$l.cp-1252 CP1252" + echo "$l.cp-1252@euro CP1252" + #echo "$l.atari-st ATARI-ST" # not a commonly used encoding + echo "$l.utf-8 UTF-8" + echo "$l.utf-8@euro UTF-8" + done + for l in cs cs_CZ hr hr_HR hu hu_HU pl pl_PL ro ro_RO sk sk_SK sl \ + sl_SI sr sr_CS sr_YU; do + echo "$l ISO-8859-2" + echo "$l.iso-8859-2 ISO-8859-2" + echo "$l.cp-852 CP852" + echo "$l.cp-1250 CP1250" + echo "$l.utf-8 UTF-8" + done + for l in mk mk_MK ru ru_RU; do + echo "$l ISO-8859-5" + echo "$l.iso-8859-5 ISO-8859-5" + echo "$l.koi8-r KOI8-R" + echo "$l.cp-866 CP866" + echo "$l.cp-1251 CP1251" + echo "$l.utf-8 UTF-8" + done + for l in ar ar_SA; do + echo "$l ISO-8859-6" + echo "$l.iso-8859-6 ISO-8859-6" + echo "$l.cp-864 CP864" + #echo "$l.cp-868 CP868" # not a commonly used encoding + echo "$l.cp-1256 CP1256" + echo "$l.utf-8 UTF-8" + done + for l in el el_GR gr gr_GR; do + echo "$l ISO-8859-7" + echo "$l.iso-8859-7 ISO-8859-7" + echo "$l.cp-869 CP869" + echo "$l.cp-1253 CP1253" + echo "$l.cp-1253@euro CP1253" + echo "$l.utf-8 UTF-8" + echo "$l.utf-8@euro UTF-8" + done + for l in he he_IL iw iw_IL; do + echo "$l ISO-8859-8" + echo "$l.iso-8859-8 ISO-8859-8" + echo "$l.cp-862 CP862" + echo "$l.cp-1255 CP1255" + echo "$l.utf-8 UTF-8" + done + for l in tr tr_TR; do + echo "$l ISO-8859-9" + echo "$l.iso-8859-9 ISO-8859-9" + echo "$l.cp-857 CP857" + echo "$l.cp-1254 CP1254" + echo "$l.utf-8 UTF-8" + done + for l in lt lt_LT lv lv_LV; do + #echo "$l BALTIC" # not a commonly used encoding, wrong encoding name + echo "$l ISO-8859-13" + done + for l in ru_UA uk uk_UA; do + echo "$l KOI8-U" + done + for l in zh zh_CN; do + #echo "$l GB_2312-80" # not a commonly used encoding, wrong encoding name + echo "$l GB2312" + done + for l in ja ja_JP ja_JP.EUC; do + echo "$l EUC-JP" + done + for l in ko ko_KR; do + echo "$l EUC-KR" + done + for l in th th_TH; do + echo "$l TIS-620" + done + for l in fa fa_IR; do + #echo "$l ISIRI-3342" # a broken encoding + echo "$l.utf-8 UTF-8" + done + ;; + linux* | *-gnu*) + # With glibc-2.1 or newer, we don't need any canonicalization, + # because glibc has iconv and both glibc and libiconv support all + # GNU canonical names directly. Therefore, the Makefile does not + # need to install the alias file at all. + # The following applies only to glibc-2.0.x and older libcs. + echo "ISO_646.IRV:1983 ASCII" + ;; + aix*) + echo "ISO8859-1 ISO-8859-1" + echo "ISO8859-2 ISO-8859-2" + echo "ISO8859-5 ISO-8859-5" + echo "ISO8859-6 ISO-8859-6" + echo "ISO8859-7 ISO-8859-7" + echo "ISO8859-8 ISO-8859-8" + echo "ISO8859-9 ISO-8859-9" + echo "ISO8859-15 ISO-8859-15" + echo "IBM-850 CP850" + echo "IBM-856 CP856" + echo "IBM-921 ISO-8859-13" + echo "IBM-922 CP922" + echo "IBM-932 CP932" + echo "IBM-943 CP943" + echo "IBM-1046 CP1046" + echo "IBM-1124 CP1124" + echo "IBM-1129 CP1129" + echo "IBM-1252 CP1252" + echo "IBM-eucCN GB2312" + echo "IBM-eucJP EUC-JP" + echo "IBM-eucKR EUC-KR" + echo "IBM-eucTW EUC-TW" + echo "big5 BIG5" + echo "GBK GBK" + echo "TIS-620 TIS-620" + echo "UTF-8 UTF-8" + ;; + hpux*) + echo "iso88591 ISO-8859-1" + echo "iso88592 ISO-8859-2" + echo "iso88595 ISO-8859-5" + echo "iso88596 ISO-8859-6" + echo "iso88597 ISO-8859-7" + echo "iso88598 ISO-8859-8" + echo "iso88599 ISO-8859-9" + echo "iso885915 ISO-8859-15" + echo "roman8 HP-ROMAN8" + echo "arabic8 HP-ARABIC8" + echo "greek8 HP-GREEK8" + echo "hebrew8 HP-HEBREW8" + echo "turkish8 HP-TURKISH8" + echo "kana8 HP-KANA8" + echo "tis620 TIS-620" + echo "big5 BIG5" + echo "eucJP EUC-JP" + echo "eucKR EUC-KR" + echo "eucTW EUC-TW" + echo "hp15CN GB2312" + #echo "ccdc ?" # what is this? + echo "SJIS SHIFT_JIS" + echo "utf8 UTF-8" + ;; + irix*) + echo "ISO8859-1 ISO-8859-1" + echo "ISO8859-2 ISO-8859-2" + echo "ISO8859-5 ISO-8859-5" + echo "ISO8859-7 ISO-8859-7" + echo "ISO8859-9 ISO-8859-9" + echo "eucCN GB2312" + echo "eucJP EUC-JP" + echo "eucKR EUC-KR" + echo "eucTW EUC-TW" + ;; + osf*) + echo "ISO8859-1 ISO-8859-1" + echo "ISO8859-2 ISO-8859-2" + echo "ISO8859-4 ISO-8859-4" + echo "ISO8859-5 ISO-8859-5" + echo "ISO8859-7 ISO-8859-7" + echo "ISO8859-8 ISO-8859-8" + echo "ISO8859-9 ISO-8859-9" + echo "ISO8859-15 ISO-8859-15" + echo "cp850 CP850" + echo "big5 BIG5" + echo "dechanyu DEC-HANYU" + echo "dechanzi GB2312" + echo "deckanji DEC-KANJI" + echo "deckorean EUC-KR" + echo "eucJP EUC-JP" + echo "eucKR EUC-KR" + echo "eucTW EUC-TW" + echo "GBK GBK" + echo "KSC5601 CP949" + echo "sdeckanji EUC-JP" + echo "SJIS SHIFT_JIS" + echo "TACTIS TIS-620" + echo "UTF-8 UTF-8" + ;; + solaris*) + echo "646 ASCII" + echo "ISO8859-1 ISO-8859-1" + echo "ISO8859-2 ISO-8859-2" + echo "ISO8859-3 ISO-8859-3" + echo "ISO8859-4 ISO-8859-4" + echo "ISO8859-5 ISO-8859-5" + echo "ISO8859-6 ISO-8859-6" + echo "ISO8859-7 ISO-8859-7" + echo "ISO8859-8 ISO-8859-8" + echo "ISO8859-9 ISO-8859-9" + echo "ISO8859-15 ISO-8859-15" + echo "koi8-r KOI8-R" + echo "ansi-1251 CP1251" + echo "BIG5 BIG5" + echo "Big5-HKSCS BIG5-HKSCS" + echo "gb2312 GB2312" + echo "GBK GBK" + echo "GB18030 GB18030" + echo "cns11643 EUC-TW" + echo "5601 EUC-KR" + echo "ko_KR.johap92 JOHAB" + echo "eucJP EUC-JP" + echo "PCK SHIFT_JIS" + echo "TIS620.2533 TIS-620" + #echo "sun_eu_greek ?" # what is this? + echo "UTF-8 UTF-8" + ;; + freebsd* | os2*) + # FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore + # localcharset.c falls back to using the full locale name + # from the environment variables. + # Likewise for OS/2. OS/2 has XFree86 just like FreeBSD. Just + # reuse FreeBSD's locale data for OS/2. + echo "C ASCII" + echo "US-ASCII ASCII" + for l in la_LN lt_LN; do + echo "$l.ASCII ASCII" + done + for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \ + fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT la_LN \ + lt_LN nl_BE nl_NL no_NO pt_PT sv_SE; do + echo "$l.ISO_8859-1 ISO-8859-1" + echo "$l.DIS_8859-15 ISO-8859-15" + done + for l in cs_CZ hr_HR hu_HU la_LN lt_LN pl_PL sl_SI; do + echo "$l.ISO_8859-2 ISO-8859-2" + done + for l in la_LN lt_LT; do + echo "$l.ISO_8859-4 ISO-8859-4" + done + for l in ru_RU ru_SU; do + echo "$l.KOI8-R KOI8-R" + echo "$l.ISO_8859-5 ISO-8859-5" + echo "$l.CP866 CP866" + done + echo "uk_UA.KOI8-U KOI8-U" + echo "zh_TW.BIG5 BIG5" + echo "zh_TW.Big5 BIG5" + echo "zh_CN.EUC GB2312" + echo "ja_JP.EUC EUC-JP" + echo "ja_JP.SJIS SHIFT_JIS" + echo "ja_JP.Shift_JIS SHIFT_JIS" + echo "ko_KR.EUC EUC-KR" + ;; + netbsd*) + echo "646 ASCII" + echo "ISO8859-1 ISO-8859-1" + echo "ISO8859-2 ISO-8859-2" + echo "ISO8859-4 ISO-8859-4" + echo "ISO8859-5 ISO-8859-5" + echo "ISO8859-7 ISO-8859-7" + echo "ISO8859-13 ISO-8859-13" + echo "ISO8859-15 ISO-8859-15" + echo "eucCN GB2312" + echo "eucJP EUC-JP" + echo "eucKR EUC-KR" + echo "eucTW EUC-TW" + echo "BIG5 BIG5" + echo "SJIS SHIFT_JIS" + ;; + openbsd*) + echo "646 ASCII" + echo "ISO8859-1 ISO-8859-1" + echo "ISO8859-2 ISO-8859-2" + echo "ISO8859-4 ISO-8859-4" + echo "ISO8859-5 ISO-8859-5" + echo "ISO8859-7 ISO-8859-7" + echo "ISO8859-13 ISO-8859-13" + echo "ISO8859-15 ISO-8859-15" + ;; + darwin[56]*) + # Darwin 6.8 doesn't have nl_langinfo(CODESET); therefore + # localcharset.c falls back to using the full locale name + # from the environment variables. + echo "C ASCII" + for l in en_AU en_CA en_GB en_US la_LN; do + echo "$l.US-ASCII ASCII" + done + for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \ + fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT nl_BE \ + nl_NL no_NO pt_PT sv_SE; do + echo "$l ISO-8859-1" + echo "$l.ISO8859-1 ISO-8859-1" + echo "$l.ISO8859-15 ISO-8859-15" + done + for l in la_LN; do + echo "$l.ISO8859-1 ISO-8859-1" + echo "$l.ISO8859-15 ISO-8859-15" + done + for l in cs_CZ hr_HR hu_HU la_LN pl_PL sl_SI; do + echo "$l.ISO8859-2 ISO-8859-2" + done + for l in la_LN lt_LT; do + echo "$l.ISO8859-4 ISO-8859-4" + done + for l in ru_RU; do + echo "$l.KOI8-R KOI8-R" + echo "$l.ISO8859-5 ISO-8859-5" + echo "$l.CP866 CP866" + done + for l in bg_BG; do + echo "$l.CP1251 CP1251" + done + echo "uk_UA.KOI8-U KOI8-U" + echo "zh_TW.BIG5 BIG5" + echo "zh_TW.Big5 BIG5" + echo "zh_CN.EUC GB2312" + echo "ja_JP.EUC EUC-JP" + echo "ja_JP.SJIS SHIFT_JIS" + echo "ko_KR.EUC EUC-KR" + ;; + darwin*) + # Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is + # useless: + # - It returns the empty string when LANG is set to a locale of the + # form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8 + # LC_CTYPE file. + # - The environment variables LANG, LC_CTYPE, LC_ALL are not set by + # the system; nl_langinfo(CODESET) returns "US-ASCII" in this case. + # - The documentation says: + # "... all code that calls BSD system routines should ensure + # that the const *char parameters of these routines are in UTF-8 + # encoding. All BSD system functions expect their string + # parameters to be in UTF-8 encoding and nothing else." + # It also says + # "An additional caveat is that string parameters for files, + # paths, and other file-system entities must be in canonical + # UTF-8. In a canonical UTF-8 Unicode string, all decomposable + # characters are decomposed ..." + # but this is not true: You can pass non-decomposed UTF-8 strings + # to file system functions, and it is the OS which will convert + # them to decomposed UTF-8 before accessing the file system. + # - The Apple Terminal application displays UTF-8 by default. + # - However, other applications are free to use different encodings: + # - xterm uses ISO-8859-1 by default. + # - TextEdit uses MacRoman by default. + # We prefer UTF-8 over decomposed UTF-8-MAC because one should + # minimize the use of decomposed Unicode. Unfortunately, through the + # Darwin file system, decomposed UTF-8 strings are leaked into user + # space nevertheless. + # Then there are also the locales with encodings other than US-ASCII + # and UTF-8. These locales can be occasionally useful to users (e.g. + # when grepping through ISO-8859-1 encoded text files), when all their + # file names are in US-ASCII. + echo "ISO8859-1 ISO-8859-1" + echo "ISO8859-2 ISO-8859-2" + echo "ISO8859-4 ISO-8859-4" + echo "ISO8859-5 ISO-8859-5" + echo "ISO8859-7 ISO-8859-7" + echo "ISO8859-9 ISO-8859-9" + echo "ISO8859-13 ISO-8859-13" + echo "ISO8859-15 ISO-8859-15" + echo "KOI8-R KOI8-R" + echo "KOI8-U KOI8-U" + echo "CP866 CP866" + echo "CP949 CP949" + echo "CP1131 CP1131" + echo "CP1251 CP1251" + echo "eucCN GB2312" + echo "GB2312 GB2312" + echo "eucJP EUC-JP" + echo "eucKR EUC-KR" + echo "Big5 BIG5" + echo "Big5HKSCS BIG5-HKSCS" + echo "GBK GBK" + echo "GB18030 GB18030" + echo "SJIS SHIFT_JIS" + echo "ARMSCII-8 ARMSCII-8" + echo "PT154 PT154" + #echo "ISCII-DEV ?" + echo "* UTF-8" + ;; + beos* | haiku*) + # BeOS and Haiku have a single locale, and it has UTF-8 encoding. + echo "* UTF-8" + ;; + msdosdjgpp*) + # DJGPP 2.03 doesn't have nl_langinfo(CODESET); therefore + # localcharset.c falls back to using the full locale name + # from the environment variables. + echo "#" + echo "# The encodings given here may not all be correct." + echo "# If you find that the encoding given for your language and" + echo "# country is not the one your DOS machine actually uses, just" + echo "# correct it in this file, and send a mail to" + echo "# Juan Manuel Guerrero " + echo "# and Bruno Haible ." + echo "#" + echo "C ASCII" + # ISO-8859-1 languages + echo "ca CP850" + echo "ca_ES CP850" + echo "da CP865" # not CP850 ?? + echo "da_DK CP865" # not CP850 ?? + echo "de CP850" + echo "de_AT CP850" + echo "de_CH CP850" + echo "de_DE CP850" + echo "en CP850" + echo "en_AU CP850" # not CP437 ?? + echo "en_CA CP850" + echo "en_GB CP850" + echo "en_NZ CP437" + echo "en_US CP437" + echo "en_ZA CP850" # not CP437 ?? + echo "es CP850" + echo "es_AR CP850" + echo "es_BO CP850" + echo "es_CL CP850" + echo "es_CO CP850" + echo "es_CR CP850" + echo "es_CU CP850" + echo "es_DO CP850" + echo "es_EC CP850" + echo "es_ES CP850" + echo "es_GT CP850" + echo "es_HN CP850" + echo "es_MX CP850" + echo "es_NI CP850" + echo "es_PA CP850" + echo "es_PY CP850" + echo "es_PE CP850" + echo "es_SV CP850" + echo "es_UY CP850" + echo "es_VE CP850" + echo "et CP850" + echo "et_EE CP850" + echo "eu CP850" + echo "eu_ES CP850" + echo "fi CP850" + echo "fi_FI CP850" + echo "fr CP850" + echo "fr_BE CP850" + echo "fr_CA CP850" + echo "fr_CH CP850" + echo "fr_FR CP850" + echo "ga CP850" + echo "ga_IE CP850" + echo "gd CP850" + echo "gd_GB CP850" + echo "gl CP850" + echo "gl_ES CP850" + echo "id CP850" # not CP437 ?? + echo "id_ID CP850" # not CP437 ?? + echo "is CP861" # not CP850 ?? + echo "is_IS CP861" # not CP850 ?? + echo "it CP850" + echo "it_CH CP850" + echo "it_IT CP850" + echo "lt CP775" + echo "lt_LT CP775" + echo "lv CP775" + echo "lv_LV CP775" + echo "nb CP865" # not CP850 ?? + echo "nb_NO CP865" # not CP850 ?? + echo "nl CP850" + echo "nl_BE CP850" + echo "nl_NL CP850" + echo "nn CP865" # not CP850 ?? + echo "nn_NO CP865" # not CP850 ?? + echo "no CP865" # not CP850 ?? + echo "no_NO CP865" # not CP850 ?? + echo "pt CP850" + echo "pt_BR CP850" + echo "pt_PT CP850" + echo "sv CP850" + echo "sv_SE CP850" + # ISO-8859-2 languages + echo "cs CP852" + echo "cs_CZ CP852" + echo "hr CP852" + echo "hr_HR CP852" + echo "hu CP852" + echo "hu_HU CP852" + echo "pl CP852" + echo "pl_PL CP852" + echo "ro CP852" + echo "ro_RO CP852" + echo "sk CP852" + echo "sk_SK CP852" + echo "sl CP852" + echo "sl_SI CP852" + echo "sq CP852" + echo "sq_AL CP852" + echo "sr CP852" # CP852 or CP866 or CP855 ?? + echo "sr_CS CP852" # CP852 or CP866 or CP855 ?? + echo "sr_YU CP852" # CP852 or CP866 or CP855 ?? + # ISO-8859-3 languages + echo "mt CP850" + echo "mt_MT CP850" + # ISO-8859-5 languages + echo "be CP866" + echo "be_BE CP866" + echo "bg CP866" # not CP855 ?? + echo "bg_BG CP866" # not CP855 ?? + echo "mk CP866" # not CP855 ?? + echo "mk_MK CP866" # not CP855 ?? + echo "ru CP866" + echo "ru_RU CP866" + echo "uk CP1125" + echo "uk_UA CP1125" + # ISO-8859-6 languages + echo "ar CP864" + echo "ar_AE CP864" + echo "ar_DZ CP864" + echo "ar_EG CP864" + echo "ar_IQ CP864" + echo "ar_IR CP864" + echo "ar_JO CP864" + echo "ar_KW CP864" + echo "ar_MA CP864" + echo "ar_OM CP864" + echo "ar_QA CP864" + echo "ar_SA CP864" + echo "ar_SY CP864" + # ISO-8859-7 languages + echo "el CP869" + echo "el_GR CP869" + # ISO-8859-8 languages + echo "he CP862" + echo "he_IL CP862" + # ISO-8859-9 languages + echo "tr CP857" + echo "tr_TR CP857" + # Japanese + echo "ja CP932" + echo "ja_JP CP932" + # Chinese + echo "zh_CN GBK" + echo "zh_TW CP950" # not CP938 ?? + # Korean + echo "kr CP949" # not CP934 ?? + echo "kr_KR CP949" # not CP934 ?? + # Thai + echo "th CP874" + echo "th_TH CP874" + # Other + echo "eo CP850" + echo "eo_EO CP850" + ;; esac diff --git a/src/bin/coreutils/lib/config.h b/src/bin/coreutils/lib/config.h index 4f9d97e371..e76620867c 100644 --- a/src/bin/coreutils/lib/config.h +++ b/src/bin/coreutils/lib/config.h @@ -33,12 +33,19 @@ non-IEEE-754 'long double' values. */ #define CHECK_PRINTF_SAFE 1 +/* Define to 1 if chown fails to change ctime when at least one argument was + not -1. */ +/* #undef CHOWN_CHANGE_TIME_BUG */ + /* Define if chown is not POSIX compliant regarding IDs of -1. */ #define CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE 1 /* Define if chown modifies symlinks. */ /* #undef CHOWN_MODIFIES_SYMLINK */ +/* Define to 1 if chown mishandles trailing slash. */ +#define CHOWN_TRAILING_SLASH_BUG 1 + /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP systems. This function is required for `alloca.c' support on those systems. */ @@ -98,8 +105,12 @@ language is requested. */ /* #undef ENABLE_NLS */ -/* Define if gnulib's fchdir() replacement is used. */ -/* #undef FCHDIR_REPLACEMENT */ +/* Define to 1 if your platform has fchownat, but it cannot perform lchown + tasks. */ +#define FCHOWNAT_NOFOLLOW_BUG 1 + +/* Define this to 1 if F_DUPFD behavior does not match POSIX */ +/* #undef FCNTL_DUPFD_BUGGY */ /* Define on systems for which file names may have a so-called `drive letter' prefix, define this to compute the length of that prefix, including the @@ -136,13 +147,31 @@ /* Define as the word index where to find the sign of 'float'. */ /* #undef FLT_SIGNBIT_WORD */ +/* Define to 1 if fopen() fails to recognize a trailing slash. */ +#define FOPEN_TRAILING_SLASH_BUG 1 + +/* Define to 1 if mkdir mistakenly creates a directory given with a trailing + dot component. */ +/* #undef FUNC_MKDIR_DOT_BUG */ + +/* Define to 1 if realpath() can malloc memory, always gives an absolute path, + and handles trailing slash correctly. */ +/* #undef FUNC_REALPATH_WORKS */ + /* Define to 1 if ungetc is broken when used on arbitrary bytes. */ #define FUNC_UNGETC_BROKEN 1 +/* Define to 1 if futimesat mishandles a NULL file name. */ +/* #undef FUTIMESAT_NULL_BUG */ + /* Define to the type of elements in the array set by `getgroups'. Usually this is either `int' or `gid_t'. */ #define GETGROUPS_T gid_t +/* Define this to 1 if getgroups(0,NULL) does not return the number of groups. + */ +/* #undef GETGROUPS_ZERO_BUG */ + /* Define to 1 if the `getloadavg' function needs to be run setuid or setgid. */ /* #undef GETLOADAVG_PRIVILEGED */ @@ -153,18 +182,42 @@ /* Define to make the limit macros in visible. */ #define GL_TRIGGER_STDC_LIMIT_MACROS 1 +/* Define to 1 when using the gnulib module areadlinkat. */ +#define GNULIB_AREADLINKAT 1 + /* Define to 1 when using the gnulib module canonicalize. */ #define GNULIB_CANONICALIZE 1 +/* Define to 1 when using the gnulib module cloexec. */ +#define GNULIB_CLOEXEC 1 + /* Define to 1 when using the gnulib module close-stream. */ #define GNULIB_CLOSE_STREAM 1 +/* Define to 1 when using the gnulib module dirent-safer. */ +#define GNULIB_DIRENT_SAFER 1 + +/* Define to 1 when using the gnulib module dirname. */ +#define GNULIB_DIRNAME 1 + +/* Define to 1 when using the gnulib module faccessat. */ +#define GNULIB_FACCESSAT 1 + /* Define to 1 when using the gnulib module fcntl-safer. */ #define GNULIB_FCNTL_SAFER 1 +/* Define to 1 when using the gnulib module fd-safer-flag. */ +#define GNULIB_FD_SAFER_FLAG 1 + +/* Define to 1 when using the gnulib module filenamecat. */ +#define GNULIB_FILENAMECAT 1 + /* Define to 1 when using the gnulib module fopen-safer. */ #define GNULIB_FOPEN_SAFER 1 +/* Define to 1 when using the gnulib module freopen-safer. */ +#define GNULIB_FREOPEN_SAFER 1 + /* Define to 1 when using the gnulib module fts. */ #define GNULIB_FTS 1 @@ -180,12 +233,18 @@ /* Define to 1 when using the gnulib module open. */ #define GNULIB_OPEN 1 +/* Define to 1 when using the gnulib module openat-safer. */ +#define GNULIB_OPENAT_SAFER 1 + /* enable some gnulib portability checks */ /* #undef GNULIB_PORTCHECK */ /* Define to indicate the 'realloc' module. */ #define GNULIB_REALLOC_GNU 1 +/* Define to 1 when using the gnulib module stdlib-safer. */ +#define GNULIB_STDLIB_SAFER 1 + /* Define to 1 when using the gnulib module unistr/u8-uctomb. */ #define GNULIB_UNISTR_U8_UCTOMB 1 @@ -195,6 +254,9 @@ /* Define if your system defines TIOCGWINSZ in sys/pty.h. */ /* #undef GWINSZ_IN_SYS_PTY */ +/* Define to 1 if you have the `access' function. */ +#define HAVE_ACCESS 1 + /* Define to 1 if you have the `acl' function. */ /* #undef HAVE_ACL */ @@ -323,8 +385,8 @@ the CoreFoundation framework. */ /* #undef HAVE_CFPREFERENCESCOPYAPPVALUE */ -/* Define to 1 if your system has a working `chown' function. */ -/* #undef HAVE_CHOWN */ +/* Define to 1 if you have the `chown' function. */ +#define HAVE_CHOWN 1 /* Define to 1 if you have the `chroot' function. */ #define HAVE_CHROOT 1 @@ -353,6 +415,9 @@ libc. */ /* #undef HAVE_COPYSIGN_IN_LIBC */ +/* Define to 1 if you have the header file. */ +#define HAVE_CTYPE_H 1 + /* FIXME */ #define HAVE_C_LINE 1 @@ -364,10 +429,6 @@ */ #define HAVE_DECL_ALARM 1 -/* Define to 1 if you have the declaration of `canonicalize_file_name', and to - 0 if you don't. */ -#define HAVE_DECL_CANONICALIZE_FILE_NAME 0 - /* Define to 1 if you have the declaration of `clearerr_unlocked', and to 0 if you don't. */ #define HAVE_DECL_CLEARERR_UNLOCKED 1 @@ -424,10 +485,6 @@ you don't. */ #define HAVE_DECL_FREAD_UNLOCKED 0 -/* Define to 1 if you have the declaration of `free', and to 0 if you don't. - */ -#define HAVE_DECL_FREE 1 - /* Define to 1 if you have the declaration of `freeaddrinfo', and to 0 if you don't. */ #define HAVE_DECL_FREEADDRINFO 1 @@ -528,26 +585,26 @@ don't. */ #define HAVE_DECL_ISBLANK 1 -/* Define to 1 if you have the declaration of `lseek', and to 0 if you don't. - */ -#define HAVE_DECL_LSEEK 1 - -/* Define to 1 if you have the declaration of `malloc', and to 0 if you don't. - */ -#define HAVE_DECL_MALLOC 1 - /* Define to 1 if you have a declaration of mbswidth() in , and to 0 otherwise. */ #define HAVE_DECL_MBSWIDTH_IN_WCHAR_H 0 -/* Define to 1 if you have the declaration of `memchr', and to 0 if you don't. - */ -#define HAVE_DECL_MEMCHR 1 - /* Define to 1 if you have the declaration of `memrchr', and to 0 if you don't. */ #define HAVE_DECL_MEMRCHR 0 +/* Define to 1 if you have the declaration of `optreset', and to 0 if you + don't. */ +#define HAVE_DECL_OPTRESET 0 + +/* Define to 1 if you have the declaration of `program_invocation_name', and + to 0 if you don't. */ +#define HAVE_DECL_PROGRAM_INVOCATION_NAME 0 + +/* Define to 1 if you have the declaration of `program_invocation_short_name', + and to 0 if you don't. */ +#define HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME 0 + /* Define to 1 if you have the declaration of `putchar_unlocked', and to 0 if you don't. */ #define HAVE_DECL_PUTCHAR_UNLOCKED 1 @@ -556,10 +613,6 @@ don't. */ #define HAVE_DECL_PUTC_UNLOCKED 1 -/* Define to 1 if you have the declaration of `realloc', and to 0 if you - don't. */ -#define HAVE_DECL_REALLOC 1 - /* Define to 1 if you have the declaration of `setregid', and to 0 if you don't. */ #define HAVE_DECL_SETREGID 1 @@ -689,6 +742,9 @@ /* Define to 1 if you have the `euidaccess' function. */ /* #undef HAVE_EUIDACCESS */ +/* Define to 1 if you have the `faccessat' function. */ +#define HAVE_FACCESSAT 1 + /* Define to 1 if you have the `fchdir' function. */ #define HAVE_FCHDIR 1 @@ -696,11 +752,14 @@ #define HAVE_FCHMOD 1 /* Define to 1 if you have the `fchmodat' function. */ -/* #undef HAVE_FCHMODAT */ +#define HAVE_FCHMODAT 1 /* Define to 1 if you have the `fchown' function. */ #define HAVE_FCHOWN 1 +/* Define to 1 if you have the `fcntl' function. */ +#define HAVE_FCNTL 1 + /* Define to 1 if you have the header file. */ #define HAVE_FCNTL_H 1 @@ -708,7 +767,7 @@ /* #undef HAVE_FDATASYNC */ /* Define to 1 if you have the `fdopendir' function. */ -/* #undef HAVE_FDOPENDIR */ +#define HAVE_FDOPENDIR 1 /* Define to 1 if pipes are FIFOs, 0 if sockets. Leave undefined if not known. */ @@ -735,9 +794,15 @@ /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ #define HAVE_FSEEKO 1 +/* Define to 1 if you have the `fstatat' function. */ +#define HAVE_FSTATAT 1 + /* Define to 1 if you have the `fstatfs' function. */ /* #undef HAVE_FSTATFS */ +/* Define to 1 if you have the `fsync' function. */ +#define HAVE_FSYNC 1 + /* Define to 1 if you have the header file. */ #define HAVE_FS_INFO_H 1 @@ -751,7 +816,7 @@ #define HAVE_FUNLOCKFILE 1 /* Define to 1 if you have the `futimens' function. */ -/* #undef HAVE_FUTIMENS */ +#define HAVE_FUTIMENS 1 /* Define to 1 if you have the `futimes' function. */ /* #undef HAVE_FUTIMES */ @@ -765,6 +830,12 @@ /* Define to 1 if you have the `getdelim' function. */ #define HAVE_GETDELIM 1 +/* Define to 1 if you have the `getdtablesize' function. */ +#define HAVE_GETDTABLESIZE 1 + +/* Define to 1 if you have the `getegid' function. */ +#define HAVE_GETEGID 1 + /* Define to 1 if you have the `getgrouplist' function. */ #define HAVE_GETGROUPLIST 1 @@ -903,6 +974,9 @@ /* Define if you have and nl_langinfo(CODESET). */ /* #undef HAVE_LANGINFO_CODESET */ +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LANGINFO_H */ + /* Define if you have and nl_langinfo(YESEXPR). */ /* #undef HAVE_LANGINFO_YESEXPR */ @@ -942,6 +1016,12 @@ /* Define to 1 if you have the `ypsec' library (-lypsec). */ /* #undef HAVE_LIBYPSEC */ +/* Define to 1 if you have the `link' function. */ +#define HAVE_LINK 1 + +/* Define to 1 if you have the `linkat' function. */ +#define HAVE_LINKAT 1 + /* Define to 1 if you have the `listmntent' function. */ /* #undef HAVE_LISTMNTENT */ @@ -961,6 +1041,9 @@ zero-length file name argument. */ /* #undef HAVE_LSTAT_EMPTY_STRING_BUG */ +/* Define to 1 if you have the `lutimes' function. */ +/* #undef HAVE_LUTIMES */ + /* Define to 1 if you have the header file. */ /* #undef HAVE_MACHINE_HAL_SYSINFO_H */ @@ -993,6 +1076,9 @@ /* Define to 1 if you have the `mbsinit' function. */ #define HAVE_MBSINIT 1 +/* Define to 1 if you have the `mbslen' function. */ +/* #undef HAVE_MBSLEN */ + /* Define to 1 if you have the `mbsrtowcs' function. */ #define HAVE_MBSRTOWCS 1 @@ -1024,7 +1110,7 @@ /* #undef HAVE_MICROUPTIME */ /* Define to 1 if you have the `mkdirat' function. */ -/* #undef HAVE_MKDIRAT */ +#define HAVE_MKDIRAT 1 /* Define to 1 if you have the `mkfifo' function. */ #define HAVE_MKFIFO 1 @@ -1047,6 +1133,9 @@ /* Define to 1 if you have the header file. */ #define HAVE_NETINET_IN_H 1 +/* Define to 1 if you have the `newlocale' function. */ +/* #undef HAVE_NEWLOCALE */ + /* Define to 1 if you have the `next_dev' function. */ #define HAVE_NEXT_DEV 1 @@ -1069,7 +1158,7 @@ /* #undef HAVE_OBSTACK */ /* Define to 1 if you have the `openat' function. */ -/* #undef HAVE_OPENAT */ +#define HAVE_OPENAT 1 /* Define to 1 if you have the header file. */ #define HAVE_OS_H 1 @@ -1101,6 +1190,15 @@ /* Define to 1 if you have the `pstat_getstatic' function. */ /* #undef HAVE_PSTAT_GETSTATIC */ +/* Define to 1 if you have the `pthread_atfork' function. */ +#define HAVE_PTHREAD_ATFORK 1 + +/* Define if the defines PTHREAD_MUTEX_RECURSIVE. */ +#define HAVE_PTHREAD_MUTEX_RECURSIVE 1 + +/* Define if the POSIX multithreading library has read/write locks. */ +#define HAVE_PTHREAD_RWLOCK 1 + /* Define to 1 if you have the header file. */ #define HAVE_PWD_H 1 @@ -1110,9 +1208,21 @@ /* Define to 1 if you have the header file. */ /* #undef HAVE_RANDOM_H */ +/* Define to 1 if environ is declared even after undefining macros. */ +#define HAVE_RAW_DECL_ENVIRON 1 + +/* Define to 1 if fseeko is declared even after undefining macros. */ +#define HAVE_RAW_DECL_FSEEKO 1 + +/* Define to 1 if ftello is declared even after undefining macros. */ +#define HAVE_RAW_DECL_FTELLO 1 + /* Define to 1 if you have the `readlink' function. */ #define HAVE_READLINK 1 +/* Define to 1 if you have the `readlinkat' function. */ +#define HAVE_READLINKAT 1 + /* Define to 1 if your system has a GNU libc compatible `realloc' function, and to 0 otherwise. */ #define HAVE_REALLOC 1 @@ -1120,8 +1230,8 @@ /* Define if the 'realloc' function is POSIX compliant. */ #define HAVE_REALLOC_POSIX 1 -/* Define to 1 if you have the `resolvepath' function. */ -/* #undef HAVE_RESOLVEPATH */ +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 /* Define to 1 if you have the `rmdir' function. */ #define HAVE_RMDIR 1 @@ -1135,8 +1245,17 @@ /* Define to 1 if the system has the type `sa_family_t'. */ /* #undef HAVE_SA_FAMILY_T */ +/* Define to 1 if you have the `sched_getaffinity' function. */ +/* #undef HAVE_SCHED_GETAFFINITY */ + +/* Define to 1 if sched_getaffinity has a glibc compatible declaration. */ +/* #undef HAVE_SCHED_GETAFFINITY_LIKE_GLIBC */ + +/* Define to 1 if you have the `sched_getaffinity_np' function. */ +/* #undef HAVE_SCHED_GETAFFINITY_NP */ + /* Define to 1 if you have the header file. */ -/* #undef HAVE_SEARCH_H */ +#define HAVE_SEARCH_H 1 /* Define to 1 if you have the header file. */ /* #undef HAVE_SELINUX_CONTEXT_H */ @@ -1195,6 +1314,9 @@ /* Define to 1 if the system has the type `sigset_t'. */ /* #undef HAVE_SIGSET_T */ +/* Define to 1 if you have the `sleep' function. */ +#define HAVE_SLEEP 1 + /* Define to 1 if you have the `snprintf' function. */ #define HAVE_SNPRINTF 1 @@ -1254,7 +1376,7 @@ /* Define to 1 if you have the header file. */ #define HAVE_STRING_H 1 -/* Define if you have the strndup() function and it works. */ +/* Define to 1 if you have the `strndup' function. */ #define HAVE_STRNDUP 1 /* Define to 1 if you have the `strnlen' function. */ @@ -1266,6 +1388,9 @@ /* Define to 1 if you have the `strpbrk' function. */ #define HAVE_STRPBRK 1 +/* Define to 1 if you have the `strsignal' function. */ +#define HAVE_STRSIGNAL 1 + /* Define to 1 if you have the `strtoimax' function. */ #define HAVE_STRTOIMAX 1 @@ -1427,8 +1552,8 @@ /* Define to 1 if `ut_user' is a member of `struct utmp'. */ /* #undef HAVE_STRUCT_UTMP_UT_USER */ -/* Define to 1 if you have the `strverscmp' function. */ -/* #undef HAVE_STRVERSCMP */ +/* Define to 1 if the system has the type `struct utsname'. */ +#define HAVE_STRUCT_UTSNAME 1 /* Define to 1 if you have the `strxfrm' function. */ #define HAVE_STRXFRM 1 @@ -1440,6 +1565,12 @@ /* Define if struct stat has an st_dm_mode member. */ /* #undef HAVE_ST_DM_MODE */ +/* Define to 1 if you have the `symlink' function. */ +#define HAVE_SYMLINK 1 + +/* Define to 1 if you have the `symlinkat' function. */ +#define HAVE_SYMLINKAT 1 + /* Define to 1 if you have the `sync' function. */ #define HAVE_SYNC 1 @@ -1545,6 +1676,9 @@ /* Define to 1 if you have the header file. */ /* #undef HAVE_SYS_UCRED_H */ +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + /* Define to 1 if you have the header file. */ /* #undef HAVE_SYS_VFS_H */ @@ -1577,7 +1711,7 @@ #define HAVE_TM_ZONE 1 /* Define to 1 if you have the `tsearch' function. */ -/* #undef HAVE_TSEARCH */ +#define HAVE_TSEARCH 1 /* Define to 1 if you don't have `tm_zone' but do have the external array `tzname'. */ @@ -1592,14 +1726,20 @@ /* Define to 1 if you have the header file. */ #define HAVE_UNISTD_H 1 +/* Define to 1 if you have the `unlinkat' function. */ +#define HAVE_UNLINKAT 1 + /* Define to 1 if you have the `unsetenv' function. */ #define HAVE_UNSETENV 1 /* Define to 1 if the system has the type `unsigned long long int'. */ #define HAVE_UNSIGNED_LONG_LONG_INT 1 +/* Define to 1 if you have the `usleep' function. */ +#define HAVE_USLEEP 1 + /* Define to 1 if you have the `utimensat' function. */ -/* #undef HAVE_UTIMENSAT */ +#define HAVE_UTIMENSAT 1 /* Define to 1 if you have the header file. */ #define HAVE_UTIME_H 1 @@ -1680,7 +1820,7 @@ #define HAVE_WORKING_O_NOATIME 0 /* Define to 1 if O_NOFOLLOW works. */ -#define HAVE_WORKING_O_NOFOLLOW 0 +#define HAVE_WORKING_O_NOFOLLOW 1 /* Define if utimes works properly. */ /* #undef HAVE_WORKING_UTIMES */ @@ -1691,6 +1831,9 @@ /* Define to 1 if you have the header file. */ /* #undef HAVE_WS2TCPIP_H */ +/* Define to 1 if you have the header file. */ +/* #undef HAVE_XLOCALE_H */ + /* Define to 1 if the system has the type `_Bool'. */ /* #undef HAVE__BOOL */ @@ -1746,8 +1889,9 @@ /* Define as the word index where to find the sign of 'long double'. */ /* #undef LDBL_SIGNBIT_WORD */ -/* Define if `link(2)' dereferences symbolic links. */ -#define LINK_FOLLOWS_SYMLINKS -1 +/* Define to 1 if `link(2)' dereferences symbolic links, 0 if it creates hard + links to symlinks, and -1 if unknown. */ +#define LINK_FOLLOWS_SYMLINKS 1 /* FIXME */ /* #undef LOCALTIME_CACHE */ @@ -1914,7 +2058,7 @@ /* #undef PACKAGE_PACKAGER_VERSION */ /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "GNU coreutils 7.5" +#define PACKAGE_STRING "GNU coreutils 8.4" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "coreutils" @@ -1923,7 +2067,7 @@ #define PACKAGE_URL "http://www.gnu.org/software/coreutils/" /* Define to the version of this package. */ -#define PACKAGE_VERSION "7.5" +#define PACKAGE_VERSION "8.4" /* the number of pending output bytes on stream `fp' */ #define PENDING_OUTPUT_N_BYTES fp->_IO_write_ptr - fp->_IO_write_base @@ -1948,20 +2092,49 @@ /* Define to 1 if the C compiler supports function prototypes. */ #define PROTOTYPES 1 +/* Define if the pthread_in_use() detection is hard. */ +/* #undef PTHREAD_IN_USE_DETECTION_HARD */ + /* Define to l, ll, u, ul, ull, etc., as suitable for constants of type 'ptrdiff_t'. */ #define PTRDIFF_T_SUFFIX l +/* Define to 1 if readlink fails to recognize a trailing slash. */ +#define READLINK_TRAILING_SLASH_BUG 1 + /* Define if rename does not work when the destination file exists, as on - Windows. */ + Cygwin 1.5 or Windows. */ /* #undef RENAME_DEST_EXISTS_BUG */ -/* Define if rename does not work for source file names with a trailing slash, - like the one from SunOS 4.1.1_U1. */ -/* #undef RENAME_TRAILING_SLASH_BUG */ +/* Define if rename fails to leave hard links alone, as on NetBSD 1.6 or + Cygwin 1.5. */ +#define RENAME_HARD_LINK_BUG 1 -/* Define to 1 if dup2 returns 0 instead of the target fd. */ -#define REPLACE_DUP2 0 +/* Define if rename does not correctly handle slashes on the destination + argument, such as on Solaris 10 or NetBSD 1.6. */ +#define RENAME_TRAILING_SLASH_DEST_BUG 1 + +/* Define if rename does not correctly handle slashes on the source argument, + such as on Solaris 9 or cygwin 1.5. */ +#define RENAME_TRAILING_SLASH_SOURCE_BUG 1 + +/* Define to 1 if gnulib's fchdir() replacement is used. */ +/* #undef REPLACE_FCHDIR */ + +/* Define to 1 if stat needs help when passed a directory name with a trailing + slash */ +/* #undef REPLACE_FUNC_STAT_DIR */ + +/* Define to 1 if stat needs help when passed a file name with a trailing + slash */ +#define REPLACE_FUNC_STAT_FILE 1 + +/* Define if nl_langinfo exists but is overridden by gnulib. */ +/* #undef REPLACE_NL_LANGINFO */ + +/* Define to 1 if open() should work around the inability to open a directory. + */ +/* #undef REPLACE_OPEN_DIRECTORY */ /* Define this to 1 if strerror is broken. */ /* #undef REPLACE_STRERROR */ @@ -1971,14 +2144,11 @@ /* Define if vfprintf is overridden by a POSIX compliant gnulib implementation. */ -#define REPLACE_VFPRINTF_POSIX 1 +/* #undef REPLACE_VFPRINTF_POSIX */ /* Define if vprintf is overridden by a POSIX compliant gnulib implementation. */ -#define REPLACE_VPRINTF_POSIX 1 - -/* the value to which errno is set when rmdir fails on a nonempty directory */ -#define RMDIR_ERRNO_NOT_EMPTY -2147459066 +/* #undef REPLACE_VPRINTF_POSIX */ /* Define to l, ll, u, ul, ull, etc., as suitable for constants of type 'sig_atomic_t'. */ @@ -2054,6 +2224,9 @@ /* FIXME */ /* #undef TERMIOS_NEEDS_XOPEN_SOURCE */ +/* Define to 1 if all 'time_t' values fit in a 'long int'. */ +#define TIME_T_FITS_IN_LONG_INT 1 + /* Define to 1 if you can safely include both and . */ #define TIME_WITH_SYS_TIME 1 @@ -2080,16 +2253,43 @@ /* Define to nonzero if you want access control list support. */ #define USE_ACL 0 +/* Define if the POSIX multithreading library can be used. */ +#define USE_POSIX_THREADS 1 + +/* Define if references to the POSIX multithreading library should be made + weak. */ +/* #undef USE_POSIX_THREADS_WEAK */ + +/* Define if the GNU Pth multithreading library can be used. */ +/* #undef USE_PTH_THREADS */ + +/* Define if references to the GNU Pth multithreading library should be made + weak. */ +/* #undef USE_PTH_THREADS_WEAK */ + +/* Define if the old Solaris multithreading library can be used. */ +/* #undef USE_SOLARIS_THREADS */ + +/* Define if references to the old Solaris multithreading library should be + made weak. */ +/* #undef USE_SOLARIS_THREADS_WEAK */ + /* Define to 1 if you want getc etc. to use unlocked I/O if available. Unlocked I/O can improve performance in unithreaded apps, but it is not safe for multithreaded apps. */ #define USE_UNLOCKED_IO 1 +/* Define if the Win32 multithreading API can be used. */ +/* #undef USE_WIN32_THREADS */ + /* Define if you want extended attribute support. */ -#define USE_XATTR 0 +#define USE_XATTR no /* Version number of package */ -#define VERSION "7.5" +#define VERSION "8.4" + +/* Define to 1 if unsetenv returns void instead of int. */ +/* #undef VOID_UNSETENV */ /* Define to l, ll, u, ul, ull, etc., as suitable for constants of type 'wchar_t'. */ @@ -2171,9 +2371,6 @@ used. */ /* #undef __GETOPT_PREFIX */ -/* Define to rpl_ if the openat replacement function should be used. */ -#define __OPENAT_PREFIX rpl_ - /* Define like PROTOTYPES; this can be used by system headers. */ #define __PROTOTYPES 1 @@ -2187,14 +2384,14 @@ /* Define to rpl_calloc if the replacement function should be used. */ #define calloc rpl_calloc -/* Define to rpl_fchownat if the replacement function should be used. */ -#define fchownat rpl_fchownat +/* Always use our fgetfilecon wrapper. */ +/* #undef fgetfilecon */ /* Define to a replacement function name for fnmatch(). */ #define fnmatch gnu_fnmatch -/* Define as rpl_getgroups if getgroups doesn't work right. */ -/* #undef getgroups */ +/* Always use our getfilecon wrapper. */ +/* #undef getfilecon */ /* Define to a replacement function name for getpass(). */ #define getpass gnu_getpass @@ -2230,6 +2427,9 @@ # define __GNUC_STDC_INLINE__ 1 #endif +/* Always use our lgetfilecon wrapper. */ +/* #undef lgetfilecon */ + /* Define to 1 if the compiler is checking for lint. */ /* #undef lint */ @@ -2318,10 +2518,6 @@ /* Define to rpl_regfree if the replacement should be used. */ /* #undef regfree rpl_regfree */ -/* Define to rpl_rename_dest_slash if the replacement function should be used. - */ -/* #undef rename */ - /* Define to the equivalent of the C99 'restrict' keyword, or to nothing if this is not supported. Do not define if restrict is supported directly. */ @@ -2353,16 +2549,22 @@ /* Define to `int' if doesn't define. */ /* #undef uid_t */ -/* Define as a marker that can be attached to function parameter declarations - for parameters that are not used. This helps to reduce warnings, such as - from GCC -Wunused-parameter. */ +/* Define as a marker that can be attached to declarations that might not + be used. This helps to reduce warnings, such as from + GCC -Wunused-parameter. */ #if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) -# define _UNUSED_PARAMETER_ __attribute__ ((__unused__)) +# define _GL_UNUSED __attribute__ ((__unused__)) #else -# define _UNUSED_PARAMETER_ +# define _GL_UNUSED #endif +/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name + is a misnomer outside of parameter lists. */ +#define _UNUSED_PARAMETER_ _GL_UNUSED +/* Define to an unsigned 32-bit type if lacks this type. */ +/* #undef useconds_t */ + /* Define as a macro for copying va_list variables. */ #if __GNUC__ < 3 #define va_copy __va_copy diff --git a/src/bin/coreutils/lib/config.hin b/src/bin/coreutils/lib/config.hin index 20f5195bf1..b87050d9cf 100644 --- a/src/bin/coreutils/lib/config.hin +++ b/src/bin/coreutils/lib/config.hin @@ -32,12 +32,19 @@ non-IEEE-754 'long double' values. */ #undef CHECK_PRINTF_SAFE +/* Define to 1 if chown fails to change ctime when at least one argument was + not -1. */ +#undef CHOWN_CHANGE_TIME_BUG + /* Define if chown is not POSIX compliant regarding IDs of -1. */ #undef CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE /* Define if chown modifies symlinks. */ #undef CHOWN_MODIFIES_SYMLINK +/* Define to 1 if chown mishandles trailing slash. */ +#undef CHOWN_TRAILING_SLASH_BUG + /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP systems. This function is required for `alloca.c' support on those systems. */ @@ -97,6 +104,13 @@ language is requested. */ #undef ENABLE_NLS +/* Define to 1 if your platform has fchownat, but it cannot perform lchown + tasks. */ +#undef FCHOWNAT_NOFOLLOW_BUG + +/* Define this to 1 if F_DUPFD behavior does not match POSIX */ +#undef FCNTL_DUPFD_BUGGY + /* Define on systems for which file names may have a so-called `drive letter' prefix, define this to compute the length of that prefix, including the colon. */ @@ -135,13 +149,28 @@ /* Define to 1 if fopen() fails to recognize a trailing slash. */ #undef FOPEN_TRAILING_SLASH_BUG +/* Define to 1 if mkdir mistakenly creates a directory given with a trailing + dot component. */ +#undef FUNC_MKDIR_DOT_BUG + +/* Define to 1 if realpath() can malloc memory, always gives an absolute path, + and handles trailing slash correctly. */ +#undef FUNC_REALPATH_WORKS + /* Define to 1 if ungetc is broken when used on arbitrary bytes. */ #undef FUNC_UNGETC_BROKEN +/* Define to 1 if futimesat mishandles a NULL file name. */ +#undef FUTIMESAT_NULL_BUG + /* Define to the type of elements in the array set by `getgroups'. Usually this is either `int' or `gid_t'. */ #undef GETGROUPS_T +/* Define this to 1 if getgroups(0,NULL) does not return the number of groups. + */ +#undef GETGROUPS_ZERO_BUG + /* Define to 1 if the `getloadavg' function needs to be run setuid or setgid. */ #undef GETLOADAVG_PRIVILEGED @@ -152,21 +181,42 @@ /* Define to make the limit macros in visible. */ #undef GL_TRIGGER_STDC_LIMIT_MACROS +/* Define to 1 when using the gnulib module areadlinkat. */ +#undef GNULIB_AREADLINKAT + /* Define to 1 when using the gnulib module canonicalize. */ #undef GNULIB_CANONICALIZE +/* Define to 1 when using the gnulib module cloexec. */ +#undef GNULIB_CLOEXEC + /* Define to 1 when using the gnulib module close-stream. */ #undef GNULIB_CLOSE_STREAM /* Define to 1 when using the gnulib module dirent-safer. */ #undef GNULIB_DIRENT_SAFER +/* Define to 1 when using the gnulib module dirname. */ +#undef GNULIB_DIRNAME + +/* Define to 1 when using the gnulib module faccessat. */ +#undef GNULIB_FACCESSAT + /* Define to 1 when using the gnulib module fcntl-safer. */ #undef GNULIB_FCNTL_SAFER +/* Define to 1 when using the gnulib module fd-safer-flag. */ +#undef GNULIB_FD_SAFER_FLAG + +/* Define to 1 when using the gnulib module filenamecat. */ +#undef GNULIB_FILENAMECAT + /* Define to 1 when using the gnulib module fopen-safer. */ #undef GNULIB_FOPEN_SAFER +/* Define to 1 when using the gnulib module freopen-safer. */ +#undef GNULIB_FREOPEN_SAFER + /* Define to 1 when using the gnulib module fts. */ #undef GNULIB_FTS @@ -194,9 +244,6 @@ /* Define to 1 when using the gnulib module stdlib-safer. */ #undef GNULIB_STDLIB_SAFER -/* Define to 1 when using the gnulib module unistd-safer. */ -#undef GNULIB_UNISTD_SAFER - /* Define to 1 when using the gnulib module unistr/u8-uctomb. */ #undef GNULIB_UNISTR_U8_UCTOMB @@ -206,6 +253,9 @@ /* Define if your system defines TIOCGWINSZ in sys/pty.h. */ #undef GWINSZ_IN_SYS_PTY +/* Define to 1 if you have the `access' function. */ +#undef HAVE_ACCESS + /* Define to 1 if you have the `acl' function. */ #undef HAVE_ACL @@ -364,6 +414,9 @@ libc. */ #undef HAVE_COPYSIGN_IN_LIBC +/* Define to 1 if you have the header file. */ +#undef HAVE_CTYPE_H + /* FIXME */ #undef HAVE_C_LINE @@ -375,10 +428,6 @@ */ #undef HAVE_DECL_ALARM -/* Define to 1 if you have the declaration of `canonicalize_file_name', and to - 0 if you don't. */ -#undef HAVE_DECL_CANONICALIZE_FILE_NAME - /* Define to 1 if you have the declaration of `clearerr_unlocked', and to 0 if you don't. */ #undef HAVE_DECL_CLEARERR_UNLOCKED @@ -435,10 +484,6 @@ you don't. */ #undef HAVE_DECL_FREAD_UNLOCKED -/* Define to 1 if you have the declaration of `free', and to 0 if you don't. - */ -#undef HAVE_DECL_FREE - /* Define to 1 if you have the declaration of `freeaddrinfo', and to 0 if you don't. */ #undef HAVE_DECL_FREEADDRINFO @@ -539,30 +584,26 @@ don't. */ #undef HAVE_DECL_ISBLANK -/* Define to 1 if you have the declaration of `lseek', and to 0 if you don't. - */ -#undef HAVE_DECL_LSEEK - -/* Define to 1 if you have the declaration of `malloc', and to 0 if you don't. - */ -#undef HAVE_DECL_MALLOC - /* Define to 1 if you have a declaration of mbswidth() in , and to 0 otherwise. */ #undef HAVE_DECL_MBSWIDTH_IN_WCHAR_H -/* Define to 1 if you have the declaration of `memchr', and to 0 if you don't. - */ -#undef HAVE_DECL_MEMCHR - /* Define to 1 if you have the declaration of `memrchr', and to 0 if you don't. */ #undef HAVE_DECL_MEMRCHR +/* Define to 1 if you have the declaration of `optreset', and to 0 if you + don't. */ +#undef HAVE_DECL_OPTRESET + /* Define to 1 if you have the declaration of `program_invocation_name', and to 0 if you don't. */ #undef HAVE_DECL_PROGRAM_INVOCATION_NAME +/* Define to 1 if you have the declaration of `program_invocation_short_name', + and to 0 if you don't. */ +#undef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME + /* Define to 1 if you have the declaration of `putchar_unlocked', and to 0 if you don't. */ #undef HAVE_DECL_PUTCHAR_UNLOCKED @@ -571,10 +612,6 @@ don't. */ #undef HAVE_DECL_PUTC_UNLOCKED -/* Define to 1 if you have the declaration of `realloc', and to 0 if you - don't. */ -#undef HAVE_DECL_REALLOC - /* Define to 1 if you have the declaration of `setregid', and to 0 if you don't. */ #undef HAVE_DECL_SETREGID @@ -719,6 +756,9 @@ /* Define to 1 if you have the `fchown' function. */ #undef HAVE_FCHOWN +/* Define to 1 if you have the `fcntl' function. */ +#undef HAVE_FCNTL + /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H @@ -753,9 +793,15 @@ /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ #undef HAVE_FSEEKO +/* Define to 1 if you have the `fstatat' function. */ +#undef HAVE_FSTATAT + /* Define to 1 if you have the `fstatfs' function. */ #undef HAVE_FSTATFS +/* Define to 1 if you have the `fsync' function. */ +#undef HAVE_FSYNC + /* Define to 1 if you have the header file. */ #undef HAVE_FS_INFO_H @@ -783,6 +829,12 @@ /* Define to 1 if you have the `getdelim' function. */ #undef HAVE_GETDELIM +/* Define to 1 if you have the `getdtablesize' function. */ +#undef HAVE_GETDTABLESIZE + +/* Define to 1 if you have the `getegid' function. */ +#undef HAVE_GETEGID + /* Define to 1 if you have the `getgrouplist' function. */ #undef HAVE_GETGROUPLIST @@ -921,6 +973,9 @@ /* Define if you have and nl_langinfo(CODESET). */ #undef HAVE_LANGINFO_CODESET +/* Define to 1 if you have the header file. */ +#undef HAVE_LANGINFO_H + /* Define if you have and nl_langinfo(YESEXPR). */ #undef HAVE_LANGINFO_YESEXPR @@ -963,6 +1018,9 @@ /* Define to 1 if you have the `link' function. */ #undef HAVE_LINK +/* Define to 1 if you have the `linkat' function. */ +#undef HAVE_LINKAT + /* Define to 1 if you have the `listmntent' function. */ #undef HAVE_LISTMNTENT @@ -982,6 +1040,9 @@ zero-length file name argument. */ #undef HAVE_LSTAT_EMPTY_STRING_BUG +/* Define to 1 if you have the `lutimes' function. */ +#undef HAVE_LUTIMES + /* Define to 1 if you have the header file. */ #undef HAVE_MACHINE_HAL_SYSINFO_H @@ -1014,6 +1075,9 @@ /* Define to 1 if you have the `mbsinit' function. */ #undef HAVE_MBSINIT +/* Define to 1 if you have the `mbslen' function. */ +#undef HAVE_MBSLEN + /* Define to 1 if you have the `mbsrtowcs' function. */ #undef HAVE_MBSRTOWCS @@ -1068,6 +1132,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H +/* Define to 1 if you have the `newlocale' function. */ +#undef HAVE_NEWLOCALE + /* Define to 1 if you have the `next_dev' function. */ #undef HAVE_NEXT_DEV @@ -1122,6 +1189,15 @@ /* Define to 1 if you have the `pstat_getstatic' function. */ #undef HAVE_PSTAT_GETSTATIC +/* Define to 1 if you have the `pthread_atfork' function. */ +#undef HAVE_PTHREAD_ATFORK + +/* Define if the defines PTHREAD_MUTEX_RECURSIVE. */ +#undef HAVE_PTHREAD_MUTEX_RECURSIVE + +/* Define if the POSIX multithreading library has read/write locks. */ +#undef HAVE_PTHREAD_RWLOCK + /* Define to 1 if you have the header file. */ #undef HAVE_PWD_H @@ -1131,9 +1207,21 @@ /* Define to 1 if you have the header file. */ #undef HAVE_RANDOM_H +/* Define to 1 if environ is declared even after undefining macros. */ +#undef HAVE_RAW_DECL_ENVIRON + +/* Define to 1 if fseeko is declared even after undefining macros. */ +#undef HAVE_RAW_DECL_FSEEKO + +/* Define to 1 if ftello is declared even after undefining macros. */ +#undef HAVE_RAW_DECL_FTELLO + /* Define to 1 if you have the `readlink' function. */ #undef HAVE_READLINK +/* Define to 1 if you have the `readlinkat' function. */ +#undef HAVE_READLINKAT + /* Define to 1 if your system has a GNU libc compatible `realloc' function, and to 0 otherwise. */ #undef HAVE_REALLOC @@ -1141,8 +1229,8 @@ /* Define if the 'realloc' function is POSIX compliant. */ #undef HAVE_REALLOC_POSIX -/* Define to 1 if you have the `resolvepath' function. */ -#undef HAVE_RESOLVEPATH +/* Define to 1 if you have the `realpath' function. */ +#undef HAVE_REALPATH /* Define to 1 if you have the `rmdir' function. */ #undef HAVE_RMDIR @@ -1156,6 +1244,15 @@ /* Define to 1 if the system has the type `sa_family_t'. */ #undef HAVE_SA_FAMILY_T +/* Define to 1 if you have the `sched_getaffinity' function. */ +#undef HAVE_SCHED_GETAFFINITY + +/* Define to 1 if sched_getaffinity has a glibc compatible declaration. */ +#undef HAVE_SCHED_GETAFFINITY_LIKE_GLIBC + +/* Define to 1 if you have the `sched_getaffinity_np' function. */ +#undef HAVE_SCHED_GETAFFINITY_NP + /* Define to 1 if you have the header file. */ #undef HAVE_SEARCH_H @@ -1216,6 +1313,9 @@ /* Define to 1 if the system has the type `sigset_t'. */ #undef HAVE_SIGSET_T +/* Define to 1 if you have the `sleep' function. */ +#undef HAVE_SLEEP + /* Define to 1 if you have the `snprintf' function. */ #undef HAVE_SNPRINTF @@ -1287,6 +1387,9 @@ /* Define to 1 if you have the `strpbrk' function. */ #undef HAVE_STRPBRK +/* Define to 1 if you have the `strsignal' function. */ +#undef HAVE_STRSIGNAL + /* Define to 1 if you have the `strtoimax' function. */ #undef HAVE_STRTOIMAX @@ -1448,8 +1551,8 @@ /* Define to 1 if `ut_user' is a member of `struct utmp'. */ #undef HAVE_STRUCT_UTMP_UT_USER -/* Define to 1 if you have the `strverscmp' function. */ -#undef HAVE_STRVERSCMP +/* Define to 1 if the system has the type `struct utsname'. */ +#undef HAVE_STRUCT_UTSNAME /* Define to 1 if you have the `strxfrm' function. */ #undef HAVE_STRXFRM @@ -1464,6 +1567,9 @@ /* Define to 1 if you have the `symlink' function. */ #undef HAVE_SYMLINK +/* Define to 1 if you have the `symlinkat' function. */ +#undef HAVE_SYMLINKAT + /* Define to 1 if you have the `sync' function. */ #undef HAVE_SYNC @@ -1569,6 +1675,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_UCRED_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_UTSNAME_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_VFS_H @@ -1616,12 +1725,18 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H +/* Define to 1 if you have the `unlinkat' function. */ +#undef HAVE_UNLINKAT + /* Define to 1 if you have the `unsetenv' function. */ #undef HAVE_UNSETENV /* Define to 1 if the system has the type `unsigned long long int'. */ #undef HAVE_UNSIGNED_LONG_LONG_INT +/* Define to 1 if you have the `usleep' function. */ +#undef HAVE_USLEEP + /* Define to 1 if you have the `utimensat' function. */ #undef HAVE_UTIMENSAT @@ -1715,6 +1830,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_WS2TCPIP_H +/* Define to 1 if you have the header file. */ +#undef HAVE_XLOCALE_H + /* Define to 1 if the system has the type `_Bool'. */ #undef HAVE__BOOL @@ -1973,24 +2091,46 @@ /* Define to 1 if the C compiler supports function prototypes. */ #undef PROTOTYPES +/* Define if the pthread_in_use() detection is hard. */ +#undef PTHREAD_IN_USE_DETECTION_HARD + /* Define to l, ll, u, ul, ull, etc., as suitable for constants of type 'ptrdiff_t'. */ #undef PTRDIFF_T_SUFFIX +/* Define to 1 if readlink fails to recognize a trailing slash. */ +#undef READLINK_TRAILING_SLASH_BUG + /* Define if rename does not work when the destination file exists, as on - Windows. */ + Cygwin 1.5 or Windows. */ #undef RENAME_DEST_EXISTS_BUG -/* Define if rename does not work for source file names with a trailing slash, - like the one from SunOS 4.1.1_U1. */ -#undef RENAME_TRAILING_SLASH_BUG +/* Define if rename fails to leave hard links alone, as on NetBSD 1.6 or + Cygwin 1.5. */ +#undef RENAME_HARD_LINK_BUG -/* Define to 1 if dup2 returns 0 instead of the target fd. */ -#undef REPLACE_DUP2 +/* Define if rename does not correctly handle slashes on the destination + argument, such as on Solaris 10 or NetBSD 1.6. */ +#undef RENAME_TRAILING_SLASH_DEST_BUG + +/* Define if rename does not correctly handle slashes on the source argument, + such as on Solaris 9 or cygwin 1.5. */ +#undef RENAME_TRAILING_SLASH_SOURCE_BUG /* Define to 1 if gnulib's fchdir() replacement is used. */ #undef REPLACE_FCHDIR +/* Define to 1 if stat needs help when passed a directory name with a trailing + slash */ +#undef REPLACE_FUNC_STAT_DIR + +/* Define to 1 if stat needs help when passed a file name with a trailing + slash */ +#undef REPLACE_FUNC_STAT_FILE + +/* Define if nl_langinfo exists but is overridden by gnulib. */ +#undef REPLACE_NL_LANGINFO + /* Define to 1 if open() should work around the inability to open a directory. */ #undef REPLACE_OPEN_DIRECTORY @@ -2009,9 +2149,6 @@ */ #undef REPLACE_VPRINTF_POSIX -/* the value to which errno is set when rmdir fails on a nonempty directory */ -#undef RMDIR_ERRNO_NOT_EMPTY - /* Define to l, ll, u, ul, ull, etc., as suitable for constants of type 'sig_atomic_t'. */ #undef SIG_ATOMIC_T_SUFFIX @@ -2086,6 +2223,9 @@ /* FIXME */ #undef TERMIOS_NEEDS_XOPEN_SOURCE +/* Define to 1 if all 'time_t' values fit in a 'long int'. */ +#undef TIME_T_FITS_IN_LONG_INT + /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME @@ -2112,17 +2252,44 @@ /* Define to nonzero if you want access control list support. */ #undef USE_ACL +/* Define if the POSIX multithreading library can be used. */ +#undef USE_POSIX_THREADS + +/* Define if references to the POSIX multithreading library should be made + weak. */ +#undef USE_POSIX_THREADS_WEAK + +/* Define if the GNU Pth multithreading library can be used. */ +#undef USE_PTH_THREADS + +/* Define if references to the GNU Pth multithreading library should be made + weak. */ +#undef USE_PTH_THREADS_WEAK + +/* Define if the old Solaris multithreading library can be used. */ +#undef USE_SOLARIS_THREADS + +/* Define if references to the old Solaris multithreading library should be + made weak. */ +#undef USE_SOLARIS_THREADS_WEAK + /* Define to 1 if you want getc etc. to use unlocked I/O if available. Unlocked I/O can improve performance in unithreaded apps, but it is not safe for multithreaded apps. */ #undef USE_UNLOCKED_IO +/* Define if the Win32 multithreading API can be used. */ +#undef USE_WIN32_THREADS + /* Define if you want extended attribute support. */ #undef USE_XATTR /* Version number of package */ #undef VERSION +/* Define to 1 if unsetenv returns void instead of int. */ +#undef VOID_UNSETENV + /* Define to l, ll, u, ul, ull, etc., as suitable for constants of type 'wchar_t'. */ #undef WCHAR_T_SUFFIX @@ -2216,11 +2383,14 @@ /* Define to rpl_calloc if the replacement function should be used. */ #undef calloc +/* Always use our fgetfilecon wrapper. */ +#undef fgetfilecon + /* Define to a replacement function name for fnmatch(). */ #undef fnmatch -/* Define as rpl_getgroups if getgroups doesn't work right. */ -#undef getgroups +/* Always use our getfilecon wrapper. */ +#undef getfilecon /* Define to a replacement function name for getpass(). */ #undef getpass @@ -2256,6 +2426,9 @@ # define __GNUC_STDC_INLINE__ 1 #endif +/* Always use our lgetfilecon wrapper. */ +#undef lgetfilecon + /* Define to 1 if the compiler is checking for lint. */ #undef lint @@ -2344,10 +2517,6 @@ /* Define to rpl_regfree if the replacement should be used. */ #undef regfree -/* Define to rpl_rename_dest_slash if the replacement function should be used. - */ -#undef rename - /* Define to the equivalent of the C99 'restrict' keyword, or to nothing if this is not supported. Do not define if restrict is supported directly. */ @@ -2379,16 +2548,22 @@ /* Define to `int' if doesn't define. */ #undef uid_t -/* Define as a marker that can be attached to function parameter declarations - for parameters that are not used. This helps to reduce warnings, such as - from GCC -Wunused-parameter. */ +/* Define as a marker that can be attached to declarations that might not + be used. This helps to reduce warnings, such as from + GCC -Wunused-parameter. */ #if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) -# define _UNUSED_PARAMETER_ __attribute__ ((__unused__)) +# define _GL_UNUSED __attribute__ ((__unused__)) #else -# define _UNUSED_PARAMETER_ +# define _GL_UNUSED #endif +/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name + is a misnomer outside of parameter lists. */ +#define _UNUSED_PARAMETER_ _GL_UNUSED +/* Define to an unsigned 32-bit type if lacks this type. */ +#undef useconds_t + /* Define as a macro for copying va_list variables. */ #undef va_copy diff --git a/src/bin/coreutils/lib/configmake.h b/src/bin/coreutils/lib/configmake.h index 1e7d13cca5..6a032689ca 100644 --- a/src/bin/coreutils/lib/configmake.h +++ b/src/bin/coreutils/lib/configmake.h @@ -1,25 +1,26 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ -#define PREFIX "/usr/local" -#define EXEC_PREFIX "/usr/local" -#define BINDIR "/usr/local/bin" -#define SBINDIR "/usr/local/sbin" -#define LIBEXECDIR "/usr/local/libexec" -#define DATAROOTDIR "/usr/local/share" -#define DATADIR "/usr/local/share" -#define SYSCONFDIR "/usr/local/etc" -#define SHAREDSTATEDIR "/usr/local/com" -#define LOCALSTATEDIR "/usr/local/var" -#define INCLUDEDIR "/usr/local/include" +#define PREFIX "/boot/common" +#define EXEC_PREFIX "/boot/common" +#define BINDIR "/boot/common/bin" +#define SBINDIR "/boot/common/sbin" +#define LIBEXECDIR "/boot/common/libexec" +#define DATAROOTDIR "/boot/common/share" +#define DATADIR "/boot/common/share" +#define SYSCONFDIR "/boot/common/etc" +#define SHAREDSTATEDIR "/boot/common/com" +#define LOCALSTATEDIR "/boot/common/var" +#define INCLUDEDIR "/boot/common/include" #define OLDINCLUDEDIR "/usr/include" -#define DOCDIR "/usr/local/share/doc/coreutils" -#define INFODIR "/usr/local/share/info" -#define HTMLDIR "/usr/local/share/doc/coreutils" -#define DVIDIR "/usr/local/share/doc/coreutils" -#define PDFDIR "/usr/local/share/doc/coreutils" -#define PSDIR "/usr/local/share/doc/coreutils" -#define LIBDIR "/usr/local/lib" -#define LOCALEDIR "/usr/local/share/locale" -#define MANDIR "/usr/local/share/man" -#define PKGDATADIR "/usr/local/share/coreutils" -#define PKGINCLUDEDIR "/usr/local/include/coreutils" -#define PKGLIBDIR "/usr/local/lib/coreutils" +#define DOCDIR "/boot/common/share/doc/coreutils" +#define INFODIR "/boot/common/share/info" +#define HTMLDIR "/boot/common/share/doc/coreutils" +#define DVIDIR "/boot/common/share/doc/coreutils" +#define PDFDIR "/boot/common/share/doc/coreutils" +#define PSDIR "/boot/common/share/doc/coreutils" +#define LIBDIR "/boot/common/lib" +#define LOCALEDIR "/boot/common/share/locale" +#define MANDIR "/boot/common/share/man" +#define PKGDATADIR "/boot/common/share/coreutils" +#define PKGINCLUDEDIR "/boot/common/include/coreutils" +#define PKGLIBDIR "/boot/common/lib/coreutils" +#define PKGLIBEXECDIR "/boot/common/libexec/coreutils" diff --git a/src/bin/coreutils/lib/copy-acl.c b/src/bin/coreutils/lib/copy-acl.c index af85a08fb9..1e822408e2 100644 --- a/src/bin/coreutils/lib/copy-acl.c +++ b/src/bin/coreutils/lib/copy-acl.c @@ -1,6 +1,6 @@ /* copy-acl.c - copy access control list from one file to another file - Copyright (C) 2002-2003, 2005-2008 Free Software Foundation, Inc. + Copyright (C) 2002-2003, 2005-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -40,7 +40,7 @@ static int qcopy_acl (const char *src_name, int source_desc, const char *dst_name, - int dest_desc, mode_t mode) + int dest_desc, mode_t mode) { #if USE_ACL && HAVE_ACL_GET_FILE /* POSIX 1003.1e (draft 17 -- abandoned) specific version. */ @@ -58,9 +58,9 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, if (acl == NULL) { if (ACL_NOT_WELL_SUPPORTED (errno)) - return qset_acl (dst_name, dest_desc, mode); + return qset_acl (dst_name, dest_desc, mode); else - return -2; + return -2; } if (HAVE_ACL_SET_FD && dest_desc != -1) @@ -72,17 +72,17 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, int saved_errno = errno; if (ACL_NOT_WELL_SUPPORTED (errno) && !acl_access_nontrivial (acl)) - { - acl_free (acl); - return chmod_or_fchmod (dst_name, dest_desc, mode); - } + { + acl_free (acl); + return chmod_or_fchmod (dst_name, dest_desc, mode); + } else - { - acl_free (acl); - chmod_or_fchmod (dst_name, dest_desc, mode); - errno = saved_errno; - return -1; - } + { + acl_free (acl); + chmod_or_fchmod (dst_name, dest_desc, mode); + errno = saved_errno; + return -1; + } } else acl_free (acl); @@ -90,28 +90,28 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, if (mode & (S_ISUID | S_ISGID | S_ISVTX)) { /* We did not call chmod so far, and either the mode and the ACL are - separate or special bits are to be set which don't fit into ACLs. */ + separate or special bits are to be set which don't fit into ACLs. */ if (chmod_or_fchmod (dst_name, dest_desc, mode) != 0) - return -1; + return -1; } if (S_ISDIR (mode)) { acl = acl_get_file (src_name, ACL_TYPE_DEFAULT); if (acl == NULL) - return -2; + return -2; if (acl_set_file (dst_name, ACL_TYPE_DEFAULT, acl)) - { - int saved_errno = errno; + { + int saved_errno = errno; - acl_free (acl); - errno = saved_errno; - return -1; - } + acl_free (acl); + errno = saved_errno; + return -1; + } else - acl_free (acl); + acl_free (acl); } return 0; @@ -125,14 +125,14 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, /* On MacOS X, acl_get_file (name, ACL_TYPE_ACCESS) and acl_get_file (name, ACL_TYPE_DEFAULT) always return NULL / EINVAL. You have to use - acl_get_file (name, ACL_TYPE_EXTENDED) + acl_get_file (name, ACL_TYPE_EXTENDED) or acl_get_fd (open (name, ...)) to retrieve an ACL. On the other hand, - acl_set_file (name, ACL_TYPE_ACCESS, acl) + acl_set_file (name, ACL_TYPE_ACCESS, acl) and acl_set_file (name, ACL_TYPE_DEFAULT, acl) have the same effect as - acl_set_file (name, ACL_TYPE_EXTENDED, acl): + acl_set_file (name, ACL_TYPE_EXTENDED, acl): Each of these calls sets the file's ACL. */ acl_t acl; @@ -145,9 +145,9 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, if (acl == NULL) { if (ACL_NOT_WELL_SUPPORTED (errno)) - return qset_acl (dst_name, dest_desc, mode); + return qset_acl (dst_name, dest_desc, mode); else - return -2; + return -2; } if (HAVE_ACL_SET_FD && dest_desc != -1) @@ -159,17 +159,17 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, int saved_errno = errno; if (ACL_NOT_WELL_SUPPORTED (errno) && !acl_extended_nontrivial (acl)) - { - acl_free (acl); - return chmod_or_fchmod (dst_name, dest_desc, mode); - } + { + acl_free (acl); + return chmod_or_fchmod (dst_name, dest_desc, mode); + } else - { - acl_free (acl); - chmod_or_fchmod (dst_name, dest_desc, mode); - errno = saved_errno; - return -1; - } + { + acl_free (acl); + chmod_or_fchmod (dst_name, dest_desc, mode); + errno = saved_errno; + return -1; + } } else acl_free (acl); @@ -189,8 +189,8 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, int ret; acl_t *aclp = NULL; ret = (source_desc < 0 - ? acl_get (src_name, ACL_NO_TRIVIAL, &aclp) - : facl_get (source_desc, ACL_NO_TRIVIAL, &aclp)); + ? acl_get (src_name, ACL_NO_TRIVIAL, &aclp) + : facl_get (source_desc, ACL_NO_TRIVIAL, &aclp)); if (ret != 0 && errno != ENOSYS) return -2; @@ -201,16 +201,16 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, if (aclp) { ret = (dest_desc < 0 - ? acl_set (dst_name, aclp) - : facl_set (dest_desc, aclp)); + ? acl_set (dst_name, aclp) + : facl_set (dest_desc, aclp)); if (ret != 0) - { - int saved_errno = errno; + { + int saved_errno = errno; - acl_free (aclp); - errno = saved_errno; - return -1; - } + acl_free (aclp); + errno = saved_errno; + return -1; + } acl_free (aclp); } @@ -248,82 +248,82 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, for (;;) { ace_count = (source_desc != -1 - ? facl (source_desc, ACE_GETACLCNT, 0, NULL) - : acl (src_name, ACE_GETACLCNT, 0, NULL)); + ? facl (source_desc, ACE_GETACLCNT, 0, NULL) + : acl (src_name, ACE_GETACLCNT, 0, NULL)); if (ace_count < 0) - { - if (errno == ENOSYS || errno == EINVAL) - { - ace_count = 0; - ace_entries = NULL; - break; - } - else - return -2; - } + { + if (errno == ENOSYS || errno == EINVAL) + { + ace_count = 0; + ace_entries = NULL; + break; + } + else + return -2; + } if (ace_count == 0) - { - ace_entries = NULL; - break; - } + { + ace_entries = NULL; + break; + } ace_entries = (ace_t *) malloc (ace_count * sizeof (ace_t)); if (ace_entries == NULL) - { - errno = ENOMEM; - return -2; - } + { + errno = ENOMEM; + return -2; + } if ((source_desc != -1 - ? facl (source_desc, ACE_GETACL, ace_count, ace_entries) - : acl (src_name, ACE_GETACL, ace_count, ace_entries)) - == ace_count) - break; + ? facl (source_desc, ACE_GETACL, ace_count, ace_entries) + : acl (src_name, ACE_GETACL, ace_count, ace_entries)) + == ace_count) + break; /* Huh? The number of ACL entries changed since the last call. - Repeat. */ + Repeat. */ } # endif for (;;) { count = (source_desc != -1 - ? facl (source_desc, GETACLCNT, 0, NULL) - : acl (src_name, GETACLCNT, 0, NULL)); + ? facl (source_desc, GETACLCNT, 0, NULL) + : acl (src_name, GETACLCNT, 0, NULL)); if (count < 0) - { - if (errno == ENOSYS || errno == ENOTSUP) - { - count = 0; - entries = NULL; - break; - } - else - return -2; - } + { + if (errno == ENOSYS || errno == ENOTSUP) + { + count = 0; + entries = NULL; + break; + } + else + return -2; + } if (count == 0) - { - entries = NULL; - break; - } + { + entries = NULL; + break; + } entries = (aclent_t *) malloc (count * sizeof (aclent_t)); if (entries == NULL) - { - errno = ENOMEM; - return -2; - } + { + errno = ENOMEM; + return -2; + } if ((source_desc != -1 - ? facl (source_desc, GETACL, count, entries) - : acl (src_name, GETACL, count, entries)) - == count) - break; + ? facl (source_desc, GETACL, count, entries) + : acl (src_name, GETACL, count, entries)) + == count) + break; /* Huh? The number of ACL entries changed since the last call. - Repeat. */ + Repeat. */ } /* Is there an ACL of either kind? */ @@ -339,10 +339,10 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, if (!MODE_INSIDE_ACL) { /* On Cygwin, it is necessary to call chmod before acl, because - chmod can change the contents of the ACL (in ways that don't - change the allowed accesses, but still visible). */ + chmod can change the contents of the ACL (in ways that don't + change the allowed accesses, but still visible). */ if (chmod_or_fchmod (dst_name, dest_desc, mode) != 0) - saved_errno = errno; + saved_errno = errno; did_chmod = 1; } @@ -353,16 +353,16 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, if (count > 0) { ret = (dest_desc != -1 - ? facl (dest_desc, SETACL, count, entries) - : acl (dst_name, SETACL, count, entries)); + ? facl (dest_desc, SETACL, count, entries) + : acl (dst_name, SETACL, count, entries)); if (ret < 0 && saved_errno == 0) - { - saved_errno = errno; - if (errno == ENOSYS && !acl_nontrivial (count, entries)) - saved_errno = 0; - } + { + saved_errno = errno; + if (errno == ENOSYS && !acl_nontrivial (count, entries)) + saved_errno = 0; + } else - did_chmod = 1; + did_chmod = 1; } free (entries); @@ -370,15 +370,15 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, if (ace_count > 0) { ret = (dest_desc != -1 - ? facl (dest_desc, ACE_SETACL, ace_count, ace_entries) - : acl (dst_name, ACE_SETACL, ace_count, ace_entries)); + ? facl (dest_desc, ACE_SETACL, ace_count, ace_entries) + : acl (dst_name, ACE_SETACL, ace_count, ace_entries)); if (ret < 0 && saved_errno == 0) - { - saved_errno = errno; - if ((errno == ENOSYS || errno == EINVAL || errno == ENOTSUP) - && !acl_ace_nontrivial (ace_count, ace_entries)) - saved_errno = 0; - } + { + saved_errno = errno; + if ((errno == ENOSYS || errno == EINVAL || errno == ENOTSUP) + && !acl_ace_nontrivial (ace_count, ace_entries)) + saved_errno = 0; + } } free (ace_entries); # endif @@ -387,13 +387,13 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, && did_chmod <= ((mode & (S_ISUID | S_ISGID | S_ISVTX)) ? 1 : 0)) { /* We did not call chmod so far, and either the mode and the ACL are - separate or special bits are to be set which don't fit into ACLs. */ + separate or special bits are to be set which don't fit into ACLs. */ if (chmod_or_fchmod (dst_name, dest_desc, mode) != 0) - { - if (saved_errno == 0) - saved_errno = errno; - } + { + if (saved_errno == 0) + saved_errno = errno; + } } if (saved_errno) @@ -414,60 +414,60 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, for (;;) { count = (source_desc != -1 - ? fgetacl (source_desc, 0, NULL) - : getacl (src_name, 0, NULL)); + ? fgetacl (source_desc, 0, NULL) + : getacl (src_name, 0, NULL)); if (count < 0) - { - if (errno == ENOSYS || errno == EOPNOTSUPP) - { - count = 0; - break; - } - else - return -2; - } + { + if (errno == ENOSYS || errno == EOPNOTSUPP) + { + count = 0; + break; + } + else + return -2; + } if (count == 0) - break; + break; if (count > NACLENTRIES) - /* If NACLENTRIES cannot be trusted, use dynamic memory allocation. */ - abort (); + /* If NACLENTRIES cannot be trusted, use dynamic memory allocation. */ + abort (); if ((source_desc != -1 - ? fgetacl (source_desc, count, entries) - : getacl (src_name, count, entries)) - == count) - break; + ? fgetacl (source_desc, count, entries) + : getacl (src_name, count, entries)) + == count) + break; /* Huh? The number of ACL entries changed since the last call. - Repeat. */ + Repeat. */ } if (count == 0) return qset_acl (dst_name, dest_desc, mode); ret = (dest_desc != -1 - ? fsetacl (dest_desc, count, entries) - : setacl (dst_name, count, entries)); + ? fsetacl (dest_desc, count, entries) + : setacl (dst_name, count, entries)); if (ret < 0) { int saved_errno = errno; if (errno == ENOSYS || errno == EOPNOTSUPP) - { - struct stat source_statbuf; + { + struct stat source_statbuf; - if ((source_desc != -1 - ? fstat (source_desc, &source_statbuf) - : stat (src_name, &source_statbuf)) == 0) - { - if (!acl_nontrivial (count, entries, &source_statbuf)) - return chmod_or_fchmod (dst_name, dest_desc, mode); - } - else - saved_errno = errno; - } + if ((source_desc != -1 + ? fstat (source_desc, &source_statbuf) + : stat (src_name, &source_statbuf)) == 0) + { + if (!acl_nontrivial (count, entries, &source_statbuf)) + return chmod_or_fchmod (dst_name, dest_desc, mode); + } + else + saved_errno = errno; + } chmod_or_fchmod (dst_name, dest_desc, mode); errno = saved_errno; @@ -477,7 +477,7 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, if (mode & (S_ISUID | S_ISGID | S_ISVTX)) { /* We did not call chmod so far, and either the mode and the ACL are - separate or special bits are to be set which don't fit into ACLs. */ + separate or special bits are to be set which don't fit into ACLs. */ return chmod_or_fchmod (dst_name, dest_desc, mode); } @@ -499,8 +499,8 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, return -2; ret = (dest_desc != -1 - ? fchacl (dest_desc, &u.a, u.a.acl_len) - : chacl (dst_name, &u.a, u.a.acl_len)); + ? fchacl (dest_desc, &u.a, u.a.acl_len) + : chacl (dst_name, &u.a, u.a.acl_len)); if (ret < 0) { int saved_errno = errno; @@ -534,7 +534,7 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name, int copy_acl (const char *src_name, int source_desc, const char *dst_name, - int dest_desc, mode_t mode) + int dest_desc, mode_t mode) { int ret = qcopy_acl (src_name, source_desc, dst_name, dest_desc, mode); switch (ret) diff --git a/src/bin/coreutils/lib/creat-safer.c b/src/bin/coreutils/lib/creat-safer.c index fc314ba432..da0418dfb9 100644 --- a/src/bin/coreutils/lib/creat-safer.c +++ b/src/bin/coreutils/lib/creat-safer.c @@ -1,6 +1,6 @@ /* Invoke creat, but avoid some glitches. - Copyright (C) 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/ctype.h b/src/bin/coreutils/lib/ctype.h new file mode 100644 index 0000000000..a321cfc957 --- /dev/null +++ b/src/bin/coreutils/lib/ctype.h @@ -0,0 +1,87 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +#line 1 +/* A substitute for ISO C99 , for platforms on which it is incomplete. + + Copyright (C) 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Bruno Haible. */ + +/* + * ISO C 99 for platforms on which it is incomplete. + * + */ + +#ifndef _GL_CTYPE_H + +#if __GNUC__ >= 3 +#pragma GCC system_header +#endif + +/* Include the original . */ +/* The include_next requires a split double-inclusion guard. */ +#include_next + +#ifndef _GL_CTYPE_H +#define _GL_CTYPE_H + +/* The definition of GL_LINK_WARNING is copied here. */ +/* GL_LINK_WARNING("literal string") arranges to emit the literal string as + a linker warning on most glibc systems. + We use a linker warning rather than a preprocessor warning, because + #warning cannot be used inside macros. */ +#ifndef GL_LINK_WARNING + /* This works on platforms with GNU ld and ELF object format. + Testing __GLIBC__ is sufficient for asserting that GNU ld is in use. + Testing __ELF__ guarantees the ELF object format. + Testing __GNUC__ is necessary for the compound expression syntax. */ +# if defined __GLIBC__ && defined __ELF__ && defined __GNUC__ +# define GL_LINK_WARNING(message) \ + GL_LINK_WARNING1 (__FILE__, __LINE__, message) +# define GL_LINK_WARNING1(file, line, message) \ + GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */ +# define GL_LINK_WARNING2(file, line, message) \ + GL_LINK_WARNING3 (file ":" #line ": warning: " message) +# define GL_LINK_WARNING3(message) \ + ({ static const char warning[sizeof (message)] \ + __attribute__ ((__unused__, \ + __section__ (".gnu.warning"), \ + __aligned__ (1))) \ + = message "\n"; \ + (void)0; \ + }) +# else +# define GL_LINK_WARNING(message) ((void) 0) +# endif +#endif + +/* Return non-zero if c is a blank, i.e. a space or tab character. */ +#if 1 +# if !1 +extern int isblank (int c); +# endif +#elif defined GNULIB_POSIXCHECK +# undef isblank +# define isblank(c) \ + (GL_LINK_WARNING ("isblank is unportable - " \ + "use gnulib module isblank for portability"), \ + isblank (c)) +#endif + +#endif /* _GL_CTYPE_H */ +#endif /* _GL_CTYPE_H */ diff --git a/src/bin/coreutils/lib/ctype.in.h b/src/bin/coreutils/lib/ctype.in.h new file mode 100644 index 0000000000..63762928fc --- /dev/null +++ b/src/bin/coreutils/lib/ctype.in.h @@ -0,0 +1,58 @@ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +#line 1 +/* A substitute for ISO C99 , for platforms on which it is incomplete. + + Copyright (C) 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Bruno Haible. */ + +/* + * ISO C 99 for platforms on which it is incomplete. + * + */ + +#ifndef _GL_CTYPE_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif + +/* Include the original . */ +/* The include_next requires a split double-inclusion guard. */ +#@INCLUDE_NEXT@ @NEXT_CTYPE_H@ + +#ifndef _GL_CTYPE_H +#define _GL_CTYPE_H + +/* The definition of GL_LINK_WARNING is copied here. */ + +/* Return non-zero if c is a blank, i.e. a space or tab character. */ +#if @GNULIB_ISBLANK@ +# if !@HAVE_ISBLANK@ +extern int isblank (int c); +# endif +#elif defined GNULIB_POSIXCHECK +# undef isblank +# define isblank(c) \ + (GL_LINK_WARNING ("isblank is unportable - " \ + "use gnulib module isblank for portability"), \ + isblank (c)) +#endif + +#endif /* _GL_CTYPE_H */ +#endif /* _GL_CTYPE_H */ diff --git a/src/bin/coreutils/lib/cycle-check.c b/src/bin/coreutils/lib/cycle-check.c index e120460e61..2f31cb9f01 100644 --- a/src/bin/coreutils/lib/cycle-check.c +++ b/src/bin/coreutils/lib/cycle-check.c @@ -1,6 +1,6 @@ /* help detect directory cycles efficiently - Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2003-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -70,12 +70,12 @@ cycle_check (struct cycle_check_state *state, struct stat const *sb) if (is_zero_or_power_of_two (++(state->chdir_counter))) { /* On all architectures that we know about, if the counter - overflows then there is a directory cycle here somewhere, - even if we haven't detected it yet. Typically this happens - only after the counter is incremented 2**64 times, so it's a - fairly theoretical point. */ + overflows then there is a directory cycle here somewhere, + even if we haven't detected it yet. Typically this happens + only after the counter is incremented 2**64 times, so it's a + fairly theoretical point. */ if (state->chdir_counter == 0) - return true; + return true; state->dev_ino.st_dev = sb->st_dev; state->dev_ino.st_ino = sb->st_ino; diff --git a/src/bin/coreutils/lib/cycle-check.h b/src/bin/coreutils/lib/cycle-check.h index ee3bf214ba..546f56b8da 100644 --- a/src/bin/coreutils/lib/cycle-check.h +++ b/src/bin/coreutils/lib/cycle-check.h @@ -1,6 +1,6 @@ /* help detect directory cycles efficiently - Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2003-2004, 2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -35,18 +35,18 @@ struct cycle_check_state void cycle_check_init (struct cycle_check_state *state); bool cycle_check (struct cycle_check_state *state, struct stat const *sb); -# define CYCLE_CHECK_REFLECT_CHDIR_UP(State, SB_dir, SB_subdir) \ - do \ - { \ +# define CYCLE_CHECK_REFLECT_CHDIR_UP(State, SB_dir, SB_subdir) \ + do \ + { \ /* You must call cycle_check at least once before using this macro. */ \ - if ((State)->chdir_counter == 0) \ - abort (); \ - if (SAME_INODE ((State)->dev_ino, SB_subdir)) \ - { \ - (State)->dev_ino.st_dev = (SB_dir).st_dev; \ - (State)->dev_ino.st_ino = (SB_dir).st_ino; \ - } \ - } \ + if ((State)->chdir_counter == 0) \ + abort (); \ + if (SAME_INODE ((State)->dev_ino, SB_subdir)) \ + { \ + (State)->dev_ino.st_dev = (SB_dir).st_dev; \ + (State)->dev_ino.st_ino = (SB_dir).st_ino; \ + } \ + } \ while (0) #endif diff --git a/src/bin/coreutils/lib/diacrit.c b/src/bin/coreutils/lib/diacrit.c index 7fe3a81f82..9a6b613451 100644 --- a/src/bin/coreutils/lib/diacrit.c +++ b/src/bin/coreutils/lib/diacrit.c @@ -1,7 +1,7 @@ /* Diacritics processing for a few character codes. - Copyright (C) 1990, 1991, 1992, 1993, 2000, 2006 Free Software - Foundation, Inc. + Copyright (C) 1990-1993, 2000, 2006, 2009-2010 Free Software Foundation, + Inc. François Pinard , 1988. @@ -29,7 +29,7 @@ /*--------------------------------------------------------------------. | For each alphabetic character, returns what it would be without its | -| possible diacritic symbol. | +| possible diacritic symbol. | `--------------------------------------------------------------------*/ const char diacrit_base[256] = @@ -95,9 +95,9 @@ const char diacrit_base[256] = /*------------------------------------------------------------------------. | For each alphabetic character, returns a code of what its diacritic is, | | according to the following codes: 1 (eE) over aA for latin diphtongs; 2 | -| (') acute accent; 3 (`) grave accent; 4 (^) circumflex accent; 5 (") | +| (') acute accent; 3 (`) grave accent; 4 (^) circumflex accent; 5 (") | | umlaut or diaraesis; 6 (~) tilda; 7 (,) cedilla; 8 (o) covering degree | -| symbol; 9 (|) slashed character. | +| symbol; 9 (|) slashed character. | `------------------------------------------------------------------------*/ const char diacrit_diac[256] = diff --git a/src/bin/coreutils/lib/diacrit.h b/src/bin/coreutils/lib/diacrit.h index 36b514d7a6..9237f51894 100644 --- a/src/bin/coreutils/lib/diacrit.h +++ b/src/bin/coreutils/lib/diacrit.h @@ -1,5 +1,5 @@ /* Diacritics processing for a few character codes. - Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc. + Copyright (C) 1990-1993, 2009-2010 Free Software Foundation, Inc. François Pinard , 1988. All this file is a temporary hack, waiting for locales in GNU. diff --git a/src/bin/coreutils/lib/dirchownmod.c b/src/bin/coreutils/lib/dirchownmod.c index 3b21a758a5..a07c5f0c9b 100644 --- a/src/bin/coreutils/lib/dirchownmod.c +++ b/src/bin/coreutils/lib/dirchownmod.c @@ -1,6 +1,6 @@ /* Change the ownership and mode bits of a directory. - Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 2006-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -59,8 +59,8 @@ int dirchownmod (int fd, char const *dir, mode_t mkdir_mode, - uid_t owner, gid_t group, - mode_t mode, mode_t mode_bits) + uid_t owner, gid_t group, + mode_t mode, mode_t mode_bits) { struct stat st; int result = (fd < 0 ? stat (dir, &st) : fstat (fd, &st)); @@ -70,71 +70,71 @@ dirchownmod (int fd, char const *dir, mode_t mkdir_mode, mode_t dir_mode = st.st_mode; /* Check whether DIR is a directory. If FD is nonnegative, this - check avoids changing the ownership and mode bits of the - wrong file in many cases. This doesn't fix all the race - conditions, but it is better than nothing. */ + check avoids changing the ownership and mode bits of the + wrong file in many cases. This doesn't fix all the race + conditions, but it is better than nothing. */ if (! S_ISDIR (dir_mode)) - { - errno = ENOTDIR; - result = -1; - } + { + errno = ENOTDIR; + result = -1; + } else - { - /* If at least one of the S_IXUGO bits are set, chown might - clear the S_ISUID and S_SGID bits. Keep track of any - file mode bits whose values are indeterminate due to this - issue. */ - mode_t indeterminate = 0; + { + /* If at least one of the S_IXUGO bits are set, chown might + clear the S_ISUID and S_SGID bits. Keep track of any + file mode bits whose values are indeterminate due to this + issue. */ + mode_t indeterminate = 0; - /* On some systems, chown clears S_ISUID and S_ISGID, so do - chown before chmod. On older System V hosts, ordinary - users can give their files away via chown; don't worry - about that here, since users shouldn't do that. */ + /* On some systems, chown clears S_ISUID and S_ISGID, so do + chown before chmod. On older System V hosts, ordinary + users can give their files away via chown; don't worry + about that here, since users shouldn't do that. */ - if ((owner != (uid_t) -1 && owner != st.st_uid) - || (group != (gid_t) -1 && group != st.st_gid)) - { - result = (0 <= fd - ? fchown (fd, owner, group) - : mkdir_mode != (mode_t) -1 - ? lchown (dir, owner, group) - : chown (dir, owner, group)); + if ((owner != (uid_t) -1 && owner != st.st_uid) + || (group != (gid_t) -1 && group != st.st_gid)) + { + result = (0 <= fd + ? fchown (fd, owner, group) + : mkdir_mode != (mode_t) -1 + ? lchown (dir, owner, group) + : chown (dir, owner, group)); - /* Either the user cares about an indeterminate bit and - it'll be set properly by chmod below, or the user - doesn't care and it's OK to use the bit's pre-chown - value. So there's no need to re-stat DIR here. */ + /* Either the user cares about an indeterminate bit and + it'll be set properly by chmod below, or the user + doesn't care and it's OK to use the bit's pre-chown + value. So there's no need to re-stat DIR here. */ - if (result == 0 && (dir_mode & S_IXUGO)) - indeterminate = dir_mode & (S_ISUID | S_ISGID); - } + if (result == 0 && (dir_mode & S_IXUGO)) + indeterminate = dir_mode & (S_ISUID | S_ISGID); + } - /* If the file mode bits might not be right, use chmod to - change them. Don't change bits the user doesn't care - about. */ - if (result == 0 && (((dir_mode ^ mode) | indeterminate) & mode_bits)) - { - mode_t chmod_mode = - mode | (dir_mode & CHMOD_MODE_BITS & ~mode_bits); - result = (HAVE_FCHMOD && 0 <= fd - ? fchmod (fd, chmod_mode) - : mkdir_mode != (mode_t) -1 - ? lchmod (dir, chmod_mode) - : chmod (dir, chmod_mode)); - } - } + /* If the file mode bits might not be right, use chmod to + change them. Don't change bits the user doesn't care + about. */ + if (result == 0 && (((dir_mode ^ mode) | indeterminate) & mode_bits)) + { + mode_t chmod_mode = + mode | (dir_mode & CHMOD_MODE_BITS & ~mode_bits); + result = (HAVE_FCHMOD && 0 <= fd + ? fchmod (fd, chmod_mode) + : mkdir_mode != (mode_t) -1 + ? lchmod (dir, chmod_mode) + : chmod (dir, chmod_mode)); + } + } } if (0 <= fd) { if (result == 0) - result = close (fd); + result = close (fd); else - { - int e = errno; - close (fd); - errno = e; - } + { + int e = errno; + close (fd); + errno = e; + } } return result; diff --git a/src/bin/coreutils/lib/dirent--.h b/src/bin/coreutils/lib/dirent--.h index 088aafdc6c..aebab2dfe2 100644 --- a/src/bin/coreutils/lib/dirent--.h +++ b/src/bin/coreutils/lib/dirent--.h @@ -1,6 +1,6 @@ /* Like dirent.h, but redefine some names to avoid glitches. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/dirent-safer.h b/src/bin/coreutils/lib/dirent-safer.h index 0debe26bf7..c72359f010 100644 --- a/src/bin/coreutils/lib/dirent-safer.h +++ b/src/bin/coreutils/lib/dirent-safer.h @@ -1,6 +1,6 @@ /* Invoke dirent-like functions, but avoid some glitches. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/dirent.h b/src/bin/coreutils/lib/dirent.h new file mode 100644 index 0000000000..7b4807cef0 --- /dev/null +++ b/src/bin/coreutils/lib/dirent.h @@ -0,0 +1,166 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* A GNU-like . + Copyright (C) 2006-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef _GL_DIRENT_H + +#if __GNUC__ >= 3 +#pragma GCC system_header +#endif + +/* The include_next requires a split double-inclusion guard. */ +#include_next + +#ifndef _GL_DIRENT_H +#define _GL_DIRENT_H + +/* Get ino_t. Needed on some systems, including glibc 2.8. */ +#include + +/* The definition of GL_LINK_WARNING is copied here. */ +/* GL_LINK_WARNING("literal string") arranges to emit the literal string as + a linker warning on most glibc systems. + We use a linker warning rather than a preprocessor warning, because + #warning cannot be used inside macros. */ +#ifndef GL_LINK_WARNING + /* This works on platforms with GNU ld and ELF object format. + Testing __GLIBC__ is sufficient for asserting that GNU ld is in use. + Testing __ELF__ guarantees the ELF object format. + Testing __GNUC__ is necessary for the compound expression syntax. */ +# if defined __GLIBC__ && defined __ELF__ && defined __GNUC__ +# define GL_LINK_WARNING(message) \ + GL_LINK_WARNING1 (__FILE__, __LINE__, message) +# define GL_LINK_WARNING1(file, line, message) \ + GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */ +# define GL_LINK_WARNING2(file, line, message) \ + GL_LINK_WARNING3 (file ":" #line ": warning: " message) +# define GL_LINK_WARNING3(message) \ + ({ static const char warning[sizeof (message)] \ + __attribute__ ((__unused__, \ + __section__ (".gnu.warning"), \ + __aligned__ (1))) \ + = message "\n"; \ + (void)0; \ + }) +# else +# define GL_LINK_WARNING(message) ((void) 0) +# endif +#endif + +/* The definition of _GL_ARG_NONNULL is copied here. */ +/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools + that the values passed as arguments n, ..., m must be non-NULL pointers. + n = 1 stands for the first argument, n = 2 for the second argument etc. */ +#ifndef _GL_ARG_NONNULL +# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 +# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) +# else +# define _GL_ARG_NONNULL(params) +# endif +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Declare overridden functions. */ + +#if 0 +# define closedir rpl_closedir +extern int closedir (DIR *) _GL_ARG_NONNULL ((1)); +#endif + +#if 1 +# if !1 && !defined dirfd +/* Return the file descriptor associated with the given directory stream, + or -1 if none exists. */ +extern int dirfd (DIR *dir) _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef dirfd +# define dirfd(d) \ + (GL_LINK_WARNING ("dirfd is unportable - " \ + "use gnulib module dirfd for portability"), \ + dirfd (d)) +#endif + +#if 1 +# if 0 +# undef fdopendir +# define fdopendir rpl_fdopendir +# endif +# if !1 || 0 +/* Open a directory stream visiting the given directory file + descriptor. Return NULL and set errno if fd is not visiting a + directory. On success, this function consumes fd (it will be + implicitly closed either by this function or by a subsequent + closedir). */ +extern DIR *fdopendir (int fd); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fdopendir +# define fdopendir(f) \ + (GL_LINK_WARNING ("fdopendir is unportable - " \ + "use gnulib module fdopendir for portability"), \ + fdopendir (f)) +#endif + +#if 0 +# define opendir rpl_opendir +extern DIR * opendir (const char *) _GL_ARG_NONNULL ((1)); +#endif + +#if 0 +/* Scan the directory DIR, calling FILTER on each directory entry. + Entries for which FILTER returns nonzero are individually malloc'd, + sorted using qsort with CMP, and collected in a malloc'd array in + *NAMELIST. Returns the number of entries selected, or -1 on error. */ +# if !1 +extern int scandir (const char *dir, struct dirent ***namelist, + int (*filter) (const struct dirent *), + int (*cmp) (const struct dirent **, const struct dirent **)) + _GL_ARG_NONNULL ((1, 2, 4)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef scandir +# define scandir(d,n,f,c) \ + (GL_LINK_WARNING ("scandir is unportable - " \ + "use gnulib module scandir for portability"), \ + scandir (d, n, f, c)) +#endif + +#if 0 +/* Compare two 'struct dirent' entries alphabetically. */ +# if !1 +extern int alphasort (const struct dirent **, const struct dirent **) + _GL_ARG_NONNULL ((1, 2)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef alphasort +# define alphasort(a,b) \ + (GL_LINK_WARNING ("alphasort is unportable - " \ + "use gnulib module alphasort for portability"), \ + alphasort (a, b)) +#endif + +#ifdef __cplusplus +} +#endif + + +#endif /* _GL_DIRENT_H */ +#endif /* _GL_DIRENT_H */ diff --git a/src/bin/coreutils/lib/dirent.in.h b/src/bin/coreutils/lib/dirent.in.h index 8930765672..4b02cfbcf6 100644 --- a/src/bin/coreutils/lib/dirent.in.h +++ b/src/bin/coreutils/lib/dirent.in.h @@ -1,5 +1,5 @@ /* A GNU-like . - Copyright (C) 2006-2009 Free Software Foundation, Inc. + Copyright (C) 2006-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,8 +26,13 @@ #ifndef _GL_DIRENT_H #define _GL_DIRENT_H +/* Get ino_t. Needed on some systems, including glibc 2.8. */ +#include + /* The definition of GL_LINK_WARNING is copied here. */ +/* The definition of _GL_ARG_NONNULL is copied here. */ + #ifdef __cplusplus extern "C" { @@ -35,20 +40,16 @@ extern "C" { /* Declare overridden functions. */ -#if @REPLACE_FCHDIR@ -# define opendir rpl_opendir -extern DIR * opendir (const char *); +#if @REPLACE_CLOSEDIR@ # define closedir rpl_closedir -extern int closedir (DIR *); +extern int closedir (DIR *) _GL_ARG_NONNULL ((1)); #endif -/* Declare other POSIX functions. */ - #if @GNULIB_DIRFD@ # if !@HAVE_DECL_DIRFD@ && !defined dirfd /* Return the file descriptor associated with the given directory stream, or -1 if none exists. */ -extern int dirfd (DIR const *dir); +extern int dirfd (DIR *dir) _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef dirfd @@ -59,7 +60,11 @@ extern int dirfd (DIR const *dir); #endif #if @GNULIB_FDOPENDIR@ -# if !@HAVE_FDOPENDIR@ +# if @REPLACE_FDOPENDIR@ +# undef fdopendir +# define fdopendir rpl_fdopendir +# endif +# if !@HAVE_FDOPENDIR@ || @REPLACE_FDOPENDIR@ /* Open a directory stream visiting the given directory file descriptor. Return NULL and set errno if fd is not visiting a directory. On success, this function consumes fd (it will be @@ -75,6 +80,11 @@ extern DIR *fdopendir (int fd); fdopendir (f)) #endif +#if @REPLACE_OPENDIR@ +# define opendir rpl_opendir +extern DIR * opendir (const char *) _GL_ARG_NONNULL ((1)); +#endif + #if @GNULIB_SCANDIR@ /* Scan the directory DIR, calling FILTER on each directory entry. Entries for which FILTER returns nonzero are individually malloc'd, @@ -82,8 +92,9 @@ extern DIR *fdopendir (int fd); *NAMELIST. Returns the number of entries selected, or -1 on error. */ # if !@HAVE_SCANDIR@ extern int scandir (const char *dir, struct dirent ***namelist, - int (*filter) (const struct dirent *), - int (*cmp) (const struct dirent **, const struct dirent **)); + int (*filter) (const struct dirent *), + int (*cmp) (const struct dirent **, const struct dirent **)) + _GL_ARG_NONNULL ((1, 2, 4)); # endif #elif defined GNULIB_POSIXCHECK # undef scandir @@ -96,7 +107,8 @@ extern int scandir (const char *dir, struct dirent ***namelist, #if @GNULIB_ALPHASORT@ /* Compare two 'struct dirent' entries alphabetically. */ # if !@HAVE_ALPHASORT@ -extern int alphasort (const struct dirent **, const struct dirent **); +extern int alphasort (const struct dirent **, const struct dirent **) + _GL_ARG_NONNULL ((1, 2)); # endif #elif defined GNULIB_POSIXCHECK # undef alphasort diff --git a/src/bin/coreutils/lib/dirfd.c b/src/bin/coreutils/lib/dirfd.c index 81993c502c..c285370d36 100644 --- a/src/bin/coreutils/lib/dirfd.c +++ b/src/bin/coreutils/lib/dirfd.c @@ -1,6 +1,6 @@ /* dirfd.c -- return the file descriptor associated with an open DIR* - Copyright (C) 2001, 2006, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2001, 2006, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ #include int -dirfd (DIR const *dir_p) +dirfd (DIR *dir_p) { int fd = DIR_TO_FD (dir_p); if (fd == -1) diff --git a/src/bin/coreutils/lib/dirname-lgpl.c b/src/bin/coreutils/lib/dirname-lgpl.c new file mode 100644 index 0000000000..d4506e060d --- /dev/null +++ b/src/bin/coreutils/lib/dirname-lgpl.c @@ -0,0 +1,86 @@ +/* dirname.c -- return all but the last element in a file name + + Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2010 Free Software + Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +#include "dirname.h" + +#include +#include + +/* Return the length of the prefix of FILE that will be used by + dir_name. If FILE is in the working directory, this returns zero + even though `dir_name (FILE)' will return ".". Works properly even + if there are trailing slashes (by effectively ignoring them). */ + +size_t +dir_len (char const *file) +{ + size_t prefix_length = FILE_SYSTEM_PREFIX_LEN (file); + size_t length; + + /* Advance prefix_length beyond important leading slashes. */ + prefix_length += (prefix_length != 0 + ? (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE + && ISSLASH (file[prefix_length])) + : (ISSLASH (file[0]) + ? ((DOUBLE_SLASH_IS_DISTINCT_ROOT + && ISSLASH (file[1]) && ! ISSLASH (file[2]) + ? 2 : 1)) + : 0)); + + /* Strip the basename and any redundant slashes before it. */ + for (length = last_component (file) - file; + prefix_length < length; length--) + if (! ISSLASH (file[length - 1])) + break; + return length; +} + + +/* In general, we can't use the builtin `dirname' function if available, + since it has different meanings in different environments. + In some environments the builtin `dirname' modifies its argument. + + Return the leading directories part of FILE, allocated with malloc. + Works properly even if there are trailing slashes (by effectively + ignoring them). Return NULL on failure. + + If lstat (FILE) would succeed, then { chdir (dir_name (FILE)); + lstat (base_name (FILE)); } will access the same file. Likewise, + if the sequence { chdir (dir_name (FILE)); + rename (base_name (FILE), "foo"); } succeeds, you have renamed FILE + to "foo" in the same directory FILE was in. */ + +char * +mdir_name (char const *file) +{ + size_t length = dir_len (file); + bool append_dot = (length == 0 + || (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE + && length == FILE_SYSTEM_PREFIX_LEN (file) + && file[2] != '\0' && ! ISSLASH (file[2]))); + char *dir = malloc (length + append_dot + 1); + if (!dir) + return NULL; + memcpy (dir, file, length); + if (append_dot) + dir[length++] = '.'; + dir[length] = '\0'; + return dir; +} diff --git a/src/bin/coreutils/lib/dirname.c b/src/bin/coreutils/lib/dirname.c index c27e5b5d8b..953a9acc3d 100644 --- a/src/bin/coreutils/lib/dirname.c +++ b/src/bin/coreutils/lib/dirname.c @@ -1,6 +1,6 @@ /* dirname.c -- return all but the last element in a file name - Copyright (C) 1990, 1998, 2000, 2001, 2003, 2004, 2005, 2006 Free Software + Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -20,65 +20,19 @@ #include "dirname.h" +#include #include #include "xalloc.h" -/* Return the length of the prefix of FILE that will be used by - dir_name. If FILE is in the working directory, this returns zero - even though `dir_name (FILE)' will return ".". Works properly even - if there are trailing slashes (by effectively ignoring them). */ - -size_t -dir_len (char const *file) -{ - size_t prefix_length = FILE_SYSTEM_PREFIX_LEN (file); - size_t length; - - /* Advance prefix_length beyond important leading slashes. */ - prefix_length += (prefix_length != 0 - ? (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE - && ISSLASH (file[prefix_length])) - : (ISSLASH (file[0]) - ? ((DOUBLE_SLASH_IS_DISTINCT_ROOT - && ISSLASH (file[1]) && ! ISSLASH (file[2]) - ? 2 : 1)) - : 0)); - - /* Strip the basename and any redundant slashes before it. */ - for (length = last_component (file) - file; - prefix_length < length; length--) - if (! ISSLASH (file[length - 1])) - break; - return length; -} - - -/* In general, we can't use the builtin `dirname' function if available, - since it has different meanings in different environments. - In some environments the builtin `dirname' modifies its argument. - - Return the leading directories part of FILE, allocated with xmalloc. - Works properly even if there are trailing slashes (by effectively - ignoring them). Unlike POSIX dirname(), FILE cannot be NULL. - - If lstat (FILE) would succeed, then { chdir (dir_name (FILE)); - lstat (base_name (FILE)); } will access the same file. Likewise, - if the sequence { chdir (dir_name (FILE)); - rename (base_name (FILE), "foo"); } succeeds, you have renamed FILE - to "foo" in the same directory FILE was in. */ +/* Just like mdir_name (dirname-lgpl.c), except, rather than + returning NULL upon malloc failure, here, we report the + "memory exhausted" condition and exit. */ char * dir_name (char const *file) { - size_t length = dir_len (file); - bool append_dot = (length == 0 - || (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE - && length == FILE_SYSTEM_PREFIX_LEN (file) - && file[2] != '\0' && ! ISSLASH (file[2]))); - char *dir = xmalloc (length + append_dot + 1); - memcpy (dir, file, length); - if (append_dot) - dir[length++] = '.'; - dir[length] = '\0'; - return dir; + char *result = mdir_name (file); + if (!result) + xalloc_die (); + return result; } diff --git a/src/bin/coreutils/lib/dirname.h b/src/bin/coreutils/lib/dirname.h index f592350b81..fb19508f75 100644 --- a/src/bin/coreutils/lib/dirname.h +++ b/src/bin/coreutils/lib/dirname.h @@ -1,6 +1,7 @@ /* Take file names apart into directory and base names. - Copyright (C) 1998, 2001, 2003-2006 Free Software Foundation, Inc. + Copyright (C) 1998, 2001, 2003-2006, 2009-2010 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,9 +35,9 @@ /* This internal macro assumes ASCII, but all hosts that support drive letters use ASCII. */ # define _IS_DRIVE_LETTER(c) (((unsigned int) (c) | ('a' - 'A')) - 'a' \ - <= 'z' - 'a') + <= 'z' - 'a') # define FILE_SYSTEM_PREFIX_LEN(Filename) \ - (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0) + (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0) # else # define FILE_SYSTEM_PREFIX_LEN(Filename) 0 # endif @@ -54,12 +55,16 @@ # define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)]) # else # define IS_ABSOLUTE_FILE_NAME(F) \ - (ISSLASH ((F)[0]) || 0 < FILE_SYSTEM_PREFIX_LEN (F)) + (ISSLASH ((F)[0]) || 0 < FILE_SYSTEM_PREFIX_LEN (F)) # endif # define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F)) +# if GNULIB_DIRNAME char *base_name (char const *file); char *dir_name (char const *file); +# endif + +char *mdir_name (char const *file); size_t base_len (char const *file); size_t dir_len (char const *file); char *last_component (char const *file); diff --git a/src/bin/coreutils/lib/dup-safer-flag.c b/src/bin/coreutils/lib/dup-safer-flag.c new file mode 100644 index 0000000000..10d6a1bb31 --- /dev/null +++ b/src/bin/coreutils/lib/dup-safer-flag.c @@ -0,0 +1,44 @@ +/* Duplicate a file descriptor result, avoiding clobbering + STD{IN,OUT,ERR}_FILENO, with specific flags. + + Copyright (C) 2001, 2004-2006, 2009-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Paul Eggert and Eric Blake. */ + +#include + +/* Specification. */ +#include "unistd-safer.h" + +#include +#include + +#include "cloexec.h" + +#ifndef O_CLOEXEC +# define O_CLOEXEC 0 +#endif + +/* Like dup, but do not return STDIN_FILENO, STDOUT_FILENO, or + STDERR_FILENO. If FLAG contains O_CLOEXEC, behave like + fcntl(F_DUPFD_CLOEXEC) rather than fcntl(F_DUPFD). */ + +int +dup_safer_flag (int fd, int flag) +{ + return fcntl (fd, (flag & O_CLOEXEC) ? F_DUPFD_CLOEXEC : F_DUPFD, + STDERR_FILENO + 1); +} diff --git a/src/bin/coreutils/lib/dup-safer.c b/src/bin/coreutils/lib/dup-safer.c index 22b96babf5..33f599beef 100644 --- a/src/bin/coreutils/lib/dup-safer.c +++ b/src/bin/coreutils/lib/dup-safer.c @@ -1,7 +1,6 @@ /* Invoke dup, but avoid some glitches. - Copyright (C) 2001, 2004, 2005, 2006, 2009 Free Software - Foundation, Inc. + Copyright (C) 2001, 2004-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,7 +22,6 @@ #include "unistd-safer.h" #include - #include /* Like dup, but do not return STDIN_FILENO, STDOUT_FILENO, or @@ -32,11 +30,5 @@ int dup_safer (int fd) { -#if defined F_DUPFD && !REPLACE_FCHDIR return fcntl (fd, F_DUPFD, STDERR_FILENO + 1); -#else - /* fd_safer calls us back, but eventually the recursion unwinds and - does the right thing. */ - return fd_safer (dup (fd)); -#endif } diff --git a/src/bin/coreutils/lib/dup2.c b/src/bin/coreutils/lib/dup2.c index 140af1b9fb..a4422bf3b8 100644 --- a/src/bin/coreutils/lib/dup2.c +++ b/src/bin/coreutils/lib/dup2.c @@ -1,7 +1,6 @@ /* Duplicate an open file descriptor to a specified file descriptor. - Copyright (C) 1999, 2004, 2005, 2006, 2007, 2009 Free Software - Foundation, Inc. + Copyright (C) 1999, 2004-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -32,7 +31,7 @@ # include #endif -#if REPLACE_DUP2 +#if HAVE_DUP2 # undef dup2 @@ -53,6 +52,13 @@ rpl_dup2 (int fd, int desired_fd) } return fd; } + /* Wine 1.0.1 return 0 when desired_fd is negative but not -1: + http://bugs.winehq.org/show_bug.cgi?id=21289 */ + if (desired_fd < 0) + { + errno = EBADF; + return -1; + } # endif result = dup2 (fd, desired_fd); # ifdef __linux__ @@ -70,14 +76,14 @@ rpl_dup2 (int fd, int desired_fd) /* Correct a cygwin 1.5.x errno value. */ else if (result == -1 && errno == EMFILE) errno = EBADF; -#if REPLACE_FCHDIR - if (fd != desired_fd && result == desired_fd) - result = _gl_register_dup (fd, desired_fd); -#endif +# if REPLACE_FCHDIR + if (fd != desired_fd && result != -1) + result = _gl_register_dup (fd, result); +# endif return result; } -#else /* !REPLACE_DUP2 */ +#else /* !HAVE_DUP2 */ /* On older platforms, dup2 did not exist. */ @@ -102,19 +108,21 @@ dupfd (int fd, int desired_fd) int dup2 (int fd, int desired_fd) { - int result; - if (fd == desired_fd) - return fcntl (fd, F_GETFL) < 0 ? -1 : fd; + int result = fcntl (fd, F_GETFL) < 0 ? -1 : fd; + if (result == -1 || fd == desired_fd) + return result; close (desired_fd); # ifdef F_DUPFD result = fcntl (fd, F_DUPFD, desired_fd); +# if REPLACE_FCHDIR + if (0 <= result) + result = _gl_register_dup (fd, result); +# endif # else result = dupfd (fd, desired_fd); # endif -#if REPLACE_FCHDIR - if (0 <= result) - result = _gl_register_dup (fd, desired_fd); -#endif + if (result == -1 && (errno == EMFILE || errno == EINVAL)) + errno = EBADF; return result; } -#endif /* !REPLACE_DUP2 */ +#endif /* !HAVE_DUP2 */ diff --git a/src/bin/coreutils/lib/errno.in.h b/src/bin/coreutils/lib/errno.in.h index d374f6c238..340f914728 100644 --- a/src/bin/coreutils/lib/errno.in.h +++ b/src/bin/coreutils/lib/errno.in.h @@ -3,7 +3,7 @@ #line 1 /* A POSIX-like . - Copyright (C) 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/error.c b/src/bin/coreutils/lib/error.c index af2287b271..c79e8d42cb 100644 --- a/src/bin/coreutils/lib/error.c +++ b/src/bin/coreutils/lib/error.c @@ -1,5 +1,5 @@ /* Error handler for noninteractive utilities - Copyright (C) 1990-1998, 2000-2007, 2009 Free Software Foundation, Inc. + Copyright (C) 1990-1998, 2000-2007, 2009-2010 Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software: you can redistribute it and/or modify @@ -70,8 +70,8 @@ unsigned int error_message_count; extern void __error (int status, int errnum, const char *message, ...) __attribute__ ((__format__ (__printf__, 3, 4))); extern void __error_at_line (int status, int errnum, const char *file_name, - unsigned int line_number, const char *message, - ...) + unsigned int line_number, const char *message, + ...) __attribute__ ((__format__ (__printf__, 5, 6)));; # define error __error # define error_at_line __error_at_line @@ -86,6 +86,7 @@ extern void __error_at_line (int status, int errnum, const char *file_name, #else /* not _LIBC */ # include +# include # if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P # ifndef HAVE_DECL_STRERROR_R @@ -100,8 +101,33 @@ extern char *program_name; # if HAVE_STRERROR_R || defined strerror_r # define __strerror_r strerror_r -# endif /* HAVE_STRERROR_R || defined strerror_r */ -#endif /* not _LIBC */ +# endif /* HAVE_STRERROR_R || defined strerror_r */ +#endif /* not _LIBC */ + +static inline void +flush_stdout (void) +{ +#if !_LIBC && defined F_GETFL + int stdout_fd; + +# if GNULIB_FREOPEN_SAFER + /* Use of gnulib's freopen-safer module normally ensures that + fileno (stdout) == 1 + whenever stdout is open. */ + stdout_fd = STDOUT_FILENO; +# else + /* POSIX states that fileno (stdout) after fclose is unspecified. But in + practice it is not a problem, because stdout is statically allocated and + the fd of a FILE stream is stored as a field in its allocated memory. */ + stdout_fd = fileno (stdout); +# endif + /* POSIX states that fflush (stdout) after fclose is unspecified; it + is safe in glibc, but not on all other platforms. fflush (NULL) + is always defined, but too draconian. */ + if (0 <= stdout_fd && 0 <= fcntl (stdout_fd, F_GETFL)) +#endif + fflush (stdout); +} static void print_errno_message (int errnum) @@ -149,58 +175,58 @@ error_tail (int status, int errnum, const char *message, va_list args) bool use_malloc = false; while (1) - { - if (__libc_use_alloca (len * sizeof (wchar_t))) - wmessage = (wchar_t *) alloca (len * sizeof (wchar_t)); - else - { - if (!use_malloc) - wmessage = NULL; + { + if (__libc_use_alloca (len * sizeof (wchar_t))) + wmessage = (wchar_t *) alloca (len * sizeof (wchar_t)); + else + { + if (!use_malloc) + wmessage = NULL; - wchar_t *p = (wchar_t *) realloc (wmessage, - len * sizeof (wchar_t)); - if (p == NULL) - { - free (wmessage); - fputws_unlocked (L"out of memory\n", stderr); - return; - } - wmessage = p; - use_malloc = true; - } + wchar_t *p = (wchar_t *) realloc (wmessage, + len * sizeof (wchar_t)); + if (p == NULL) + { + free (wmessage); + fputws_unlocked (L"out of memory\n", stderr); + return; + } + wmessage = p; + use_malloc = true; + } - memset (&st, '\0', sizeof (st)); - tmp = message; + memset (&st, '\0', sizeof (st)); + tmp = message; - res = mbsrtowcs (wmessage, &tmp, len, &st); - if (res != len) - break; + res = mbsrtowcs (wmessage, &tmp, len, &st); + if (res != len) + break; - if (__builtin_expect (len >= SIZE_MAX / 2, 0)) - { - /* This really should not happen if everything is fine. */ - res = (size_t) -1; - break; - } + if (__builtin_expect (len >= SIZE_MAX / 2, 0)) + { + /* This really should not happen if everything is fine. */ + res = (size_t) -1; + break; + } - len *= 2; - } + len *= 2; + } if (res == (size_t) -1) - { - /* The string cannot be converted. */ - if (use_malloc) - { - free (wmessage); - use_malloc = false; - } - wmessage = (wchar_t *) L"???"; - } + { + /* The string cannot be converted. */ + if (use_malloc) + { + free (wmessage); + use_malloc = false; + } + wmessage = (wchar_t *) L"???"; + } __vfwprintf (stderr, wmessage, args); if (use_malloc) - free (wmessage); + free (wmessage); } else #endif @@ -235,16 +261,10 @@ error (int status, int errnum, const char *message, ...) cancellation. Therefore disable cancellation for now. */ int state = PTHREAD_CANCEL_ENABLE; __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state), - 0); + 0); #endif -#if !_LIBC && defined F_GETFL - /* POSIX states that fflush (stdout) after fclose is unspecified; it - is safe in glibc, but not on all other platforms. fflush (NULL) - is always defined, but too draconian. */ - if (0 <= fcntl (1, F_GETFL)) -#endif - fflush (stdout); + flush_stdout (); #ifdef _LIBC _IO_flockfile (stderr); #endif @@ -276,7 +296,7 @@ int error_one_per_line; void error_at_line (int status, int errnum, const char *file_name, - unsigned int line_number, const char *message, ...) + unsigned int line_number, const char *message, ...) { va_list args; @@ -286,10 +306,10 @@ error_at_line (int status, int errnum, const char *file_name, static unsigned int old_line_number; if (old_line_number == line_number - && (file_name == old_file_name - || strcmp (old_file_name, file_name) == 0)) - /* Simply return and print nothing. */ - return; + && (file_name == old_file_name + || strcmp (old_file_name, file_name) == 0)) + /* Simply return and print nothing. */ + return; old_file_name = file_name; old_line_number = line_number; @@ -300,16 +320,10 @@ error_at_line (int status, int errnum, const char *file_name, cancellation. Therefore disable cancellation for now. */ int state = PTHREAD_CANCEL_ENABLE; __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state), - 0); + 0); #endif -#if !_LIBC && defined F_GETFL - /* POSIX states that fflush (stdout) after fclose is unspecified; it - is safe in glibc, but not on all other platforms. fflush (NULL) - is always defined, but too draconian. */ - if (0 <= fcntl (1, F_GETFL)) -#endif - fflush (stdout); + flush_stdout (); #ifdef _LIBC _IO_flockfile (stderr); #endif @@ -326,10 +340,10 @@ error_at_line (int status, int errnum, const char *file_name, #if _LIBC __fxprintf (NULL, file_name != NULL ? "%s:%d: " : " ", - file_name, line_number); + file_name, line_number); #else fprintf (stderr, file_name != NULL ? "%s:%d: " : " ", - file_name, line_number); + file_name, line_number); #endif va_start (args, message); diff --git a/src/bin/coreutils/lib/error.h b/src/bin/coreutils/lib/error.h index 6d49681146..b4ae98241d 100644 --- a/src/bin/coreutils/lib/error.h +++ b/src/bin/coreutils/lib/error.h @@ -1,5 +1,6 @@ /* Declaration for error-reporting function - Copyright (C) 1995, 1996, 1997, 2003, 2006, 2008 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 2003, 2006, 2008, 2009, 2010 Free Software + Foundation, Inc. This file is part of the GNU C Library. This program is free software: you can redistribute it and/or modify @@ -31,7 +32,7 @@ # endif #endif -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif @@ -43,7 +44,7 @@ extern void error (int __status, int __errnum, const char *__format, ...) __attribute__ ((__format__ (__printf__, 3, 4))); extern void error_at_line (int __status, int __errnum, const char *__fname, - unsigned int __lineno, const char *__format, ...) + unsigned int __lineno, const char *__format, ...) __attribute__ ((__format__ (__printf__, 5, 6))); /* If NULL, error will flush stdout, then print on stderr the program @@ -58,7 +59,7 @@ extern unsigned int error_message_count; variable controls whether this mode is selected or not. */ extern int error_one_per_line; -#ifdef __cplusplus +#ifdef __cplusplus } #endif diff --git a/src/bin/coreutils/lib/euidaccess-stat.c b/src/bin/coreutils/lib/euidaccess-stat.c index 98ce28157e..634c0e41bb 100644 --- a/src/bin/coreutils/lib/euidaccess-stat.c +++ b/src/bin/coreutils/lib/euidaccess-stat.c @@ -2,7 +2,7 @@ This function is probably useful only for choosing whether to issue a prompt in an implementation of POSIX-specified rm. - Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,13 +25,6 @@ #include -#ifndef F_OK -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 -#endif - #include "group-member.h" #include "stat-macros.h" @@ -137,6 +130,6 @@ main (int argc, char **argv) ok = euidaccess_stat (&st, mode); printf ("%s: %s\n", file, ok ? "y" : "n"); - exit (0); + return 0; } #endif diff --git a/src/bin/coreutils/lib/euidaccess.c b/src/bin/coreutils/lib/euidaccess.c index dcb6e3a931..ba744d5cf7 100644 --- a/src/bin/coreutils/lib/euidaccess.c +++ b/src/bin/coreutils/lib/euidaccess.c @@ -1,7 +1,7 @@ /* euidaccess -- check if effective user id can access file - Copyright (C) 1990, 1991, 1995, 1998, 2000, 2003, 2004, 2005, 2006, - 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 1990-1991, 1995, 1998, 2000, 2003-2006, 2008-2010 Free + Software Foundation, Inc. This file is part of the GNU C Library. @@ -111,18 +111,18 @@ euidaccess (const char *file, int mode) int saved_errno; if (uid != euid) - setreuid (euid, uid); + setreuid (euid, uid); if (gid != egid) - setregid (egid, gid); + setregid (egid, gid); result = access (file, mode); saved_errno = errno; /* Restore them. */ if (uid != euid) - setreuid (uid, euid); + setreuid (uid, euid); if (gid != egid) - setregid (gid, egid); + setregid (gid, egid); errno = saved_errno; return result; @@ -145,7 +145,7 @@ euidaccess (const char *file, int mode) /* The super-user can read and write any file, and execute any file that anyone can execute. */ if (euid == 0 && ((mode & X_OK) == 0 - || (stats.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))) + || (stats.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))) return 0; /* Convert the mode to traditional form, clearing any bogus bits. */ @@ -153,11 +153,11 @@ euidaccess (const char *file, int mode) mode &= 7; else mode = ((mode & R_OK ? 4 : 0) - + (mode & W_OK ? 2 : 0) - + (mode & X_OK ? 1 : 0)); + + (mode & W_OK ? 2 : 0) + + (mode & X_OK ? 1 : 0)); if (mode == 0) - return 0; /* The file exists. */ + return 0; /* The file exists. */ /* Convert the file's permission bits to traditional form. */ if (S_IRUSR == (4 << 6) && S_IWUSR == (2 << 6) && S_IXUSR == (1 << 6) @@ -166,14 +166,14 @@ euidaccess (const char *file, int mode) granted = stats.st_mode; else granted = ((stats.st_mode & S_IRUSR ? 4 << 6 : 0) - + (stats.st_mode & S_IWUSR ? 2 << 6 : 0) - + (stats.st_mode & S_IXUSR ? 1 << 6 : 0) - + (stats.st_mode & S_IRGRP ? 4 << 3 : 0) - + (stats.st_mode & S_IWGRP ? 2 << 3 : 0) - + (stats.st_mode & S_IXGRP ? 1 << 3 : 0) - + (stats.st_mode & S_IROTH ? 4 << 0 : 0) - + (stats.st_mode & S_IWOTH ? 2 << 0 : 0) - + (stats.st_mode & S_IXOTH ? 1 << 0 : 0)); + + (stats.st_mode & S_IWUSR ? 2 << 6 : 0) + + (stats.st_mode & S_IXUSR ? 1 << 6 : 0) + + (stats.st_mode & S_IRGRP ? 4 << 3 : 0) + + (stats.st_mode & S_IWGRP ? 2 << 3 : 0) + + (stats.st_mode & S_IXGRP ? 1 << 3 : 0) + + (stats.st_mode & S_IROTH ? 4 << 0 : 0) + + (stats.st_mode & S_IWOTH ? 2 << 0 : 0) + + (stats.st_mode & S_IXOTH ? 1 << 0 : 0)); if (euid == stats.st_uid) granted >>= 6; diff --git a/src/bin/coreutils/lib/exclude.c b/src/bin/coreutils/lib/exclude.c index 3ceeed7bef..d4dcd76bd9 100644 --- a/src/bin/coreutils/lib/exclude.c +++ b/src/bin/coreutils/lib/exclude.c @@ -1,7 +1,7 @@ /* exclude.c -- exclude file names - Copyright (C) 1992, 1993, 1994, 1997, 1999, 2000, 2001, 2002, 2003, - 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 1992, 1993, 1994, 1997, 1999, 2000, 2001, 2002, 2003, 2004, + 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -56,9 +56,9 @@ #endif verify (((EXCLUDE_ANCHORED | EXCLUDE_INCLUDE | EXCLUDE_WILDCARDS) - & (FNM_PATHNAME | FNM_NOESCAPE | FNM_PERIOD | FNM_LEADING_DIR - | FNM_CASEFOLD | FNM_EXTMATCH)) - == 0); + & (FNM_PATHNAME | FNM_NOESCAPE | FNM_PERIOD | FNM_LEADING_DIR + | FNM_CASEFOLD | FNM_EXTMATCH)) + == 0); /* Exclusion patterns are grouped into a singly-linked list of @@ -121,15 +121,15 @@ fnmatch_pattern_has_wildcards (const char *str, int options) { size_t n = strcspn (str, cset); if (str[n] == 0) - break; + break; else if (str[n] == '\\') - { - str += n + 1; - if (*str) - str++; - } + { + str += n + 1; + if (*str) + str++; + } else - return true; + return true; } return false; } @@ -164,9 +164,9 @@ string_hasher_ci (void const *data, size_t n_buckets) wchar_t wc; if (m.wc_valid) - wc = towlower (m.wc); + wc = towlower (m.wc); else - wc = *m.ptr; + wc = *m.ptr; value = (value * 31 + wc) % n_buckets; } @@ -213,13 +213,13 @@ new_exclude_segment (struct exclude *ex, enum exclude_type type, int options) case exclude_hash: sp->v.table = hash_initialize (0, NULL, - (options & FNM_CASEFOLD) ? - string_hasher_ci - : string_hasher, - (options & FNM_CASEFOLD) ? - string_compare_ci - : string_compare, - string_free); + (options & FNM_CASEFOLD) ? + string_hasher_ci + : string_hasher, + (options & FNM_CASEFOLD) ? + string_compare_ci + : string_compare, + string_free); break; } if (ex->tail) @@ -269,41 +269,41 @@ fnmatch_no_wildcards (char const *pattern, char const *f, int options) { if (! (options & FNM_LEADING_DIR)) return ((options & FNM_CASEFOLD) - ? mbscasecmp (pattern, f) - : strcmp (pattern, f)); + ? mbscasecmp (pattern, f) + : strcmp (pattern, f)); else if (! (options & FNM_CASEFOLD)) { size_t patlen = strlen (pattern); int r = strncmp (pattern, f, patlen); if (! r) - { - r = f[patlen]; - if (r == '/') - r = 0; - } + { + r = f[patlen]; + if (r == '/') + r = 0; + } return r; } else { /* Walk through a copy of F, seeing whether P matches any prefix - of F. + of F. - FIXME: This is an O(N**2) algorithm; it should be O(N). - Also, the copy should not be necessary. However, fixing this - will probably involve a change to the mbs* API. */ + FIXME: This is an O(N**2) algorithm; it should be O(N). + Also, the copy should not be necessary. However, fixing this + will probably involve a change to the mbs* API. */ char *fcopy = xstrdup (f); char *p; int r; for (p = fcopy; ; *p++ = '/') - { - p = strchr (p, '/'); - if (p) - *p = '\0'; - r = mbscasecmp (pattern, fcopy); - if (!p || r <= 0) - break; - } + { + p = strchr (p, '/'); + if (p) + *p = '\0'; + r = mbscasecmp (pattern, fcopy); + if (!p || r <= 0) + break; + } free (fcopy); return r; } @@ -322,7 +322,7 @@ exclude_fnmatch (char const *pattern, char const *f, int options) if (! (options & EXCLUDE_ANCHORED)) for (p = f; *p && ! matched; p++) if (*p == '/' && p[1] != '/') - matched = ((*matcher) (pattern, p + 1, options) == 0); + matched = ((*matcher) (pattern, p + 1, options) == 0); return matched; } @@ -343,7 +343,7 @@ excluded_file_pattern_p (struct exclude_segment const *seg, char const *f) char const *pattern = exclude[i].pattern; int options = exclude[i].options; if (excluded != exclude_fnmatch (pattern, f, options)) - return !excluded; + return !excluded; } return excluded; } @@ -353,7 +353,7 @@ excluded_file_pattern_p (struct exclude_segment const *seg, char const *f) terminator included) */ static bool excluded_file_name_p (struct exclude_segment const *seg, char const *f, - char *buffer) + char *buffer) { int options = seg->options; bool excluded = !! (options & EXCLUDE_INCLUDE); @@ -365,29 +365,29 @@ excluded_file_name_p (struct exclude_segment const *seg, char const *f, strcpy (buffer, f); while (1) - { - if (hash_lookup (table, buffer)) - return !excluded; - if (options & FNM_LEADING_DIR) - { - char *p = strrchr (buffer, '/'); - if (p) - { - *p = 0; - continue; - } - } - break; - } + { + if (hash_lookup (table, buffer)) + return !excluded; + if (options & FNM_LEADING_DIR) + { + char *p = strrchr (buffer, '/'); + if (p) + { + *p = 0; + continue; + } + } + break; + } if (!(options & EXCLUDE_ANCHORED)) - { - f = strchr (f, '/'); - if (f) - f++; - } + { + f = strchr (f, '/'); + if (f) + f++; + } else - break; + break; } while (f); return excluded; @@ -415,22 +415,25 @@ excluded_file_name (struct exclude const *ex, char const *f) bool rc; switch (seg->type) - { - case exclude_pattern: - rc = excluded_file_pattern_p (seg, f); - break; + { + case exclude_pattern: + rc = excluded_file_pattern_p (seg, f); + break; - case exclude_hash: - if (!filename) - filename = xmalloc (strlen (f) + 1); - rc = excluded_file_name_p (seg, f, filename); - break; - } + case exclude_hash: + if (!filename) + filename = xmalloc (strlen (f) + 1); + rc = excluded_file_name_p (seg, f, filename); + break; + + default: + abort (); + } if (rc != excluded) - { - excluded = rc; - break; - } + { + excluded = rc; + break; + } } free (filename); return excluded; @@ -450,16 +453,16 @@ add_exclude (struct exclude *ex, char const *pattern, int options) struct patopts *patopts; if (ex->tail && ex->tail->type == exclude_pattern - && ((ex->tail->options & EXCLUDE_INCLUDE) == - (options & EXCLUDE_INCLUDE))) - seg = ex->tail; + && ((ex->tail->options & EXCLUDE_INCLUDE) == + (options & EXCLUDE_INCLUDE))) + seg = ex->tail; else - seg = new_exclude_segment (ex, exclude_pattern, options); + seg = new_exclude_segment (ex, exclude_pattern, options); pat = &seg->v.pat; if (pat->exclude_count == pat->exclude_alloc) - pat->exclude = x2nrealloc (pat->exclude, &pat->exclude_alloc, - sizeof *pat->exclude); + pat->exclude = x2nrealloc (pat->exclude, &pat->exclude_alloc, + sizeof *pat->exclude); patopts = &pat->exclude[pat->exclude_count++]; patopts->pattern = pattern; patopts->options = options; @@ -468,18 +471,18 @@ add_exclude (struct exclude *ex, char const *pattern, int options) { char *str, *p; #define EXCLUDE_HASH_FLAGS (EXCLUDE_INCLUDE|EXCLUDE_ANCHORED|\ - FNM_LEADING_DIR|FNM_CASEFOLD) + FNM_LEADING_DIR|FNM_CASEFOLD) if (ex->tail && ex->tail->type == exclude_hash - && ((ex->tail->options & EXCLUDE_HASH_FLAGS) == - (options & EXCLUDE_HASH_FLAGS))) - seg = ex->tail; + && ((ex->tail->options & EXCLUDE_HASH_FLAGS) == + (options & EXCLUDE_HASH_FLAGS))) + seg = ex->tail; else - seg = new_exclude_segment (ex, exclude_hash, options); + seg = new_exclude_segment (ex, exclude_hash, options); str = xstrdup (pattern); p = hash_insert (seg->v.table, str); if (p != str) - free (str); + free (str); } } @@ -490,8 +493,8 @@ add_exclude (struct exclude *ex, char const *pattern, int options) int add_exclude_file (void (*add_func) (struct exclude *, char const *, int), - struct exclude *ex, char const *file_name, int options, - char line_end) + struct exclude *ex, char const *file_name, int options, + char line_end) { bool use_stdin = file_name[0] == '-' && !file_name[1]; FILE *in; @@ -512,7 +515,7 @@ add_exclude_file (void (*add_func) (struct exclude *, char const *, int), while ((c = getc (in)) != EOF) { if (buf_count == buf_alloc) - buf = x2realloc (buf, &buf_alloc); + buf = x2realloc (buf, &buf_alloc); buf[buf_count++] = c; } @@ -530,22 +533,22 @@ add_exclude_file (void (*add_func) (struct exclude *, char const *, int), for (p = buf; p < lim; p++) if (*p == line_end) { - char *pattern_end = p; + char *pattern_end = p; - if (isspace ((unsigned char) line_end)) - { - for (; ; pattern_end--) - if (pattern_end == pattern) - goto next_pattern; - else if (! isspace ((unsigned char) pattern_end[-1])) - break; - } + if (isspace ((unsigned char) line_end)) + { + for (; ; pattern_end--) + if (pattern_end == pattern) + goto next_pattern; + else if (! isspace ((unsigned char) pattern_end[-1])) + break; + } - *pattern_end = '\0'; - (*add_func) (ex, pattern, options); + *pattern_end = '\0'; + (*add_func) (ex, pattern, options); next_pattern: - pattern = p + 1; + pattern = p + 1; } errno = e; diff --git a/src/bin/coreutils/lib/exclude.h b/src/bin/coreutils/lib/exclude.h index e0735e1594..65d3128763 100644 --- a/src/bin/coreutils/lib/exclude.h +++ b/src/bin/coreutils/lib/exclude.h @@ -1,7 +1,7 @@ /* exclude.h -- declarations for excluding file names - Copyright (C) 1992, 1993, 1994, 1997, 1999, 2001, 2002, 2003, 2005, - 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 1992, 1993, 1994, 1997, 1999, 2001, 2002, 2003, 2005, 2006, + 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,6 +16,11 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#ifndef _GL_EXCLUDE_H +#define _GL_EXCLUDE_H 1 + +#include + /* Written by Paul Eggert and Sergey Poznyakoff */ @@ -40,6 +45,8 @@ struct exclude *new_exclude (void); void free_exclude (struct exclude *); void add_exclude (struct exclude *, char const *, int); int add_exclude_file (void (*) (struct exclude *, char const *, int), - struct exclude *, char const *, int, char); + struct exclude *, char const *, int, char); bool excluded_file_name (struct exclude const *, char const *); bool exclude_fnmatch (char const *pattern, char const *f, int options); + +#endif /* _GL_EXCLUDE_H */ diff --git a/src/bin/coreutils/lib/exitfail.c b/src/bin/coreutils/lib/exitfail.c index 6d1fe4aea0..3b63f8a123 100644 --- a/src/bin/coreutils/lib/exitfail.c +++ b/src/bin/coreutils/lib/exitfail.c @@ -1,6 +1,7 @@ /* Failure exit status - Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2005, 2006, 2007, 2009, 2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/exitfail.h b/src/bin/coreutils/lib/exitfail.h index 713f2591a7..7ffffe5c99 100644 --- a/src/bin/coreutils/lib/exitfail.h +++ b/src/bin/coreutils/lib/exitfail.h @@ -1,6 +1,6 @@ /* Failure exit status - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/faccessat.c b/src/bin/coreutils/lib/faccessat.c new file mode 100644 index 0000000000..d110aaa210 --- /dev/null +++ b/src/bin/coreutils/lib/faccessat.c @@ -0,0 +1,44 @@ +/* Check the access rights of a file relative to an open directory. + Copyright (C) 2009-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* written by Eric Blake */ + +#include + +#include + +#ifndef HAVE_ACCESS +/* Mingw lacks access, but it also lacks real vs. effective ids, so + the gnulib euidaccess module is good enough. */ +# undef access +# define access euidaccess +#endif + +/* Invoke access or euidaccess on file, FILE, using mode MODE, in the directory + open on descriptor FD. If possible, do it without changing the + working directory. Otherwise, resort to using save_cwd/fchdir, then + (access|euidaccess)/restore_cwd. If either the save_cwd or the + restore_cwd fails, then give a diagnostic and exit nonzero. + Note that this implementation only supports AT_EACCESS, although some + native versions also support AT_SYMLINK_NOFOLLOW. */ + +#define AT_FUNC_NAME faccessat +#define AT_FUNC_F1 euidaccess +#define AT_FUNC_F2 access +#define AT_FUNC_USE_F1_COND AT_EACCESS +#define AT_FUNC_POST_FILE_PARAM_DECLS , int mode, int flag +#define AT_FUNC_POST_FILE_ARGS , mode +#include "at-func.c" diff --git a/src/bin/coreutils/lib/fchdir.c b/src/bin/coreutils/lib/fchdir.c index f35562911a..015e5f382f 100644 --- a/src/bin/coreutils/lib/fchdir.c +++ b/src/bin/coreutils/lib/fchdir.c @@ -1,5 +1,5 @@ /* fchdir replacement. - Copyright (C) 2006-2009 Free Software Foundation, Inc. + Copyright (C) 2006-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,12 +29,19 @@ #include #include -#include "canonicalize.h" - #ifndef REPLACE_OPEN_DIRECTORY # define REPLACE_OPEN_DIRECTORY 0 #endif +#ifndef HAVE_CANONICALIZE_FILE_NAME +# if GNULIB_CANONICALIZE || GNULIB_CANONICALIZE_LGPL +# define HAVE_CANONICALIZE_FILE_NAME 1 +# else +# define HAVE_CANONICALIZE_FILE_NAME 0 +# define canonicalize_file_name(name) NULL +# endif +#endif + /* This replacement assumes that a directory is not renamed while opened through a file descriptor. @@ -43,8 +50,8 @@ descriptor, since mingw refuses to rename any in-use file system object. */ -/* Array of file descriptors opened. If it points to a directory, it stores - info about this directory. */ +/* Array of file descriptors opened. If REPLACE_OPEN_DIRECTORY or if it points + to a directory, it stores info about this directory. */ typedef struct { char *name; /* Absolute name of the directory, or NULL. */ @@ -53,23 +60,26 @@ typedef struct static dir_info_t *dirs; static size_t dirs_allocated; -/* Try to ensure dirs has enough room for a slot at index fd. Return - false and set errno to ENOMEM on allocation failure. */ +/* Try to ensure dirs has enough room for a slot at index fd; free any + contents already in that slot. Return false and set errno to + ENOMEM on allocation failure. */ static bool ensure_dirs_slot (size_t fd) { - if (fd >= dirs_allocated) + if (fd < dirs_allocated) + free (dirs[fd].name); + else { size_t new_allocated; dir_info_t *new_dirs; new_allocated = 2 * dirs_allocated + 1; if (new_allocated <= fd) - new_allocated = fd + 1; + new_allocated = fd + 1; new_dirs = - (dirs != NULL - ? (dir_info_t *) realloc (dirs, new_allocated * sizeof *dirs) - : (dir_info_t *) malloc (new_allocated * sizeof *dirs)); + (dirs != NULL + ? (dir_info_t *) realloc (dirs, new_allocated * sizeof *dirs) + : (dir_info_t *) malloc (new_allocated * sizeof *dirs)); if (new_dirs == NULL) return false; memset (new_dirs + dirs_allocated, 0, @@ -80,6 +90,39 @@ ensure_dirs_slot (size_t fd) return true; } +/* Return the canonical name of DIR in malloc'd storage. */ +static char * +get_name (char const *dir) +{ + char *result; + if (REPLACE_OPEN_DIRECTORY || !HAVE_CANONICALIZE_FILE_NAME) + { + /* The function canonicalize_file_name has not yet been ported + to mingw, with all its drive letter and backslash quirks. + Fortunately, getcwd is reliable in this case, but we ensure + we can get back to where we started before using it. Treat + "." as a special case, as it is frequently encountered. */ + char *cwd = getcwd (NULL, 0); + int saved_errno; + if (dir[0] == '.' && dir[1] == '\0') + return cwd; + if (chdir (cwd)) + return NULL; + result = chdir (dir) ? NULL : getcwd (NULL, 0); + saved_errno = errno; + if (chdir (cwd)) + abort (); + free (cwd); + errno = saved_errno; + } + else + { + /* Avoid changing the directory. */ + result = canonicalize_file_name (dir); + } + return result; +} + /* Hook into the gnulib replacements for open() and close() to keep track of the open file descriptors. */ @@ -110,7 +153,7 @@ _gl_register_fd (int fd, const char *filename) || (fstat (fd, &statbuf) == 0 && S_ISDIR (statbuf.st_mode))) { if (!ensure_dirs_slot (fd) - || (dirs[fd].name = canonicalize_file_name (filename)) == NULL) + || (dirs[fd].name = get_name (filename)) == NULL) { int saved_errno = errno; close (fd); @@ -125,10 +168,7 @@ _gl_register_fd (int fd, const char *filename) and fcntl. Both arguments must be valid and distinct file descriptors. Close NEWFD and return -1 if OLDFD is tracking a directory, but there is insufficient memory to track the same - directory in NEWFD; otherwise return NEWFD. - - FIXME: Need to implement rpl_fcntl in gnulib, and have it call - this. */ + directory in NEWFD; otherwise return NEWFD. */ int _gl_register_dup (int oldfd, int newfd) { @@ -173,10 +213,11 @@ _gl_directory_name (int fd) return NULL; } +#if REPLACE_OPEN_DIRECTORY /* Return stat information about FD in STATBUF. Needed when rpl_open() used a dummy file to work around an open() that can't normally visit directories. */ -#if REPLACE_OPEN_DIRECTORY +# undef fstat int rpl_fstat (int fd, struct stat *statbuf) { diff --git a/src/bin/coreutils/lib/fchmodat.c b/src/bin/coreutils/lib/fchmodat.c index 53cafe06d5..0a7654315d 100644 --- a/src/bin/coreutils/lib/fchmodat.c +++ b/src/bin/coreutils/lib/fchmodat.c @@ -1,5 +1,5 @@ /* Change the protections of file relative to an open directory. - Copyright (C) 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,17 +20,19 @@ #include -#include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ -#include "openat.h" -#include "openat-priv.h" -#include "save-cwd.h" +#include #ifndef HAVE_LCHMOD /* Use a different name, to avoid conflicting with any system-supplied declaration. */ # undef lchmod # define lchmod lchmod_rpl -static int lchmod (char const *f, mode_t m) { errno = ENOSYS; return -1; } +static int +lchmod (char const *f _GL_UNUSED, mode_t m _GL_UNUSED) +{ + errno = ENOSYS; + return -1; +} #endif /* Solaris 10 has no function like this. diff --git a/src/bin/coreutils/lib/fchownat.c b/src/bin/coreutils/lib/fchownat.c index 6da3537340..00126acf09 100644 --- a/src/bin/coreutils/lib/fchownat.c +++ b/src/bin/coreutils/lib/fchownat.c @@ -4,7 +4,7 @@ when the buggy fchownat-with-AT_SYMLINK_NOFOLLOW operates on a symlink, it mistakenly affects the symlink referent, rather than the symlink itself. - Copyright (C) 2006-2007, 2009 Free Software Foundation, Inc. + Copyright (C) 2006-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,10 +25,12 @@ #include -#include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ +#include +#include + #include "openat.h" -#include "openat-priv.h" -#include "save-cwd.h" + +#if !HAVE_FCHOWNAT /* Replacement for Solaris' function by the same name. Invoke chown or lchown on file, FILE, using OWNER and GROUP, in the @@ -38,10 +40,68 @@ then (chown|lchown)/restore_cwd. If either the save_cwd or the restore_cwd fails, then give a diagnostic and exit nonzero. */ -#define AT_FUNC_NAME fchownat -#define AT_FUNC_F1 lchown -#define AT_FUNC_F2 chown -#define AT_FUNC_USE_F1_COND AT_SYMLINK_NOFOLLOW -#define AT_FUNC_POST_FILE_PARAM_DECLS , uid_t owner, gid_t group, int flag -#define AT_FUNC_POST_FILE_ARGS , owner, group -#include "at-func.c" +# define AT_FUNC_NAME fchownat +# define AT_FUNC_F1 lchown +# define AT_FUNC_F2 chown +# define AT_FUNC_USE_F1_COND AT_SYMLINK_NOFOLLOW +# define AT_FUNC_POST_FILE_PARAM_DECLS , uid_t owner, gid_t group, int flag +# define AT_FUNC_POST_FILE_ARGS , owner, group +# include "at-func.c" +# undef AT_FUNC_NAME +# undef AT_FUNC_F1 +# undef AT_FUNC_F2 +# undef AT_FUNC_USE_F1_COND +# undef AT_FUNC_POST_FILE_PARAM_DECLS +# undef AT_FUNC_POST_FILE_ARGS + +#else /* HAVE_FCHOWNAT */ + +# undef fchownat + +# if FCHOWNAT_NOFOLLOW_BUG + +/* Failure to handle AT_SYMLINK_NOFOLLOW requires the /proc/self/fd or + fchdir workaround to call lchown for lchownat, but there is no need + to penalize chownat. */ +static int +local_lchownat (int fd, char const *file, uid_t owner, gid_t group); + +# define AT_FUNC_NAME local_lchownat +# define AT_FUNC_F1 lchown +# define AT_FUNC_POST_FILE_PARAM_DECLS , uid_t owner, gid_t group +# define AT_FUNC_POST_FILE_ARGS , owner, group +# include "at-func.c" +# undef AT_FUNC_NAME +# undef AT_FUNC_F1 +# undef AT_FUNC_POST_FILE_PARAM_DECLS +# undef AT_FUNC_POST_FILE_ARGS + +# endif + +/* Work around bugs with trailing slash, using the same workarounds as + chown and lchown. */ + +int +rpl_fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag) +{ +# if FCHOWNAT_NOFOLLOW_BUG + if (flag == AT_SYMLINK_NOFOLLOW) + return local_lchownat (fd, file, owner, group); +# endif +# if CHOWN_TRAILING_SLASH_BUG + { + size_t len = strlen (file); + struct stat st; + if (len && file[len - 1] == '/') + { + if (statat (fd, file, &st)) + return -1; + if (flag == AT_SYMLINK_NOFOLLOW) + return fchownat (fd, file, owner, group, 0); + } + } +# endif + return fchownat (fd, file, owner, group, flag); +} + +#endif /* HAVE_FCHOWNAT */ diff --git a/src/bin/coreutils/lib/fclose.c b/src/bin/coreutils/lib/fclose.c index a0074b77d7..9f4388912a 100644 --- a/src/bin/coreutils/lib/fclose.c +++ b/src/bin/coreutils/lib/fclose.c @@ -1,5 +1,5 @@ /* fclose replacement. - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/fcntl--.h b/src/bin/coreutils/lib/fcntl--.h index 588b69aab6..7baa2cbca6 100644 --- a/src/bin/coreutils/lib/fcntl--.h +++ b/src/bin/coreutils/lib/fcntl--.h @@ -1,6 +1,6 @@ /* Like fcntl.h, but redefine some names to avoid glitches. - Copyright (C) 2005, 2009 Free Software Foundation, Inc. + Copyright (C) 2005, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/fcntl-safer.h b/src/bin/coreutils/lib/fcntl-safer.h index 2b10ba68f4..5c76b4bce7 100644 --- a/src/bin/coreutils/lib/fcntl-safer.h +++ b/src/bin/coreutils/lib/fcntl-safer.h @@ -1,6 +1,6 @@ /* Invoke fcntl-like functions, but avoid some glitches. - Copyright (C) 2005, 2009 Free Software Foundation, Inc. + Copyright (C) 2005, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/fcntl.c b/src/bin/coreutils/lib/fcntl.c new file mode 100644 index 0000000000..c51e8ded56 --- /dev/null +++ b/src/bin/coreutils/lib/fcntl.c @@ -0,0 +1,294 @@ +/* Provide file descriptor control. + + Copyright (C) 2009, 2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Eric Blake . */ + +#include + +/* Specification. */ +#include + +#include +#include +#include +#include + +#if !HAVE_FCNTL +# define rpl_fcntl fcntl +#endif +#undef fcntl + +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +/* Get declarations of the Win32 API functions. */ +# define WIN32_LEAN_AND_MEAN +# include + +/* Upper bound on getdtablesize(). See lib/getdtablesize.c. */ +# define OPEN_MAX_MAX 0x10000 + +/* Duplicate OLDFD into the first available slot of at least NEWFD, + which must be positive, with FLAGS determining whether the duplicate + will be inheritable. */ +static int +dupfd (int oldfd, int newfd, int flags) +{ + /* Mingw has no way to create an arbitrary fd. Iterate until all + file descriptors less than newfd are filled up. */ + HANDLE curr_process = GetCurrentProcess (); + HANDLE old_handle = (HANDLE) _get_osfhandle (oldfd); + unsigned char fds_to_close[OPEN_MAX_MAX / CHAR_BIT]; + unsigned int fds_to_close_bound = 0; + int result; + BOOL inherit = flags & O_CLOEXEC ? FALSE : TRUE; + int mode; + + if (newfd < 0 || getdtablesize () <= newfd) + { + errno = EINVAL; + return -1; + } + if (old_handle == INVALID_HANDLE_VALUE + || (mode = setmode (oldfd, O_BINARY)) == -1) + { + /* oldfd is not open, or is an unassigned standard file + descriptor. */ + errno = EBADF; + return -1; + } + setmode (oldfd, mode); + flags |= mode; + + for (;;) + { + HANDLE new_handle; + int duplicated_fd; + unsigned int index; + + if (!DuplicateHandle (curr_process, /* SourceProcessHandle */ + old_handle, /* SourceHandle */ + curr_process, /* TargetProcessHandle */ + (PHANDLE) &new_handle, /* TargetHandle */ + (DWORD) 0, /* DesiredAccess */ + inherit, /* InheritHandle */ + DUPLICATE_SAME_ACCESS)) /* Options */ + { + /* TODO: Translate GetLastError () into errno. */ + errno = EMFILE; + result = -1; + break; + } + duplicated_fd = _open_osfhandle ((long) new_handle, flags); + if (duplicated_fd < 0) + { + CloseHandle (new_handle); + errno = EMFILE; + result = -1; + break; + } + if (newfd <= duplicated_fd) + { + result = duplicated_fd; + break; + } + + /* Set the bit duplicated_fd in fds_to_close[]. */ + index = (unsigned int) duplicated_fd / CHAR_BIT; + if (fds_to_close_bound <= index) + { + if (sizeof fds_to_close <= index) + /* Need to increase OPEN_MAX_MAX. */ + abort (); + memset (fds_to_close + fds_to_close_bound, '\0', + index + 1 - fds_to_close_bound); + fds_to_close_bound = index + 1; + } + fds_to_close[index] |= 1 << ((unsigned int) duplicated_fd % CHAR_BIT); + } + + /* Close the previous fds that turned out to be too small. */ + { + int saved_errno = errno; + unsigned int duplicated_fd; + + for (duplicated_fd = 0; + duplicated_fd < fds_to_close_bound * CHAR_BIT; + duplicated_fd++) + if ((fds_to_close[duplicated_fd / CHAR_BIT] + >> (duplicated_fd % CHAR_BIT)) + & 1) + close (duplicated_fd); + + errno = saved_errno; + } + +# if REPLACE_FCHDIR + if (0 <= result) + result = _gl_register_dup (oldfd, result); +# endif + return result; +} +#endif /* W32 */ + +/* Perform the specified ACTION on the file descriptor FD, possibly + using the argument ARG further described below. This replacement + handles the following actions, and forwards all others on to the + native fcntl. An unrecognized ACTION returns -1 with errno set to + EINVAL. + + F_DUPFD - duplicate FD, with int ARG being the minimum target fd. + If successful, return the duplicate, which will be inheritable; + otherwise return -1 and set errno. + + F_DUPFD_CLOEXEC - duplicate FD, with int ARG being the minimum + target fd. If successful, return the duplicate, which will not be + inheritable; otherwise return -1 and set errno. + + F_GETFD - ARG need not be present. If successful, return a + non-negative value containing the descriptor flags of FD (only + FD_CLOEXEC is portable, but other flags may be present); otherwise + return -1 and set errno. */ + +int +rpl_fcntl (int fd, int action, /* arg */...) +{ + va_list arg; + int result = -1; + va_start (arg, action); + switch (action) + { + +#if !HAVE_FCNTL + case F_DUPFD: + { + int target = va_arg (arg, int); + result = dupfd (fd, target, 0); + break; + } +#elif FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR + case F_DUPFD: + { + int target = va_arg (arg, int); + /* Detect invalid target; needed for cygwin 1.5.x. */ + if (target < 0 || getdtablesize () <= target) + errno = EINVAL; + else + { + result = fcntl (fd, action, target); +# if REPLACE_FCHDIR + if (0 <= result) + result = _gl_register_dup (fd, result); +# endif + } + break; + } /* F_DUPFD */ +#endif /* FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR */ + + case F_DUPFD_CLOEXEC: + { + int target = va_arg (arg, int); + +#if !HAVE_FCNTL + result = dupfd (fd, target, O_CLOEXEC); + break; +#else /* HAVE_FCNTL */ + /* Try the system call first, if the headers claim it exists + (that is, if GNULIB_defined_F_DUPFD_CLOEXEC is 0), since we + may be running with a glibc that has the macro but with an + older kernel that does not support it. Cache the + information on whether the system call really works, but + avoid caching failure if the corresponding F_DUPFD fails + for any reason. 0 = unknown, 1 = yes, -1 = no. */ + static int have_dupfd_cloexec = GNULIB_defined_F_DUPFD_CLOEXEC ? -1 : 0; + if (0 <= have_dupfd_cloexec) + { + result = fcntl (fd, action, target); + if (0 <= result || errno != EINVAL) + { + have_dupfd_cloexec = 1; +# if REPLACE_FCHDIR + if (0 <= result) + result = _gl_register_dup (fd, result); +# endif + } + else + { + result = rpl_fcntl (fd, F_DUPFD, target); + if (result < 0) + break; + have_dupfd_cloexec = -1; + } + } + else + result = rpl_fcntl (fd, F_DUPFD, target); + if (0 <= result && have_dupfd_cloexec == -1) + { + int flags = fcntl (result, F_GETFD); + if (flags < 0 || fcntl (result, F_SETFD, flags | FD_CLOEXEC) == -1) + { + int saved_errno = errno; + close (result); + errno = saved_errno; + result = -1; + } + } + break; +#endif /* HAVE_FCNTL */ + } /* F_DUPFD_CLOEXEC */ + +#if !HAVE_FCNTL + case F_GETFD: + { +# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ + HANDLE handle = (HANDLE) _get_osfhandle (fd); + DWORD flags; + if (handle == INVALID_HANDLE_VALUE + || GetHandleInformation (handle, &flags) == 0) + errno = EBADF; + else + result = (flags & HANDLE_FLAG_INHERIT) ? 0 : FD_CLOEXEC; +# else /* !W32 */ + /* Use dup2 to reject invalid file descriptors. No way to + access this information, so punt. */ + if (0 <= dup2 (fd, fd)) + result = 0; +# endif /* !W32 */ + break; + } /* F_GETFD */ +#endif /* !HAVE_FCNTL */ + + /* Implementing F_SETFD on mingw is not trivial - there is no + API for changing the O_NOINHERIT bit on an fd, and merely + changing the HANDLE_FLAG_INHERIT bit on the underlying handle + can lead to odd state. It may be possible by duplicating the + handle, using _open_osfhandle with the right flags, then + using dup2 to move the duplicate onto the original, but that + is not supported for now. */ + + default: + { +#if HAVE_FCNTL + void *p = va_arg (arg, void *); + result = fcntl (fd, action, p); +#else + errno = EINVAL; +#endif + break; + } + } + va_end (arg); + return result; +} diff --git a/src/bin/coreutils/lib/fcntl.h b/src/bin/coreutils/lib/fcntl.h index 3766860f53..062fb60e09 100644 --- a/src/bin/coreutils/lib/fcntl.h +++ b/src/bin/coreutils/lib/fcntl.h @@ -1,12 +1,12 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Like , but with non-working flags defined to 0. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006-2010 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,24 +14,179 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + along with this program. If not, see . */ /* written by Paul Eggert */ +#if __GNUC__ >= 3 +#pragma GCC system_header +#endif + +#if defined __need_system_fcntl_h +/* Special invocation convention. */ + +#include +#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */ +# include +# include +#endif +#include_next + +#else +/* Normal invocation convention. */ + +#ifndef _GL_FCNTL_H + +#include +#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */ +# include +# include +#endif +/* The include_next requires a split double-inclusion guard. */ +#include_next + #ifndef _GL_FCNTL_H #define _GL_FCNTL_H -#include -#include -#include -#include_next "fcntl.h" + +/* The definition of GL_LINK_WARNING is copied here. */ +/* GL_LINK_WARNING("literal string") arranges to emit the literal string as + a linker warning on most glibc systems. + We use a linker warning rather than a preprocessor warning, because + #warning cannot be used inside macros. */ +#ifndef GL_LINK_WARNING + /* This works on platforms with GNU ld and ELF object format. + Testing __GLIBC__ is sufficient for asserting that GNU ld is in use. + Testing __ELF__ guarantees the ELF object format. + Testing __GNUC__ is necessary for the compound expression syntax. */ +# if defined __GLIBC__ && defined __ELF__ && defined __GNUC__ +# define GL_LINK_WARNING(message) \ + GL_LINK_WARNING1 (__FILE__, __LINE__, message) +# define GL_LINK_WARNING1(file, line, message) \ + GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */ +# define GL_LINK_WARNING2(file, line, message) \ + GL_LINK_WARNING3 (file ":" #line ": warning: " message) +# define GL_LINK_WARNING3(message) \ + ({ static const char warning[sizeof (message)] \ + __attribute__ ((__unused__, \ + __section__ (".gnu.warning"), \ + __aligned__ (1))) \ + = message "\n"; \ + (void)0; \ + }) +# else +# define GL_LINK_WARNING(message) ((void) 0) +# endif +#endif + +/* The definition of _GL_ARG_NONNULL is copied here. */ +/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools + that the values passed as arguments n, ..., m must be non-NULL pointers. + n = 1 stands for the first argument, n = 2 for the second argument etc. */ +#ifndef _GL_ARG_NONNULL +# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 +# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) +# else +# define _GL_ARG_NONNULL(params) +# endif +#endif + + +/* Declare overridden functions. */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if 1 +# if 1 +# undef fcntl +# define fcntl rpl_fcntl +# endif +# if !1 || 1 +extern int fcntl (int fd, int action, ...); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fcntl +# define fcntl \ + (GL_LINK_WARNING ("fcntl is not always POSIX compliant - " \ + "use gnulib module fcntl for portability"), \ + fcntl) +#endif + +#if 1 +# if 1 +# undef open +# define open rpl_open +extern int open (const char *filename, int flags, ...) _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef open +# define open \ + (GL_LINK_WARNING ("open is not always POSIX compliant - " \ + "use gnulib module open for portability"), \ + open) +#endif + +#if 1 +# if 1 +# undef openat +# define openat rpl_openat +# endif +# if !1 || 1 +extern int openat (int fd, char const *file, int flags, /* mode_t mode */ ...) + _GL_ARG_NONNULL ((2)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef openat +# define openat \ + (GL_LINK_WARNING ("openat is not portable - " \ + "use gnulib module openat for portability"), \ + openat) +#endif + +#ifdef __cplusplus +} +#endif + +/* Fix up the FD_* macros, only known to be missing on mingw. */ + +#ifndef FD_CLOEXEC +# define FD_CLOEXEC 1 +#endif + +/* Fix up the supported F_* macros. Intentionally leave other F_* + macros undefined. Only known to be missing on mingw. */ + +#ifndef F_DUPFD_CLOEXEC +# define F_DUPFD_CLOEXEC 0x40000000 +/* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise. */ +# define GNULIB_defined_F_DUPFD_CLOEXEC 1 +#else +# define GNULIB_defined_F_DUPFD_CLOEXEC 0 +#endif + +#ifndef F_DUPFD +# define F_DUPFD 1 +#endif + +#ifndef F_GETFD +# define F_GETFD 2 +#endif + +/* Fix up the O_* macros. */ #if !defined O_DIRECT && defined O_DIRECTIO /* Tru64 spells it `O_DIRECTIO'. */ # define O_DIRECT O_DIRECTIO #endif +#if !defined O_CLOEXEC && defined O_NOINHERIT +/* Mingw spells it `O_NOINHERIT'. Intentionally leave it + undefined if not available. */ +# define O_CLOEXEC O_NOINHERIT +#endif + #ifndef O_DIRECT # define O_DIRECT 0 #endif @@ -76,6 +231,10 @@ # define O_SYNC 0 #endif +#ifndef O_TTY_INIT +# define O_TTY_INIT 0 +#endif + /* For systems that distinguish between text and binary I/O. O_BINARY is usually declared in fcntl.h */ #if !defined O_BINARY && defined _O_BINARY @@ -84,8 +243,8 @@ # define O_TEXT _O_TEXT #endif -#if (defined(__BEOS__) || defined(__HAIKU__)) - /* BeOS 5 has O_BINARY and O_TEXT, but they have no effect. */ +#if defined __BEOS__ || defined __HAIKU__ + /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect. */ # undef O_BINARY # undef O_TEXT #endif @@ -95,4 +254,43 @@ # define O_TEXT 0 #endif +/* Fix up the AT_* macros. */ + +/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its + value exceeds INT_MAX, so its use as an int doesn't conform to the + C standard, and GCC and Sun C complain in some cases. If the bug + is present, undef AT_FDCWD here, so it can be redefined below. */ +#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553 +# undef AT_FDCWD +#endif + +/* Use the same bit pattern as Solaris 9, but with the proper + signedness. The bit pattern is important, in case this actually is + Solaris with the above workaround. */ +#ifndef AT_FDCWD +# define AT_FDCWD (-3041965) +#endif + +/* Use the same values as Solaris 9. This shouldn't matter, but + there's no real reason to differ. */ +#ifndef AT_SYMLINK_NOFOLLOW +# define AT_SYMLINK_NOFOLLOW 4096 +#endif + +#ifndef AT_REMOVEDIR +# define AT_REMOVEDIR 1 +#endif + +/* Solaris 9 lacks these two, so just pick unique values. */ +#ifndef AT_SYMLINK_FOLLOW +# define AT_SYMLINK_FOLLOW 2 +#endif + +#ifndef AT_EACCESS +# define AT_EACCESS 4 +#endif + + +#endif /* _GL_FCNTL_H */ +#endif /* _GL_FCNTL_H */ #endif diff --git a/src/bin/coreutils/lib/fcntl.in.h b/src/bin/coreutils/lib/fcntl.in.h index cadb6a1572..92bb50d5c6 100644 --- a/src/bin/coreutils/lib/fcntl.in.h +++ b/src/bin/coreutils/lib/fcntl.in.h @@ -1,6 +1,6 @@ /* Like , but with non-working flags defined to 0. - Copyright (C) 2006-2009 Free Software Foundation, Inc. + Copyright (C) 2006-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,8 +25,10 @@ /* Special invocation convention. */ #include -#include -#include +#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */ +# include +# include +#endif #@INCLUDE_NEXT@ @NEXT_FCNTL_H@ #else @@ -35,8 +37,10 @@ #ifndef _GL_FCNTL_H #include -#include -#include +#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */ +# include +# include +#endif /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_FCNTL_H@ @@ -46,6 +50,8 @@ /* The definition of GL_LINK_WARNING is copied here. */ +/* The definition of _GL_ARG_NONNULL is copied here. */ + /* Declare overridden functions. */ @@ -53,23 +59,48 @@ extern "C" { #endif +#if @GNULIB_FCNTL@ +# if @REPLACE_FCNTL@ +# undef fcntl +# define fcntl rpl_fcntl +# endif +# if !@HAVE_FCNTL@ || @REPLACE_FCNTL@ +extern int fcntl (int fd, int action, ...); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fcntl +# define fcntl \ + (GL_LINK_WARNING ("fcntl is not always POSIX compliant - " \ + "use gnulib module fcntl for portability"), \ + fcntl) +#endif + #if @GNULIB_OPEN@ # if @REPLACE_OPEN@ # undef open # define open rpl_open -extern int open (const char *filename, int flags, ...); +extern int open (const char *filename, int flags, ...) _GL_ARG_NONNULL ((1)); # endif +#elif defined GNULIB_POSIXCHECK +# undef open +# define open \ + (GL_LINK_WARNING ("open is not always POSIX compliant - " \ + "use gnulib module open for portability"), \ + open) #endif #if @GNULIB_OPENAT@ -# if !@HAVE_OPENAT@ +# if @REPLACE_OPENAT@ # undef openat # define openat rpl_openat -int openat (int fd, char const *file, int flags, /* mode_t mode */ ...); +# endif +# if !@HAVE_OPENAT@ || @REPLACE_OPENAT@ +extern int openat (int fd, char const *file, int flags, /* mode_t mode */ ...) + _GL_ARG_NONNULL ((2)); # endif #elif defined GNULIB_POSIXCHECK # undef openat -# define openat(f,u,g) \ +# define openat \ (GL_LINK_WARNING ("openat is not portable - " \ "use gnulib module openat for portability"), \ openat) @@ -79,12 +110,31 @@ int openat (int fd, char const *file, int flags, /* mode_t mode */ ...); } #endif -/* Fix up the FD_* macros. */ +/* Fix up the FD_* macros, only known to be missing on mingw. */ #ifndef FD_CLOEXEC # define FD_CLOEXEC 1 #endif +/* Fix up the supported F_* macros. Intentionally leave other F_* + macros undefined. Only known to be missing on mingw. */ + +#ifndef F_DUPFD_CLOEXEC +# define F_DUPFD_CLOEXEC 0x40000000 +/* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise. */ +# define GNULIB_defined_F_DUPFD_CLOEXEC 1 +#else +# define GNULIB_defined_F_DUPFD_CLOEXEC 0 +#endif + +#ifndef F_DUPFD +# define F_DUPFD 1 +#endif + +#ifndef F_GETFD +# define F_GETFD 2 +#endif + /* Fix up the O_* macros. */ #if !defined O_DIRECT && defined O_DIRECTIO diff --git a/src/bin/coreutils/lib/fd-reopen.c b/src/bin/coreutils/lib/fd-reopen.c index de5f63d1dc..1ee0dd9d62 100644 --- a/src/bin/coreutils/lib/fd-reopen.c +++ b/src/bin/coreutils/lib/fd-reopen.c @@ -1,6 +1,6 @@ /* Invoke open, but return either a desired file descriptor or -1. - Copyright (C) 2005, 2006, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/fd-reopen.h b/src/bin/coreutils/lib/fd-reopen.h index 014466fdeb..7834af2d8b 100644 --- a/src/bin/coreutils/lib/fd-reopen.h +++ b/src/bin/coreutils/lib/fd-reopen.h @@ -1,6 +1,6 @@ /* Invoke open, but return either a desired file descriptor or -1. - Copyright (C) 2005, 2009 Free Software Foundation, Inc. + Copyright (C) 2005, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/fd-safer-flag.c b/src/bin/coreutils/lib/fd-safer-flag.c new file mode 100644 index 0000000000..0e3019b89b --- /dev/null +++ b/src/bin/coreutils/lib/fd-safer-flag.c @@ -0,0 +1,52 @@ +/* Adjust a file descriptor result so that it avoids clobbering + STD{IN,OUT,ERR}_FILENO, with specific flags. + + Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Paul Eggert and Eric Blake. */ + +#include + +/* Specification. */ +#include "unistd-safer.h" + +#include +#include + +/* Return FD, unless FD would be a copy of standard input, output, or + error; in that case, return a duplicate of FD, closing FD. If FLAG + contains O_CLOEXEC, the returned FD will have close-on-exec + semantics. On failure to duplicate, close FD, set errno, and + return -1. Preserve errno if FD is negative, so that the caller + can always inspect errno when the returned value is negative. + + This function is usefully wrapped around functions that return file + descriptors, e.g., fd_safer_flag (open ("file", O_RDONLY | flag), flag). */ + +int +fd_safer_flag (int fd, int flag) +{ + if (STDIN_FILENO <= fd && fd <= STDERR_FILENO) + { + int f = dup_safer_flag (fd, flag); + int e = errno; + close (fd); + errno = e; + fd = f; + } + + return fd; +} diff --git a/src/bin/coreutils/lib/fd-safer.c b/src/bin/coreutils/lib/fd-safer.c index fb9900180e..c1c6000512 100644 --- a/src/bin/coreutils/lib/fd-safer.c +++ b/src/bin/coreutils/lib/fd-safer.c @@ -1,6 +1,6 @@ /* Return a safer copy of a file descriptor. - Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,7 +22,6 @@ #include "unistd-safer.h" #include - #include /* Return FD, unless FD would be a copy of standard input, output, or diff --git a/src/bin/coreutils/lib/fdopendir.c b/src/bin/coreutils/lib/fdopendir.c index 14dc111c81..f7b29af30c 100644 --- a/src/bin/coreutils/lib/fdopendir.c +++ b/src/bin/coreutils/lib/fdopendir.c @@ -1,5 +1,5 @@ /* provide a replacement fdopendir function - Copyright (C) 2004-2009 Free Software Foundation, Inc. + Copyright (C) 2004-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,13 +23,15 @@ #include #include -#include "openat.h" -#include "openat-priv.h" -#include "save-cwd.h" +#if !HAVE_FDOPENDIR -#if GNULIB_DIRENT_SAFER -# include "dirent--.h" -#endif +# include "openat.h" +# include "openat-priv.h" +# include "save-cwd.h" + +# if GNULIB_DIRENT_SAFER +# include "dirent--.h" +# endif /* Replacement for Solaris' function by the same name. @@ -70,32 +72,32 @@ fdopendir (int fd) save_cwd/restore_cwd. */ if (! dir && EXPECTED_ERRNO (saved_errno)) { -#if REPLACE_FCHDIR +# if REPLACE_FCHDIR const char *name = _gl_directory_name (fd); if (name) dir = opendir (name); saved_errno = errno; -#else /* !REPLACE_FCHDIR */ +# else /* !REPLACE_FCHDIR */ struct saved_cwd saved_cwd; if (save_cwd (&saved_cwd) != 0) - openat_save_fail (errno); + openat_save_fail (errno); if (fchdir (fd) != 0) - { - dir = NULL; - saved_errno = errno; - } + { + dir = NULL; + saved_errno = errno; + } else - { - dir = opendir ("."); - saved_errno = errno; + { + dir = opendir ("."); + saved_errno = errno; - if (restore_cwd (&saved_cwd) != 0) - openat_restore_fail (errno); - } + if (restore_cwd (&saved_cwd) != 0) + openat_restore_fail (errno); + } free_cwd (&saved_cwd); -#endif /* !REPLACE_FCHDIR */ +# endif /* !REPLACE_FCHDIR */ } if (dir) @@ -105,3 +107,28 @@ fdopendir (int fd) errno = saved_errno; return dir; } + +#else /* HAVE_FDOPENDIR */ + +# include +# include + +# undef fdopendir + +/* Like fdopendir, but work around GNU/Hurd bug by validating FD. */ + +DIR * +rpl_fdopendir (int fd) +{ + struct stat st; + if (fstat (fd, &st)) + return NULL; + if (!S_ISDIR (st.st_mode)) + { + errno = ENOTDIR; + return NULL; + } + return fdopendir (fd); +} + +#endif /* HAVE_FDOPENDIR */ diff --git a/src/bin/coreutils/lib/fflush.c b/src/bin/coreutils/lib/fflush.c index 7c6085cfd8..ead4875498 100644 --- a/src/bin/coreutils/lib/fflush.c +++ b/src/bin/coreutils/lib/fflush.c @@ -1,5 +1,5 @@ /* fflush.c -- allow flushing input streams - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -39,7 +39,7 @@ clear_ungetc_buffer_preserving_position (FILE *fp) { if (fp->_flags & _IO_IN_BACKUP) /* _IO_free_backup_area is a bit complicated. Simply call fseek. */ - fseek (fp, 0, SEEK_CUR); + fseeko (fp, 0, SEEK_CUR); } #else @@ -63,7 +63,7 @@ clear_ungetc_buffer (FILE *fp) # elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw */ /* Nothing to do. */ # else /* other implementations */ - fseek (fp, 0, SEEK_CUR); + fseeko (fp, 0, SEEK_CUR); # endif } @@ -91,7 +91,22 @@ static inline void update_fpos_cache (FILE *fp, off_t pos) { #if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */ +# if defined __CYGWIN__ + /* fp_->_offset is typed as an integer. */ fp_->_offset = pos; +# else + /* fp_->_offset is an fpos_t. */ + /* Use a union, since on NetBSD, the compilation flags determine + whether fpos_t is typedef'd to off_t or a struct containing a + single off_t member. */ + union + { + fpos_t f; + off_t o; + } u; + u.o = pos; + fp_->_offset = u.f; +# endif fp_->_flags |= __SOFF; #endif } diff --git a/src/bin/coreutils/lib/file-has-acl.c b/src/bin/coreutils/lib/file-has-acl.c index c3b77c395f..92aa07ed05 100644 --- a/src/bin/coreutils/lib/file-has-acl.c +++ b/src/bin/coreutils/lib/file-has-acl.c @@ -1,6 +1,6 @@ /* Test whether a file has a nontrivial access control list. - Copyright (C) 2002-2003, 2005-2009 Free Software Foundation, Inc. + Copyright (C) 2002-2003, 2005-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -50,7 +50,7 @@ acl_access_nontrivial (acl_t acl) /* acl is non-trivial if it has some entries other than for "user::", "group::", and "other::". Normally these three should be present at least, allowing us to write - return (3 < acl_entries (acl)); + return (3 < acl_entries (acl)); but the following code is more robust. */ # if HAVE_ACL_FIRST_ENTRY /* Linux, FreeBSD */ @@ -63,9 +63,9 @@ acl_access_nontrivial (acl_t acl) { acl_tag_t tag; if (acl_get_tag_type (ace, &tag) < 0) - return -1; + return -1; if (!(tag == ACL_USER_OBJ || tag == ACL_GROUP_OBJ || tag == ACL_OTHER)) - return 1; + return 1; } return got_one; @@ -82,8 +82,8 @@ acl_access_nontrivial (acl_t acl) acl_tag_t tag = ace->ae_tag; if (!(tag == ACL_USER_OBJ || tag == ACL_GROUP_OBJ - || tag == ACL_OTHER_OBJ)) - return 1; + || tag == ACL_OTHER_OBJ)) + return 1; } return 0; @@ -101,13 +101,13 @@ acl_access_nontrivial (acl_t acl) tag = ace->entry->acl_type; if (!(tag == ACL_USER_OBJ || tag == ACL_GROUP_OBJ || tag == ACL_OTHER)) - return 1; + return 1; perm = ace->entry->acl_perm; /* On Tru64, perm can also contain non-standard bits such as - PERM_INSERT, PERM_DELETE, PERM_MODIFY, PERM_LOOKUP, ... */ + PERM_INSERT, PERM_DELETE, PERM_MODIFY, PERM_LOOKUP, ... */ if ((perm & ~(ACL_READ | ACL_WRITE | ACL_EXECUTE)) != 0) - return 1; + return 1; } return 0; @@ -135,15 +135,15 @@ acl_nontrivial (int count, aclent_t *entries) aclent_t *ace = &entries[i]; /* Note: If ace->a_type = USER_OBJ, ace->a_id is the st_uid from stat(). - If ace->a_type = GROUP_OBJ, ace->a_id is the st_gid from stat(). - We don't need to check ace->a_id in these cases. */ + If ace->a_type = GROUP_OBJ, ace->a_id is the st_gid from stat(). + We don't need to check ace->a_id in these cases. */ if (!(ace->a_type == USER_OBJ - || ace->a_type == GROUP_OBJ - || ace->a_type == OTHER_OBJ - /* Note: Cygwin does not return a CLASS_OBJ ("mask:") entry - sometimes. */ - || ace->a_type == CLASS_OBJ)) - return 1; + || ace->a_type == GROUP_OBJ + || ace->a_type == OTHER_OBJ + /* Note: Cygwin does not return a CLASS_OBJ ("mask:") entry + sometimes. */ + || ace->a_type == CLASS_OBJ)) + return 1; } return 0; } @@ -169,41 +169,41 @@ acl_ace_nontrivial (int count, ace_t *entries) for (i = 0; i < count; i++) if (entries[i].a_flags & (ACE_OWNER | ACE_GROUP | ACE_OTHER)) { - old_convention = 1; - break; + old_convention = 1; + break; } if (old_convention) /* Running on Solaris 10. */ for (i = 0; i < count; i++) { - ace_t *ace = &entries[i]; + ace_t *ace = &entries[i]; - /* Note: - If ace->a_flags = ACE_OWNER, ace->a_who is the st_uid from stat(). - If ace->a_flags = ACE_GROUP, ace->a_who is the st_gid from stat(). - We don't need to check ace->a_who in these cases. */ - if (!(ace->a_type == ALLOW - && (ace->a_flags == ACE_OWNER - || ace->a_flags == ACE_GROUP - || ace->a_flags == ACE_OTHER))) - return 1; + /* Note: + If ace->a_flags = ACE_OWNER, ace->a_who is the st_uid from stat(). + If ace->a_flags = ACE_GROUP, ace->a_who is the st_gid from stat(). + We don't need to check ace->a_who in these cases. */ + if (!(ace->a_type == ALLOW + && (ace->a_flags == ACE_OWNER + || ace->a_flags == ACE_GROUP + || ace->a_flags == ACE_OTHER))) + return 1; } else /* Running on Solaris 10 (newer version) or Solaris 11. */ for (i = 0; i < count; i++) { - ace_t *ace = &entries[i]; + ace_t *ace = &entries[i]; - if (!(ace->a_type == ACE_ACCESS_ALLOWED_ACE_TYPE - && (ace->a_flags == NEW_ACE_OWNER - || ace->a_flags - == (NEW_ACE_GROUP | NEW_ACE_IDENTIFIER_GROUP) - || ace->a_flags == ACE_EVERYONE) - && (ace->a_access_mask - & ~(NEW_ACE_READ_DATA | NEW_ACE_WRITE_DATA | NEW_ACE_EXECUTE)) - == 0)) - return 1; + if (!(ace->a_type == ACE_ACCESS_ALLOWED_ACE_TYPE + && (ace->a_flags == NEW_ACE_OWNER + || ace->a_flags + == (NEW_ACE_GROUP | NEW_ACE_IDENTIFIER_GROUP) + || ace->a_flags == ACE_EVERYONE) + && (ace->a_access_mask + & ~(NEW_ACE_READ_DATA | NEW_ACE_WRITE_DATA | NEW_ACE_EXECUTE)) + == 0)) + return 1; } return 0; @@ -227,18 +227,14 @@ acl_nontrivial (int count, struct acl_entry *entries, struct stat *sb) struct acl_entry *ace = &entries[i]; if (!((ace->uid == sb->st_uid && ace->gid == ACL_NSGROUP) - || (ace->uid == ACL_NSUSER && ace->gid == sb->st_gid) - || (ace->uid == ACL_NSUSER && ace->gid == ACL_NSGROUP))) - return 1; + || (ace->uid == ACL_NSUSER && ace->gid == sb->st_gid) + || (ace->uid == ACL_NSUSER && ace->gid == ACL_NSGROUP))) + return 1; } return 0; } -#elif USE_ACL && HAVE_ACLX_GET && 0 /* AIX */ - -/* TODO */ - -#elif USE_ACL && HAVE_STATACL /* older AIX */ +#elif USE_ACL && (HAVE_ACLX_GET || HAVE_STATACL) /* AIX */ /* Return 1 if the given ACL is non-trivial. Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */ @@ -264,6 +260,40 @@ acl_nontrivial (struct acl *a) return (acl_last (a) != a->acl_ext ? 1 : 0); } +# if HAVE_ACLX_GET && defined ACL_AIX_WIP /* newer AIX */ + +/* Return 1 if the given ACL is non-trivial. + Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */ +int +acl_nfs4_nontrivial (nfs4_acl_int_t *a) +{ +# if 1 /* let's try this first */ + return (a->aclEntryN > 0 ? 1 : 0); +# else + int count = a->aclEntryN; + int i; + + for (i = 0; i < count; i++) + { + nfs4_ace_int_t *ace = &a->aclEntry[i]; + + if (!((ace->flags & ACE4_ID_SPECIAL) != 0 + && (ace->aceWho.special_whoid == ACE4_WHO_OWNER + || ace->aceWho.special_whoid == ACE4_WHO_GROUP + || ace->aceWho.special_whoid == ACE4_WHO_EVERYONE) + && ace->aceType == ACE4_ACCESS_ALLOWED_ACE_TYPE + && ace->aceFlags == 0 + && (ace->aceMask & ~(ACE4_READ_DATA | ACE4_LIST_DIRECTORY + | ACE4_WRITE_DATA | ACE4_ADD_FILE + | ACE4_EXECUTE)) == 0)) + return 1; + } + return 0; +# endif +} + +# endif + #endif @@ -284,67 +314,67 @@ file_has_acl (char const *name, struct stat const *sb) int ret; if (HAVE_ACL_EXTENDED_FILE) /* Linux */ - { - /* On Linux, acl_extended_file is an optimized function: It only - makes two calls to getxattr(), one for ACL_TYPE_ACCESS, one for - ACL_TYPE_DEFAULT. */ - ret = acl_extended_file (name); - } + { + /* On Linux, acl_extended_file is an optimized function: It only + makes two calls to getxattr(), one for ACL_TYPE_ACCESS, one for + ACL_TYPE_DEFAULT. */ + ret = acl_extended_file (name); + } else /* FreeBSD, MacOS X, IRIX, Tru64 */ - { + { # if HAVE_ACL_TYPE_EXTENDED /* MacOS X */ - /* On MacOS X, acl_get_file (name, ACL_TYPE_ACCESS) - and acl_get_file (name, ACL_TYPE_DEFAULT) - always return NULL / EINVAL. There is no point in making - these two useless calls. The real ACL is retrieved through - acl_get_file (name, ACL_TYPE_EXTENDED). */ - acl_t acl = acl_get_file (name, ACL_TYPE_EXTENDED); - if (acl) - { - ret = acl_extended_nontrivial (acl); - acl_free (acl); - } - else - ret = -1; + /* On MacOS X, acl_get_file (name, ACL_TYPE_ACCESS) + and acl_get_file (name, ACL_TYPE_DEFAULT) + always return NULL / EINVAL. There is no point in making + these two useless calls. The real ACL is retrieved through + acl_get_file (name, ACL_TYPE_EXTENDED). */ + acl_t acl = acl_get_file (name, ACL_TYPE_EXTENDED); + if (acl) + { + ret = acl_extended_nontrivial (acl); + acl_free (acl); + } + else + ret = -1; # else /* FreeBSD, IRIX, Tru64 */ - acl_t acl = acl_get_file (name, ACL_TYPE_ACCESS); - if (acl) - { - int saved_errno; + acl_t acl = acl_get_file (name, ACL_TYPE_ACCESS); + if (acl) + { + int saved_errno; - ret = acl_access_nontrivial (acl); - saved_errno = errno; - acl_free (acl); - errno = saved_errno; + ret = acl_access_nontrivial (acl); + saved_errno = errno; + acl_free (acl); + errno = saved_errno; # if HAVE_ACL_FREE_TEXT /* Tru64 */ - /* On OSF/1, acl_get_file (name, ACL_TYPE_DEFAULT) always - returns NULL with errno not set. There is no point in - making this call. */ + /* On OSF/1, acl_get_file (name, ACL_TYPE_DEFAULT) always + returns NULL with errno not set. There is no point in + making this call. */ # else /* FreeBSD, IRIX */ - /* On Linux, FreeBSD, IRIX, acl_get_file (name, ACL_TYPE_ACCESS) - and acl_get_file (name, ACL_TYPE_DEFAULT) on a directory - either both succeed or both fail; it depends on the - filesystem. Therefore there is no point in making the second - call if the first one already failed. */ - if (ret == 0 && S_ISDIR (sb->st_mode)) - { - acl = acl_get_file (name, ACL_TYPE_DEFAULT); - if (acl) - { - ret = (0 < acl_entries (acl)); - acl_free (acl); - } - else - ret = -1; - } + /* On Linux, FreeBSD, IRIX, acl_get_file (name, ACL_TYPE_ACCESS) + and acl_get_file (name, ACL_TYPE_DEFAULT) on a directory + either both succeed or both fail; it depends on the + file system. Therefore there is no point in making the second + call if the first one already failed. */ + if (ret == 0 && S_ISDIR (sb->st_mode)) + { + acl = acl_get_file (name, ACL_TYPE_DEFAULT); + if (acl) + { + ret = (0 < acl_entries (acl)); + acl_free (acl); + } + else + ret = -1; + } # endif - } - else - ret = -1; + } + else + ret = -1; # endif - } + } if (ret < 0) - return ACL_NOT_WELL_SUPPORTED (errno) ? 0 : -1; + return ACL_NOT_WELL_SUPPORTED (errno) ? 0 : -1; return ret; # elif HAVE_ACL && defined GETACLCNT /* Solaris, Cygwin, not HP-UX */ @@ -352,109 +382,109 @@ file_has_acl (char const *name, struct stat const *sb) # if defined ACL_NO_TRIVIAL /* Solaris 10 (newer version), which has additional API declared in - (acl_t) and implemented in libsec (acl_set, acl_trivial, - acl_fromtext, ...). */ + (acl_t) and implemented in libsec (acl_set, acl_trivial, + acl_fromtext, ...). */ return acl_trivial (name); # else /* Solaris, Cygwin, general case */ /* Solaris 2.5 through Solaris 10, Cygwin, and contemporaneous versions - of Unixware. The acl() call returns the access and default ACL both - at once. */ + of Unixware. The acl() call returns the access and default ACL both + at once. */ int count; { - aclent_t *entries; + aclent_t *entries; - for (;;) - { - count = acl (name, GETACLCNT, 0, NULL); + for (;;) + { + count = acl (name, GETACLCNT, 0, NULL); - if (count < 0) - { - if (errno == ENOSYS || errno == ENOTSUP) - break; - else - return -1; - } + if (count < 0) + { + if (errno == ENOSYS || errno == ENOTSUP) + break; + else + return -1; + } - if (count == 0) - break; + if (count == 0) + break; - /* Don't use MIN_ACL_ENTRIES: It's set to 4 on Cygwin, but Cygwin - returns only 3 entries for files with no ACL. But this is safe: - If there are more than 4 entries, there cannot be only the - "user::", "group::", "other:", and "mask:" entries. */ - if (count > 4) - return 1; + /* Don't use MIN_ACL_ENTRIES: It's set to 4 on Cygwin, but Cygwin + returns only 3 entries for files with no ACL. But this is safe: + If there are more than 4 entries, there cannot be only the + "user::", "group::", "other:", and "mask:" entries. */ + if (count > 4) + return 1; - entries = (aclent_t *) malloc (count * sizeof (aclent_t)); - if (entries == NULL) - { - errno = ENOMEM; - return -1; - } - if (acl (name, GETACL, count, entries) == count) - { - if (acl_nontrivial (count, entries)) - { - free (entries); - return 1; - } - free (entries); - break; - } - /* Huh? The number of ACL entries changed since the last call. - Repeat. */ - free (entries); - } + entries = (aclent_t *) malloc (count * sizeof (aclent_t)); + if (entries == NULL) + { + errno = ENOMEM; + return -1; + } + if (acl (name, GETACL, count, entries) == count) + { + if (acl_nontrivial (count, entries)) + { + free (entries); + return 1; + } + free (entries); + break; + } + /* Huh? The number of ACL entries changed since the last call. + Repeat. */ + free (entries); + } } # ifdef ACE_GETACL /* Solaris also has a different variant of ACLs, used in ZFS and NFSv4 - file systems (whereas the other ones are used in UFS file systems). */ + file systems (whereas the other ones are used in UFS file systems). */ { - ace_t *entries; + ace_t *entries; - for (;;) - { - count = acl (name, ACE_GETACLCNT, 0, NULL); + for (;;) + { + count = acl (name, ACE_GETACLCNT, 0, NULL); - if (count < 0) - { - if (errno == ENOSYS || errno == EINVAL) - break; - else - return -1; - } + if (count < 0) + { + if (errno == ENOSYS || errno == EINVAL) + break; + else + return -1; + } - if (count == 0) - break; + if (count == 0) + break; - /* If there are more than 3 entries, there cannot be only the - ACE_OWNER, ACE_GROUP, ACE_OTHER entries. */ - if (count > 3) - return 1; + /* If there are more than 3 entries, there cannot be only the + ACE_OWNER, ACE_GROUP, ACE_OTHER entries. */ + if (count > 3) + return 1; - entries = (ace_t *) malloc (count * sizeof (ace_t)); - if (entries == NULL) - { - errno = ENOMEM; - return -1; - } - if (acl (name, ACE_GETACL, count, entries) == count) - { - if (acl_ace_nontrivial (count, entries)) - { - free (entries); - return 1; - } - free (entries); - break; - } - /* Huh? The number of ACL entries changed since the last call. - Repeat. */ - free (entries); - } + entries = (ace_t *) malloc (count * sizeof (ace_t)); + if (entries == NULL) + { + errno = ENOMEM; + return -1; + } + if (acl (name, ACE_GETACL, count, entries) == count) + { + if (acl_ace_nontrivial (count, entries)) + { + free (entries); + return 1; + } + free (entries); + break; + } + /* Huh? The number of ACL entries changed since the last call. + Repeat. */ + free (entries); + } } # endif @@ -467,48 +497,104 @@ file_has_acl (char const *name, struct stat const *sb) struct acl_entry entries[NACLENTRIES]; for (;;) - { - count = getacl (name, 0, NULL); + { + count = getacl (name, 0, NULL); - if (count < 0) - return (errno == ENOSYS || errno == EOPNOTSUPP ? 0 : -1); + if (count < 0) + return (errno == ENOSYS || errno == EOPNOTSUPP ? 0 : -1); - if (count == 0) - return 0; + if (count == 0) + return 0; - if (count > NACLENTRIES) - /* If NACLENTRIES cannot be trusted, use dynamic memory - allocation. */ - abort (); + if (count > NACLENTRIES) + /* If NACLENTRIES cannot be trusted, use dynamic memory + allocation. */ + abort (); - /* If there are more than 3 entries, there cannot be only the - (uid,%), (%,gid), (%,%) entries. */ - if (count > 3) - return 1; + /* If there are more than 3 entries, there cannot be only the + (uid,%), (%,gid), (%,%) entries. */ + if (count > 3) + return 1; - if (getacl (name, count, entries) == count) - { - struct stat statbuf; + if (getacl (name, count, entries) == count) + { + struct stat statbuf; - if (stat (name, &statbuf) < 0) - return -1; + if (stat (name, &statbuf) < 0) + return -1; - return acl_nontrivial (count, entries, &statbuf); - } - /* Huh? The number of ACL entries changed since the last call. - Repeat. */ - } + return acl_nontrivial (count, entries, &statbuf); + } + /* Huh? The number of ACL entries changed since the last call. + Repeat. */ + } -# elif HAVE_ACLX_GET && 0 /* AIX */ +# elif HAVE_ACLX_GET && defined ACL_AIX_WIP /* AIX */ - /* TODO: use aclx_get(), and then? */ + acl_type_t type; + char aclbuf[1024]; + void *acl = aclbuf; + size_t aclsize = sizeof (aclbuf); + mode_t mode; + + for (;;) + { + /* The docs say that type being 0 is equivalent to ACL_ANY, but it + is not true, in AIX 5.3. */ + type.u64 = ACL_ANY; + if (aclx_get (name, 0, &type, aclbuf, &aclsize, &mode) >= 0) + break; + if (errno != ENOSPC) + { + if (acl != aclbuf) + { + int saved_errno = errno; + free (acl); + errno = saved_errno; + } + return -1; + } + aclsize = 2 * aclsize; + if (acl != aclbuf) + free (acl); + acl = malloc (aclsize); + if (acl == NULL) + { + errno = ENOMEM; + return -1; + } + } + + if (type.u64 == ACL_AIXC) + { + int result = acl_nontrivial ((struct acl *) acl); + if (acl != aclbuf) + free (acl); + return result; + } + else if (type.u64 == ACL_NFS4) + { + int result = acl_nfs4_nontrivial ((nfs4_acl_int_t *) acl); + if (acl != aclbuf) + free (acl); + return result; + } + else + { + /* A newer type of ACL has been introduced in the system. + We should better support it. */ + if (acl != aclbuf) + free (acl); + errno = EINVAL; + return -1; + } # elif HAVE_STATACL /* older AIX */ union { struct acl a; char room[4096]; } u; if (statacl (name, STX_NORMAL, &u.a, sizeof (u)) < 0) - return -1; + return -1; return acl_nontrivial (&u.a); diff --git a/src/bin/coreutils/lib/file-set.c b/src/bin/coreutils/lib/file-set.c index 46dcf5fbb4..d72f6ba53e 100644 --- a/src/bin/coreutils/lib/file-set.c +++ b/src/bin/coreutils/lib/file-set.c @@ -1,5 +1,5 @@ /* Specialized functions to manipulate a set of files. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -42,15 +42,15 @@ record_file (Hash_table *ht, char const *file, struct stat const *stats) struct F_triple *ent_from_table = hash_insert (ht, ent); if (ent_from_table == NULL) { - /* Insertion failed due to lack of memory. */ - xalloc_die (); + /* Insertion failed due to lack of memory. */ + xalloc_die (); } if (ent_from_table != ent) { - /* There was alread a matching entry in the table, so ENT was - not inserted. Free it. */ - triple_free (ent); + /* There was alread a matching entry in the table, so ENT was + not inserted. Free it. */ + triple_free (ent); } } } @@ -59,7 +59,7 @@ record_file (Hash_table *ht, char const *file, struct stat const *stats) for the file described by FILE and STATS. */ bool seen_file (Hash_table const *ht, char const *file, - struct stat const *stats) + struct stat const *stats) { struct F_triple new_ent; diff --git a/src/bin/coreutils/lib/file-set.h b/src/bin/coreutils/lib/file-set.h index a5a159e94d..1e9365f871 100644 --- a/src/bin/coreutils/lib/file-set.h +++ b/src/bin/coreutils/lib/file-set.h @@ -5,8 +5,8 @@ #include "hash.h" extern void record_file (Hash_table *ht, char const *file, - struct stat const *stats) + struct stat const *stats) __attribute__((nonnull(2, 3))); extern bool seen_file (Hash_table const *ht, char const *file, - struct stat const *stats); + struct stat const *stats); diff --git a/src/bin/coreutils/lib/file-type.c b/src/bin/coreutils/lib/file-type.c index 3035f75f9d..5a2bf7c68d 100644 --- a/src/bin/coreutils/lib/file-type.c +++ b/src/bin/coreutils/lib/file-type.c @@ -1,7 +1,7 @@ /* Return a string describing the type of a file. - Copyright (C) 1993, 1994, 2001, 2002, 2004, 2005, 2006 Free - Software Foundation, Inc. + Copyright (C) 1993-1994, 2001-2002, 2004-2006, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/file-type.h b/src/bin/coreutils/lib/file-type.h index 5596d7866e..11ccc0777f 100644 --- a/src/bin/coreutils/lib/file-type.h +++ b/src/bin/coreutils/lib/file-type.h @@ -1,6 +1,6 @@ /* Return a string describing the type of a file. - Copyright (C) 1993, 1994, 2001, 2002, 2004, 2005 Free Software + Copyright (C) 1993-1994, 2001-2002, 2004-2005, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/src/bin/coreutils/lib/fileblocks.c b/src/bin/coreutils/lib/fileblocks.c index 822935af93..63897c8f87 100644 --- a/src/bin/coreutils/lib/fileblocks.c +++ b/src/bin/coreutils/lib/fileblocks.c @@ -1,6 +1,6 @@ /* Convert file size to number of blocks on System V-like machines. - Copyright (C) 1990, 1997, 1998, 1999, 2004, 2005, 2006 Free Software + Copyright (C) 1990, 1997-1999, 2004-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -42,7 +42,7 @@ typedef long daddr_t; /* for disk address */ # endif /* !NINDIR */ /* Number of direct block addresses in an inode. */ -# define NDIR 10 +# define NDIR 10 /* Return the number of 512-byte blocks in a file of SIZE bytes. */ @@ -57,12 +57,12 @@ st_blocks (off_t size) indrblks = (datablks - NDIR - 1) / NINDIR + 1; if (datablks > NDIR + NINDIR) - { - indrblks += (datablks - NDIR - NINDIR - 1) / (NINDIR * NINDIR) + 1; + { + indrblks += (datablks - NDIR - NINDIR - 1) / (NINDIR * NINDIR) + 1; - if (datablks > NDIR + NINDIR + NINDIR * NINDIR) - indrblks++; - } + if (datablks > NDIR + NINDIR + NINDIR * NINDIR) + indrblks++; + } } return datablks + indrblks; diff --git a/src/bin/coreutils/lib/filemode.c b/src/bin/coreutils/lib/filemode.c index ac62bfc6ef..2b8035a4bf 100644 --- a/src/bin/coreutils/lib/filemode.c +++ b/src/bin/coreutils/lib/filemode.c @@ -1,7 +1,7 @@ /* filemode.c -- make a string describing file modes - Copyright (C) 1985, 1990, 1993, 1998-2000, 2004, 2006 Free Software - Foundation, Inc. + Copyright (C) 1985, 1990, 1993, 1998-2000, 2004, 2006, 2009-2010 Free + Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -99,18 +99,18 @@ strmode (mode_t mode, char *str) str[1] = mode & S_IRUSR ? 'r' : '-'; str[2] = mode & S_IWUSR ? 'w' : '-'; str[3] = (mode & S_ISUID - ? (mode & S_IXUSR ? 's' : 'S') - : (mode & S_IXUSR ? 'x' : '-')); + ? (mode & S_IXUSR ? 's' : 'S') + : (mode & S_IXUSR ? 'x' : '-')); str[4] = mode & S_IRGRP ? 'r' : '-'; str[5] = mode & S_IWGRP ? 'w' : '-'; str[6] = (mode & S_ISGID - ? (mode & S_IXGRP ? 's' : 'S') - : (mode & S_IXGRP ? 'x' : '-')); + ? (mode & S_IXGRP ? 's' : 'S') + : (mode & S_IXGRP ? 'x' : '-')); str[7] = mode & S_IROTH ? 'r' : '-'; str[8] = mode & S_IWOTH ? 'w' : '-'; str[9] = (mode & S_ISVTX - ? (mode & S_IXOTH ? 't' : 'T') - : (mode & S_IXOTH ? 'x' : '-')); + ? (mode & S_IXOTH ? 't' : 'T') + : (mode & S_IXOTH ? 'x' : '-')); str[10] = ' '; str[11] = '\0'; } @@ -122,43 +122,43 @@ strmode (mode_t mode, char *str) 12 characters are stored in STR. The characters stored in STR are: - 0 File type, as in ftypelet above, except that other letters are used + 0 File type, as in ftypelet above, except that other letters are used for files whose type cannot be determined solely from st_mode: - 'F' semaphore - 'M' migrated file (Cray DMF) - 'Q' message queue - 'S' shared memory object - 'T' typed memory object + 'F' semaphore + 'M' migrated file (Cray DMF) + 'Q' message queue + 'S' shared memory object + 'T' typed memory object - 1 'r' if the owner may read, '-' otherwise. + 1 'r' if the owner may read, '-' otherwise. - 2 'w' if the owner may write, '-' otherwise. + 2 'w' if the owner may write, '-' otherwise. - 3 'x' if the owner may execute, 's' if the file is - set-user-id, '-' otherwise. - 'S' if the file is set-user-id, but the execute - bit isn't set. + 3 'x' if the owner may execute, 's' if the file is + set-user-id, '-' otherwise. + 'S' if the file is set-user-id, but the execute + bit isn't set. - 4 'r' if group members may read, '-' otherwise. + 4 'r' if group members may read, '-' otherwise. - 5 'w' if group members may write, '-' otherwise. + 5 'w' if group members may write, '-' otherwise. - 6 'x' if group members may execute, 's' if the file is - set-group-id, '-' otherwise. - 'S' if it is set-group-id but not executable. + 6 'x' if group members may execute, 's' if the file is + set-group-id, '-' otherwise. + 'S' if it is set-group-id but not executable. - 7 'r' if any user may read, '-' otherwise. + 7 'r' if any user may read, '-' otherwise. - 8 'w' if any user may write, '-' otherwise. + 8 'w' if any user may write, '-' otherwise. - 9 'x' if any user may execute, 't' if the file is "sticky" - (will be retained in swap space after execution), '-' - otherwise. - 'T' if the file is sticky but not executable. + 9 'x' if any user may execute, 't' if the file is "sticky" + (will be retained in swap space after execution), '-' + otherwise. + 'T' if the file is sticky but not executable. 10 ' ' for compatibility with 4.4BSD strmode, - since this interface does not support ACLs. + since this interface does not support ACLs. 11 '\0'. */ diff --git a/src/bin/coreutils/lib/filemode.h b/src/bin/coreutils/lib/filemode.h index 29deecdc75..83864dfab2 100644 --- a/src/bin/coreutils/lib/filemode.h +++ b/src/bin/coreutils/lib/filemode.h @@ -1,6 +1,7 @@ /* Make a string describing file modes. - Copyright (C) 1998, 1999, 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 1998-1999, 2003, 2006, 2009-2010 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/filenamecat-lgpl.c b/src/bin/coreutils/lib/filenamecat-lgpl.c new file mode 100644 index 0000000000..7653c5ed1f --- /dev/null +++ b/src/bin/coreutils/lib/filenamecat-lgpl.c @@ -0,0 +1,88 @@ +/* Concatenate two arbitrary file names. + + Copyright (C) 1996-2007, 2009-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Jim Meyering. */ + +#include + +/* Specification. */ +#include "filenamecat.h" + +#include +#include + +#include "dirname.h" + +#if ! HAVE_MEMPCPY && ! defined mempcpy +# define mempcpy(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N))) +#endif + +/* Return the longest suffix of F that is a relative file name. + If it has no such suffix, return the empty string. */ + +static char const * +longest_relative_suffix (char const *f) +{ + for (f += FILE_SYSTEM_PREFIX_LEN (f); ISSLASH (*f); f++) + continue; + return f; +} + +/* Concatenate two file name components, DIR and ABASE, in + newly-allocated storage and return the result. + The resulting file name F is such that the commands "ls F" and "(cd + DIR; ls BASE)" refer to the same file, where BASE is ABASE with any + file system prefixes and leading separators removed. + Arrange for a directory separator if necessary between DIR and BASE + in the result, removing any redundant separators. + In any case, if BASE_IN_RESULT is non-NULL, set + *BASE_IN_RESULT to point to the copy of ABASE in the returned + concatenation. However, if ABASE begins with more than one slash, + set *BASE_IN_RESULT to point to the sole corresponding slash that + is copied into the result buffer. + + Return NULL if malloc fails. */ + +char * +mfile_name_concat (char const *dir, char const *abase, char **base_in_result) +{ + char const *dirbase = last_component (dir); + size_t dirbaselen = base_len (dirbase); + size_t dirlen = dirbase - dir + dirbaselen; + size_t needs_separator = (dirbaselen && ! ISSLASH (dirbase[dirbaselen - 1])); + + char const *base = longest_relative_suffix (abase); + size_t baselen = strlen (base); + + char *p_concat = malloc (dirlen + needs_separator + baselen + 1); + char *p; + + if (p_concat == NULL) + return NULL; + + p = mempcpy (p_concat, dir, dirlen); + *p = DIRECTORY_SEPARATOR; + p += needs_separator; + + if (base_in_result) + *base_in_result = p - IS_ABSOLUTE_FILE_NAME (abase); + + p = mempcpy (p, base, baselen); + *p = '\0'; + + return p_concat; +} diff --git a/src/bin/coreutils/lib/filenamecat.c b/src/bin/coreutils/lib/filenamecat.c index ef46de209a..64a7ebb1ef 100644 --- a/src/bin/coreutils/lib/filenamecat.c +++ b/src/bin/coreutils/lib/filenamecat.c @@ -1,6 +1,6 @@ /* Concatenate two arbitrary file names. - Copyright (C) 1996-2007 Free Software Foundation, Inc. + Copyright (C) 1996-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,70 +25,9 @@ #include #include -#include "dirname.h" #include "xalloc.h" -#if ! HAVE_MEMPCPY && ! defined mempcpy -# define mempcpy(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N))) -#endif - -/* Return the longest suffix of F that is a relative file name. - If it has no such suffix, return the empty string. */ - -static char const * -longest_relative_suffix (char const *f) -{ - for (f += FILE_SYSTEM_PREFIX_LEN (f); ISSLASH (*f); f++) - continue; - return f; -} - -/* Concatenate two file name components, DIR and ABASE, in - newly-allocated storage and return the result. - The resulting file name F is such that the commands "ls F" and "(cd - DIR; ls BASE)" refer to the same file, where BASE is ABASE with any - file system prefixes and leading separators removed. - Arrange for a directory separator if necessary between DIR and BASE - in the result, removing any redundant separators. - In any case, if BASE_IN_RESULT is non-NULL, set - *BASE_IN_RESULT to point to the copy of ABASE in the returned - concatenation. However, if ABASE begins with more than one slash, - set *BASE_IN_RESULT to point to the sole corresponding slash that - is copied into the result buffer. - - Return NULL if malloc fails. */ - -char * -mfile_name_concat (char const *dir, char const *abase, char **base_in_result) -{ - char const *dirbase = last_component (dir); - size_t dirbaselen = base_len (dirbase); - size_t dirlen = dirbase - dir + dirbaselen; - size_t needs_separator = (dirbaselen && ! ISSLASH (dirbase[dirbaselen - 1])); - - char const *base = longest_relative_suffix (abase); - size_t baselen = strlen (base); - - char *p_concat = malloc (dirlen + needs_separator + baselen + 1); - char *p; - - if (p_concat == NULL) - return NULL; - - p = mempcpy (p_concat, dir, dirlen); - *p = DIRECTORY_SEPARATOR; - p += needs_separator; - - if (base_in_result) - *base_in_result = p - IS_ABSOLUTE_FILE_NAME (abase); - - p = mempcpy (p, base, baselen); - *p = '\0'; - - return p_concat; -} - -/* Just like mfile_name_concat, above, except, rather than +/* Just like mfile_name_concat (filenamecat-lgpl.c), except, rather than returning NULL upon malloc failure, here, we report the "memory exhausted" condition and exit. */ diff --git a/src/bin/coreutils/lib/filenamecat.h b/src/bin/coreutils/lib/filenamecat.h index 334c887c77..950f456b7b 100644 --- a/src/bin/coreutils/lib/filenamecat.h +++ b/src/bin/coreutils/lib/filenamecat.h @@ -1,6 +1,7 @@ /* Concatenate two arbitrary file names. - Copyright (C) 1996, 1997, 2003, 2005, 2007 Free Software Foundation, Inc. + Copyright (C) 1996-1997, 2003, 2005, 2007, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,8 +18,10 @@ /* Written by Jim Meyering. */ +#if GNULIB_FILENAMECAT char *file_name_concat (char const *dir, char const *base, - char **base_in_result); + char **base_in_result); +#endif char *mfile_name_concat (char const *dir, char const *base, - char **base_in_result); + char **base_in_result); diff --git a/src/bin/coreutils/lib/filevercmp.c b/src/bin/coreutils/lib/filevercmp.c index 20522d1c4c..cb7c25cb89 100644 --- a/src/bin/coreutils/lib/filevercmp.c +++ b/src/bin/coreutils/lib/filevercmp.c @@ -1,7 +1,7 @@ /* Copyright (C) 1995 Ian Jackson Copyright (C) 2001 Anthony Towns - Copyright (C) 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -89,32 +89,32 @@ verrevcmp (const char *s1, size_t s1_len, const char *s2, size_t s2_len) { int first_diff = 0; while ((s1_pos < s1_len && !c_isdigit (s1[s1_pos])) - || (s2_pos < s2_len && !c_isdigit (s2[s2_pos]))) - { - int s1_c = (s1_pos == s1_len) ? 0 : order (s1[s1_pos]); - int s2_c = (s2_pos == s2_len) ? 0 : order (s2[s2_pos]); - if (s1_c != s2_c) - return s1_c - s2_c; - s1_pos++; - s2_pos++; - } + || (s2_pos < s2_len && !c_isdigit (s2[s2_pos]))) + { + int s1_c = (s1_pos == s1_len) ? 0 : order (s1[s1_pos]); + int s2_c = (s2_pos == s2_len) ? 0 : order (s2[s2_pos]); + if (s1_c != s2_c) + return s1_c - s2_c; + s1_pos++; + s2_pos++; + } while (s1[s1_pos] == '0') - s1_pos++; + s1_pos++; while (s2[s2_pos] == '0') - s2_pos++; + s2_pos++; while (c_isdigit (s1[s1_pos]) && c_isdigit (s2[s2_pos])) - { - if (!first_diff) - first_diff = s1[s1_pos] - s2[s2_pos]; - s1_pos++; - s2_pos++; - } + { + if (!first_diff) + first_diff = s1[s1_pos] - s2[s2_pos]; + s1_pos++; + s2_pos++; + } if (c_isdigit (s1[s1_pos])) - return 1; + return 1; if (c_isdigit (s2[s2_pos])) - return -1; + return -1; if (first_diff) - return first_diff; + return first_diff; } return 0; } diff --git a/src/bin/coreutils/lib/filevercmp.h b/src/bin/coreutils/lib/filevercmp.h index f3d78f0cdc..1865b53592 100644 --- a/src/bin/coreutils/lib/filevercmp.h +++ b/src/bin/coreutils/lib/filevercmp.h @@ -1,7 +1,7 @@ /* Copyright (C) 1995 Ian Jackson Copyright (C) 2001 Anthony Towns - Copyright (C) 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/float+.h b/src/bin/coreutils/lib/float+.h index f401cabc88..336e71d6f6 100644 --- a/src/bin/coreutils/lib/float+.h +++ b/src/bin/coreutils/lib/float+.h @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Supplemental information about the floating-point formats. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. Written by Bruno Haible , 2007. This program is free software; you can redistribute it and/or modify diff --git a/src/bin/coreutils/lib/float.in.h b/src/bin/coreutils/lib/float.in.h index 9ba2bce4b5..caf822f1d0 100644 --- a/src/bin/coreutils/lib/float.in.h +++ b/src/bin/coreutils/lib/float.in.h @@ -1,6 +1,6 @@ /* A correct . - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/fnmatch.c b/src/bin/coreutils/lib/fnmatch.c index 83a3f922d4..113d03baf5 100644 --- a/src/bin/coreutils/lib/fnmatch.c +++ b/src/bin/coreutils/lib/fnmatch.c @@ -1,8 +1,8 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 -/* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2009 - Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002, + 2003, 2004, 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ /* Enable GNU extensions in fnmatch.h. */ #ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 +# define _GNU_SOURCE 1 #endif #if ! defined __builtin_expect && __GNUC__ < 3 @@ -112,25 +112,25 @@ extern int fnmatch (const char *pattern, const char *string, int flags); # endif # ifdef _LIBC -# define ISWCTYPE(WC, WT) __iswctype (WC, WT) +# define ISWCTYPE(WC, WT) __iswctype (WC, WT) # else -# define ISWCTYPE(WC, WT) iswctype (WC, WT) +# define ISWCTYPE(WC, WT) iswctype (WC, WT) # endif # if (HAVE_MBSTATE_T && HAVE_MBSRTOWCS) || _LIBC /* In this case we are implementing the multibyte character handling. */ -# define HANDLE_MULTIBYTE 1 +# define HANDLE_MULTIBYTE 1 # endif # else # define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */ -# define IS_CHAR_CLASS(string) \ - (STREQ (string, "alpha") || STREQ (string, "upper") \ - || STREQ (string, "lower") || STREQ (string, "digit") \ - || STREQ (string, "alnum") || STREQ (string, "xdigit") \ - || STREQ (string, "space") || STREQ (string, "print") \ - || STREQ (string, "punct") || STREQ (string, "graph") \ +# define IS_CHAR_CLASS(string) \ + (STREQ (string, "alpha") || STREQ (string, "upper") \ + || STREQ (string, "lower") || STREQ (string, "digit") \ + || STREQ (string, "alnum") || STREQ (string, "xdigit") \ + || STREQ (string, "space") || STREQ (string, "print") \ + || STREQ (string, "punct") || STREQ (string, "graph") \ || STREQ (string, "cntrl") || STREQ (string, "blank")) # endif @@ -148,17 +148,17 @@ static int posixly_correct; /* Note that this evaluates C many times. */ # define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c)) -# define CHAR char -# define UCHAR unsigned char -# define INT int -# define FCT internal_fnmatch -# define EXT ext_match -# define END end_pattern -# define L_(CS) CS +# define CHAR char +# define UCHAR unsigned char +# define INT int +# define FCT internal_fnmatch +# define EXT ext_match +# define END end_pattern +# define L_(CS) CS # ifdef _LIBC -# define BTOWC(C) __btowc (C) +# define BTOWC(C) __btowc (C) # else -# define BTOWC(C) btowc (C) +# define BTOWC(C) btowc (C) # endif # define STRLEN(S) strlen (S) # define STRCAT(D, S) strcat (D, S) @@ -178,14 +178,14 @@ static int posixly_correct; # if HANDLE_MULTIBYTE # define FOLD(c) ((flags & FNM_CASEFOLD) ? towlower (c) : (c)) -# define CHAR wchar_t -# define UCHAR wint_t -# define INT wint_t -# define FCT internal_fnwmatch -# define EXT ext_wmatch -# define END end_wpattern -# define L_(CS) L##CS -# define BTOWC(C) (C) +# define CHAR wchar_t +# define UCHAR wint_t +# define INT wint_t +# define FCT internal_fnwmatch +# define EXT ext_wmatch +# define END end_wpattern +# define L_(CS) L##CS +# define BTOWC(C) (C) # ifdef _LIBC # define STRLEN(S) __wcslen (S) # define STRCAT(D, S) __wcscat (D, S) @@ -221,40 +221,40 @@ is_char_class (const wchar_t *wcs) /* Test for a printable character from the portable character set. */ # ifdef _LIBC if (*wcs < 0x20 || *wcs > 0x7e - || *wcs == 0x24 || *wcs == 0x40 || *wcs == 0x60) - return (wctype_t) 0; + || *wcs == 0x24 || *wcs == 0x40 || *wcs == 0x60) + return (wctype_t) 0; # else switch (*wcs) - { - case L' ': case L'!': case L'"': case L'#': case L'%': - case L'&': case L'\'': case L'(': case L')': case L'*': - case L'+': case L',': case L'-': case L'.': case L'/': - case L'0': case L'1': case L'2': case L'3': case L'4': - case L'5': case L'6': case L'7': case L'8': case L'9': - case L':': case L';': case L'<': case L'=': case L'>': - case L'?': - case L'A': case L'B': case L'C': case L'D': case L'E': - case L'F': case L'G': case L'H': case L'I': case L'J': - case L'K': case L'L': case L'M': case L'N': case L'O': - case L'P': case L'Q': case L'R': case L'S': case L'T': - case L'U': case L'V': case L'W': case L'X': case L'Y': - case L'Z': - case L'[': case L'\\': case L']': case L'^': case L'_': - case L'a': case L'b': case L'c': case L'd': case L'e': - case L'f': case L'g': case L'h': case L'i': case L'j': - case L'k': case L'l': case L'm': case L'n': case L'o': - case L'p': case L'q': case L'r': case L's': case L't': - case L'u': case L'v': case L'w': case L'x': case L'y': - case L'z': case L'{': case L'|': case L'}': case L'~': - break; - default: - return (wctype_t) 0; - } + { + case L' ': case L'!': case L'"': case L'#': case L'%': + case L'&': case L'\'': case L'(': case L')': case L'*': + case L'+': case L',': case L'-': case L'.': case L'/': + case L'0': case L'1': case L'2': case L'3': case L'4': + case L'5': case L'6': case L'7': case L'8': case L'9': + case L':': case L';': case L'<': case L'=': case L'>': + case L'?': + case L'A': case L'B': case L'C': case L'D': case L'E': + case L'F': case L'G': case L'H': case L'I': case L'J': + case L'K': case L'L': case L'M': case L'N': case L'O': + case L'P': case L'Q': case L'R': case L'S': case L'T': + case L'U': case L'V': case L'W': case L'X': case L'Y': + case L'Z': + case L'[': case L'\\': case L']': case L'^': case L'_': + case L'a': case L'b': case L'c': case L'd': case L'e': + case L'f': case L'g': case L'h': case L'i': case L'j': + case L'k': case L'l': case L'm': case L'n': case L'o': + case L'p': case L'q': case L'r': case L's': case L't': + case L'u': case L'v': case L'w': case L'x': case L'y': + case L'z': case L'{': case L'|': case L'}': case L'~': + break; + default: + return (wctype_t) 0; + } # endif /* Avoid overrunning the buffer. */ if (cp == s + CHAR_CLASS_MAX_LENGTH) - return (wctype_t) 0; + return (wctype_t) 0; *cp++ = (char) *wcs++; } @@ -290,58 +290,58 @@ fnmatch (const char *pattern, const char *string, int flags) int res; /* Calculate the size needed to convert the strings to - wide characters. */ + wide characters. */ memset (&ps, '\0', sizeof (ps)); patsize = mbsrtowcs (NULL, &pattern, 0, &ps) + 1; if (__builtin_expect (patsize != 0, 1)) - { - assert (mbsinit (&ps)); - strsize = mbsrtowcs (NULL, &string, 0, &ps) + 1; - if (__builtin_expect (strsize != 0, 1)) - { - assert (mbsinit (&ps)); - totsize = patsize + strsize; - if (__builtin_expect (! (patsize <= totsize - && totsize <= SIZE_MAX / sizeof (wchar_t)), - 0)) - { - errno = ENOMEM; - return -1; - } + { + assert (mbsinit (&ps)); + strsize = mbsrtowcs (NULL, &string, 0, &ps) + 1; + if (__builtin_expect (strsize != 0, 1)) + { + assert (mbsinit (&ps)); + totsize = patsize + strsize; + if (__builtin_expect (! (patsize <= totsize + && totsize <= SIZE_MAX / sizeof (wchar_t)), + 0)) + { + errno = ENOMEM; + return -1; + } - /* Allocate room for the wide characters. */ - if (__builtin_expect (totsize < ALLOCA_LIMIT, 1)) - wpattern = (wchar_t *) alloca (totsize * sizeof (wchar_t)); - else - { - wpattern = malloc (totsize * sizeof (wchar_t)); - if (__builtin_expect (! wpattern, 0)) - { - errno = ENOMEM; - return -1; - } - } - wstring = wpattern + patsize; + /* Allocate room for the wide characters. */ + if (__builtin_expect (totsize < ALLOCA_LIMIT, 1)) + wpattern = (wchar_t *) alloca (totsize * sizeof (wchar_t)); + else + { + wpattern = malloc (totsize * sizeof (wchar_t)); + if (__builtin_expect (! wpattern, 0)) + { + errno = ENOMEM; + return -1; + } + } + wstring = wpattern + patsize; - /* Convert the strings into wide characters. */ - mbsrtowcs (wpattern, &pattern, patsize, &ps); - assert (mbsinit (&ps)); - mbsrtowcs (wstring, &string, strsize, &ps); + /* Convert the strings into wide characters. */ + mbsrtowcs (wpattern, &pattern, patsize, &ps); + assert (mbsinit (&ps)); + mbsrtowcs (wstring, &string, strsize, &ps); - res = internal_fnwmatch (wpattern, wstring, wstring + strsize - 1, - flags & FNM_PERIOD, flags); + res = internal_fnwmatch (wpattern, wstring, wstring + strsize - 1, + flags & FNM_PERIOD, flags); - if (__builtin_expect (! (totsize < ALLOCA_LIMIT), 0)) - free (wpattern); - return res; - } - } + if (__builtin_expect (! (totsize < ALLOCA_LIMIT), 0)) + free (wpattern); + return res; + } + } } # endif /* HANDLE_MULTIBYTE */ return internal_fnmatch (pattern, string, string + strlen (string), - flags & FNM_PERIOD, flags); + flags & FNM_PERIOD, flags); } # ifdef _LIBC @@ -354,4 +354,4 @@ compat_symbol (libc, __fnmatch_old, fnmatch, GLIBC_2_0); libc_hidden_ver (__fnmatch, fnmatch) # endif -#endif /* _LIBC or not __GNU_LIBRARY__. */ +#endif /* _LIBC or not __GNU_LIBRARY__. */ diff --git a/src/bin/coreutils/lib/fnmatch.h b/src/bin/coreutils/lib/fnmatch.h index 9883ef0007..4e103f3e3f 100644 --- a/src/bin/coreutils/lib/fnmatch.h +++ b/src/bin/coreutils/lib/fnmatch.h @@ -1,10 +1,15 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +#line 1 /* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2001, 2002, 2003, - 2005 Free Software Foundation, Inc. + 2005, 2007, 2009, 2010 Free Software Foundation, Inc. + + This file is part of the GNU C Library. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) + the Free Software Foundation; either version 3, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,49 +21,62 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef _FNMATCH_H -# define _FNMATCH_H 1 +#ifndef _FNMATCH_H +#define _FNMATCH_H 1 -# ifdef __cplusplus -extern "C" { +/* The definition of _GL_ARG_NONNULL is copied here. */ +/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools + that the values passed as arguments n, ..., m must be non-NULL pointers. + n = 1 stands for the first argument, n = 2 for the second argument etc. */ +#ifndef _GL_ARG_NONNULL +# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 +# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) +# else +# define _GL_ARG_NONNULL(params) # endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* We #undef these before defining them because some losing systems (HP-UX A.08.07 for example) define these in . */ -# undef FNM_PATHNAME -# undef FNM_NOESCAPE -# undef FNM_PERIOD +#undef FNM_PATHNAME +#undef FNM_NOESCAPE +#undef FNM_PERIOD /* Bits set in the FLAGS argument to `fnmatch'. */ -# define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */ -# define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */ -# define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */ +#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */ +#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */ +#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */ -# if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE -# define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */ -# define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */ -# define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */ -# define FNM_EXTMATCH (1 << 5) /* Use ksh-like extended matching. */ -# endif +#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE +# define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */ +# define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */ +# define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */ +# define FNM_EXTMATCH (1 << 5) /* Use ksh-like extended matching. */ +#endif /* Value returned by `fnmatch' if STRING does not match PATTERN. */ -# define FNM_NOMATCH 1 +#define FNM_NOMATCH 1 /* This value is returned if the implementation does not support `fnmatch'. Since this is not the case here it will never be returned but the conformance test suites still require the symbol to be defined. */ -# ifdef _XOPEN_SOURCE -# define FNM_NOSYS (-1) -# endif +#ifdef _XOPEN_SOURCE +# define FNM_NOSYS (-1) +#endif /* Match NAME against the file name pattern PATTERN, returning zero if it matches, FNM_NOMATCH if not. */ extern int fnmatch (const char *__pattern, const char *__name, - int __flags); + int __flags) + _GL_ARG_NONNULL ((1, 2)); -# ifdef __cplusplus +#ifdef __cplusplus } -# endif +#endif #endif /* fnmatch.h */ diff --git a/src/bin/coreutils/lib/fnmatch.in.h b/src/bin/coreutils/lib/fnmatch.in.h index 6ba297f105..29cd7e3a9e 100644 --- a/src/bin/coreutils/lib/fnmatch.in.h +++ b/src/bin/coreutils/lib/fnmatch.in.h @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2001, 2002, 2003, - 2005, 2007 Free Software Foundation, Inc. + 2005, 2007, 2009, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -20,8 +20,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef _FNMATCH_H -#define _FNMATCH_H 1 +#ifndef _FNMATCH_H +#define _FNMATCH_H 1 + +/* The definition of _GL_ARG_NONNULL is copied here. */ #ifdef __cplusplus extern "C" { @@ -29,37 +31,38 @@ extern "C" { /* We #undef these before defining them because some losing systems (HP-UX A.08.07 for example) define these in . */ -#undef FNM_PATHNAME -#undef FNM_NOESCAPE -#undef FNM_PERIOD +#undef FNM_PATHNAME +#undef FNM_NOESCAPE +#undef FNM_PERIOD /* Bits set in the FLAGS argument to `fnmatch'. */ -#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */ -#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */ -#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */ +#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */ +#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */ +#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */ #if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE -# define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */ -# define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */ -# define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */ -# define FNM_EXTMATCH (1 << 5) /* Use ksh-like extended matching. */ +# define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */ +# define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */ +# define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */ +# define FNM_EXTMATCH (1 << 5) /* Use ksh-like extended matching. */ #endif /* Value returned by `fnmatch' if STRING does not match PATTERN. */ -#define FNM_NOMATCH 1 +#define FNM_NOMATCH 1 /* This value is returned if the implementation does not support `fnmatch'. Since this is not the case here it will never be returned but the conformance test suites still require the symbol to be defined. */ #ifdef _XOPEN_SOURCE -# define FNM_NOSYS (-1) +# define FNM_NOSYS (-1) #endif /* Match NAME against the file name pattern PATTERN, returning zero if it matches, FNM_NOMATCH if not. */ extern int fnmatch (const char *__pattern, const char *__name, - int __flags); + int __flags) + _GL_ARG_NONNULL ((1, 2)); #ifdef __cplusplus } diff --git a/src/bin/coreutils/lib/fnmatch_loop.c b/src/bin/coreutils/lib/fnmatch_loop.c index 4f857b5233..68bcb223c7 100644 --- a/src/bin/coreutils/lib/fnmatch_loop.c +++ b/src/bin/coreutils/lib/fnmatch_loop.c @@ -1,8 +1,8 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 -/* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006 - Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002, + 2003, 2004, 2005, 2006, 2009, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software; you can redistribute it and/or modify @@ -22,7 +22,7 @@ /* Match STRING against the file name pattern PATTERN, returning zero if it matches, nonzero if not. */ static int EXT (INT opt, const CHAR *pattern, const CHAR *string, - const CHAR *string_end, bool no_leading_period, int flags) + const CHAR *string_end, bool no_leading_period, int flags) internal_function; static const CHAR *END (const CHAR *patternp) internal_function; @@ -49,310 +49,310 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end, c = FOLD (c); switch (c) - { - case L_('?'): - if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(') - { - int res; + { + case L_('?'): + if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(') + { + int res; - res = EXT (c, p, n, string_end, no_leading_period, - flags); - if (res != -1) - return res; - } + res = EXT (c, p, n, string_end, no_leading_period, + flags); + if (res != -1) + return res; + } - if (n == string_end) - return FNM_NOMATCH; - else if (*n == L_('/') && (flags & FNM_FILE_NAME)) - return FNM_NOMATCH; - else if (*n == L_('.') && no_leading_period) - return FNM_NOMATCH; - break; + if (n == string_end) + return FNM_NOMATCH; + else if (*n == L_('/') && (flags & FNM_FILE_NAME)) + return FNM_NOMATCH; + else if (*n == L_('.') && no_leading_period) + return FNM_NOMATCH; + break; - case L_('\\'): - if (!(flags & FNM_NOESCAPE)) - { - c = *p++; - if (c == L_('\0')) - /* Trailing \ loses. */ - return FNM_NOMATCH; - c = FOLD (c); - } - if (n == string_end || FOLD ((UCHAR) *n) != c) - return FNM_NOMATCH; - break; + case L_('\\'): + if (!(flags & FNM_NOESCAPE)) + { + c = *p++; + if (c == L_('\0')) + /* Trailing \ loses. */ + return FNM_NOMATCH; + c = FOLD (c); + } + if (n == string_end || FOLD ((UCHAR) *n) != c) + return FNM_NOMATCH; + break; - case L_('*'): - if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(') - { - int res; + case L_('*'): + if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(') + { + int res; - res = EXT (c, p, n, string_end, no_leading_period, - flags); - if (res != -1) - return res; - } + res = EXT (c, p, n, string_end, no_leading_period, + flags); + if (res != -1) + return res; + } - if (n != string_end && *n == L_('.') && no_leading_period) - return FNM_NOMATCH; + if (n != string_end && *n == L_('.') && no_leading_period) + return FNM_NOMATCH; - for (c = *p++; c == L_('?') || c == L_('*'); c = *p++) - { - if (*p == L_('(') && (flags & FNM_EXTMATCH) != 0) - { - const CHAR *endp = END (p); - if (endp != p) - { - /* This is a pattern. Skip over it. */ - p = endp; - continue; - } - } + for (c = *p++; c == L_('?') || c == L_('*'); c = *p++) + { + if (*p == L_('(') && (flags & FNM_EXTMATCH) != 0) + { + const CHAR *endp = END (p); + if (endp != p) + { + /* This is a pattern. Skip over it. */ + p = endp; + continue; + } + } - if (c == L_('?')) - { - /* A ? needs to match one character. */ - if (n == string_end) - /* There isn't another character; no match. */ - return FNM_NOMATCH; - else if (*n == L_('/') - && __builtin_expect (flags & FNM_FILE_NAME, 0)) - /* A slash does not match a wildcard under - FNM_FILE_NAME. */ - return FNM_NOMATCH; - else - /* One character of the string is consumed in matching - this ? wildcard, so *??? won't match if there are - less than three characters. */ - ++n; - } - } + if (c == L_('?')) + { + /* A ? needs to match one character. */ + if (n == string_end) + /* There isn't another character; no match. */ + return FNM_NOMATCH; + else if (*n == L_('/') + && __builtin_expect (flags & FNM_FILE_NAME, 0)) + /* A slash does not match a wildcard under + FNM_FILE_NAME. */ + return FNM_NOMATCH; + else + /* One character of the string is consumed in matching + this ? wildcard, so *??? won't match if there are + less than three characters. */ + ++n; + } + } - if (c == L_('\0')) - /* The wildcard(s) is/are the last element of the pattern. - If the name is a file name and contains another slash - this means it cannot match, unless the FNM_LEADING_DIR - flag is set. */ - { - int result = (flags & FNM_FILE_NAME) == 0 ? 0 : FNM_NOMATCH; + if (c == L_('\0')) + /* The wildcard(s) is/are the last element of the pattern. + If the name is a file name and contains another slash + this means it cannot match, unless the FNM_LEADING_DIR + flag is set. */ + { + int result = (flags & FNM_FILE_NAME) == 0 ? 0 : FNM_NOMATCH; - if (flags & FNM_FILE_NAME) - { - if (flags & FNM_LEADING_DIR) - result = 0; - else - { - if (MEMCHR (n, L_('/'), string_end - n) == NULL) - result = 0; - } - } + if (flags & FNM_FILE_NAME) + { + if (flags & FNM_LEADING_DIR) + result = 0; + else + { + if (MEMCHR (n, L_('/'), string_end - n) == NULL) + result = 0; + } + } - return result; - } - else - { - const CHAR *endp; + return result; + } + else + { + const CHAR *endp; - endp = MEMCHR (n, (flags & FNM_FILE_NAME) ? L_('/') : L_('\0'), - string_end - n); - if (endp == NULL) - endp = string_end; + endp = MEMCHR (n, (flags & FNM_FILE_NAME) ? L_('/') : L_('\0'), + string_end - n); + if (endp == NULL) + endp = string_end; - if (c == L_('[') - || (__builtin_expect (flags & FNM_EXTMATCH, 0) != 0 - && (c == L_('@') || c == L_('+') || c == L_('!')) - && *p == L_('('))) - { - int flags2 = ((flags & FNM_FILE_NAME) - ? flags : (flags & ~FNM_PERIOD)); - bool no_leading_period2 = no_leading_period; + if (c == L_('[') + || (__builtin_expect (flags & FNM_EXTMATCH, 0) != 0 + && (c == L_('@') || c == L_('+') || c == L_('!')) + && *p == L_('('))) + { + int flags2 = ((flags & FNM_FILE_NAME) + ? flags : (flags & ~FNM_PERIOD)); + bool no_leading_period2 = no_leading_period; - for (--p; n < endp; ++n, no_leading_period2 = false) - if (FCT (p, n, string_end, no_leading_period2, flags2) - == 0) - return 0; - } - else if (c == L_('/') && (flags & FNM_FILE_NAME)) - { - while (n < string_end && *n != L_('/')) - ++n; - if (n < string_end && *n == L_('/') - && (FCT (p, n + 1, string_end, flags & FNM_PERIOD, flags) - == 0)) - return 0; - } - else - { - int flags2 = ((flags & FNM_FILE_NAME) - ? flags : (flags & ~FNM_PERIOD)); - int no_leading_period2 = no_leading_period; + for (--p; n < endp; ++n, no_leading_period2 = false) + if (FCT (p, n, string_end, no_leading_period2, flags2) + == 0) + return 0; + } + else if (c == L_('/') && (flags & FNM_FILE_NAME)) + { + while (n < string_end && *n != L_('/')) + ++n; + if (n < string_end && *n == L_('/') + && (FCT (p, n + 1, string_end, flags & FNM_PERIOD, flags) + == 0)) + return 0; + } + else + { + int flags2 = ((flags & FNM_FILE_NAME) + ? flags : (flags & ~FNM_PERIOD)); + int no_leading_period2 = no_leading_period; - if (c == L_('\\') && !(flags & FNM_NOESCAPE)) - c = *p; - c = FOLD (c); - for (--p; n < endp; ++n, no_leading_period2 = false) - if (FOLD ((UCHAR) *n) == c - && (FCT (p, n, string_end, no_leading_period2, flags2) - == 0)) - return 0; - } - } + if (c == L_('\\') && !(flags & FNM_NOESCAPE)) + c = *p; + c = FOLD (c); + for (--p; n < endp; ++n, no_leading_period2 = false) + if (FOLD ((UCHAR) *n) == c + && (FCT (p, n, string_end, no_leading_period2, flags2) + == 0)) + return 0; + } + } - /* If we come here no match is possible with the wildcard. */ - return FNM_NOMATCH; + /* If we come here no match is possible with the wildcard. */ + return FNM_NOMATCH; - case L_('['): - { - /* Nonzero if the sense of the character class is inverted. */ - register bool not; - CHAR cold; - UCHAR fn; + case L_('['): + { + /* Nonzero if the sense of the character class is inverted. */ + register bool not; + CHAR cold; + UCHAR fn; - if (posixly_correct == 0) - posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1; + if (posixly_correct == 0) + posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1; - if (n == string_end) - return FNM_NOMATCH; + if (n == string_end) + return FNM_NOMATCH; - if (*n == L_('.') && no_leading_period) - return FNM_NOMATCH; + if (*n == L_('.') && no_leading_period) + return FNM_NOMATCH; - if (*n == L_('/') && (flags & FNM_FILE_NAME)) - /* `/' cannot be matched. */ - return FNM_NOMATCH; + if (*n == L_('/') && (flags & FNM_FILE_NAME)) + /* `/' cannot be matched. */ + return FNM_NOMATCH; - not = (*p == L_('!') || (posixly_correct < 0 && *p == L_('^'))); - if (not) - ++p; + not = (*p == L_('!') || (posixly_correct < 0 && *p == L_('^'))); + if (not) + ++p; - fn = FOLD ((UCHAR) *n); + fn = FOLD ((UCHAR) *n); - c = *p++; - for (;;) - { - if (!(flags & FNM_NOESCAPE) && c == L_('\\')) - { - if (*p == L_('\0')) - return FNM_NOMATCH; - c = FOLD ((UCHAR) *p); - ++p; + c = *p++; + for (;;) + { + if (!(flags & FNM_NOESCAPE) && c == L_('\\')) + { + if (*p == L_('\0')) + return FNM_NOMATCH; + c = FOLD ((UCHAR) *p); + ++p; - goto normal_bracket; - } - else if (c == L_('[') && *p == L_(':')) - { - /* Leave room for the null. */ - CHAR str[CHAR_CLASS_MAX_LENGTH + 1]; - size_t c1 = 0; + goto normal_bracket; + } + else if (c == L_('[') && *p == L_(':')) + { + /* Leave room for the null. */ + CHAR str[CHAR_CLASS_MAX_LENGTH + 1]; + size_t c1 = 0; #if defined _LIBC || WIDE_CHAR_SUPPORT - wctype_t wt; + wctype_t wt; #endif - const CHAR *startp = p; + const CHAR *startp = p; - for (;;) - { - if (c1 == CHAR_CLASS_MAX_LENGTH) - /* The name is too long and therefore the pattern - is ill-formed. */ - return FNM_NOMATCH; + for (;;) + { + if (c1 == CHAR_CLASS_MAX_LENGTH) + /* The name is too long and therefore the pattern + is ill-formed. */ + return FNM_NOMATCH; - c = *++p; - if (c == L_(':') && p[1] == L_(']')) - { - p += 2; - break; - } - if (c < L_('a') || c >= L_('z')) - { - /* This cannot possibly be a character class name. - Match it as a normal range. */ - p = startp; - c = L_('['); - goto normal_bracket; - } - str[c1++] = c; - } - str[c1] = L_('\0'); + c = *++p; + if (c == L_(':') && p[1] == L_(']')) + { + p += 2; + break; + } + if (c < L_('a') || c >= L_('z')) + { + /* This cannot possibly be a character class name. + Match it as a normal range. */ + p = startp; + c = L_('['); + goto normal_bracket; + } + str[c1++] = c; + } + str[c1] = L_('\0'); #if defined _LIBC || WIDE_CHAR_SUPPORT - wt = IS_CHAR_CLASS (str); - if (wt == 0) - /* Invalid character class name. */ - return FNM_NOMATCH; + wt = IS_CHAR_CLASS (str); + if (wt == 0) + /* Invalid character class name. */ + return FNM_NOMATCH; # if defined _LIBC && ! WIDE_CHAR_VERSION - /* The following code is glibc specific but does - there a good job in speeding up the code since - we can avoid the btowc() call. */ - if (_ISCTYPE ((UCHAR) *n, wt)) - goto matched; + /* The following code is glibc specific but does + there a good job in speeding up the code since + we can avoid the btowc() call. */ + if (_ISCTYPE ((UCHAR) *n, wt)) + goto matched; # else - if (ISWCTYPE (BTOWC ((UCHAR) *n), wt)) - goto matched; + if (ISWCTYPE (BTOWC ((UCHAR) *n), wt)) + goto matched; # endif #else - if ((STREQ (str, L_("alnum")) && isalnum ((UCHAR) *n)) - || (STREQ (str, L_("alpha")) && isalpha ((UCHAR) *n)) - || (STREQ (str, L_("blank")) && isblank ((UCHAR) *n)) - || (STREQ (str, L_("cntrl")) && iscntrl ((UCHAR) *n)) - || (STREQ (str, L_("digit")) && isdigit ((UCHAR) *n)) - || (STREQ (str, L_("graph")) && isgraph ((UCHAR) *n)) - || (STREQ (str, L_("lower")) && islower ((UCHAR) *n)) - || (STREQ (str, L_("print")) && isprint ((UCHAR) *n)) - || (STREQ (str, L_("punct")) && ispunct ((UCHAR) *n)) - || (STREQ (str, L_("space")) && isspace ((UCHAR) *n)) - || (STREQ (str, L_("upper")) && isupper ((UCHAR) *n)) - || (STREQ (str, L_("xdigit")) && isxdigit ((UCHAR) *n))) - goto matched; + if ((STREQ (str, L_("alnum")) && isalnum ((UCHAR) *n)) + || (STREQ (str, L_("alpha")) && isalpha ((UCHAR) *n)) + || (STREQ (str, L_("blank")) && isblank ((UCHAR) *n)) + || (STREQ (str, L_("cntrl")) && iscntrl ((UCHAR) *n)) + || (STREQ (str, L_("digit")) && isdigit ((UCHAR) *n)) + || (STREQ (str, L_("graph")) && isgraph ((UCHAR) *n)) + || (STREQ (str, L_("lower")) && islower ((UCHAR) *n)) + || (STREQ (str, L_("print")) && isprint ((UCHAR) *n)) + || (STREQ (str, L_("punct")) && ispunct ((UCHAR) *n)) + || (STREQ (str, L_("space")) && isspace ((UCHAR) *n)) + || (STREQ (str, L_("upper")) && isupper ((UCHAR) *n)) + || (STREQ (str, L_("xdigit")) && isxdigit ((UCHAR) *n))) + goto matched; #endif - c = *p++; - } + c = *p++; + } #ifdef _LIBC - else if (c == L_('[') && *p == L_('=')) - { - UCHAR str[1]; - uint32_t nrules = - _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); - const CHAR *startp = p; + else if (c == L_('[') && *p == L_('=')) + { + UCHAR str[1]; + uint32_t nrules = + _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); + const CHAR *startp = p; - c = *++p; - if (c == L_('\0')) - { - p = startp; - c = L_('['); - goto normal_bracket; - } - str[0] = c; + c = *++p; + if (c == L_('\0')) + { + p = startp; + c = L_('['); + goto normal_bracket; + } + str[0] = c; - c = *++p; - if (c != L_('=') || p[1] != L_(']')) - { - p = startp; - c = L_('['); - goto normal_bracket; - } - p += 2; + c = *++p; + if (c != L_('=') || p[1] != L_(']')) + { + p = startp; + c = L_('['); + goto normal_bracket; + } + p += 2; - if (nrules == 0) - { - if ((UCHAR) *n == str[0]) - goto matched; - } - else - { - const int32_t *table; + if (nrules == 0) + { + if ((UCHAR) *n == str[0]) + goto matched; + } + else + { + const int32_t *table; # if WIDE_CHAR_VERSION - const int32_t *weights; - const int32_t *extra; + const int32_t *weights; + const int32_t *extra; # else - const unsigned char *weights; - const unsigned char *extra; + const unsigned char *weights; + const unsigned char *extra; # endif - const int32_t *indirect; - int32_t idx; - const UCHAR *cp = (const UCHAR *) str; + const int32_t *indirect; + int32_t idx; + const UCHAR *cp = (const UCHAR *) str; - /* This #include defines a local function! */ + /* This #include defines a local function! */ # if WIDE_CHAR_VERSION # include # else @@ -360,605 +360,610 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end, # endif # if WIDE_CHAR_VERSION - table = (const int32_t *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEWC); - weights = (const int32_t *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTWC); - extra = (const int32_t *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAWC); - indirect = (const int32_t *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTWC); + table = (const int32_t *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEWC); + weights = (const int32_t *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTWC); + extra = (const int32_t *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAWC); + indirect = (const int32_t *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTWC); # else - table = (const int32_t *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); - weights = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB); - extra = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB); - indirect = (const int32_t *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB); + table = (const int32_t *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); + weights = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB); + extra = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB); + indirect = (const int32_t *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB); # endif - idx = findidx (&cp); - if (idx != 0) - { - /* We found a table entry. Now see whether the - character we are currently at has the same - equivalance class value. */ - int len = weights[idx]; - int32_t idx2; - const UCHAR *np = (const UCHAR *) n; + idx = findidx (&cp); + if (idx != 0) + { + /* We found a table entry. Now see whether the + character we are currently at has the same + equivalance class value. */ + int len = weights[idx & 0xffffff]; + int32_t idx2; + const UCHAR *np = (const UCHAR *) n; - idx2 = findidx (&np); - if (idx2 != 0 && len == weights[idx2]) - { - int cnt = 0; + idx2 = findidx (&np); + if (idx2 != 0 + && (idx >> 24) == (idx2 >> 24) + && len == weights[idx2 & 0xffffff]) + { + int cnt = 0; - while (cnt < len - && (weights[idx + 1 + cnt] - == weights[idx2 + 1 + cnt])) - ++cnt; + idx &= 0xffffff; + idx2 &= 0xffffff; - if (cnt == len) - goto matched; - } - } - } + while (cnt < len + && (weights[idx + 1 + cnt] + == weights[idx2 + 1 + cnt])) + ++cnt; - c = *p++; - } + if (cnt == len) + goto matched; + } + } + } + + c = *p++; + } #endif - else if (c == L_('\0')) - /* [ (unterminated) loses. */ - return FNM_NOMATCH; - else - { - bool is_range = false; + else if (c == L_('\0')) + /* [ (unterminated) loses. */ + return FNM_NOMATCH; + else + { + bool is_range = false; #ifdef _LIBC - bool is_seqval = false; + bool is_seqval = false; - if (c == L_('[') && *p == L_('.')) - { - uint32_t nrules = - _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); - const CHAR *startp = p; - size_t c1 = 0; + if (c == L_('[') && *p == L_('.')) + { + uint32_t nrules = + _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); + const CHAR *startp = p; + size_t c1 = 0; - while (1) - { - c = *++p; - if (c == L_('.') && p[1] == L_(']')) - { - p += 2; - break; - } - if (c == '\0') - return FNM_NOMATCH; - ++c1; - } + while (1) + { + c = *++p; + if (c == L_('.') && p[1] == L_(']')) + { + p += 2; + break; + } + if (c == '\0') + return FNM_NOMATCH; + ++c1; + } - /* We have to handling the symbols differently in - ranges since then the collation sequence is - important. */ - is_range = *p == L_('-') && p[1] != L_('\0'); + /* We have to handling the symbols differently in + ranges since then the collation sequence is + important. */ + is_range = *p == L_('-') && p[1] != L_('\0'); - if (nrules == 0) - { - /* There are no names defined in the collation - data. Therefore we only accept the trivial - names consisting of the character itself. */ - if (c1 != 1) - return FNM_NOMATCH; + if (nrules == 0) + { + /* There are no names defined in the collation + data. Therefore we only accept the trivial + names consisting of the character itself. */ + if (c1 != 1) + return FNM_NOMATCH; - if (!is_range && *n == startp[1]) - goto matched; + if (!is_range && *n == startp[1]) + goto matched; - cold = startp[1]; - c = *p++; - } - else - { - int32_t table_size; - const int32_t *symb_table; + cold = startp[1]; + c = *p++; + } + else + { + int32_t table_size; + const int32_t *symb_table; # ifdef WIDE_CHAR_VERSION - char str[c1]; - size_t strcnt; + char str[c1]; + size_t strcnt; # else # define str (startp + 1) # endif - const unsigned char *extra; - int32_t idx; - int32_t elem; - int32_t second; - int32_t hash; + const unsigned char *extra; + int32_t idx; + int32_t elem; + int32_t second; + int32_t hash; # ifdef WIDE_CHAR_VERSION - /* We have to convert the name to a single-byte - string. This is possible since the names - consist of ASCII characters and the internal - representation is UCS4. */ - for (strcnt = 0; strcnt < c1; ++strcnt) - str[strcnt] = startp[1 + strcnt]; + /* We have to convert the name to a single-byte + string. This is possible since the names + consist of ASCII characters and the internal + representation is UCS4. */ + for (strcnt = 0; strcnt < c1; ++strcnt) + str[strcnt] = startp[1 + strcnt]; # endif - table_size = - _NL_CURRENT_WORD (LC_COLLATE, - _NL_COLLATE_SYMB_HASH_SIZEMB); - symb_table = (const int32_t *) - _NL_CURRENT (LC_COLLATE, - _NL_COLLATE_SYMB_TABLEMB); - extra = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, - _NL_COLLATE_SYMB_EXTRAMB); + table_size = + _NL_CURRENT_WORD (LC_COLLATE, + _NL_COLLATE_SYMB_HASH_SIZEMB); + symb_table = (const int32_t *) + _NL_CURRENT (LC_COLLATE, + _NL_COLLATE_SYMB_TABLEMB); + extra = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, + _NL_COLLATE_SYMB_EXTRAMB); - /* Locate the character in the hashing table. */ - hash = elem_hash (str, c1); + /* Locate the character in the hashing table. */ + hash = elem_hash (str, c1); - idx = 0; - elem = hash % table_size; - if (symb_table[2 * elem] != 0) - { - second = hash % (table_size - 2) + 1; + idx = 0; + elem = hash % table_size; + if (symb_table[2 * elem] != 0) + { + second = hash % (table_size - 2) + 1; - do - { - /* First compare the hashing value. */ - if (symb_table[2 * elem] == hash - && (c1 - == extra[symb_table[2 * elem + 1]]) - && memcmp (str, - &extra[symb_table[2 * elem - + 1] - + 1], c1) == 0) - { - /* Yep, this is the entry. */ - idx = symb_table[2 * elem + 1]; - idx += 1 + extra[idx]; - break; - } + do + { + /* First compare the hashing value. */ + if (symb_table[2 * elem] == hash + && (c1 + == extra[symb_table[2 * elem + 1]]) + && memcmp (str, + &extra[symb_table[2 * elem + + 1] + + 1], c1) == 0) + { + /* Yep, this is the entry. */ + idx = symb_table[2 * elem + 1]; + idx += 1 + extra[idx]; + break; + } - /* Next entry. */ - elem += second; - } - while (symb_table[2 * elem] != 0); - } + /* Next entry. */ + elem += second; + } + while (symb_table[2 * elem] != 0); + } - if (symb_table[2 * elem] != 0) - { - /* Compare the byte sequence but only if - this is not part of a range. */ + if (symb_table[2 * elem] != 0) + { + /* Compare the byte sequence but only if + this is not part of a range. */ # ifdef WIDE_CHAR_VERSION - int32_t *wextra; + int32_t *wextra; - idx += 1 + extra[idx]; - /* Adjust for the alignment. */ - idx = (idx + 3) & ~3; + idx += 1 + extra[idx]; + /* Adjust for the alignment. */ + idx = (idx + 3) & ~3; - wextra = (int32_t *) &extra[idx + 4]; + wextra = (int32_t *) &extra[idx + 4]; # endif - if (! is_range) - { + if (! is_range) + { # ifdef WIDE_CHAR_VERSION - for (c1 = 0; - (int32_t) c1 < wextra[idx]; - ++c1) - if (n[c1] != wextra[1 + c1]) - break; + for (c1 = 0; + (int32_t) c1 < wextra[idx]; + ++c1) + if (n[c1] != wextra[1 + c1]) + break; - if ((int32_t) c1 == wextra[idx]) - goto matched; + if ((int32_t) c1 == wextra[idx]) + goto matched; # else - for (c1 = 0; c1 < extra[idx]; ++c1) - if (n[c1] != extra[1 + c1]) - break; + for (c1 = 0; c1 < extra[idx]; ++c1) + if (n[c1] != extra[1 + c1]) + break; - if (c1 == extra[idx]) - goto matched; + if (c1 == extra[idx]) + goto matched; # endif - } + } - /* Get the collation sequence value. */ - is_seqval = true; + /* Get the collation sequence value. */ + is_seqval = true; # ifdef WIDE_CHAR_VERSION - cold = wextra[1 + wextra[idx]]; + cold = wextra[1 + wextra[idx]]; # else - /* Adjust for the alignment. */ - idx += 1 + extra[idx]; - idx = (idx + 3) & ~4; - cold = *((int32_t *) &extra[idx]); + /* Adjust for the alignment. */ + idx += 1 + extra[idx]; + idx = (idx + 3) & ~4; + cold = *((int32_t *) &extra[idx]); # endif - c = *p++; - } - else if (c1 == 1) - { - /* No valid character. Match it as a - single byte. */ - if (!is_range && *n == str[0]) - goto matched; + c = *p++; + } + else if (c1 == 1) + { + /* No valid character. Match it as a + single byte. */ + if (!is_range && *n == str[0]) + goto matched; - cold = str[0]; - c = *p++; - } - else - return FNM_NOMATCH; - } - } - else + cold = str[0]; + c = *p++; + } + else + return FNM_NOMATCH; + } + } + else # undef str #endif - { - c = FOLD (c); - normal_bracket: + { + c = FOLD (c); + normal_bracket: - /* We have to handling the symbols differently in - ranges since then the collation sequence is - important. */ - is_range = (*p == L_('-') && p[1] != L_('\0') - && p[1] != L_(']')); + /* We have to handling the symbols differently in + ranges since then the collation sequence is + important. */ + is_range = (*p == L_('-') && p[1] != L_('\0') + && p[1] != L_(']')); - if (!is_range && c == fn) - goto matched; + if (!is_range && c == fn) + goto matched; #if _LIBC - /* This is needed if we goto normal_bracket; from - outside of is_seqval's scope. */ - is_seqval = false; + /* This is needed if we goto normal_bracket; from + outside of is_seqval's scope. */ + is_seqval = false; #endif - cold = c; - c = *p++; - } + cold = c; + c = *p++; + } - if (c == L_('-') && *p != L_(']')) - { + if (c == L_('-') && *p != L_(']')) + { #if _LIBC - /* We have to find the collation sequence - value for C. Collation sequence is nothing - we can regularly access. The sequence - value is defined by the order in which the - definitions of the collation values for the - various characters appear in the source - file. A strange concept, nowhere - documented. */ - uint32_t fcollseq; - uint32_t lcollseq; - UCHAR cend = *p++; + /* We have to find the collation sequence + value for C. Collation sequence is nothing + we can regularly access. The sequence + value is defined by the order in which the + definitions of the collation values for the + various characters appear in the source + file. A strange concept, nowhere + documented. */ + uint32_t fcollseq; + uint32_t lcollseq; + UCHAR cend = *p++; # ifdef WIDE_CHAR_VERSION - /* Search in the `names' array for the characters. */ - fcollseq = __collseq_table_lookup (collseq, fn); - if (fcollseq == ~((uint32_t) 0)) - /* XXX We don't know anything about the character - we are supposed to match. This means we are - failing. */ - goto range_not_matched; + /* Search in the `names' array for the characters. */ + fcollseq = __collseq_table_lookup (collseq, fn); + if (fcollseq == ~((uint32_t) 0)) + /* XXX We don't know anything about the character + we are supposed to match. This means we are + failing. */ + goto range_not_matched; - if (is_seqval) - lcollseq = cold; - else - lcollseq = __collseq_table_lookup (collseq, cold); + if (is_seqval) + lcollseq = cold; + else + lcollseq = __collseq_table_lookup (collseq, cold); # else - fcollseq = collseq[fn]; - lcollseq = is_seqval ? cold : collseq[(UCHAR) cold]; + fcollseq = collseq[fn]; + lcollseq = is_seqval ? cold : collseq[(UCHAR) cold]; # endif - is_seqval = false; - if (cend == L_('[') && *p == L_('.')) - { - uint32_t nrules = - _NL_CURRENT_WORD (LC_COLLATE, - _NL_COLLATE_NRULES); - const CHAR *startp = p; - size_t c1 = 0; + is_seqval = false; + if (cend == L_('[') && *p == L_('.')) + { + uint32_t nrules = + _NL_CURRENT_WORD (LC_COLLATE, + _NL_COLLATE_NRULES); + const CHAR *startp = p; + size_t c1 = 0; - while (1) - { - c = *++p; - if (c == L_('.') && p[1] == L_(']')) - { - p += 2; - break; - } - if (c == '\0') - return FNM_NOMATCH; - ++c1; - } + while (1) + { + c = *++p; + if (c == L_('.') && p[1] == L_(']')) + { + p += 2; + break; + } + if (c == '\0') + return FNM_NOMATCH; + ++c1; + } - if (nrules == 0) - { - /* There are no names defined in the - collation data. Therefore we only - accept the trivial names consisting - of the character itself. */ - if (c1 != 1) - return FNM_NOMATCH; + if (nrules == 0) + { + /* There are no names defined in the + collation data. Therefore we only + accept the trivial names consisting + of the character itself. */ + if (c1 != 1) + return FNM_NOMATCH; - cend = startp[1]; - } - else - { - int32_t table_size; - const int32_t *symb_table; + cend = startp[1]; + } + else + { + int32_t table_size; + const int32_t *symb_table; # ifdef WIDE_CHAR_VERSION - char str[c1]; - size_t strcnt; + char str[c1]; + size_t strcnt; # else # define str (startp + 1) # endif - const unsigned char *extra; - int32_t idx; - int32_t elem; - int32_t second; - int32_t hash; + const unsigned char *extra; + int32_t idx; + int32_t elem; + int32_t second; + int32_t hash; # ifdef WIDE_CHAR_VERSION - /* We have to convert the name to a single-byte - string. This is possible since the names - consist of ASCII characters and the internal - representation is UCS4. */ - for (strcnt = 0; strcnt < c1; ++strcnt) - str[strcnt] = startp[1 + strcnt]; + /* We have to convert the name to a single-byte + string. This is possible since the names + consist of ASCII characters and the internal + representation is UCS4. */ + for (strcnt = 0; strcnt < c1; ++strcnt) + str[strcnt] = startp[1 + strcnt]; # endif - table_size = - _NL_CURRENT_WORD (LC_COLLATE, - _NL_COLLATE_SYMB_HASH_SIZEMB); - symb_table = (const int32_t *) - _NL_CURRENT (LC_COLLATE, - _NL_COLLATE_SYMB_TABLEMB); - extra = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, - _NL_COLLATE_SYMB_EXTRAMB); + table_size = + _NL_CURRENT_WORD (LC_COLLATE, + _NL_COLLATE_SYMB_HASH_SIZEMB); + symb_table = (const int32_t *) + _NL_CURRENT (LC_COLLATE, + _NL_COLLATE_SYMB_TABLEMB); + extra = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, + _NL_COLLATE_SYMB_EXTRAMB); - /* Locate the character in the hashing + /* Locate the character in the hashing table. */ - hash = elem_hash (str, c1); + hash = elem_hash (str, c1); - idx = 0; - elem = hash % table_size; - if (symb_table[2 * elem] != 0) - { - second = hash % (table_size - 2) + 1; + idx = 0; + elem = hash % table_size; + if (symb_table[2 * elem] != 0) + { + second = hash % (table_size - 2) + 1; - do - { - /* First compare the hashing value. */ - if (symb_table[2 * elem] == hash - && (c1 - == extra[symb_table[2 * elem + 1]]) - && memcmp (str, - &extra[symb_table[2 * elem + 1] - + 1], c1) == 0) - { - /* Yep, this is the entry. */ - idx = symb_table[2 * elem + 1]; - idx += 1 + extra[idx]; - break; - } + do + { + /* First compare the hashing value. */ + if (symb_table[2 * elem] == hash + && (c1 + == extra[symb_table[2 * elem + 1]]) + && memcmp (str, + &extra[symb_table[2 * elem + 1] + + 1], c1) == 0) + { + /* Yep, this is the entry. */ + idx = symb_table[2 * elem + 1]; + idx += 1 + extra[idx]; + break; + } - /* Next entry. */ - elem += second; - } - while (symb_table[2 * elem] != 0); - } + /* Next entry. */ + elem += second; + } + while (symb_table[2 * elem] != 0); + } - if (symb_table[2 * elem] != 0) - { - /* Compare the byte sequence but only if - this is not part of a range. */ + if (symb_table[2 * elem] != 0) + { + /* Compare the byte sequence but only if + this is not part of a range. */ # ifdef WIDE_CHAR_VERSION - int32_t *wextra; + int32_t *wextra; - idx += 1 + extra[idx]; - /* Adjust for the alignment. */ - idx = (idx + 3) & ~4; + idx += 1 + extra[idx]; + /* Adjust for the alignment. */ + idx = (idx + 3) & ~4; - wextra = (int32_t *) &extra[idx + 4]; + wextra = (int32_t *) &extra[idx + 4]; # endif - /* Get the collation sequence value. */ - is_seqval = true; + /* Get the collation sequence value. */ + is_seqval = true; # ifdef WIDE_CHAR_VERSION - cend = wextra[1 + wextra[idx]]; + cend = wextra[1 + wextra[idx]]; # else - /* Adjust for the alignment. */ - idx += 1 + extra[idx]; - idx = (idx + 3) & ~4; - cend = *((int32_t *) &extra[idx]); + /* Adjust for the alignment. */ + idx += 1 + extra[idx]; + idx = (idx + 3) & ~4; + cend = *((int32_t *) &extra[idx]); # endif - } - else if (symb_table[2 * elem] != 0 && c1 == 1) - { - cend = str[0]; - c = *p++; - } - else - return FNM_NOMATCH; - } + } + else if (symb_table[2 * elem] != 0 && c1 == 1) + { + cend = str[0]; + c = *p++; + } + else + return FNM_NOMATCH; + } # undef str - } - else - { - if (!(flags & FNM_NOESCAPE) && cend == L_('\\')) - cend = *p++; - if (cend == L_('\0')) - return FNM_NOMATCH; - cend = FOLD (cend); - } + } + else + { + if (!(flags & FNM_NOESCAPE) && cend == L_('\\')) + cend = *p++; + if (cend == L_('\0')) + return FNM_NOMATCH; + cend = FOLD (cend); + } - /* XXX It is not entirely clear to me how to handle - characters which are not mentioned in the - collation specification. */ - if ( + /* XXX It is not entirely clear to me how to handle + characters which are not mentioned in the + collation specification. */ + if ( # ifdef WIDE_CHAR_VERSION - lcollseq == 0xffffffff || + lcollseq == 0xffffffff || # endif - lcollseq <= fcollseq) - { - /* We have to look at the upper bound. */ - uint32_t hcollseq; + lcollseq <= fcollseq) + { + /* We have to look at the upper bound. */ + uint32_t hcollseq; - if (is_seqval) - hcollseq = cend; - else - { + if (is_seqval) + hcollseq = cend; + else + { # ifdef WIDE_CHAR_VERSION - hcollseq = - __collseq_table_lookup (collseq, cend); - if (hcollseq == ~((uint32_t) 0)) - { - /* Hum, no information about the upper - bound. The matching succeeds if the - lower bound is matched exactly. */ - if (lcollseq != fcollseq) - goto range_not_matched; + hcollseq = + __collseq_table_lookup (collseq, cend); + if (hcollseq == ~((uint32_t) 0)) + { + /* Hum, no information about the upper + bound. The matching succeeds if the + lower bound is matched exactly. */ + if (lcollseq != fcollseq) + goto range_not_matched; - goto matched; - } + goto matched; + } # else - hcollseq = collseq[cend]; + hcollseq = collseq[cend]; # endif - } + } - if (lcollseq <= hcollseq && fcollseq <= hcollseq) - goto matched; - } + if (lcollseq <= hcollseq && fcollseq <= hcollseq) + goto matched; + } # ifdef WIDE_CHAR_VERSION - range_not_matched: + range_not_matched: # endif #else - /* We use a boring value comparison of the character - values. This is better than comparing using - `strcoll' since the latter would have surprising - and sometimes fatal consequences. */ - UCHAR cend = *p++; + /* We use a boring value comparison of the character + values. This is better than comparing using + `strcoll' since the latter would have surprising + and sometimes fatal consequences. */ + UCHAR cend = *p++; - if (!(flags & FNM_NOESCAPE) && cend == L_('\\')) - cend = *p++; - if (cend == L_('\0')) - return FNM_NOMATCH; + if (!(flags & FNM_NOESCAPE) && cend == L_('\\')) + cend = *p++; + if (cend == L_('\0')) + return FNM_NOMATCH; - /* It is a range. */ - if (cold <= fn && fn <= cend) - goto matched; + /* It is a range. */ + if (cold <= fn && fn <= cend) + goto matched; #endif - c = *p++; - } - } + c = *p++; + } + } - if (c == L_(']')) - break; - } + if (c == L_(']')) + break; + } - if (!not) - return FNM_NOMATCH; - break; + if (!not) + return FNM_NOMATCH; + break; - matched: - /* Skip the rest of the [...] that already matched. */ - do - { - ignore_next: - c = *p++; + matched: + /* Skip the rest of the [...] that already matched. */ + do + { + ignore_next: + c = *p++; - if (c == L_('\0')) - /* [... (unterminated) loses. */ - return FNM_NOMATCH; + if (c == L_('\0')) + /* [... (unterminated) loses. */ + return FNM_NOMATCH; - if (!(flags & FNM_NOESCAPE) && c == L_('\\')) - { - if (*p == L_('\0')) - return FNM_NOMATCH; - /* XXX 1003.2d11 is unclear if this is right. */ - ++p; - } - else if (c == L_('[') && *p == L_(':')) - { - int c1 = 0; - const CHAR *startp = p; + if (!(flags & FNM_NOESCAPE) && c == L_('\\')) + { + if (*p == L_('\0')) + return FNM_NOMATCH; + /* XXX 1003.2d11 is unclear if this is right. */ + ++p; + } + else if (c == L_('[') && *p == L_(':')) + { + int c1 = 0; + const CHAR *startp = p; - while (1) - { - c = *++p; - if (++c1 == CHAR_CLASS_MAX_LENGTH) - return FNM_NOMATCH; + while (1) + { + c = *++p; + if (++c1 == CHAR_CLASS_MAX_LENGTH) + return FNM_NOMATCH; - if (*p == L_(':') && p[1] == L_(']')) - break; + if (*p == L_(':') && p[1] == L_(']')) + break; - if (c < L_('a') || c >= L_('z')) - { - p = startp; - goto ignore_next; - } - } - p += 2; - c = *p++; - } - else if (c == L_('[') && *p == L_('=')) - { - c = *++p; - if (c == L_('\0')) - return FNM_NOMATCH; - c = *++p; - if (c != L_('=') || p[1] != L_(']')) - return FNM_NOMATCH; - p += 2; - c = *p++; - } - else if (c == L_('[') && *p == L_('.')) - { - ++p; - while (1) - { - c = *++p; - if (c == '\0') - return FNM_NOMATCH; + if (c < L_('a') || c >= L_('z')) + { + p = startp; + goto ignore_next; + } + } + p += 2; + c = *p++; + } + else if (c == L_('[') && *p == L_('=')) + { + c = *++p; + if (c == L_('\0')) + return FNM_NOMATCH; + c = *++p; + if (c != L_('=') || p[1] != L_(']')) + return FNM_NOMATCH; + p += 2; + c = *p++; + } + else if (c == L_('[') && *p == L_('.')) + { + ++p; + while (1) + { + c = *++p; + if (c == '\0') + return FNM_NOMATCH; - if (*p == L_('.') && p[1] == L_(']')) - break; - } - p += 2; - c = *p++; - } - } - while (c != L_(']')); - if (not) - return FNM_NOMATCH; - } - break; + if (*p == L_('.') && p[1] == L_(']')) + break; + } + p += 2; + c = *p++; + } + } + while (c != L_(']')); + if (not) + return FNM_NOMATCH; + } + break; - case L_('+'): - case L_('@'): - case L_('!'): - if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(') - { - int res; + case L_('+'): + case L_('@'): + case L_('!'): + if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(') + { + int res; - res = EXT (c, p, n, string_end, no_leading_period, flags); - if (res != -1) - return res; - } - goto normal_match; + res = EXT (c, p, n, string_end, no_leading_period, flags); + if (res != -1) + return res; + } + goto normal_match; - case L_('/'): - if (NO_LEADING_PERIOD (flags)) - { - if (n == string_end || c != (UCHAR) *n) - return FNM_NOMATCH; + case L_('/'): + if (NO_LEADING_PERIOD (flags)) + { + if (n == string_end || c != (UCHAR) *n) + return FNM_NOMATCH; - new_no_leading_period = true; - break; - } - /* FALLTHROUGH */ - default: - normal_match: - if (n == string_end || c != FOLD ((UCHAR) *n)) - return FNM_NOMATCH; - } + new_no_leading_period = true; + break; + } + /* FALLTHROUGH */ + default: + normal_match: + if (n == string_end || c != FOLD ((UCHAR) *n)) + return FNM_NOMATCH; + } no_leading_period = new_no_leading_period; ++n; @@ -987,25 +992,25 @@ END (const CHAR *pattern) return pattern; else if (*p == L_('[')) { - /* Handle brackets special. */ - if (posixly_correct == 0) - posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1; + /* Handle brackets special. */ + if (posixly_correct == 0) + posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1; - /* Skip the not sign. We have to recognize it because of a possibly - following ']'. */ - if (*++p == L_('!') || (posixly_correct < 0 && *p == L_('^'))) - ++p; - /* A leading ']' is recognized as such. */ - if (*p == L_(']')) - ++p; - /* Skip over all characters of the list. */ - while (*p != L_(']')) - if (*p++ == L_('\0')) - /* This is no valid pattern. */ - return pattern; + /* Skip the not sign. We have to recognize it because of a possibly + following ']'. */ + if (*++p == L_('!') || (posixly_correct < 0 && *p == L_('^'))) + ++p; + /* A leading ']' is recognized as such. */ + if (*p == L_(']')) + ++p; + /* Skip over all characters of the list. */ + while (*p != L_(']')) + if (*p++ == L_('\0')) + /* This is no valid pattern. */ + return pattern; } else if ((*p == L_('?') || *p == L_('*') || *p == L_('+') || *p == L_('@') - || *p == L_('!')) && p[1] == L_('(')) + || *p == L_('!')) && p[1] == L_('(')) p = END (p + 1); else if (*p == L_(')')) break; @@ -1040,63 +1045,63 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end, return -1; else if (*p == L_('[')) { - /* Handle brackets special. */ - if (posixly_correct == 0) - posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1; + /* Handle brackets special. */ + if (posixly_correct == 0) + posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1; - /* Skip the not sign. We have to recognize it because of a possibly - following ']'. */ - if (*++p == L_('!') || (posixly_correct < 0 && *p == L_('^'))) - ++p; - /* A leading ']' is recognized as such. */ - if (*p == L_(']')) - ++p; - /* Skip over all characters of the list. */ - while (*p != L_(']')) - if (*p++ == L_('\0')) - /* This is no valid pattern. */ - return -1; + /* Skip the not sign. We have to recognize it because of a possibly + following ']'. */ + if (*++p == L_('!') || (posixly_correct < 0 && *p == L_('^'))) + ++p; + /* A leading ']' is recognized as such. */ + if (*p == L_(']')) + ++p; + /* Skip over all characters of the list. */ + while (*p != L_(']')) + if (*p++ == L_('\0')) + /* This is no valid pattern. */ + return -1; } else if ((*p == L_('?') || *p == L_('*') || *p == L_('+') || *p == L_('@') - || *p == L_('!')) && p[1] == L_('(')) + || *p == L_('!')) && p[1] == L_('(')) /* Remember the nesting level. */ ++level; else if (*p == L_(')')) { - if (level-- == 0) - { - /* This means we found the end of the pattern. */ + if (level-- == 0) + { + /* This means we found the end of the pattern. */ #define NEW_PATTERN \ - struct patternlist *newp; \ - size_t plen; \ - size_t plensize; \ - size_t newpsize; \ - \ - plen = (opt == L_('?') || opt == L_('@') \ - ? pattern_len \ - : p - startp + 1); \ - plensize = plen * sizeof (CHAR); \ - newpsize = offsetof (struct patternlist, str) + plensize; \ - if ((size_t) -1 / sizeof (CHAR) < plen \ - || newpsize < offsetof (struct patternlist, str) \ - || ALLOCA_LIMIT <= newpsize) \ - return -1; \ - newp = (struct patternlist *) alloca (newpsize); \ - *((CHAR *) MEMPCPY (newp->str, startp, p - startp)) = L_('\0'); \ - newp->next = NULL; \ - *lastp = newp; \ - lastp = &newp->next - NEW_PATTERN; - break; - } + struct patternlist *newp; \ + size_t plen; \ + size_t plensize; \ + size_t newpsize; \ + \ + plen = (opt == L_('?') || opt == L_('@') \ + ? pattern_len \ + : p - startp + 1UL); \ + plensize = plen * sizeof (CHAR); \ + newpsize = offsetof (struct patternlist, str) + plensize; \ + if ((size_t) -1 / sizeof (CHAR) < plen \ + || newpsize < offsetof (struct patternlist, str) \ + || ALLOCA_LIMIT <= newpsize) \ + return -1; \ + newp = (struct patternlist *) alloca (newpsize); \ + *((CHAR *) MEMPCPY (newp->str, startp, p - startp)) = L_('\0'); \ + newp->next = NULL; \ + *lastp = newp; \ + lastp = &newp->next + NEW_PATTERN; + break; + } } else if (*p == L_('|')) { - if (level == 0) - { - NEW_PATTERN; - startp = p + 1; - } + if (level == 0) + { + NEW_PATTERN; + startp = p + 1; + } } assert (list != NULL); assert (p[-1] == L_(')')); @@ -1106,36 +1111,36 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end, { case L_('*'): if (FCT (p, string, string_end, no_leading_period, flags) == 0) - return 0; + return 0; /* FALLTHROUGH */ case L_('+'): do - { - for (rs = string; rs <= string_end; ++rs) - /* First match the prefix with the current pattern with the - current pattern. */ - if (FCT (list->str, string, rs, no_leading_period, - flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0 - /* This was successful. Now match the rest with the rest - of the pattern. */ - && (FCT (p, rs, string_end, - rs == string - ? no_leading_period - : rs[-1] == '/' && NO_LEADING_PERIOD (flags), - flags & FNM_FILE_NAME - ? flags : flags & ~FNM_PERIOD) == 0 - /* This didn't work. Try the whole pattern. */ - || (rs != string - && FCT (pattern - 1, rs, string_end, - rs == string - ? no_leading_period - : rs[-1] == '/' && NO_LEADING_PERIOD (flags), - flags & FNM_FILE_NAME - ? flags : flags & ~FNM_PERIOD) == 0))) - /* It worked. Signal success. */ - return 0; - } + { + for (rs = string; rs <= string_end; ++rs) + /* First match the prefix with the current pattern with the + current pattern. */ + if (FCT (list->str, string, rs, no_leading_period, + flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0 + /* This was successful. Now match the rest with the rest + of the pattern. */ + && (FCT (p, rs, string_end, + rs == string + ? no_leading_period + : rs[-1] == '/' && NO_LEADING_PERIOD (flags), + flags & FNM_FILE_NAME + ? flags : flags & ~FNM_PERIOD) == 0 + /* This didn't work. Try the whole pattern. */ + || (rs != string + && FCT (pattern - 1, rs, string_end, + rs == string + ? no_leading_period + : rs[-1] == '/' && NO_LEADING_PERIOD (flags), + flags & FNM_FILE_NAME + ? flags : flags & ~FNM_PERIOD) == 0))) + /* It worked. Signal success. */ + return 0; + } while ((list = list->next) != NULL); /* None of the patterns lead to a match. */ @@ -1143,20 +1148,20 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end, case L_('?'): if (FCT (p, string, string_end, no_leading_period, flags) == 0) - return 0; + return 0; /* FALLTHROUGH */ case L_('@'): do - /* I cannot believe it but `strcat' is actually acceptable - here. Match the entire string with the prefix from the - pattern list and the rest of the pattern following the - pattern list. */ - if (FCT (STRCAT (list->str, p), string, string_end, - no_leading_period, - flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0) - /* It worked. Signal success. */ - return 0; + /* I cannot believe it but `strcat' is actually acceptable + here. Match the entire string with the prefix from the + pattern list and the rest of the pattern following the + pattern list. */ + if (FCT (STRCAT (list->str, p), string, string_end, + no_leading_period, + flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0) + /* It worked. Signal success. */ + return 0; while ((list = list->next) != NULL); /* None of the patterns lead to a match. */ @@ -1164,28 +1169,28 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end, case L_('!'): for (rs = string; rs <= string_end; ++rs) - { - struct patternlist *runp; + { + struct patternlist *runp; - for (runp = list; runp != NULL; runp = runp->next) - if (FCT (runp->str, string, rs, no_leading_period, - flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0) - break; + for (runp = list; runp != NULL; runp = runp->next) + if (FCT (runp->str, string, rs, no_leading_period, + flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0) + break; - /* If none of the patterns matched see whether the rest does. */ - if (runp == NULL - && (FCT (p, rs, string_end, - rs == string - ? no_leading_period - : rs[-1] == '/' && NO_LEADING_PERIOD (flags), - flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) - == 0)) - /* This is successful. */ - return 0; - } + /* If none of the patterns matched see whether the rest does. */ + if (runp == NULL + && (FCT (p, rs, string_end, + rs == string + ? no_leading_period + : rs[-1] == '/' && NO_LEADING_PERIOD (flags), + flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) + == 0)) + /* This is successful. */ + return 0; + } /* None of the patterns together with the rest of the pattern - lead to a match. */ + lead to a match. */ return FNM_NOMATCH; default: diff --git a/src/bin/coreutils/lib/fopen-safer.c b/src/bin/coreutils/lib/fopen-safer.c index 9c79922371..0151182d08 100644 --- a/src/bin/coreutils/lib/fopen-safer.c +++ b/src/bin/coreutils/lib/fopen-safer.c @@ -1,7 +1,6 @@ /* Invoke fopen, but avoid some glitches. - Copyright (C) 2001, 2004, 2005, 2006, 2009 Free Software - Foundation, Inc. + Copyright (C) 2001, 2004-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -38,26 +37,26 @@ fopen_safer (char const *file, char const *mode) int fd = fileno (fp); if (0 <= fd && fd <= STDERR_FILENO) - { - int f = dup_safer (fd); + { + int f = dup_safer (fd); - if (f < 0) - { - int e = errno; - fclose (fp); - errno = e; - return NULL; - } + if (f < 0) + { + int e = errno; + fclose (fp); + errno = e; + return NULL; + } - if (fclose (fp) != 0 - || ! (fp = fdopen (f, mode))) - { - int e = errno; - close (f); - errno = e; - return NULL; - } - } + if (fclose (fp) != 0 + || ! (fp = fdopen (f, mode))) + { + int e = errno; + close (f); + errno = e; + return NULL; + } + } } return fp; diff --git a/src/bin/coreutils/lib/fopen.c b/src/bin/coreutils/lib/fopen.c index 72610bd9b4..377b14f716 100644 --- a/src/bin/coreutils/lib/fopen.c +++ b/src/bin/coreutils/lib/fopen.c @@ -1,5 +1,5 @@ /* Open a stream to a file. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -68,35 +68,35 @@ rpl_fopen (const char *filename, const char *mode) size_t len = strlen (filename); if (len > 0 && filename[len - 1] == '/') { - int fd; - struct stat statbuf; - FILE *fp; + int fd; + struct stat statbuf; + FILE *fp; - if (mode[0] == 'w' || mode[0] == 'a') - { - errno = EISDIR; - return NULL; - } + if (mode[0] == 'w' || mode[0] == 'a') + { + errno = EISDIR; + return NULL; + } - fd = open (filename, O_RDONLY); - if (fd < 0) - return NULL; + fd = open (filename, O_RDONLY); + if (fd < 0) + return NULL; - if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode)) - { - close (fd); - errno = ENOTDIR; - return NULL; - } + if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode)) + { + close (fd); + errno = ENOTDIR; + return NULL; + } - fp = fdopen (fd, mode); - if (fp == NULL) - { - int saved_errno = errno; - close (fd); - errno = saved_errno; - } - return fp; + fp = fdopen (fd, mode); + if (fp == NULL) + { + int saved_errno = errno; + close (fd); + errno = saved_errno; + } + return fp; } } # endif diff --git a/src/bin/coreutils/lib/fpending.c b/src/bin/coreutils/lib/fpending.c index 9250d6af9d..774b396e65 100644 --- a/src/bin/coreutils/lib/fpending.c +++ b/src/bin/coreutils/lib/fpending.c @@ -1,5 +1,6 @@ /* fpending.c -- return the number of pending output bytes on a stream - Copyright (C) 2000, 2004, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2000, 2004, 2006-2007, 2009-2010 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/fpending.h b/src/bin/coreutils/lib/fpending.h index c6a493ddf4..fff34f1ed4 100644 --- a/src/bin/coreutils/lib/fpending.h +++ b/src/bin/coreutils/lib/fpending.h @@ -1,6 +1,7 @@ /* Declare __fpending. - Copyright (C) 2000, 2003, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2000, 2003, 2005-2006, 2009-2010 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/fprintftime.h b/src/bin/coreutils/lib/fprintftime.h index 886a7dd4f3..e702e6cae4 100644 --- a/src/bin/coreutils/lib/fprintftime.h +++ b/src/bin/coreutils/lib/fprintftime.h @@ -1,6 +1,6 @@ /* Generate time strings directly to the output. */ -/* Copyright (C) 2005 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,4 +26,4 @@ nstrftime format string, FMT) the time data, *TM, and the UTC and NANOSECONDS values. */ size_t fprintftime (FILE *fp, char const *fmt, struct tm const *tm, - int utc, int nanoseconds); + int utc, int nanoseconds); diff --git a/src/bin/coreutils/lib/fpucw.h b/src/bin/coreutils/lib/fpucw.h index a6226afcf8..c855faea5d 100644 --- a/src/bin/coreutils/lib/fpucw.h +++ b/src/bin/coreutils/lib/fpucw.h @@ -1,5 +1,5 @@ /* Manipulating the FPU control word. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. Written by Bruno Haible , 2007. This program is free software: you can redistribute it and/or modify @@ -70,19 +70,19 @@ typedef unsigned short fpucw_t; /* glibc calls this fpu_control_t */ # define FPU_PC_EXTENDED 0x300 /* glibc calls this _FPU_EXTENDED */ # define GET_FPUCW() \ - ({ fpucw_t _cw; \ - __asm__ __volatile__ ("fnstcw %0" : "=m" (*&_cw)); \ - _cw; \ + ({ fpucw_t _cw; \ + __asm__ __volatile__ ("fnstcw %0" : "=m" (*&_cw)); \ + _cw; \ }) # define SET_FPUCW(word) \ - (void)({ fpucw_t _ncw = (word); \ - __asm__ __volatile__ ("fldcw %0" : : "m" (*&_ncw)); \ + (void)({ fpucw_t _ncw = (word); \ + __asm__ __volatile__ ("fldcw %0" : : "m" (*&_ncw)); \ }) # define DECL_LONG_DOUBLE_ROUNDING \ fpucw_t oldcw; # define BEGIN_LONG_DOUBLE_ROUNDING() \ - (void)(oldcw = GET_FPUCW (), \ + (void)(oldcw = GET_FPUCW (), \ SET_FPUCW ((oldcw & ~FPU_PC_MASK) | FPU_PC_EXTENDED)) # define END_LONG_DOUBLE_ROUNDING() \ SET_FPUCW (oldcw) diff --git a/src/bin/coreutils/lib/fpurge.c b/src/bin/coreutils/lib/fpurge.c index 114dabf19e..079a2995ac 100644 --- a/src/bin/coreutils/lib/fpurge.c +++ b/src/bin/coreutils/lib/fpurge.c @@ -1,5 +1,5 @@ /* Flushing buffers of a FILE stream. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -75,13 +75,13 @@ fpurge (FILE *fp) fp_->_p = fp_->_bf._base; fp_->_r = 0; fp_->_w = ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */ - ? fp_->_bf._size - : 0); + ? fp_->_bf._size + : 0); /* Avoid memory leak when there is an active ungetc buffer. */ if (fp_ub._base != NULL) { if (fp_ub._base != fp_->_ubuf) - free (fp_ub._base); + free (fp_ub._base); fp_ub._base = NULL; } return 0; diff --git a/src/bin/coreutils/lib/freadahead.c b/src/bin/coreutils/lib/freadahead.c index f4b5ed7029..50ff27ee20 100644 --- a/src/bin/coreutils/lib/freadahead.c +++ b/src/bin/coreutils/lib/freadahead.c @@ -1,5 +1,5 @@ /* Retrieve information about a FILE stream. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,8 +29,8 @@ freadahead (FILE *fp) if (fp->_IO_write_ptr > fp->_IO_write_base) return 0; return (fp->_IO_read_end - fp->_IO_read_ptr) - + (fp->_flags & _IO_IN_BACKUP ? fp->_IO_save_end - fp->_IO_save_base : - 0); + + (fp->_flags & _IO_IN_BACKUP ? fp->_IO_save_end - fp->_IO_save_base : + 0); #elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */ if ((fp_->_flags & __SWR) != 0 || fp_->_r < 0) return 0; @@ -38,7 +38,7 @@ freadahead (FILE *fp) return __sreadahead (fp); # else return fp_->_r - + (HASUB (fp) ? fp_->_ur : 0); + + (HASUB (fp) ? fp_->_ur : 0); # endif #elif defined __EMX__ /* emx+gcc */ if ((fp->_flags & _IOWRT) != 0) @@ -57,7 +57,7 @@ freadahead (FILE *fp) if (fp->__modeflags & __FLAG_WRITING) return 0; return (fp->__bufread - fp->__bufpos) - + (fp->__modeflags & __FLAG_UNGOT ? 1 : 0); + + (fp->__modeflags & __FLAG_UNGOT ? 1 : 0); # else return 0; # endif @@ -67,15 +67,15 @@ freadahead (FILE *fp) /* fp->_Buf <= fp->_Next <= fp->_Rend, and fp->_Rend may be overridden by fp->_Rsave. */ return ((fp->_Rsave ? fp->_Rsave : fp->_Rend) - fp->_Next) - + (fp->_Mode & 0x4000 /* _MBYTE */ - ? (fp->_Back + sizeof (fp->_Back)) - fp->_Rback - : 0); + + (fp->_Mode & 0x4000 /* _MBYTE */ + ? (fp->_Back + sizeof (fp->_Back)) - fp->_Rback + : 0); #elif defined __MINT__ /* Atari FreeMiNT */ if (!fp->__mode.__read) return 0; return (fp->__pushed_back - ? fp->__get_limit - fp->__pushback_bufp + 1 - : fp->__get_limit - fp->__bufp); + ? fp->__get_limit - fp->__pushback_bufp + 1 + : fp->__get_limit - fp->__bufp); #elif defined SLOW_BUT_NO_HACKS /* users can define this */ abort (); return 0; diff --git a/src/bin/coreutils/lib/freadahead.h b/src/bin/coreutils/lib/freadahead.h index 96a97d192c..54466b4075 100644 --- a/src/bin/coreutils/lib/freadahead.h +++ b/src/bin/coreutils/lib/freadahead.h @@ -1,5 +1,5 @@ /* Retrieve information about a FILE stream. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/freading.c b/src/bin/coreutils/lib/freading.c index 4da0e31bb2..faca60e104 100644 --- a/src/bin/coreutils/lib/freading.c +++ b/src/bin/coreutils/lib/freading.c @@ -1,5 +1,5 @@ /* Retrieve information about a FILE stream. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,8 +33,8 @@ freading (FILE *fp) fast macros. */ #if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ return ((fp->_flags & _IO_NO_WRITES) != 0 - || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0 - && fp->_IO_read_base != NULL)); + || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0 + && fp->_IO_read_base != NULL)); #elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */ return (fp_->_flags & __SRD) != 0; #elif defined __EMX__ /* emx+gcc */ @@ -45,7 +45,7 @@ freading (FILE *fp) return (fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) != 0; #elif defined __QNX__ /* QNX */ return ((fp->_Mode & 0x2 /* _MOPENW */) == 0 - || (fp->_Mode & 0x1000 /* _MREAD */) != 0); + || (fp->_Mode & 0x1000 /* _MREAD */) != 0); #elif defined __MINT__ /* Atari FreeMiNT */ if (!fp->__mode.__write) return 1; diff --git a/src/bin/coreutils/lib/freading.h b/src/bin/coreutils/lib/freading.h index 5c41ae4451..9b3b6c6a8d 100644 --- a/src/bin/coreutils/lib/freading.h +++ b/src/bin/coreutils/lib/freading.h @@ -1,5 +1,5 @@ /* Retrieve information about a FILE stream. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/freadptr.c b/src/bin/coreutils/lib/freadptr.c index 3abe58e639..05f501bfeb 100644 --- a/src/bin/coreutils/lib/freadptr.c +++ b/src/bin/coreutils/lib/freadptr.c @@ -1,5 +1,5 @@ /* Retrieve information about a FILE stream. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/freadptr.h b/src/bin/coreutils/lib/freadptr.h index 2aa800b56d..855cbd66eb 100644 --- a/src/bin/coreutils/lib/freadptr.h +++ b/src/bin/coreutils/lib/freadptr.h @@ -1,5 +1,5 @@ /* Retrieve information about a FILE stream. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/freadseek.c b/src/bin/coreutils/lib/freadseek.c index 23046fa4c4..99af4370a1 100644 --- a/src/bin/coreutils/lib/freadseek.c +++ b/src/bin/coreutils/lib/freadseek.c @@ -1,5 +1,5 @@ /* Skipping input from a FILE stream. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -80,24 +80,24 @@ freadseek (FILE *fp, size_t offset) size_t buffered; if (freadptr (fp, &buffered) != NULL && buffered > 0) - { - size_t increment = (buffered < offset ? buffered : offset); + { + size_t increment = (buffered < offset ? buffered : offset); - freadptrinc (fp, increment); - offset -= increment; - if (offset == 0) - return 0; - total_buffered -= increment; - if (total_buffered == 0) - break; - } + freadptrinc (fp, increment); + offset -= increment; + if (offset == 0) + return 0; + total_buffered -= increment; + if (total_buffered == 0) + break; + } /* Read one byte. If we were reading from the ungetc buffer, this - switches the stream back to the main buffer. */ + switches the stream back to the main buffer. */ if (fgetc (fp) == EOF) - goto eof; + goto eof; offset--; if (offset == 0) - return 0; + return 0; total_buffered--; } @@ -106,21 +106,21 @@ freadseek (FILE *fp, size_t offset) if (fd >= 0 && lseek (fd, 0, SEEK_CUR) >= 0) { /* FP refers to a regular file. fseek is most efficient in this case. */ - return fseek (fp, offset, SEEK_CUR); + return fseeko (fp, offset, SEEK_CUR); } else { /* FP is a non-seekable stream, possibly not even referring to a file - descriptor. Read OFFSET bytes explicitly and discard them. */ + descriptor. Read OFFSET bytes explicitly and discard them. */ char buf[4096]; do - { - size_t count = (sizeof (buf) < offset ? sizeof (buf) : offset); - if (fread (buf, 1, count, fp) < count) - goto eof; - offset -= count; - } + { + size_t count = (sizeof (buf) < offset ? sizeof (buf) : offset); + if (fread (buf, 1, count, fp) < count) + goto eof; + offset -= count; + } while (offset > 0); return 0; diff --git a/src/bin/coreutils/lib/freadseek.h b/src/bin/coreutils/lib/freadseek.h index 723967250f..572d4870a4 100644 --- a/src/bin/coreutils/lib/freadseek.h +++ b/src/bin/coreutils/lib/freadseek.h @@ -1,5 +1,5 @@ /* Skipping input from a FILE stream. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/freopen-safer.c b/src/bin/coreutils/lib/freopen-safer.c new file mode 100644 index 0000000000..447a0ecf45 --- /dev/null +++ b/src/bin/coreutils/lib/freopen-safer.c @@ -0,0 +1,103 @@ +/* Invoke freopen, but avoid some glitches. + + Copyright (C) 2009, 2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Eric Blake. */ + +#include + +#include "stdio-safer.h" + +#include +#include +#include +#include + +/* Guarantee that FD is open; all smaller FDs must already be open. + Return true if successful. */ +static bool +protect_fd (int fd) +{ + int value = open ("/dev/null", O_RDONLY); + if (value != fd) + { + if (0 <= value) + { + close (value); + errno = EBADF; /* Unexpected; this is as good as anything else. */ + } + return false; + } + return true; +} + +/* Like freopen, but guarantee that reopening stdin, stdout, or stderr + preserves the invariant that STDxxx_FILENO==fileno(stdxxx), and + that no other stream will interfere with the standard streams. + This is necessary because most freopen implementations will change + the associated fd of a stream to the lowest available slot. */ + +FILE * +freopen_safer (char const *name, char const *mode, FILE *f) +{ + /* Unfortunately, we cannot use the fopen_safer approach of using + fdopen (dup_safer (fileno (freopen (cmd, mode, f)))), because we + need to return f itself. The implementation of freopen(NULL,m,f) + is system-dependent, so the best we can do is guarantee that all + lower-valued standard fds are open prior to the freopen call, + even though this puts more pressure on open fds. */ + bool protect_in = false; + bool protect_out = false; + bool protect_err = false; + int saved_errno; + + switch (fileno (f)) + { + default: /* -1 or not a standard stream. */ + if (dup2 (STDERR_FILENO, STDERR_FILENO) != STDERR_FILENO) + protect_err = true; + /* fall through */ + case STDERR_FILENO: + if (dup2 (STDOUT_FILENO, STDOUT_FILENO) != STDOUT_FILENO) + protect_out = true; + /* fall through */ + case STDOUT_FILENO: + if (dup2 (STDIN_FILENO, STDIN_FILENO) != STDIN_FILENO) + protect_in = true; + /* fall through */ + case STDIN_FILENO: + /* Nothing left to protect. */ + break; + } + if (protect_in && !protect_fd (STDIN_FILENO)) + f = NULL; + else if (protect_out && !protect_fd (STDOUT_FILENO)) + f = NULL; + else if (protect_err && !protect_fd (STDERR_FILENO)) + f = NULL; + else + f = freopen (name, mode, f); + saved_errno = errno; + if (protect_err) + close (STDERR_FILENO); + if (protect_out) + close (STDOUT_FILENO); + if (protect_in) + close (STDIN_FILENO); + if (!f) + errno = saved_errno; + return f; +} diff --git a/src/bin/coreutils/lib/freopen.c b/src/bin/coreutils/lib/freopen.c new file mode 100644 index 0000000000..5da5cedaa9 --- /dev/null +++ b/src/bin/coreutils/lib/freopen.c @@ -0,0 +1,46 @@ +/* Open a stream to a file. + Copyright (C) 2007-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2007. */ + +#include + +/* Get the original definition of freopen. It might be defined as a macro. */ +#define __need_FILE +#include +#undef __need_FILE + +static inline FILE * +orig_freopen (const char *filename, const char *mode, FILE *stream) +{ + return freopen (filename, mode, stream); +} + +/* Specification. */ +#include + +#include + +FILE * +rpl_freopen (const char *filename, const char *mode, FILE *stream) +{ +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ + if (strcmp (filename, "/dev/null") == 0) + filename = "NUL"; +#endif + + return orig_freopen (filename, mode, stream); +} diff --git a/src/bin/coreutils/lib/frexp.c b/src/bin/coreutils/lib/frexp.c index 7e1f5d1ad4..e139885c33 100644 --- a/src/bin/coreutils/lib/frexp.c +++ b/src/bin/coreutils/lib/frexp.c @@ -1,5 +1,5 @@ /* Split a double into fraction and mantissa. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -85,73 +85,73 @@ FUNC (DOUBLE x, int *expptr) exponent = 0; if (x >= L_(1.0)) { - /* A positive exponent. */ - DOUBLE pow2_i; /* = pow2[i] */ - DOUBLE powh_i; /* = powh[i] */ + /* A positive exponent. */ + DOUBLE pow2_i; /* = pow2[i] */ + DOUBLE powh_i; /* = powh[i] */ - /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i, - x * 2^exponent = argument, x >= 1.0. */ - for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5); - ; - i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i) - { - if (x >= pow2_i) - { - exponent += (1 << i); - x *= powh_i; - } - else - break; + /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i, + x * 2^exponent = argument, x >= 1.0. */ + for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5); + ; + i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i) + { + if (x >= pow2_i) + { + exponent += (1 << i); + x *= powh_i; + } + else + break; - pow2[i] = pow2_i; - powh[i] = powh_i; - } - /* Avoid making x too small, as it could become a denormalized - number and thus lose precision. */ - while (i > 0 && x < pow2[i - 1]) - { - i--; - powh_i = powh[i]; - } - exponent += (1 << i); - x *= powh_i; - /* Here 2^-2^i <= x < 1.0. */ + pow2[i] = pow2_i; + powh[i] = powh_i; + } + /* Avoid making x too small, as it could become a denormalized + number and thus lose precision. */ + while (i > 0 && x < pow2[i - 1]) + { + i--; + powh_i = powh[i]; + } + exponent += (1 << i); + x *= powh_i; + /* Here 2^-2^i <= x < 1.0. */ } else { - /* A negative or zero exponent. */ - DOUBLE pow2_i; /* = pow2[i] */ - DOUBLE powh_i; /* = powh[i] */ + /* A negative or zero exponent. */ + DOUBLE pow2_i; /* = pow2[i] */ + DOUBLE powh_i; /* = powh[i] */ - /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i, - x * 2^exponent = argument, x < 1.0. */ - for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5); - ; - i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i) - { - if (x < powh_i) - { - exponent -= (1 << i); - x *= pow2_i; - } - else - break; + /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i, + x * 2^exponent = argument, x < 1.0. */ + for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5); + ; + i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i) + { + if (x < powh_i) + { + exponent -= (1 << i); + x *= pow2_i; + } + else + break; - pow2[i] = pow2_i; - powh[i] = powh_i; - } - /* Here 2^-2^i <= x < 1.0. */ + pow2[i] = pow2_i; + powh[i] = powh_i; + } + /* Here 2^-2^i <= x < 1.0. */ } /* Invariants: x * 2^exponent = argument, and 2^-2^i <= x < 1.0. */ while (i > 0) { - i--; - if (x < powh[i]) - { - exponent -= (1 << i); - x *= pow2[i]; - } + i--; + if (x < powh[i]) + { + exponent -= (1 << i); + x *= pow2[i]; + } } /* Here 0.5 <= x < 1.0. */ } diff --git a/src/bin/coreutils/lib/frexpl.c b/src/bin/coreutils/lib/frexpl.c index d6f0d7650d..c805999539 100644 --- a/src/bin/coreutils/lib/frexpl.c +++ b/src/bin/coreutils/lib/frexpl.c @@ -1,5 +1,5 @@ /* Split a 'long double' into fraction and mantissa. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/fseeko.c b/src/bin/coreutils/lib/fseeko.c index 40f9c12d5c..1606646857 100644 --- a/src/bin/coreutils/lib/fseeko.c +++ b/src/bin/coreutils/lib/fseeko.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* An fseeko() function that, together with fflush(), is POSIX compliant. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -53,10 +53,10 @@ rpl_fseeko (FILE *fp, off_t offset, int whence) if ((fp->_flags & __SL64) == 0) { /* Cygwin 1.5.0 through 1.5.24 failed to open stdin in 64-bit - mode; but has an fseeko that requires 64-bit mode. */ + mode; but has an fseeko that requires 64-bit mode. */ FILE *tmp = fopen ("/dev/null", "r"); if (!tmp) - return -1; + return -1; fp->_flags |= __SL64; fp->_seek64 = tmp->_seek64; fclose (tmp); @@ -65,8 +65,8 @@ rpl_fseeko (FILE *fp, off_t offset, int whence) if (fp_->_p == fp_->_bf._base && fp_->_r == 0 && fp_->_w == ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */ - ? fp_->_bf._size - : 0) + ? fp_->_bf._size + : 0) && fp_ub._base == NULL) #elif defined __EMX__ /* emx+gcc */ if (fp->_ptr == fp->_buffer @@ -80,7 +80,7 @@ rpl_fseeko (FILE *fp, off_t offset, int whence) if (((fp->__modeflags & __FLAG_WRITING) == 0 || fp->__bufpos == fp->__bufstart) && ((fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) == 0 - || fp->__bufpos == fp->__bufread)) + || fp->__bufpos == fp->__bufread)) #elif defined __QNX__ /* QNX */ if ((fp->_Mode & 0x2000 /* _MWRITE */ ? fp->_Next == fp->_Buf : fp->_Next == fp->_Rend) && fp->_Rback == fp->_Back + sizeof (fp->_Back) @@ -95,25 +95,42 @@ rpl_fseeko (FILE *fp, off_t offset, int whence) #endif { /* We get here when an fflush() call immediately preceded this one. We - know there are no buffers. - POSIX requires us to modify the file descriptor's position. - But we cannot position beyond end of file here. */ + know there are no buffers. + POSIX requires us to modify the file descriptor's position. + But we cannot position beyond end of file here. */ off_t pos = - lseek (fileno (fp), - whence == SEEK_END && offset > 0 ? 0 : offset, - whence); + lseek (fileno (fp), + whence == SEEK_END && offset > 0 ? 0 : offset, + whence); if (pos == -1) - { + { #if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */ - fp_->_flags &= ~__SOFF; + fp_->_flags &= ~__SOFF; #endif - return -1; - } + return -1; + } #if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ fp->_flags &= ~_IO_EOF_SEEN; #elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */ +# if defined __CYGWIN__ + /* fp_->_offset is typed as an integer. */ fp_->_offset = pos; +# else + /* fp_->_offset is an fpos_t. */ + { + /* Use a union, since on NetBSD, the compilation flags + determine whether fpos_t is typedef'd to off_t or a struct + containing a single off_t member. */ + union + { + fpos_t f; + off_t o; + } u; + u.o = pos; + fp_->_offset = u.f; + } +# endif fp_->_flags |= __SOFF; fp_->_flags &= ~__SEOF; #elif defined __EMX__ /* emx+gcc */ @@ -125,9 +142,9 @@ rpl_fseeko (FILE *fp, off_t offset, int whence) fp->__eof = 0; #endif /* If we were not requested to position beyond end of file, we're - done. */ + done. */ if (!(whence == SEEK_END && offset > 0)) - return 0; + return 0; } return fseeko (fp, offset, whence); } diff --git a/src/bin/coreutils/lib/fseterr.c b/src/bin/coreutils/lib/fseterr.c index 110716bfdc..b1a379ebba 100644 --- a/src/bin/coreutils/lib/fseterr.c +++ b/src/bin/coreutils/lib/fseterr.c @@ -1,5 +1,5 @@ /* Set the error indicator of a stream. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -63,8 +63,8 @@ fseterr (FILE *fp) fputc ('\0', fp); /* This should set the error indicator. */ fflush (fp); /* Or this. */ if (dup2 (fd2, fd) < 0) - /* Whee... we botched the stream and now cannot restore it! */ - abort (); + /* Whee... we botched the stream and now cannot restore it! */ + abort (); close (fd2); } errno = saved_errno; diff --git a/src/bin/coreutils/lib/fseterr.h b/src/bin/coreutils/lib/fseterr.h index 3104f6fcb3..178f0bc72b 100644 --- a/src/bin/coreutils/lib/fseterr.h +++ b/src/bin/coreutils/lib/fseterr.h @@ -1,5 +1,5 @@ /* Set the error indicator of a stream. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/fstatat.c b/src/bin/coreutils/lib/fstatat.c index 9b0c1afa24..bd295b0c96 100644 --- a/src/bin/coreutils/lib/fstatat.c +++ b/src/bin/coreutils/lib/fstatat.c @@ -1,6 +1,6 @@ /* Work around an fstatat bug on Solaris 9. - Copyright (C) 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,34 +25,86 @@ #include #include -#undef fstatat +#if HAVE_FSTATAT + +# undef fstatat /* fstatat should always follow symbolic links that end in /, but on - Solaris 9 it doesn't if AT_SYMLINK_NOFOLLOW is specified. This is - the same problem that lstat.c addresses, so solve it in a similar - way. */ + Solaris 9 it doesn't if AT_SYMLINK_NOFOLLOW is specified. + Likewise, trailing slash on a non-directory should be an error. + These are the same problems that lstat.c and stat.c address, so + solve it in a similar way. */ int rpl_fstatat (int fd, char const *file, struct stat *st, int flag) { int result = fstatat (fd, file, st, flag); + size_t len; - if (result == 0 && (flag & AT_SYMLINK_NOFOLLOW) && S_ISLNK (st->st_mode) - && file[strlen (file) - 1] == '/') + if (result != 0) + return result; + len = strlen (file); + if (flag & AT_SYMLINK_NOFOLLOW) { - /* FILE refers to a symbolic link and the name ends with a slash. - Get info about the link's referent. */ + /* Fix lstat behavior. */ + if (file[len - 1] != '/' || S_ISDIR (st->st_mode)) + return 0; + if (!S_ISLNK (st->st_mode)) + { + errno = ENOTDIR; + return -1; + } result = fstatat (fd, file, st, flag & ~AT_SYMLINK_NOFOLLOW); - if (result == 0 && ! S_ISDIR (st->st_mode)) - { - /* fstatat succeeded and FILE references a non-directory. - But it was specified via a name including a trailing - slash. Fail with errno set to ENOTDIR to indicate the - contradiction. */ - errno = ENOTDIR; - return -1; - } } - + /* Fix stat behavior. */ + if (result == 0 && !S_ISDIR (st->st_mode) && file[len - 1] == '/') + { + errno = ENOTDIR; + return -1; + } return result; } + +#else /* !HAVE_FSTATAT */ + +/* On mingw, the gnulib defines `stat' as a function-like + macro; but using it in AT_FUNC_F2 causes compilation failure + because the preprocessor sees a use of a macro that requires two + arguments but is only given one. Hence, we need an inline + forwarder to get past the preprocessor. */ +static inline int +stat_func (char const *name, struct stat *st) +{ + return stat (name, st); +} + +/* Likewise, if there is no native `lstat', then the gnulib + defined it as stat, which also needs adjustment. */ +# if !HAVE_LSTAT +# undef lstat +# define lstat stat_func +# endif + +/* Replacement for Solaris' function by the same name. + + First, try to simulate it via l?stat ("/proc/self/fd/FD/FILE"). + Failing that, simulate it via save_cwd/fchdir/(stat|lstat)/restore_cwd. + If either the save_cwd or the restore_cwd fails (relatively unlikely), + then give a diagnostic and exit nonzero. + Otherwise, this function works just like Solaris' fstatat. */ + +# define AT_FUNC_NAME fstatat +# define AT_FUNC_F1 lstat +# define AT_FUNC_F2 stat_func +# define AT_FUNC_USE_F1_COND AT_SYMLINK_NOFOLLOW +# define AT_FUNC_POST_FILE_PARAM_DECLS , struct stat *st, int flag +# define AT_FUNC_POST_FILE_ARGS , st +# include "at-func.c" +# undef AT_FUNC_NAME +# undef AT_FUNC_F1 +# undef AT_FUNC_F2 +# undef AT_FUNC_USE_F1_COND +# undef AT_FUNC_POST_FILE_PARAM_DECLS +# undef AT_FUNC_POST_FILE_ARGS + +#endif /* !HAVE_FSTATAT */ diff --git a/src/bin/coreutils/lib/fsusage.c b/src/bin/coreutils/lib/fsusage.c index db0d3bc537..10db467d28 100644 --- a/src/bin/coreutils/lib/fsusage.c +++ b/src/bin/coreutils/lib/fsusage.c @@ -1,7 +1,7 @@ /* fsusage.c -- return space usage of mounted file systems - Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009 - Free Software Foundation, Inc. + Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ #include #include -#if STAT_STATVFS /* POSIX 1003.1-2001 (and later) with XSI */ +#if STAT_STATVFS /* POSIX 1003.1-2001 (and later) with XSI */ # include #else /* Don't include backward-compatibility files unless they're needed. @@ -40,16 +40,16 @@ # if HAVE_SYS_VFS_H # include # endif -# if HAVE_SYS_FS_S5PARAM_H /* Fujitsu UXP/V */ +# if HAVE_SYS_FS_S5PARAM_H /* Fujitsu UXP/V */ # include # endif # if defined HAVE_SYS_FILSYS_H && !defined _CRAY -# include /* SVR2 */ +# include /* SVR2 */ # endif # if HAVE_SYS_STATFS_H # include # endif -# if HAVE_DUSTAT_H /* AIX PS/2 */ +# if HAVE_DUSTAT_H /* AIX PS/2 */ # include # endif # include "full-read.h" @@ -67,13 +67,13 @@ #define PROPAGATE_ALL_ONES(x) \ ((sizeof (x) < sizeof (uintmax_t) \ && (~ (x) == (sizeof (x) < sizeof (int) \ - ? - (1 << (sizeof (x) * CHAR_BIT)) \ - : 0))) \ + ? - (1 << (sizeof (x) * CHAR_BIT)) \ + : 0))) \ ? UINTMAX_MAX : (uintmax_t) (x)) /* Extract the top bit of X as an uintmax_t value. */ #define EXTRACT_TOP_BIT(x) ((x) \ - & ((uintmax_t) 1 << (sizeof (x) * CHAR_BIT - 1))) + & ((uintmax_t) 1 << (sizeof (x) * CHAR_BIT - 1))) /* If a value is negative, many space usage primitives store it into an integer variable by assignment, even if the variable's type is unsigned. @@ -94,7 +94,7 @@ int get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp) { -#if defined STAT_STATVFS /* POSIX */ +#if defined STAT_STATVFS /* POSIX */ struct statvfs fsd; @@ -103,10 +103,10 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp) /* f_frsize isn't guaranteed to be supported. */ fsp->fsu_blocksize = (fsd.f_frsize - ? PROPAGATE_ALL_ONES (fsd.f_frsize) - : PROPAGATE_ALL_ONES (fsd.f_bsize)); + ? PROPAGATE_ALL_ONES (fsd.f_frsize) + : PROPAGATE_ALL_ONES (fsd.f_bsize)); -#elif defined STAT_STATFS2_FS_DATA /* Ultrix */ +#elif defined STAT_STATFS2_FS_DATA /* Ultrix */ struct fs_data fsd; @@ -121,7 +121,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp) fsp->fsu_files = PROPAGATE_ALL_ONES (fsd.fd_req.gtot); fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.fd_req.gfree); -#elif defined STAT_READ_FILSYS /* SVR2 */ +#elif defined STAT_READ_FILSYS /* SVR2 */ # ifndef SUPERBOFF # define SUPERBOFF (SUPERB * 512) # endif @@ -152,8 +152,8 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp) fsp->fsu_bavail = PROPAGATE_TOP_BIT (fsd.s_tfree); fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.s_tfree) != 0; fsp->fsu_files = (fsd.s_isize == -1 - ? UINTMAX_MAX - : (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 1)); + ? UINTMAX_MAX + : (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 1)); fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.s_tinode); #elif defined STAT_STATFS3_OSF1 @@ -165,7 +165,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp) fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize); -#elif defined STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX */ +#elif defined STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX */ struct statfs fsd; @@ -189,7 +189,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp) } # endif /* STATFS_TRUNCATES_BLOCK_COUNTS */ -#elif defined STAT_STATFS2_FSIZE /* 4.4BSD */ +#elif defined STAT_STATFS2_FSIZE /* 4.4BSD */ struct statfs fsd; @@ -198,7 +198,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp) fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize); -#elif defined STAT_STATFS4 /* SVR3, Dynix, Irix, AIX */ +#elif defined STAT_STATFS4 /* SVR3, Dynix, Irix, AIX */ # if !_AIX && !defined _SEQUENT_ && !defined DOLPHIN # define f_bavail f_bfree diff --git a/src/bin/coreutils/lib/fsusage.h b/src/bin/coreutils/lib/fsusage.h index b32abe1836..bb2d86f135 100644 --- a/src/bin/coreutils/lib/fsusage.h +++ b/src/bin/coreutils/lib/fsusage.h @@ -1,6 +1,6 @@ /* fsusage.h -- declarations for file system space usage info - Copyright (C) 1991, 1992, 1997, 2003, 2004, 2005, 2006 Free Software + Copyright (C) 1991-1992, 1997, 2003-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -26,13 +26,13 @@ struct fs_usage { - uintmax_t fsu_blocksize; /* Size of a block. */ - uintmax_t fsu_blocks; /* Total blocks. */ - uintmax_t fsu_bfree; /* Free blocks available to superuser. */ - uintmax_t fsu_bavail; /* Free blocks available to non-superuser. */ - bool fsu_bavail_top_bit_set; /* 1 if fsu_bavail represents a value < 0. */ - uintmax_t fsu_files; /* Total file nodes. */ - uintmax_t fsu_ffree; /* Free file nodes. */ + uintmax_t fsu_blocksize; /* Size of a block. */ + uintmax_t fsu_blocks; /* Total blocks. */ + uintmax_t fsu_bfree; /* Free blocks available to superuser. */ + uintmax_t fsu_bavail; /* Free blocks available to non-superuser. */ + bool fsu_bavail_top_bit_set; /* 1 if fsu_bavail represents a value < 0. */ + uintmax_t fsu_files; /* Total file nodes. */ + uintmax_t fsu_ffree; /* Free file nodes. */ }; int get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp); diff --git a/src/bin/coreutils/lib/fsync.c b/src/bin/coreutils/lib/fsync.c new file mode 100644 index 0000000000..f5b9fdf266 --- /dev/null +++ b/src/bin/coreutils/lib/fsync.c @@ -0,0 +1,81 @@ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +#line 1 +/* Emulate fsync on platforms that lack it, primarily Windows and + cross-compilers like MinGW. + + This is derived from sqlite3 sources. + http://www.sqlite.org/cvstrac/rlog?f=sqlite/src/os_win.c + http://www.sqlite.org/copyright.html + + Written by Richard W.M. Jones + + Copyright (C) 2008-2010 Free Software Foundation, Inc. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include +#include + +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ + +/* _get_osfhandle */ +#include + +/* FlushFileBuffers */ +#define WIN32_LEAN_AND_MEAN +#include + +#include + +int +fsync (int fd) +{ + HANDLE h = (HANDLE) _get_osfhandle (fd); + DWORD err; + + if (h == INVALID_HANDLE_VALUE) + { + errno = EBADF; + return -1; + } + + if (!FlushFileBuffers (h)) + { + /* Translate some Windows errors into rough approximations of Unix + * errors. MSDN is useless as usual - in this case it doesn't + * document the full range of errors. + */ + err = GetLastError (); + switch (err) + { + /* eg. Trying to fsync a tty. */ + case ERROR_INVALID_HANDLE: + errno = EINVAL; + break; + + default: + errno = EIO; + } + return -1; + } + + return 0; +} + +#else /* !Windows */ + +#error "This platform lacks fsync function, and Gnulib doesn't provide a replacement. This is a bug in Gnulib." + +#endif /* !Windows */ diff --git a/src/bin/coreutils/lib/ftello.c b/src/bin/coreutils/lib/ftello.c index f2524084c3..70cd3592e3 100644 --- a/src/bin/coreutils/lib/ftello.c +++ b/src/bin/coreutils/lib/ftello.c @@ -1,5 +1,5 @@ /* An ftello() function that works around platform bugs. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -41,10 +41,10 @@ rpl_ftello (FILE *fp) if ((fp->_flags & __SL64) == 0) { /* Cygwin 1.5.0 through 1.5.24 failed to open stdin in 64-bit - mode; but has an ftello that requires 64-bit mode. */ + mode; but has an ftello that requires 64-bit mode. */ FILE *tmp = fopen ("/dev/null", "r"); if (!tmp) - return -1; + return -1; fp->_flags |= __SL64; fp->_seek64 = tmp->_seek64; fclose (tmp); diff --git a/src/bin/coreutils/lib/ftruncate.c b/src/bin/coreutils/lib/ftruncate.c index ff7d11b090..33b69d8107 100644 --- a/src/bin/coreutils/lib/ftruncate.c +++ b/src/bin/coreutils/lib/ftruncate.c @@ -38,11 +38,11 @@ ftruncate (int fd, off_t length) { /* Extend file length. */ if (lseek (fd, (length - 1), SEEK_SET) < 0) - return -1; + return -1; /* Write a "0" byte. */ if (write (fd, "", 1) != 1) - return -1; + return -1; } else { @@ -52,14 +52,14 @@ ftruncate (int fd, off_t length) fl.l_whence = 0; fl.l_len = 0; fl.l_start = length; - fl.l_type = F_WRLCK; /* write lock on file space */ + fl.l_type = F_WRLCK; /* write lock on file space */ /* This relies on the *undocumented* F_FREESP argument to fcntl, - which truncates the file so that it ends at the position - indicated by fl.l_start. Will minor miracles never cease? */ + which truncates the file so that it ends at the position + indicated by fl.l_start. Will minor miracles never cease? */ if (fcntl (fd, F_FREESP, &fl) < 0) - return -1; + return -1; } return 0; diff --git a/src/bin/coreutils/lib/fts-cycle.c b/src/bin/coreutils/lib/fts-cycle.c index 5f81610a35..dc038cfa1f 100644 --- a/src/bin/coreutils/lib/fts-cycle.c +++ b/src/bin/coreutils/lib/fts-cycle.c @@ -1,6 +1,6 @@ /* Detect cycles in file tree walks. - Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2003-2006, 2009-2010 Free Software Foundation, Inc. Written by Jim Meyering. @@ -53,15 +53,15 @@ setup_dir (FTS *fts) { enum { HT_INITIAL_SIZE = 31 }; fts->fts_cycle.ht = hash_initialize (HT_INITIAL_SIZE, NULL, AD_hash, - AD_compare, free); + AD_compare, free); if (! fts->fts_cycle.ht) - return false; + return false; } else { fts->fts_cycle.state = malloc (sizeof *fts->fts_cycle.state); if (! fts->fts_cycle.state) - return false; + return false; cycle_check_init (fts->fts_cycle.state); } @@ -80,40 +80,40 @@ enter_dir (FTS *fts, FTSENT *ent) struct Active_dir *ad_from_table; if (!ad) - return false; + return false; ad->dev = st->st_dev; ad->ino = st->st_ino; ad->fts_ent = ent; /* See if we've already encountered this directory. - This can happen when following symlinks as well as - with a corrupted directory hierarchy. */ + This can happen when following symlinks as well as + with a corrupted directory hierarchy. */ ad_from_table = hash_insert (fts->fts_cycle.ht, ad); if (ad_from_table != ad) - { - free (ad); - if (!ad_from_table) - return false; + { + free (ad); + if (!ad_from_table) + return false; - /* There was an entry with matching dev/inode already in the table. - Record the fact that we've found a cycle. */ - ent->fts_cycle = ad_from_table->fts_ent; - ent->fts_info = FTS_DC; - } + /* There was an entry with matching dev/inode already in the table. + Record the fact that we've found a cycle. */ + ent->fts_cycle = ad_from_table->fts_ent; + ent->fts_info = FTS_DC; + } } else { if (cycle_check (fts->fts_cycle.state, ent->fts_statp)) - { - /* FIXME: setting fts_cycle like this isn't proper. - To do what the documentation requires, we'd have to - go around the cycle again and find the right entry. - But no callers in coreutils use the fts_cycle member. */ - ent->fts_cycle = ent; - ent->fts_info = FTS_DC; - } + { + /* FIXME: setting fts_cycle like this isn't proper. + To do what the documentation requires, we'd have to + go around the cycle again and find the right entry. + But no callers in coreutils use the fts_cycle member. */ + ent->fts_cycle = ent; + ent->fts_info = FTS_DC; + } } return true; @@ -133,15 +133,15 @@ leave_dir (FTS *fts, FTSENT *ent) obj.ino = st->st_ino; found = hash_delete (fts->fts_cycle.ht, &obj); if (!found) - abort (); + abort (); free (found); } else { FTSENT *parent = ent->fts_parent; if (parent != NULL && 0 <= parent->fts_level) - CYCLE_CHECK_REFLECT_CHDIR_UP (fts->fts_cycle.state, - *(parent->fts_statp), *st); + CYCLE_CHECK_REFLECT_CHDIR_UP (fts->fts_cycle.state, + *(parent->fts_statp), *st); } } @@ -153,7 +153,7 @@ free_dir (FTS *sp) if (sp->fts_options & (FTS_TIGHT_CYCLE_CHECK | FTS_LOGICAL)) { if (sp->fts_cycle.ht) - hash_free (sp->fts_cycle.ht); + hash_free (sp->fts_cycle.ht); } else free (sp->fts_cycle.state); diff --git a/src/bin/coreutils/lib/fts.c b/src/bin/coreutils/lib/fts.c index 2893e66959..ca967fc5aa 100644 --- a/src/bin/coreutils/lib/fts.c +++ b/src/bin/coreutils/lib/fts.c @@ -1,6 +1,6 @@ /* Traverse a file hierarchy. - Copyright (C) 2004-2009 Free Software Foundation, Inc. + Copyright (C) 2004-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,7 +17,7 @@ /*- * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -47,7 +47,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; +static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; #endif /* LIBC_SCCS and not lint */ #include "fts_.h" @@ -173,16 +173,6 @@ enum Fts_stat # define __set_errno(Val) errno = (Val) #endif -#ifndef __attribute__ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) -# define __attribute__(x) /* empty */ -# endif -#endif - -#ifndef ATTRIBUTE_UNUSED -# define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) -#endif - /* If this host provides the openat function, then we can avoid attempting to open "." in some initialization code below. */ #ifdef HAVE_OPENAT @@ -194,23 +184,23 @@ enum Fts_stat #ifdef NDEBUG # define fts_assert(expr) ((void) 0) #else -# define fts_assert(expr) \ - do \ - { \ - if (!(expr)) \ - abort (); \ - } \ +# define fts_assert(expr) \ + do \ + { \ + if (!(expr)) \ + abort (); \ + } \ while (false) #endif -static FTSENT *fts_alloc (FTS *, const char *, size_t) internal_function; -static FTSENT *fts_build (FTS *, int) internal_function; -static void fts_lfree (FTSENT *) internal_function; -static void fts_load (FTS *, FTSENT *) internal_function; -static size_t fts_maxarglen (char * const *) internal_function; -static void fts_padjust (FTS *, FTSENT *) internal_function; -static bool fts_palloc (FTS *, size_t) internal_function; -static FTSENT *fts_sort (FTS *, FTSENT *, size_t) internal_function; +static FTSENT *fts_alloc (FTS *, const char *, size_t) internal_function; +static FTSENT *fts_build (FTS *, int) internal_function; +static void fts_lfree (FTSENT *) internal_function; +static void fts_load (FTS *, FTSENT *) internal_function; +static size_t fts_maxarglen (char * const *) internal_function; +static void fts_padjust (FTS *, FTSENT *) internal_function; +static bool fts_palloc (FTS *, size_t) internal_function; +static FTSENT *fts_sort (FTS *, FTSENT *, size_t) internal_function; static unsigned short int fts_stat (FTS *, FTSENT *, bool) internal_function; static int fts_safe_changedir (FTS *, FTSENT *, int, const char *) internal_function; @@ -232,31 +222,31 @@ static void free_dir (FTS *fts) {} # define SIZE_MAX ((size_t) -1) #endif -#define ISDOT(a) (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2]))) -#define STREQ(a, b) (strcmp ((a), (b)) == 0) +#define ISDOT(a) (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2]))) +#define STREQ(a, b) (strcmp ((a), (b)) == 0) -#define CLR(opt) (sp->fts_options &= ~(opt)) -#define ISSET(opt) (sp->fts_options & (opt)) -#define SET(opt) (sp->fts_options |= (opt)) +#define CLR(opt) (sp->fts_options &= ~(opt)) +#define ISSET(opt) (sp->fts_options & (opt)) +#define SET(opt) (sp->fts_options |= (opt)) /* FIXME: make this a function */ -#define RESTORE_INITIAL_CWD(sp) \ - (fd_ring_clear (&((sp)->fts_fd_ring)), \ +#define RESTORE_INITIAL_CWD(sp) \ + (fd_ring_clear (&((sp)->fts_fd_ring)), \ FCHDIR ((sp), (ISSET (FTS_CWDFD) ? AT_FDCWD : (sp)->fts_rfd))) /* FIXME: FTS_NOCHDIR is now misnamed. Call it FTS_USE_FULL_RELATIVE_FILE_NAMES instead. */ -#define FCHDIR(sp, fd) \ - (!ISSET(FTS_NOCHDIR) && (ISSET(FTS_CWDFD) \ - ? (cwd_advance_fd ((sp), (fd), true), 0) \ - : fchdir (fd))) +#define FCHDIR(sp, fd) \ + (!ISSET(FTS_NOCHDIR) && (ISSET(FTS_CWDFD) \ + ? (cwd_advance_fd ((sp), (fd), true), 0) \ + : fchdir (fd))) /* fts_build flags */ /* FIXME: make this an enum */ -#define BCHILD 1 /* fts_children */ -#define BNAMES 2 /* fts_children, names only */ -#define BREAD 3 /* fts_read */ +#define BCHILD 1 /* fts_children */ +#define BNAMES 2 /* fts_children, names only */ +#define BREAD 3 /* fts_read */ #if FTS_DEBUG # include @@ -271,13 +261,13 @@ bool fts_debug = false; # define fd_ring_print(a, b, c) #endif -#define LEAVE_DIR(Fts, Ent, Tag) \ - do \ - { \ - Dprintf ((" %s-leaving: %s\n", Tag, (Ent)->fts_path)); \ - leave_dir (Fts, Ent); \ - fd_ring_check (Fts); \ - } \ +#define LEAVE_DIR(Fts, Ent, Tag) \ + do \ + { \ + Dprintf ((" %s-leaving: %s\n", Tag, (Ent)->fts_path)); \ + leave_dir (Fts, Ent); \ + fd_ring_check (Fts); \ + } \ while (false) static void @@ -287,7 +277,7 @@ fd_ring_clear (I_ring *fd_ring) { int fd = i_ring_pop (fd_ring); if (0 <= fd) - close (fd); + close (fd); } } @@ -299,8 +289,8 @@ fts_set_stat_required (FTSENT *p, bool required) { fts_assert (p->fts_info == FTS_NSOK); p->fts_statp->st_size = (required - ? FTS_STAT_REQUIRED - : FTS_NO_STAT_REQUIRED); + ? FTS_STAT_REQUIRED + : FTS_NO_STAT_REQUIRED); } /* file-descriptor-relative opendir. */ @@ -310,7 +300,7 @@ internal_function opendirat (int fd, char const *dir) { int new_fd = openat (fd, dir, - O_RDONLY | O_DIRECTORY | O_NOCTTY | O_NONBLOCK); + O_RDONLY | O_DIRECTORY | O_NOCTTY | O_NONBLOCK); DIR *dirp; if (new_fd < 0) @@ -341,16 +331,16 @@ cwd_advance_fd (FTS *sp, int fd, bool chdir_down_one) if (chdir_down_one) { /* Push "old" onto the ring. - If the displaced file descriptor is non-negative, close it. */ + If the displaced file descriptor is non-negative, close it. */ int prev_fd_in_slot = i_ring_push (&sp->fts_fd_ring, old); fd_ring_print (sp, stderr, "post-push"); if (0 <= prev_fd_in_slot) - close (prev_fd_in_slot); /* ignore any close failure */ + close (prev_fd_in_slot); /* ignore any close failure */ } else if ( ! ISSET (FTS_NOCHDIR)) { if (0 <= old) - close (old); /* ignore any close failure */ + close (old); /* ignore any close failure */ } sp->fts_cwd_fd = fd; @@ -365,7 +355,7 @@ internal_function diropen (FTS const *sp, char const *dir) { int open_flags = (O_RDONLY | O_DIRECTORY | O_NOCTTY | O_NONBLOCK - | (ISSET (FTS_PHYSICAL) ? O_NOFOLLOW : 0)); + | (ISSET (FTS_PHYSICAL) ? O_NOFOLLOW : 0)); int fd = (ISSET (FTS_CWDFD) ? openat (sp->fts_cwd_fd, dir, open_flags) @@ -377,275 +367,270 @@ diropen (FTS const *sp, char const *dir) FTS * fts_open (char * const *argv, - register int options, - int (*compar) (FTSENT const **, FTSENT const **)) + register int options, + int (*compar) (FTSENT const **, FTSENT const **)) { - register FTS *sp; - register FTSENT *p, *root; - register size_t nitems; - FTSENT *parent = NULL; - FTSENT *tmp = NULL; /* pacify gcc */ - size_t len; - bool defer_stat; + register FTS *sp; + register FTSENT *p, *root; + register size_t nitems; + FTSENT *parent = NULL; + FTSENT *tmp = NULL; /* pacify gcc */ + bool defer_stat; - /* Options check. */ - if (options & ~FTS_OPTIONMASK) { - __set_errno (EINVAL); - return (NULL); - } - if ((options & FTS_NOCHDIR) && (options & FTS_CWDFD)) { - __set_errno (EINVAL); - return (NULL); - } - if ( ! (options & (FTS_LOGICAL | FTS_PHYSICAL))) { - __set_errno (EINVAL); - return (NULL); - } + /* Options check. */ + if (options & ~FTS_OPTIONMASK) { + __set_errno (EINVAL); + return (NULL); + } + if ((options & FTS_NOCHDIR) && (options & FTS_CWDFD)) { + __set_errno (EINVAL); + return (NULL); + } + if ( ! (options & (FTS_LOGICAL | FTS_PHYSICAL))) { + __set_errno (EINVAL); + return (NULL); + } - /* Allocate/initialize the stream */ - if ((sp = malloc(sizeof(FTS))) == NULL) - return (NULL); - memset(sp, 0, sizeof(FTS)); - sp->fts_compar = compar; - sp->fts_options = options; + /* Allocate/initialize the stream */ + if ((sp = malloc(sizeof(FTS))) == NULL) + return (NULL); + memset(sp, 0, sizeof(FTS)); + sp->fts_compar = compar; + sp->fts_options = options; - /* Logical walks turn on NOCHDIR; symbolic links are too hard. */ - if (ISSET(FTS_LOGICAL)) { - SET(FTS_NOCHDIR); - CLR(FTS_CWDFD); - } + /* Logical walks turn on NOCHDIR; symbolic links are too hard. */ + if (ISSET(FTS_LOGICAL)) { + SET(FTS_NOCHDIR); + CLR(FTS_CWDFD); + } - /* Initialize fts_cwd_fd. */ - sp->fts_cwd_fd = AT_FDCWD; - if ( ISSET(FTS_CWDFD) && ! HAVE_OPENAT_SUPPORT) - { - /* While it isn't technically necessary to open "." this - early, doing it here saves us the trouble of ensuring - later (where it'd be messier) that "." can in fact - be opened. If not, revert to FTS_NOCHDIR mode. */ - int fd = open (".", O_RDONLY); - if (fd < 0) - { - /* Even if `.' is unreadable, don't revert to FTS_NOCHDIR mode - on systems like Linux+PROC_FS, where our openat emulation - is good enough. Note: on a system that emulates - openat via /proc, this technique can still fail, but - only in extreme conditions, e.g., when the working - directory cannot be saved (i.e. save_cwd fails) -- - and that happens on Linux only when "." is unreadable - and the CWD would be longer than PATH_MAX. - FIXME: once Linux kernel openat support is well established, - replace the above open call and this entire if/else block - with the body of the if-block below. */ - if ( openat_needs_fchdir ()) - { - SET(FTS_NOCHDIR); - CLR(FTS_CWDFD); - } - } - else - { - close (fd); - } - } + /* Initialize fts_cwd_fd. */ + sp->fts_cwd_fd = AT_FDCWD; + if ( ISSET(FTS_CWDFD) && ! HAVE_OPENAT_SUPPORT) + { + /* While it isn't technically necessary to open "." this + early, doing it here saves us the trouble of ensuring + later (where it'd be messier) that "." can in fact + be opened. If not, revert to FTS_NOCHDIR mode. */ + int fd = open (".", O_RDONLY); + if (fd < 0) + { + /* Even if `.' is unreadable, don't revert to FTS_NOCHDIR mode + on systems like Linux+PROC_FS, where our openat emulation + is good enough. Note: on a system that emulates + openat via /proc, this technique can still fail, but + only in extreme conditions, e.g., when the working + directory cannot be saved (i.e. save_cwd fails) -- + and that happens on Linux only when "." is unreadable + and the CWD would be longer than PATH_MAX. + FIXME: once Linux kernel openat support is well established, + replace the above open call and this entire if/else block + with the body of the if-block below. */ + if ( openat_needs_fchdir ()) + { + SET(FTS_NOCHDIR); + CLR(FTS_CWDFD); + } + } + else + { + close (fd); + } + } - /* - * Start out with 1K of file name space, and enough, in any case, - * to hold the user's file names. - */ + /* + * Start out with 1K of file name space, and enough, in any case, + * to hold the user's file names. + */ #ifndef MAXPATHLEN # define MAXPATHLEN 1024 #endif - { - size_t maxarglen = fts_maxarglen(argv); - if (! fts_palloc(sp, MAX(maxarglen, MAXPATHLEN))) - goto mem1; - } + { + size_t maxarglen = fts_maxarglen(argv); + if (! fts_palloc(sp, MAX(maxarglen, MAXPATHLEN))) + goto mem1; + } - /* Allocate/initialize root's parent. */ - if (*argv != NULL) { - if ((parent = fts_alloc(sp, "", 0)) == NULL) - goto mem2; - parent->fts_level = FTS_ROOTPARENTLEVEL; - } + /* Allocate/initialize root's parent. */ + if (*argv != NULL) { + if ((parent = fts_alloc(sp, "", 0)) == NULL) + goto mem2; + parent->fts_level = FTS_ROOTPARENTLEVEL; + } - /* The classic fts implementation would call fts_stat with - a new entry for each iteration of the loop below. - If the comparison function is not specified or if the - FTS_DEFER_STAT option is in effect, don't stat any entry - in this loop. This is an attempt to minimize the interval - between the initial stat/lstat/fstatat and the point at which - a directory argument is first opened. This matters for any - directory command line argument that resides on a file system - without genuine i-nodes. If you specify FTS_DEFER_STAT along - with a comparison function, that function must not access any - data via the fts_statp pointer. */ - defer_stat = (compar == NULL || ISSET(FTS_DEFER_STAT)); + /* The classic fts implementation would call fts_stat with + a new entry for each iteration of the loop below. + If the comparison function is not specified or if the + FTS_DEFER_STAT option is in effect, don't stat any entry + in this loop. This is an attempt to minimize the interval + between the initial stat/lstat/fstatat and the point at which + a directory argument is first opened. This matters for any + directory command line argument that resides on a file system + without genuine i-nodes. If you specify FTS_DEFER_STAT along + with a comparison function, that function must not access any + data via the fts_statp pointer. */ + defer_stat = (compar == NULL || ISSET(FTS_DEFER_STAT)); - /* Allocate/initialize root(s). */ - for (root = NULL, nitems = 0; *argv != NULL; ++argv, ++nitems) { - /* Don't allow zero-length file names. */ - if ((len = strlen(*argv)) == 0) { - __set_errno (ENOENT); - goto mem3; - } + /* Allocate/initialize root(s). */ + for (root = NULL, nitems = 0; *argv != NULL; ++argv, ++nitems) { + /* *Do* allow zero-length file names. */ + size_t len = strlen(*argv); + if ((p = fts_alloc(sp, *argv, len)) == NULL) + goto mem3; + p->fts_level = FTS_ROOTLEVEL; + p->fts_parent = parent; + p->fts_accpath = p->fts_name; + /* Even when defer_stat is true, be sure to stat the first + command line argument, since fts_read (at least with + FTS_XDEV) requires that. */ + if (defer_stat && root != NULL) { + p->fts_info = FTS_NSOK; + fts_set_stat_required(p, true); + } else { + p->fts_info = fts_stat(sp, p, false); + } - if ((p = fts_alloc(sp, *argv, len)) == NULL) - goto mem3; - p->fts_level = FTS_ROOTLEVEL; - p->fts_parent = parent; - p->fts_accpath = p->fts_name; - /* Even when defer_stat is true, be sure to stat the first - command line argument, since fts_read (at least with - FTS_XDEV) requires that. */ - if (defer_stat && root != NULL) { - p->fts_info = FTS_NSOK; - fts_set_stat_required(p, true); - } else { - p->fts_info = fts_stat(sp, p, false); - } + /* + * If comparison routine supplied, traverse in sorted + * order; otherwise traverse in the order specified. + */ + if (compar) { + p->fts_link = root; + root = p; + } else { + p->fts_link = NULL; + if (root == NULL) + tmp = root = p; + else { + tmp->fts_link = p; + tmp = p; + } + } + } + if (compar && nitems > 1) + root = fts_sort(sp, root, nitems); - /* - * If comparison routine supplied, traverse in sorted - * order; otherwise traverse in the order specified. - */ - if (compar) { - p->fts_link = root; - root = p; - } else { - p->fts_link = NULL; - if (root == NULL) - tmp = root = p; - else { - tmp->fts_link = p; - tmp = p; - } - } - } - if (compar && nitems > 1) - root = fts_sort(sp, root, nitems); + /* + * Allocate a dummy pointer and make fts_read think that we've just + * finished the node before the root(s); set p->fts_info to FTS_INIT + * so that everything about the "current" node is ignored. + */ + if ((sp->fts_cur = fts_alloc(sp, "", 0)) == NULL) + goto mem3; + sp->fts_cur->fts_link = root; + sp->fts_cur->fts_info = FTS_INIT; + if (! setup_dir (sp)) + goto mem3; - /* - * Allocate a dummy pointer and make fts_read think that we've just - * finished the node before the root(s); set p->fts_info to FTS_INIT - * so that everything about the "current" node is ignored. - */ - if ((sp->fts_cur = fts_alloc(sp, "", 0)) == NULL) - goto mem3; - sp->fts_cur->fts_link = root; - sp->fts_cur->fts_info = FTS_INIT; - if (! setup_dir (sp)) - goto mem3; + /* + * If using chdir(2), grab a file descriptor pointing to dot to ensure + * that we can get back here; this could be avoided for some file names, + * but almost certainly not worth the effort. Slashes, symbolic links, + * and ".." are all fairly nasty problems. Note, if we can't get the + * descriptor we run anyway, just more slowly. + */ + if (!ISSET(FTS_NOCHDIR) && !ISSET(FTS_CWDFD) + && (sp->fts_rfd = diropen (sp, ".")) < 0) + SET(FTS_NOCHDIR); - /* - * If using chdir(2), grab a file descriptor pointing to dot to ensure - * that we can get back here; this could be avoided for some file names, - * but almost certainly not worth the effort. Slashes, symbolic links, - * and ".." are all fairly nasty problems. Note, if we can't get the - * descriptor we run anyway, just more slowly. - */ - if (!ISSET(FTS_NOCHDIR) && !ISSET(FTS_CWDFD) - && (sp->fts_rfd = diropen (sp, ".")) < 0) - SET(FTS_NOCHDIR); + i_ring_init (&sp->fts_fd_ring, -1); + return (sp); - i_ring_init (&sp->fts_fd_ring, -1); - return (sp); - -mem3: fts_lfree(root); - free(parent); -mem2: free(sp->fts_path); -mem1: free(sp); - return (NULL); +mem3: fts_lfree(root); + free(parent); +mem2: free(sp->fts_path); +mem1: free(sp); + return (NULL); } static void internal_function fts_load (FTS *sp, register FTSENT *p) { - register size_t len; - register char *cp; + register size_t len; + register char *cp; - /* - * Load the stream structure for the next traversal. Since we don't - * actually enter the directory until after the preorder visit, set - * the fts_accpath field specially so the chdir gets done to the right - * place and the user can access the first node. From fts_open it's - * known that the file name will fit. - */ - len = p->fts_pathlen = p->fts_namelen; - memmove(sp->fts_path, p->fts_name, len + 1); - if ((cp = strrchr(p->fts_name, '/')) && (cp != p->fts_name || cp[1])) { - len = strlen(++cp); - memmove(p->fts_name, cp, len + 1); - p->fts_namelen = len; - } - p->fts_accpath = p->fts_path = sp->fts_path; + /* + * Load the stream structure for the next traversal. Since we don't + * actually enter the directory until after the preorder visit, set + * the fts_accpath field specially so the chdir gets done to the right + * place and the user can access the first node. From fts_open it's + * known that the file name will fit. + */ + len = p->fts_pathlen = p->fts_namelen; + memmove(sp->fts_path, p->fts_name, len + 1); + if ((cp = strrchr(p->fts_name, '/')) && (cp != p->fts_name || cp[1])) { + len = strlen(++cp); + memmove(p->fts_name, cp, len + 1); + p->fts_namelen = len; + } + p->fts_accpath = p->fts_path = sp->fts_path; } int fts_close (FTS *sp) { - register FTSENT *freep, *p; - int saved_errno = 0; + register FTSENT *freep, *p; + int saved_errno = 0; - /* - * This still works if we haven't read anything -- the dummy structure - * points to the root list, so we step through to the end of the root - * list which has a valid parent pointer. - */ - if (sp->fts_cur) { - for (p = sp->fts_cur; p->fts_level >= FTS_ROOTLEVEL;) { - freep = p; - p = p->fts_link != NULL ? p->fts_link : p->fts_parent; - free(freep); - } - free(p); - } + /* + * This still works if we haven't read anything -- the dummy structure + * points to the root list, so we step through to the end of the root + * list which has a valid parent pointer. + */ + if (sp->fts_cur) { + for (p = sp->fts_cur; p->fts_level >= FTS_ROOTLEVEL;) { + freep = p; + p = p->fts_link != NULL ? p->fts_link : p->fts_parent; + free(freep); + } + free(p); + } - /* Free up child linked list, sort array, file name buffer. */ - if (sp->fts_child) - fts_lfree(sp->fts_child); - free(sp->fts_array); - free(sp->fts_path); + /* Free up child linked list, sort array, file name buffer. */ + if (sp->fts_child) + fts_lfree(sp->fts_child); + free(sp->fts_array); + free(sp->fts_path); - if (ISSET(FTS_CWDFD)) - { - if (0 <= sp->fts_cwd_fd) - if (close (sp->fts_cwd_fd)) - saved_errno = errno; - } - else if (!ISSET(FTS_NOCHDIR)) - { - /* Return to original directory, save errno if necessary. */ - if (fchdir(sp->fts_rfd)) - saved_errno = errno; + if (ISSET(FTS_CWDFD)) + { + if (0 <= sp->fts_cwd_fd) + if (close (sp->fts_cwd_fd)) + saved_errno = errno; + } + else if (!ISSET(FTS_NOCHDIR)) + { + /* Return to original directory, save errno if necessary. */ + if (fchdir(sp->fts_rfd)) + saved_errno = errno; - /* If close fails, record errno only if saved_errno is zero, - so that we report the probably-more-meaningful fchdir errno. */ - if (close (sp->fts_rfd)) - if (saved_errno == 0) - saved_errno = errno; - } + /* If close fails, record errno only if saved_errno is zero, + so that we report the probably-more-meaningful fchdir errno. */ + if (close (sp->fts_rfd)) + if (saved_errno == 0) + saved_errno = errno; + } - fd_ring_clear (&sp->fts_fd_ring); + fd_ring_clear (&sp->fts_fd_ring); #if GNULIB_FTS - if (sp->fts_leaf_optimization_works_ht) - hash_free (sp->fts_leaf_optimization_works_ht); + if (sp->fts_leaf_optimization_works_ht) + hash_free (sp->fts_leaf_optimization_works_ht); #endif - free_dir (sp); + free_dir (sp); - /* Free up the stream pointer. */ - free(sp); + /* Free up the stream pointer. */ + free(sp); - /* Set errno and return. */ - if (saved_errno) { - __set_errno (saved_errno); - return (-1); - } + /* Set errno and return. */ + if (saved_errno) { + __set_errno (saved_errno); + return (-1); + } - return (0); + return (0); } #if defined __linux__ \ @@ -684,7 +669,7 @@ dirent_inode_sort_may_be_useful (int dir_fd) case S_MAGIC_TMPFS: case S_MAGIC_NFS: /* On a file system of any of these types, sorting - is unnecessary, and hence wasteful. */ + is unnecessary, and hence wasteful. */ return false; default: @@ -710,15 +695,15 @@ leaf_optimization_applies (int dir_fd) switch (fs_buf.f_type) { /* List here the file system types that lack useable dirent.d_type - info, yet for which the optimization does apply. */ + info, yet for which the optimization does apply. */ case S_MAGIC_REISERFS: return true; case S_MAGIC_PROC: /* Explicitly listing this or any other file system type for which - the optimization is not applicable is not necessary, but we leave - it here to document the risk. Per http://bugs.debian.org/143111, - /proc may have bogus stat.st_nlink values. */ + the optimization is not applicable is not necessary, but we leave + it here to document the risk. Per http://bugs.debian.org/143111, + /proc may have bogus stat.st_nlink values. */ /* fall through */ default: return false; @@ -726,8 +711,10 @@ leaf_optimization_applies (int dir_fd) } #else -static bool dirent_inode_sort_may_be_useful (int dir_fd) { return true; } -static bool leaf_optimization_applies (int dir_fd) { return false; } +static bool +dirent_inode_sort_may_be_useful (int dir_fd _GL_UNUSED) { return true; } +static bool +leaf_optimization_applies (int dir_fd _GL_UNUSED) { return false; } #endif #if GNULIB_FTS @@ -781,10 +768,10 @@ link_count_optimize_ok (FTSENT const *p) if (h == NULL) { h = sp->fts_leaf_optimization_works_ht - = hash_initialize (LCO_HT_INITIAL_SIZE, NULL, LCO_hash, - LCO_compare, free); + = hash_initialize (LCO_HT_INITIAL_SIZE, NULL, LCO_hash, + LCO_compare, free); if (h == NULL) - return false; + return false; } tmp.st_dev = p->fts_statp->st_dev; ent = hash_lookup (h, &tmp); @@ -818,255 +805,255 @@ link_count_optimize_ok (FTSENT const *p) * Special case of "/" at the end of the file name so that slashes aren't * appended which would cause file names to be written as "....//foo". */ -#define NAPPEND(p) \ - (p->fts_path[p->fts_pathlen - 1] == '/' \ - ? p->fts_pathlen - 1 : p->fts_pathlen) +#define NAPPEND(p) \ + (p->fts_path[p->fts_pathlen - 1] == '/' \ + ? p->fts_pathlen - 1 : p->fts_pathlen) FTSENT * fts_read (register FTS *sp) { - register FTSENT *p, *tmp; - register unsigned short int instr; - register char *t; + register FTSENT *p, *tmp; + register unsigned short int instr; + register char *t; - /* If finished or unrecoverable error, return NULL. */ - if (sp->fts_cur == NULL || ISSET(FTS_STOP)) - return (NULL); + /* If finished or unrecoverable error, return NULL. */ + if (sp->fts_cur == NULL || ISSET(FTS_STOP)) + return (NULL); - /* Set current node pointer. */ - p = sp->fts_cur; + /* Set current node pointer. */ + p = sp->fts_cur; - /* Save and zero out user instructions. */ - instr = p->fts_instr; - p->fts_instr = FTS_NOINSTR; + /* Save and zero out user instructions. */ + instr = p->fts_instr; + p->fts_instr = FTS_NOINSTR; - /* Any type of file may be re-visited; re-stat and re-turn. */ - if (instr == FTS_AGAIN) { - p->fts_info = fts_stat(sp, p, false); - return (p); - } - Dprintf (("fts_read: p=%s\n", - p->fts_info == FTS_INIT ? "" : p->fts_path)); + /* Any type of file may be re-visited; re-stat and re-turn. */ + if (instr == FTS_AGAIN) { + p->fts_info = fts_stat(sp, p, false); + return (p); + } + Dprintf (("fts_read: p=%s\n", + p->fts_info == FTS_INIT ? "" : p->fts_path)); - /* - * Following a symlink -- SLNONE test allows application to see - * SLNONE and recover. If indirecting through a symlink, have - * keep a pointer to current location. If unable to get that - * pointer, follow fails. - */ - if (instr == FTS_FOLLOW && - (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) { - p->fts_info = fts_stat(sp, p, true); - if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { - if ((p->fts_symfd = diropen (sp, ".")) < 0) { - p->fts_errno = errno; - p->fts_info = FTS_ERR; - } else - p->fts_flags |= FTS_SYMFOLLOW; - } - goto check_for_dir; - } + /* + * Following a symlink -- SLNONE test allows application to see + * SLNONE and recover. If indirecting through a symlink, have + * keep a pointer to current location. If unable to get that + * pointer, follow fails. + */ + if (instr == FTS_FOLLOW && + (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) { + p->fts_info = fts_stat(sp, p, true); + if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { + if ((p->fts_symfd = diropen (sp, ".")) < 0) { + p->fts_errno = errno; + p->fts_info = FTS_ERR; + } else + p->fts_flags |= FTS_SYMFOLLOW; + } + goto check_for_dir; + } - /* Directory in pre-order. */ - if (p->fts_info == FTS_D) { - /* If skipped or crossed mount point, do post-order visit. */ - if (instr == FTS_SKIP || - (ISSET(FTS_XDEV) && p->fts_statp->st_dev != sp->fts_dev)) { - if (p->fts_flags & FTS_SYMFOLLOW) - (void)close(p->fts_symfd); - if (sp->fts_child) { - fts_lfree(sp->fts_child); - sp->fts_child = NULL; - } - p->fts_info = FTS_DP; - LEAVE_DIR (sp, p, "1"); - return (p); - } + /* Directory in pre-order. */ + if (p->fts_info == FTS_D) { + /* If skipped or crossed mount point, do post-order visit. */ + if (instr == FTS_SKIP || + (ISSET(FTS_XDEV) && p->fts_statp->st_dev != sp->fts_dev)) { + if (p->fts_flags & FTS_SYMFOLLOW) + (void)close(p->fts_symfd); + if (sp->fts_child) { + fts_lfree(sp->fts_child); + sp->fts_child = NULL; + } + p->fts_info = FTS_DP; + LEAVE_DIR (sp, p, "1"); + return (p); + } - /* Rebuild if only read the names and now traversing. */ - if (sp->fts_child != NULL && ISSET(FTS_NAMEONLY)) { - CLR(FTS_NAMEONLY); - fts_lfree(sp->fts_child); - sp->fts_child = NULL; - } + /* Rebuild if only read the names and now traversing. */ + if (sp->fts_child != NULL && ISSET(FTS_NAMEONLY)) { + CLR(FTS_NAMEONLY); + fts_lfree(sp->fts_child); + sp->fts_child = NULL; + } - /* - * Cd to the subdirectory. - * - * If have already read and now fail to chdir, whack the list - * to make the names come out right, and set the parent errno - * so the application will eventually get an error condition. - * Set the FTS_DONTCHDIR flag so that when we logically change - * directories back to the parent we don't do a chdir. - * - * If haven't read do so. If the read fails, fts_build sets - * FTS_STOP or the fts_info field of the node. - */ - if (sp->fts_child != NULL) { - if (fts_safe_changedir(sp, p, -1, p->fts_accpath)) { - p->fts_errno = errno; - p->fts_flags |= FTS_DONTCHDIR; - for (p = sp->fts_child; p != NULL; - p = p->fts_link) - p->fts_accpath = - p->fts_parent->fts_accpath; - } - } else if ((sp->fts_child = fts_build(sp, BREAD)) == NULL) { - if (ISSET(FTS_STOP)) - return (NULL); - /* If fts_build's call to fts_safe_changedir failed - because it was not able to fchdir into a - subdirectory, tell the caller. */ - if (p->fts_errno && p->fts_info != FTS_DNR) - p->fts_info = FTS_ERR; - LEAVE_DIR (sp, p, "2"); - return (p); - } - p = sp->fts_child; - sp->fts_child = NULL; - goto name; - } + /* + * Cd to the subdirectory. + * + * If have already read and now fail to chdir, whack the list + * to make the names come out right, and set the parent errno + * so the application will eventually get an error condition. + * Set the FTS_DONTCHDIR flag so that when we logically change + * directories back to the parent we don't do a chdir. + * + * If haven't read do so. If the read fails, fts_build sets + * FTS_STOP or the fts_info field of the node. + */ + if (sp->fts_child != NULL) { + if (fts_safe_changedir(sp, p, -1, p->fts_accpath)) { + p->fts_errno = errno; + p->fts_flags |= FTS_DONTCHDIR; + for (p = sp->fts_child; p != NULL; + p = p->fts_link) + p->fts_accpath = + p->fts_parent->fts_accpath; + } + } else if ((sp->fts_child = fts_build(sp, BREAD)) == NULL) { + if (ISSET(FTS_STOP)) + return (NULL); + /* If fts_build's call to fts_safe_changedir failed + because it was not able to fchdir into a + subdirectory, tell the caller. */ + if (p->fts_errno && p->fts_info != FTS_DNR) + p->fts_info = FTS_ERR; + LEAVE_DIR (sp, p, "2"); + return (p); + } + p = sp->fts_child; + sp->fts_child = NULL; + goto name; + } - /* Move to the next node on this level. */ -next: tmp = p; - if ((p = p->fts_link) != NULL) { - sp->fts_cur = p; - free(tmp); + /* Move to the next node on this level. */ +next: tmp = p; + if ((p = p->fts_link) != NULL) { + sp->fts_cur = p; + free(tmp); - /* - * If reached the top, return to the original directory (or - * the root of the tree), and load the file names for the next - * root. - */ - if (p->fts_level == FTS_ROOTLEVEL) { - if (RESTORE_INITIAL_CWD(sp)) { - SET(FTS_STOP); - return (NULL); - } - free_dir(sp); - fts_load(sp, p); - setup_dir(sp); - goto check_for_dir; - } + /* + * If reached the top, return to the original directory (or + * the root of the tree), and load the file names for the next + * root. + */ + if (p->fts_level == FTS_ROOTLEVEL) { + if (RESTORE_INITIAL_CWD(sp)) { + SET(FTS_STOP); + return (NULL); + } + free_dir(sp); + fts_load(sp, p); + setup_dir(sp); + goto check_for_dir; + } - /* - * User may have called fts_set on the node. If skipped, - * ignore. If followed, get a file descriptor so we can - * get back if necessary. - */ - if (p->fts_instr == FTS_SKIP) - goto next; - if (p->fts_instr == FTS_FOLLOW) { - p->fts_info = fts_stat(sp, p, true); - if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { - if ((p->fts_symfd = diropen (sp, ".")) < 0) { - p->fts_errno = errno; - p->fts_info = FTS_ERR; - } else - p->fts_flags |= FTS_SYMFOLLOW; - } - p->fts_instr = FTS_NOINSTR; - } + /* + * User may have called fts_set on the node. If skipped, + * ignore. If followed, get a file descriptor so we can + * get back if necessary. + */ + if (p->fts_instr == FTS_SKIP) + goto next; + if (p->fts_instr == FTS_FOLLOW) { + p->fts_info = fts_stat(sp, p, true); + if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { + if ((p->fts_symfd = diropen (sp, ".")) < 0) { + p->fts_errno = errno; + p->fts_info = FTS_ERR; + } else + p->fts_flags |= FTS_SYMFOLLOW; + } + p->fts_instr = FTS_NOINSTR; + } -name: t = sp->fts_path + NAPPEND(p->fts_parent); - *t++ = '/'; - memmove(t, p->fts_name, p->fts_namelen + 1); +name: t = sp->fts_path + NAPPEND(p->fts_parent); + *t++ = '/'; + memmove(t, p->fts_name, p->fts_namelen + 1); check_for_dir: - sp->fts_cur = p; - if (p->fts_info == FTS_NSOK) - { - if (p->fts_statp->st_size == FTS_STAT_REQUIRED) - { - FTSENT *parent = p->fts_parent; - if (FTS_ROOTLEVEL < p->fts_level - /* ->fts_n_dirs_remaining is not valid - for command-line-specified names. */ - && parent->fts_n_dirs_remaining == 0 - && ISSET(FTS_NOSTAT) - && ISSET(FTS_PHYSICAL) - && link_count_optimize_ok (parent)) - { - /* nothing more needed */ - } - else - { - p->fts_info = fts_stat(sp, p, false); - if (S_ISDIR(p->fts_statp->st_mode) - && p->fts_level != FTS_ROOTLEVEL - && parent->fts_n_dirs_remaining) - parent->fts_n_dirs_remaining--; - } - } - else - fts_assert (p->fts_statp->st_size == FTS_NO_STAT_REQUIRED); - } + sp->fts_cur = p; + if (p->fts_info == FTS_NSOK) + { + if (p->fts_statp->st_size == FTS_STAT_REQUIRED) + { + FTSENT *parent = p->fts_parent; + if (FTS_ROOTLEVEL < p->fts_level + /* ->fts_n_dirs_remaining is not valid + for command-line-specified names. */ + && parent->fts_n_dirs_remaining == 0 + && ISSET(FTS_NOSTAT) + && ISSET(FTS_PHYSICAL) + && link_count_optimize_ok (parent)) + { + /* nothing more needed */ + } + else + { + p->fts_info = fts_stat(sp, p, false); + if (S_ISDIR(p->fts_statp->st_mode) + && p->fts_level != FTS_ROOTLEVEL + && parent->fts_n_dirs_remaining) + parent->fts_n_dirs_remaining--; + } + } + else + fts_assert (p->fts_statp->st_size == FTS_NO_STAT_REQUIRED); + } - if (p->fts_info == FTS_D) - { - /* Now that P->fts_statp is guaranteed to be valid, - if this is a command-line directory, record its - device number, to be used for FTS_XDEV. */ - if (p->fts_level == FTS_ROOTLEVEL) - sp->fts_dev = p->fts_statp->st_dev; - Dprintf ((" entering: %s\n", p->fts_path)); - if (! enter_dir (sp, p)) - { - __set_errno (ENOMEM); - return NULL; - } - } - return p; - } + if (p->fts_info == FTS_D) + { + /* Now that P->fts_statp is guaranteed to be valid, + if this is a command-line directory, record its + device number, to be used for FTS_XDEV. */ + if (p->fts_level == FTS_ROOTLEVEL) + sp->fts_dev = p->fts_statp->st_dev; + Dprintf ((" entering: %s\n", p->fts_path)); + if (! enter_dir (sp, p)) + { + __set_errno (ENOMEM); + return NULL; + } + } + return p; + } - /* Move up to the parent node. */ - p = tmp->fts_parent; - sp->fts_cur = p; - free(tmp); + /* Move up to the parent node. */ + p = tmp->fts_parent; + sp->fts_cur = p; + free(tmp); - if (p->fts_level == FTS_ROOTPARENTLEVEL) { - /* - * Done; free everything up and set errno to 0 so the user - * can distinguish between error and EOF. - */ - free(p); - __set_errno (0); - return (sp->fts_cur = NULL); - } + if (p->fts_level == FTS_ROOTPARENTLEVEL) { + /* + * Done; free everything up and set errno to 0 so the user + * can distinguish between error and EOF. + */ + free(p); + __set_errno (0); + return (sp->fts_cur = NULL); + } - fts_assert (p->fts_info != FTS_NSOK); + fts_assert (p->fts_info != FTS_NSOK); - /* NUL terminate the file name. */ - sp->fts_path[p->fts_pathlen] = '\0'; + /* NUL terminate the file name. */ + sp->fts_path[p->fts_pathlen] = '\0'; - /* - * Return to the parent directory. If at a root node, restore - * the initial working directory. If we came through a symlink, - * go back through the file descriptor. Otherwise, move up - * one level, via "..". - */ - if (p->fts_level == FTS_ROOTLEVEL) { - if (RESTORE_INITIAL_CWD(sp)) { - p->fts_errno = errno; - SET(FTS_STOP); - } - } else if (p->fts_flags & FTS_SYMFOLLOW) { - if (FCHDIR(sp, p->fts_symfd)) { - int saved_errno = errno; - (void)close(p->fts_symfd); - __set_errno (saved_errno); - p->fts_errno = errno; - SET(FTS_STOP); - } - (void)close(p->fts_symfd); - } else if (!(p->fts_flags & FTS_DONTCHDIR) && - fts_safe_changedir(sp, p->fts_parent, -1, "..")) { - p->fts_errno = errno; - SET(FTS_STOP); - } - p->fts_info = p->fts_errno ? FTS_ERR : FTS_DP; - if (p->fts_errno == 0) - LEAVE_DIR (sp, p, "3"); - return ISSET(FTS_STOP) ? NULL : p; + /* + * Return to the parent directory. If at a root node, restore + * the initial working directory. If we came through a symlink, + * go back through the file descriptor. Otherwise, move up + * one level, via "..". + */ + if (p->fts_level == FTS_ROOTLEVEL) { + if (RESTORE_INITIAL_CWD(sp)) { + p->fts_errno = errno; + SET(FTS_STOP); + } + } else if (p->fts_flags & FTS_SYMFOLLOW) { + if (FCHDIR(sp, p->fts_symfd)) { + int saved_errno = errno; + (void)close(p->fts_symfd); + __set_errno (saved_errno); + p->fts_errno = errno; + SET(FTS_STOP); + } + (void)close(p->fts_symfd); + } else if (!(p->fts_flags & FTS_DONTCHDIR) && + fts_safe_changedir(sp, p->fts_parent, -1, "..")) { + p->fts_errno = errno; + SET(FTS_STOP); + } + p->fts_info = p->fts_errno ? FTS_ERR : FTS_DP; + if (p->fts_errno == 0) + LEAVE_DIR (sp, p, "3"); + return ISSET(FTS_STOP) ? NULL : p; } /* @@ -1077,93 +1064,93 @@ check_for_dir: */ /* ARGSUSED */ int -fts_set(FTS *sp ATTRIBUTE_UNUSED, FTSENT *p, int instr) +fts_set(FTS *sp _GL_UNUSED, FTSENT *p, int instr) { - if (instr != 0 && instr != FTS_AGAIN && instr != FTS_FOLLOW && - instr != FTS_NOINSTR && instr != FTS_SKIP) { - __set_errno (EINVAL); - return (1); - } - p->fts_instr = instr; - return (0); + if (instr != 0 && instr != FTS_AGAIN && instr != FTS_FOLLOW && + instr != FTS_NOINSTR && instr != FTS_SKIP) { + __set_errno (EINVAL); + return (1); + } + p->fts_instr = instr; + return (0); } FTSENT * fts_children (register FTS *sp, int instr) { - register FTSENT *p; - int fd; + register FTSENT *p; + int fd; - if (instr != 0 && instr != FTS_NAMEONLY) { - __set_errno (EINVAL); - return (NULL); - } + if (instr != 0 && instr != FTS_NAMEONLY) { + __set_errno (EINVAL); + return (NULL); + } - /* Set current node pointer. */ - p = sp->fts_cur; + /* Set current node pointer. */ + p = sp->fts_cur; - /* - * Errno set to 0 so user can distinguish empty directory from - * an error. - */ - __set_errno (0); + /* + * Errno set to 0 so user can distinguish empty directory from + * an error. + */ + __set_errno (0); - /* Fatal errors stop here. */ - if (ISSET(FTS_STOP)) - return (NULL); + /* Fatal errors stop here. */ + if (ISSET(FTS_STOP)) + return (NULL); - /* Return logical hierarchy of user's arguments. */ - if (p->fts_info == FTS_INIT) - return (p->fts_link); + /* Return logical hierarchy of user's arguments. */ + if (p->fts_info == FTS_INIT) + return (p->fts_link); - /* - * If not a directory being visited in pre-order, stop here. Could - * allow FTS_DNR, assuming the user has fixed the problem, but the - * same effect is available with FTS_AGAIN. - */ - if (p->fts_info != FTS_D /* && p->fts_info != FTS_DNR */) - return (NULL); + /* + * If not a directory being visited in pre-order, stop here. Could + * allow FTS_DNR, assuming the user has fixed the problem, but the + * same effect is available with FTS_AGAIN. + */ + if (p->fts_info != FTS_D /* && p->fts_info != FTS_DNR */) + return (NULL); - /* Free up any previous child list. */ - if (sp->fts_child != NULL) - fts_lfree(sp->fts_child); + /* Free up any previous child list. */ + if (sp->fts_child != NULL) + fts_lfree(sp->fts_child); - if (instr == FTS_NAMEONLY) { - SET(FTS_NAMEONLY); - instr = BNAMES; - } else - instr = BCHILD; + if (instr == FTS_NAMEONLY) { + SET(FTS_NAMEONLY); + instr = BNAMES; + } else + instr = BCHILD; - /* - * If using chdir on a relative file name and called BEFORE fts_read - * does its chdir to the root of a traversal, we can lose -- we need to - * chdir into the subdirectory, and we don't know where the current - * directory is, so we can't get back so that the upcoming chdir by - * fts_read will work. - */ - if (p->fts_level != FTS_ROOTLEVEL || p->fts_accpath[0] == '/' || - ISSET(FTS_NOCHDIR)) - return (sp->fts_child = fts_build(sp, instr)); + /* + * If using chdir on a relative file name and called BEFORE fts_read + * does its chdir to the root of a traversal, we can lose -- we need to + * chdir into the subdirectory, and we don't know where the current + * directory is, so we can't get back so that the upcoming chdir by + * fts_read will work. + */ + if (p->fts_level != FTS_ROOTLEVEL || p->fts_accpath[0] == '/' || + ISSET(FTS_NOCHDIR)) + return (sp->fts_child = fts_build(sp, instr)); - if ((fd = diropen (sp, ".")) < 0) - return (sp->fts_child = NULL); - sp->fts_child = fts_build(sp, instr); - if (ISSET(FTS_CWDFD)) - { - cwd_advance_fd (sp, fd, true); - } - else - { - if (fchdir(fd)) - { - int saved_errno = errno; - close (fd); - __set_errno (saved_errno); - return NULL; - } - close (fd); - } - return (sp->fts_child); + if ((fd = diropen (sp, ".")) < 0) + return (sp->fts_child = NULL); + sp->fts_child = fts_build(sp, instr); + if (ISSET(FTS_CWDFD)) + { + cwd_advance_fd (sp, fd, true); + } + else + { + if (fchdir(fd)) + { + int saved_errno = errno; + close (fd); + __set_errno (saved_errno); + return NULL; + } + close (fd); + } + return (sp->fts_child); } /* A comparison function to sort on increasing inode number. @@ -1175,7 +1162,7 @@ static int fts_compare_ino (struct _ftsent const **a, struct _ftsent const **b) { return (a[0]->fts_statp->st_ino < b[0]->fts_statp->st_ino ? -1 - : b[0]->fts_statp->st_ino < a[0]->fts_statp->st_ino ? 1 : 0); + : b[0]->fts_statp->st_ino < a[0]->fts_statp->st_ino ? 1 : 0); } /* Map the dirent.d_type value, DTYPE, to the corresponding stat.st_mode @@ -1231,309 +1218,323 @@ static FTSENT * internal_function fts_build (register FTS *sp, int type) { - register struct dirent *dp; - register FTSENT *p, *head; - register size_t nitems; - FTSENT *cur, *tail; - DIR *dirp; - void *oldaddr; - int saved_errno; - bool descend; - bool doadjust; - ptrdiff_t level; - nlink_t nlinks; - bool nostat; - size_t len, maxlen, new_len; - char *cp; + register struct dirent *dp; + register FTSENT *p, *head; + register size_t nitems; + FTSENT *cur, *tail; + DIR *dirp; + void *oldaddr; + int saved_errno; + bool descend; + bool doadjust; + ptrdiff_t level; + nlink_t nlinks; + bool nostat; + size_t len, maxlen, new_len; + char *cp; - /* Set current node pointer. */ - cur = sp->fts_cur; + /* Set current node pointer. */ + cur = sp->fts_cur; - /* - * Open the directory for reading. If this fails, we're done. - * If being called from fts_read, set the fts_info field. - */ + /* + * Open the directory for reading. If this fails, we're done. + * If being called from fts_read, set the fts_info field. + */ #if defined FTS_WHITEOUT && 0 - if (ISSET(FTS_WHITEOUT)) - oflag = DTF_NODUP|DTF_REWIND; - else - oflag = DTF_HIDEW|DTF_NODUP|DTF_REWIND; + if (ISSET(FTS_WHITEOUT)) + oflag = DTF_NODUP|DTF_REWIND; + else + oflag = DTF_HIDEW|DTF_NODUP|DTF_REWIND; #else # define __opendir2(file, flag) \ - ( ! ISSET(FTS_NOCHDIR) && ISSET(FTS_CWDFD) \ - ? opendirat(sp->fts_cwd_fd, file) \ - : opendir(file)) + ( ! ISSET(FTS_NOCHDIR) && ISSET(FTS_CWDFD) \ + ? opendirat(sp->fts_cwd_fd, file) \ + : opendir(file)) #endif if ((dirp = __opendir2(cur->fts_accpath, oflag)) == NULL) { - if (type == BREAD) { - cur->fts_info = FTS_DNR; - cur->fts_errno = errno; - } - return (NULL); - } + if (type == BREAD) { + cur->fts_info = FTS_DNR; + cur->fts_errno = errno; + } + return (NULL); + } /* Rather than calling fts_stat for each and every entry encountered - in the readdir loop (below), stat each directory only right after - opening it. */ + in the readdir loop (below), stat each directory only right after + opening it. */ if (cur->fts_info == FTS_NSOK) - cur->fts_info = fts_stat(sp, cur, false); + cur->fts_info = fts_stat(sp, cur, false); + else if (sp->fts_options & FTS_TIGHT_CYCLE_CHECK) { + /* Now read the stat info again after opening a directory to + * reveal eventual changes caused by a submount triggered by + * the traversal. But do it only for utilities which use + * FTS_TIGHT_CYCLE_CHECK. Therefore, only find and du + * benefit/suffer from this feature for now. + */ + LEAVE_DIR (sp, cur, "4"); + fts_stat (sp, cur, false); + if (! enter_dir (sp, cur)) { + __set_errno (ENOMEM); + return NULL; + } + } - /* - * Nlinks is the number of possible entries of type directory in the - * directory if we're cheating on stat calls, 0 if we're not doing - * any stat calls at all, (nlink_t) -1 if we're statting everything. - */ - if (type == BNAMES) { - nlinks = 0; - /* Be quiet about nostat, GCC. */ - nostat = false; - } else if (ISSET(FTS_NOSTAT) && ISSET(FTS_PHYSICAL)) { - nlinks = (cur->fts_statp->st_nlink - - (ISSET(FTS_SEEDOT) ? 0 : 2)); - nostat = true; - } else { - nlinks = -1; - nostat = false; - } + /* + * Nlinks is the number of possible entries of type directory in the + * directory if we're cheating on stat calls, 0 if we're not doing + * any stat calls at all, (nlink_t) -1 if we're statting everything. + */ + if (type == BNAMES) { + nlinks = 0; + /* Be quiet about nostat, GCC. */ + nostat = false; + } else if (ISSET(FTS_NOSTAT) && ISSET(FTS_PHYSICAL)) { + nlinks = (cur->fts_statp->st_nlink + - (ISSET(FTS_SEEDOT) ? 0 : 2)); + nostat = true; + } else { + nlinks = -1; + nostat = false; + } - /* - * If we're going to need to stat anything or we want to descend - * and stay in the directory, chdir. If this fails we keep going, - * but set a flag so we don't chdir after the post-order visit. - * We won't be able to stat anything, but we can still return the - * names themselves. Note, that since fts_read won't be able to - * chdir into the directory, it will have to return different file - * names than before, i.e. "a/b" instead of "b". Since the node - * has already been visited in pre-order, have to wait until the - * post-order visit to return the error. There is a special case - * here, if there was nothing to stat then it's not an error to - * not be able to stat. This is all fairly nasty. If a program - * needed sorted entries or stat information, they had better be - * checking FTS_NS on the returned nodes. - */ - if (nlinks || type == BREAD) { - int dir_fd = dirfd(dirp); - if (ISSET(FTS_CWDFD) && 0 <= dir_fd) - { - dir_fd = dup (dir_fd); - set_cloexec_flag (dir_fd, true); - } - if (dir_fd < 0 || fts_safe_changedir(sp, cur, dir_fd, NULL)) { - if (nlinks && type == BREAD) - cur->fts_errno = errno; - cur->fts_flags |= FTS_DONTCHDIR; - descend = false; - closedir(dirp); - if (ISSET(FTS_CWDFD) && 0 <= dir_fd) - close (dir_fd); - dirp = NULL; - } else - descend = true; - } else - descend = false; + /* + * If we're going to need to stat anything or we want to descend + * and stay in the directory, chdir. If this fails we keep going, + * but set a flag so we don't chdir after the post-order visit. + * We won't be able to stat anything, but we can still return the + * names themselves. Note, that since fts_read won't be able to + * chdir into the directory, it will have to return different file + * names than before, i.e. "a/b" instead of "b". Since the node + * has already been visited in pre-order, have to wait until the + * post-order visit to return the error. There is a special case + * here, if there was nothing to stat then it's not an error to + * not be able to stat. This is all fairly nasty. If a program + * needed sorted entries or stat information, they had better be + * checking FTS_NS on the returned nodes. + */ + if (nlinks || type == BREAD) { + int dir_fd = dirfd(dirp); + if (ISSET(FTS_CWDFD) && 0 <= dir_fd) + { + dir_fd = dup (dir_fd); + set_cloexec_flag (dir_fd, true); + } + if (dir_fd < 0 || fts_safe_changedir(sp, cur, dir_fd, NULL)) { + if (nlinks && type == BREAD) + cur->fts_errno = errno; + cur->fts_flags |= FTS_DONTCHDIR; + descend = false; + closedir(dirp); + if (ISSET(FTS_CWDFD) && 0 <= dir_fd) + close (dir_fd); + dirp = NULL; + } else + descend = true; + } else + descend = false; - /* - * Figure out the max file name length that can be stored in the - * current buffer -- the inner loop allocates more space as necessary. - * We really wouldn't have to do the maxlen calculations here, we - * could do them in fts_read before returning the name, but it's a - * lot easier here since the length is part of the dirent structure. - * - * If not changing directories set a pointer so that can just append - * each new component into the file name. - */ - len = NAPPEND(cur); - if (ISSET(FTS_NOCHDIR)) { - cp = sp->fts_path + len; - *cp++ = '/'; - } else { - /* GCC, you're too verbose. */ - cp = NULL; - } - len++; - maxlen = sp->fts_pathlen - len; + /* + * Figure out the max file name length that can be stored in the + * current buffer -- the inner loop allocates more space as necessary. + * We really wouldn't have to do the maxlen calculations here, we + * could do them in fts_read before returning the name, but it's a + * lot easier here since the length is part of the dirent structure. + * + * If not changing directories set a pointer so that can just append + * each new component into the file name. + */ + len = NAPPEND(cur); + if (ISSET(FTS_NOCHDIR)) { + cp = sp->fts_path + len; + *cp++ = '/'; + } else { + /* GCC, you're too verbose. */ + cp = NULL; + } + len++; + maxlen = sp->fts_pathlen - len; - level = cur->fts_level + 1; + level = cur->fts_level + 1; - /* Read the directory, attaching each entry to the `link' pointer. */ - doadjust = false; - for (head = tail = NULL, nitems = 0; dirp && (dp = readdir(dirp));) { - bool is_dir; + /* Read the directory, attaching each entry to the `link' pointer. */ + doadjust = false; + for (head = tail = NULL, nitems = 0; dirp && (dp = readdir(dirp));) { + bool is_dir; - if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name)) - continue; + if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name)) + continue; - if ((p = fts_alloc (sp, dp->d_name, - _D_EXACT_NAMLEN (dp))) == NULL) - goto mem1; - if (_D_EXACT_NAMLEN (dp) >= maxlen) { - /* include space for NUL */ - oldaddr = sp->fts_path; - if (! fts_palloc(sp, _D_EXACT_NAMLEN (dp) + len + 1)) { - /* - * No more memory. Save - * errno, free up the current structure and the - * structures already allocated. - */ -mem1: saved_errno = errno; - free(p); - fts_lfree(head); - closedir(dirp); - cur->fts_info = FTS_ERR; - SET(FTS_STOP); - __set_errno (saved_errno); - return (NULL); - } - /* Did realloc() change the pointer? */ - if (oldaddr != sp->fts_path) { - doadjust = true; - if (ISSET(FTS_NOCHDIR)) - cp = sp->fts_path + len; - } - maxlen = sp->fts_pathlen - len; - } + if ((p = fts_alloc (sp, dp->d_name, + _D_EXACT_NAMLEN (dp))) == NULL) + goto mem1; + if (_D_EXACT_NAMLEN (dp) >= maxlen) { + /* include space for NUL */ + oldaddr = sp->fts_path; + if (! fts_palloc(sp, _D_EXACT_NAMLEN (dp) + len + 1)) { + /* + * No more memory. Save + * errno, free up the current structure and the + * structures already allocated. + */ +mem1: saved_errno = errno; + free(p); + fts_lfree(head); + closedir(dirp); + cur->fts_info = FTS_ERR; + SET(FTS_STOP); + __set_errno (saved_errno); + return (NULL); + } + /* Did realloc() change the pointer? */ + if (oldaddr != sp->fts_path) { + doadjust = true; + if (ISSET(FTS_NOCHDIR)) + cp = sp->fts_path + len; + } + maxlen = sp->fts_pathlen - len; + } - new_len = len + _D_EXACT_NAMLEN (dp); - if (new_len < len) { - /* - * In the unlikely event that we would end up - * with a file name longer than SIZE_MAX, free up - * the current structure and the structures already - * allocated, then error out with ENAMETOOLONG. - */ - free(p); - fts_lfree(head); - closedir(dirp); - cur->fts_info = FTS_ERR; - SET(FTS_STOP); - __set_errno (ENAMETOOLONG); - return (NULL); - } - p->fts_level = level; - p->fts_parent = sp->fts_cur; - p->fts_pathlen = new_len; + new_len = len + _D_EXACT_NAMLEN (dp); + if (new_len < len) { + /* + * In the unlikely event that we would end up + * with a file name longer than SIZE_MAX, free up + * the current structure and the structures already + * allocated, then error out with ENAMETOOLONG. + */ + free(p); + fts_lfree(head); + closedir(dirp); + cur->fts_info = FTS_ERR; + SET(FTS_STOP); + __set_errno (ENAMETOOLONG); + return (NULL); + } + p->fts_level = level; + p->fts_parent = sp->fts_cur; + p->fts_pathlen = new_len; #if defined FTS_WHITEOUT && 0 - if (dp->d_type == DT_WHT) - p->fts_flags |= FTS_ISW; + if (dp->d_type == DT_WHT) + p->fts_flags |= FTS_ISW; #endif - /* Store dirent.d_ino, in case we need to sort - entries before processing them. */ - p->fts_statp->st_ino = D_INO (dp); + /* Store dirent.d_ino, in case we need to sort + entries before processing them. */ + p->fts_statp->st_ino = D_INO (dp); - /* Build a file name for fts_stat to stat. */ - if (ISSET(FTS_NOCHDIR)) { - p->fts_accpath = p->fts_path; - memmove(cp, p->fts_name, p->fts_namelen + 1); - } else - p->fts_accpath = p->fts_name; + /* Build a file name for fts_stat to stat. */ + if (ISSET(FTS_NOCHDIR)) { + p->fts_accpath = p->fts_path; + memmove(cp, p->fts_name, p->fts_namelen + 1); + } else + p->fts_accpath = p->fts_name; - if (sp->fts_compar == NULL || ISSET(FTS_DEFER_STAT)) { - /* Record what fts_read will have to do with this - entry. In many cases, it will simply fts_stat it, - but we can take advantage of any d_type information - to optimize away the unnecessary stat calls. I.e., - if FTS_NOSTAT is in effect and we're not following - symlinks (FTS_PHYSICAL) and d_type indicates this - is *not* a directory, then we won't have to stat it - at all. If it *is* a directory, then (currently) - we stat it regardless, in order to get device and - inode numbers. Some day we might optimize that - away, too, for directories where d_ino is known to - be valid. */ - bool skip_stat = (ISSET(FTS_PHYSICAL) - && ISSET(FTS_NOSTAT) - && DT_IS_KNOWN(dp) - && ! DT_MUST_BE(dp, DT_DIR)); - p->fts_info = FTS_NSOK; - /* Propagate dirent.d_type information back - to caller, when possible. */ - set_stat_type (p->fts_statp, D_TYPE (dp)); - fts_set_stat_required(p, !skip_stat); - is_dir = (ISSET(FTS_PHYSICAL) - && DT_MUST_BE(dp, DT_DIR)); - } else { - p->fts_info = fts_stat(sp, p, false); - is_dir = (p->fts_info == FTS_D - || p->fts_info == FTS_DC - || p->fts_info == FTS_DOT); - } + if (sp->fts_compar == NULL || ISSET(FTS_DEFER_STAT)) { + /* Record what fts_read will have to do with this + entry. In many cases, it will simply fts_stat it, + but we can take advantage of any d_type information + to optimize away the unnecessary stat calls. I.e., + if FTS_NOSTAT is in effect and we're not following + symlinks (FTS_PHYSICAL) and d_type indicates this + is *not* a directory, then we won't have to stat it + at all. If it *is* a directory, then (currently) + we stat it regardless, in order to get device and + inode numbers. Some day we might optimize that + away, too, for directories where d_ino is known to + be valid. */ + bool skip_stat = (ISSET(FTS_PHYSICAL) + && ISSET(FTS_NOSTAT) + && DT_IS_KNOWN(dp) + && ! DT_MUST_BE(dp, DT_DIR)); + p->fts_info = FTS_NSOK; + /* Propagate dirent.d_type information back + to caller, when possible. */ + set_stat_type (p->fts_statp, D_TYPE (dp)); + fts_set_stat_required(p, !skip_stat); + is_dir = (ISSET(FTS_PHYSICAL) + && DT_MUST_BE(dp, DT_DIR)); + } else { + p->fts_info = fts_stat(sp, p, false); + is_dir = (p->fts_info == FTS_D + || p->fts_info == FTS_DC + || p->fts_info == FTS_DOT); + } - /* Decrement link count if applicable. */ - if (nlinks > 0 && is_dir) - nlinks -= nostat; + /* Decrement link count if applicable. */ + if (nlinks > 0 && is_dir) + nlinks -= nostat; - /* We walk in directory order so "ls -f" doesn't get upset. */ - p->fts_link = NULL; - if (head == NULL) - head = tail = p; - else { - tail->fts_link = p; - tail = p; - } - ++nitems; - } - if (dirp) - closedir(dirp); + /* We walk in directory order so "ls -f" doesn't get upset. */ + p->fts_link = NULL; + if (head == NULL) + head = tail = p; + else { + tail->fts_link = p; + tail = p; + } + ++nitems; + } + if (dirp) + closedir(dirp); - /* - * If realloc() changed the address of the file name, adjust the - * addresses for the rest of the tree and the dir list. - */ - if (doadjust) - fts_padjust(sp, head); + /* + * If realloc() changed the address of the file name, adjust the + * addresses for the rest of the tree and the dir list. + */ + if (doadjust) + fts_padjust(sp, head); - /* - * If not changing directories, reset the file name back to original - * state. - */ - if (ISSET(FTS_NOCHDIR)) { - if (len == sp->fts_pathlen || nitems == 0) - --cp; - *cp = '\0'; - } + /* + * If not changing directories, reset the file name back to original + * state. + */ + if (ISSET(FTS_NOCHDIR)) { + if (len == sp->fts_pathlen || nitems == 0) + --cp; + *cp = '\0'; + } - /* - * If descended after called from fts_children or after called from - * fts_read and nothing found, get back. At the root level we use - * the saved fd; if one of fts_open()'s arguments is a relative name - * to an empty directory, we wind up here with no other way back. If - * can't get back, we're done. - */ - if (descend && (type == BCHILD || !nitems) && - (cur->fts_level == FTS_ROOTLEVEL - ? RESTORE_INITIAL_CWD(sp) - : fts_safe_changedir(sp, cur->fts_parent, -1, ".."))) { - cur->fts_info = FTS_ERR; - SET(FTS_STOP); - fts_lfree(head); - return (NULL); - } + /* + * If descended after called from fts_children or after called from + * fts_read and nothing found, get back. At the root level we use + * the saved fd; if one of fts_open()'s arguments is a relative name + * to an empty directory, we wind up here with no other way back. If + * can't get back, we're done. + */ + if (descend && (type == BCHILD || !nitems) && + (cur->fts_level == FTS_ROOTLEVEL + ? RESTORE_INITIAL_CWD(sp) + : fts_safe_changedir(sp, cur->fts_parent, -1, ".."))) { + cur->fts_info = FTS_ERR; + SET(FTS_STOP); + fts_lfree(head); + return (NULL); + } - /* If didn't find anything, return NULL. */ - if (!nitems) { - if (type == BREAD) - cur->fts_info = FTS_DP; - fts_lfree(head); - return (NULL); - } + /* If didn't find anything, return NULL. */ + if (!nitems) { + if (type == BREAD) + cur->fts_info = FTS_DP; + fts_lfree(head); + return (NULL); + } - /* If there are many entries, no sorting function has been specified, - and this file system is of a type that may be slow with a large - number of entries, then sort the directory entries on increasing - inode numbers. */ - if (nitems > _FTS_INODE_SORT_DIR_ENTRIES_THRESHOLD - && !sp->fts_compar - && ISSET (FTS_CWDFD) - && dirent_inode_sort_may_be_useful (sp->fts_cwd_fd)) { - sp->fts_compar = fts_compare_ino; - head = fts_sort (sp, head, nitems); - sp->fts_compar = NULL; - } + /* If there are many entries, no sorting function has been specified, + and this file system is of a type that may be slow with a large + number of entries, then sort the directory entries on increasing + inode numbers. */ + if (nitems > _FTS_INODE_SORT_DIR_ENTRIES_THRESHOLD + && !sp->fts_compar + && ISSET (FTS_CWDFD) + && dirent_inode_sort_may_be_useful (sp->fts_cwd_fd)) { + sp->fts_compar = fts_compare_ino; + head = fts_sort (sp, head, nitems); + sp->fts_compar = NULL; + } - /* Sort the entries. */ - if (sp->fts_compar && nitems > 1) - head = fts_sort(sp, head, nitems); - return (head); + /* Sort the entries. */ + if (sp->fts_compar && nitems > 1) + head = fts_sort(sp, head, nitems); + return (head); } #if FTS_DEBUG @@ -1548,20 +1549,20 @@ find_matching_ancestor (FTSENT const *e_curr, struct Active_dir const *ad) for (ent = e_curr; ent->fts_level >= FTS_ROOTLEVEL; ent = ent->fts_parent) { if (ad->ino == ent->fts_statp->st_ino - && ad->dev == ent->fts_statp->st_dev) - return; + && ad->dev == ent->fts_statp->st_dev) + return; } printf ("ERROR: tree dir, %s, not active\n", ad->fts_ent->fts_accpath); printf ("active dirs:\n"); for (ent = e_curr; ent->fts_level >= FTS_ROOTLEVEL; ent = ent->fts_parent) printf (" %s(%"PRIuMAX"/%"PRIuMAX") to %s(%"PRIuMAX"/%"PRIuMAX")...\n", - ad->fts_ent->fts_accpath, - (uintmax_t) ad->dev, - (uintmax_t) ad->ino, - ent->fts_accpath, - (uintmax_t) ent->fts_statp->st_dev, - (uintmax_t) ent->fts_statp->st_ino); + ad->fts_ent->fts_accpath, + (uintmax_t) ad->dev, + (uintmax_t) ad->ino, + ent->fts_accpath, + (uintmax_t) ent->fts_statp->st_dev, + (uintmax_t) ent->fts_statp->st_ino); } void @@ -1580,21 +1581,21 @@ fts_cross_check (FTS const *sp) ad.ino = t->fts_statp->st_ino; ad.dev = t->fts_statp->st_dev; if ( ! hash_lookup (sp->fts_cycle.ht, &ad)) - printf ("ERROR: active dir, %s, not in tree\n", t->fts_path); + printf ("ERROR: active dir, %s, not in tree\n", t->fts_path); } /* Make sure every dir in the tree is an active dir. But ENT is not necessarily a directory. If so, just skip this part. */ if (ent->fts_parent->fts_level >= FTS_ROOTLEVEL && (ent->fts_info == FTS_DP - || ent->fts_info == FTS_D)) + || ent->fts_info == FTS_D)) { struct Active_dir *ad; for (ad = hash_get_first (sp->fts_cycle.ht); ad != NULL; - ad = hash_get_next (sp->fts_cycle.ht, ad)) - { - find_matching_ancestor (ent, ad); - } + ad = hash_get_next (sp->fts_cycle.ht, ad)) + { + find_matching_ancestor (ent, ad); + } } } @@ -1603,8 +1604,8 @@ same_fd (int fd1, int fd2) { struct stat sb1, sb2; return (fstat (fd1, &sb1) == 0 - && fstat (fd2, &sb2) == 0 - && SAME_INODE (sb1, sb2)); + && fstat (fd2, &sb2) == 0 + && SAME_INODE (sb1, sb2)); } static void @@ -1622,15 +1623,15 @@ fd_ring_print (FTS const *sp, FILE *stream, char const *msg) { int fd = fd_ring->fts_fd_ring[i]; if (fd < 0) - fprintf (stream, "%d: %d:\n", i, fd); + fprintf (stream, "%d: %d:\n", i, fd); else - { - char *wd = getcwdat (fd, NULL, 0); - fprintf (stream, "%d: %d: %s\n", i, fd, wd); - free (wd); - } + { + char *wd = getcwdat (fd, NULL, 0); + fprintf (stream, "%d: %d: %s\n", i, fd, wd); + free (wd); + } if (i == fd_ring->fts_back) - break; + break; i = (i + I_RING_SIZE - 1) % I_RING_SIZE; } } @@ -1655,26 +1656,26 @@ fd_ring_check (FTS const *sp) { int fd = i_ring_pop (&fd_w); if (0 <= fd) - { - int parent_fd = openat (cwd_fd, "..", O_RDONLY); - if (parent_fd < 0) - { - // Warn? - break; - } - if (!same_fd (fd, parent_fd)) - { - char *cwd = getcwdat (fd, NULL, 0); - error (0, errno, "ring : %s", cwd); - char *c2 = getcwdat (parent_fd, NULL, 0); - error (0, errno, "parent: %s", c2); - free (cwd); - free (c2); - fts_assert (0); - } - close (cwd_fd); - cwd_fd = parent_fd; - } + { + int parent_fd = openat (cwd_fd, "..", O_RDONLY); + if (parent_fd < 0) + { + // Warn? + break; + } + if (!same_fd (fd, parent_fd)) + { + char *cwd = getcwdat (fd, NULL, 0); + error (0, errno, "ring : %s", cwd); + char *c2 = getcwdat (parent_fd, NULL, 0); + error (0, errno, "parent: %s", c2); + free (cwd); + free (c2); + fts_assert (0); + } + close (cwd_fd); + cwd_fd = parent_fd; + } } close (cwd_fd); } @@ -1684,80 +1685,80 @@ static unsigned short int internal_function fts_stat(FTS *sp, register FTSENT *p, bool follow) { - struct stat *sbp = p->fts_statp; - int saved_errno; + struct stat *sbp = p->fts_statp; + int saved_errno; - if (p->fts_level == FTS_ROOTLEVEL && ISSET(FTS_COMFOLLOW)) - follow = true; + if (p->fts_level == FTS_ROOTLEVEL && ISSET(FTS_COMFOLLOW)) + follow = true; #if defined FTS_WHITEOUT && 0 - /* check for whiteout */ - if (p->fts_flags & FTS_ISW) { - memset(sbp, '\0', sizeof (*sbp)); - sbp->st_mode = S_IFWHT; - return (FTS_W); + /* check for whiteout */ + if (p->fts_flags & FTS_ISW) { + memset(sbp, '\0', sizeof (*sbp)); + sbp->st_mode = S_IFWHT; + return (FTS_W); } #endif - /* - * If doing a logical walk, or application requested FTS_FOLLOW, do - * a stat(2). If that fails, check for a non-existent symlink. If - * fail, set the errno from the stat call. - */ - if (ISSET(FTS_LOGICAL) || follow) { - if (stat(p->fts_accpath, sbp)) { - saved_errno = errno; - if (errno == ENOENT - && lstat(p->fts_accpath, sbp) == 0) { - __set_errno (0); - return (FTS_SLNONE); - } - p->fts_errno = saved_errno; - goto err; - } - } else if (fstatat(sp->fts_cwd_fd, p->fts_accpath, sbp, - AT_SYMLINK_NOFOLLOW)) { - p->fts_errno = errno; -err: memset(sbp, 0, sizeof(struct stat)); - return (FTS_NS); - } + /* + * If doing a logical walk, or application requested FTS_FOLLOW, do + * a stat(2). If that fails, check for a non-existent symlink. If + * fail, set the errno from the stat call. + */ + if (ISSET(FTS_LOGICAL) || follow) { + if (stat(p->fts_accpath, sbp)) { + saved_errno = errno; + if (errno == ENOENT + && lstat(p->fts_accpath, sbp) == 0) { + __set_errno (0); + return (FTS_SLNONE); + } + p->fts_errno = saved_errno; + goto err; + } + } else if (fstatat(sp->fts_cwd_fd, p->fts_accpath, sbp, + AT_SYMLINK_NOFOLLOW)) { + p->fts_errno = errno; +err: memset(sbp, 0, sizeof(struct stat)); + return (FTS_NS); + } - if (S_ISDIR(sbp->st_mode)) { - p->fts_n_dirs_remaining = (sbp->st_nlink - - (ISSET(FTS_SEEDOT) ? 0 : 2)); - if (ISDOT(p->fts_name)) { - /* Command-line "." and ".." are real directories. */ - return (p->fts_level == FTS_ROOTLEVEL ? FTS_D : FTS_DOT); - } + if (S_ISDIR(sbp->st_mode)) { + p->fts_n_dirs_remaining = (sbp->st_nlink + - (ISSET(FTS_SEEDOT) ? 0 : 2)); + if (ISDOT(p->fts_name)) { + /* Command-line "." and ".." are real directories. */ + return (p->fts_level == FTS_ROOTLEVEL ? FTS_D : FTS_DOT); + } #if !GNULIB_FTS - { - /* - * Cycle detection is done by brute force when the directory - * is first encountered. If the tree gets deep enough or the - * number of symbolic links to directories is high enough, - * something faster might be worthwhile. - */ - FTSENT *t; + { + /* + * Cycle detection is done by brute force when the directory + * is first encountered. If the tree gets deep enough or the + * number of symbolic links to directories is high enough, + * something faster might be worthwhile. + */ + FTSENT *t; - for (t = p->fts_parent; - t->fts_level >= FTS_ROOTLEVEL; t = t->fts_parent) - if (sbp->st_ino == t->fts_statp->st_ino - && sbp->st_dev == t->fts_statp->st_dev) - { - p->fts_cycle = t; - return (FTS_DC); - } - } + for (t = p->fts_parent; + t->fts_level >= FTS_ROOTLEVEL; t = t->fts_parent) + if (sbp->st_ino == t->fts_statp->st_ino + && sbp->st_dev == t->fts_statp->st_dev) + { + p->fts_cycle = t; + return (FTS_DC); + } + } #endif - return (FTS_D); - } - if (S_ISLNK(sbp->st_mode)) - return (FTS_SL); - if (S_ISREG(sbp->st_mode)) - return (FTS_F); - return (FTS_DEFAULT); + return (FTS_D); + } + if (S_ISLNK(sbp->st_mode)) + return (FTS_SL); + if (S_ISREG(sbp->st_mode)) + return (FTS_F); + return (FTS_DEFAULT); } static int @@ -1777,93 +1778,93 @@ static FTSENT * internal_function fts_sort (FTS *sp, FTSENT *head, register size_t nitems) { - register FTSENT **ap, *p; + register FTSENT **ap, *p; - /* On most modern hosts, void * and FTSENT ** have the same - run-time representation, and one can convert sp->fts_compar to - the type qsort expects without problem. Use the heuristic that - this is OK if the two pointer types are the same size, and if - converting FTSENT ** to long int is the same as converting - FTSENT ** to void * and then to long int. This heuristic isn't - valid in general but we don't know of any counterexamples. */ - FTSENT *dummy; - int (*compare) (void const *, void const *) = - ((sizeof &dummy == sizeof (void *) - && (long int) &dummy == (long int) (void *) &dummy) - ? (int (*) (void const *, void const *)) sp->fts_compar - : fts_compar); + /* On most modern hosts, void * and FTSENT ** have the same + run-time representation, and one can convert sp->fts_compar to + the type qsort expects without problem. Use the heuristic that + this is OK if the two pointer types are the same size, and if + converting FTSENT ** to long int is the same as converting + FTSENT ** to void * and then to long int. This heuristic isn't + valid in general but we don't know of any counterexamples. */ + FTSENT *dummy; + int (*compare) (void const *, void const *) = + ((sizeof &dummy == sizeof (void *) + && (long int) &dummy == (long int) (void *) &dummy) + ? (int (*) (void const *, void const *)) sp->fts_compar + : fts_compar); - /* - * Construct an array of pointers to the structures and call qsort(3). - * Reassemble the array in the order returned by qsort. If unable to - * sort for memory reasons, return the directory entries in their - * current order. Allocate enough space for the current needs plus - * 40 so don't realloc one entry at a time. - */ - if (nitems > sp->fts_nitems) { - FTSENT **a; + /* + * Construct an array of pointers to the structures and call qsort(3). + * Reassemble the array in the order returned by qsort. If unable to + * sort for memory reasons, return the directory entries in their + * current order. Allocate enough space for the current needs plus + * 40 so don't realloc one entry at a time. + */ + if (nitems > sp->fts_nitems) { + FTSENT **a; - sp->fts_nitems = nitems + 40; - if (SIZE_MAX / sizeof *a < sp->fts_nitems - || ! (a = realloc (sp->fts_array, - sp->fts_nitems * sizeof *a))) { - free(sp->fts_array); - sp->fts_array = NULL; - sp->fts_nitems = 0; - return (head); - } - sp->fts_array = a; - } - for (ap = sp->fts_array, p = head; p; p = p->fts_link) - *ap++ = p; - qsort((void *)sp->fts_array, nitems, sizeof(FTSENT *), compare); - for (head = *(ap = sp->fts_array); --nitems; ++ap) - ap[0]->fts_link = ap[1]; - ap[0]->fts_link = NULL; - return (head); + sp->fts_nitems = nitems + 40; + if (SIZE_MAX / sizeof *a < sp->fts_nitems + || ! (a = realloc (sp->fts_array, + sp->fts_nitems * sizeof *a))) { + free(sp->fts_array); + sp->fts_array = NULL; + sp->fts_nitems = 0; + return (head); + } + sp->fts_array = a; + } + for (ap = sp->fts_array, p = head; p; p = p->fts_link) + *ap++ = p; + qsort((void *)sp->fts_array, nitems, sizeof(FTSENT *), compare); + for (head = *(ap = sp->fts_array); --nitems; ++ap) + ap[0]->fts_link = ap[1]; + ap[0]->fts_link = NULL; + return (head); } static FTSENT * internal_function fts_alloc (FTS *sp, const char *name, register size_t namelen) { - register FTSENT *p; - size_t len; + register FTSENT *p; + size_t len; - /* - * The file name is a variable length array. Allocate the FTSENT - * structure and the file name in one chunk. - */ - len = sizeof(FTSENT) + namelen; - if ((p = malloc(len)) == NULL) - return (NULL); + /* + * The file name is a variable length array. Allocate the FTSENT + * structure and the file name in one chunk. + */ + len = sizeof(FTSENT) + namelen; + if ((p = malloc(len)) == NULL) + return (NULL); - /* Copy the name and guarantee NUL termination. */ - memmove(p->fts_name, name, namelen); - p->fts_name[namelen] = '\0'; + /* Copy the name and guarantee NUL termination. */ + memmove(p->fts_name, name, namelen); + p->fts_name[namelen] = '\0'; - p->fts_namelen = namelen; - p->fts_fts = sp; - p->fts_path = sp->fts_path; - p->fts_errno = 0; - p->fts_flags = 0; - p->fts_instr = FTS_NOINSTR; - p->fts_number = 0; - p->fts_pointer = NULL; - return (p); + p->fts_namelen = namelen; + p->fts_fts = sp; + p->fts_path = sp->fts_path; + p->fts_errno = 0; + p->fts_flags = 0; + p->fts_instr = FTS_NOINSTR; + p->fts_number = 0; + p->fts_pointer = NULL; + return (p); } static void internal_function fts_lfree (register FTSENT *head) { - register FTSENT *p; + register FTSENT *p; - /* Free a linked list of structures. */ - while ((p = head)) { - head = head->fts_link; - free(p); - } + /* Free a linked list of structures. */ + while ((p = head)) { + head = head->fts_link; + free(p); + } } /* @@ -1877,27 +1878,27 @@ static bool internal_function fts_palloc (FTS *sp, size_t more) { - char *p; - size_t new_len = sp->fts_pathlen + more + 256; + char *p; + size_t new_len = sp->fts_pathlen + more + 256; - /* - * See if fts_pathlen would overflow. - */ - if (new_len < sp->fts_pathlen) { - free(sp->fts_path); - sp->fts_path = NULL; - __set_errno (ENAMETOOLONG); - return false; - } - sp->fts_pathlen = new_len; - p = realloc(sp->fts_path, sp->fts_pathlen); - if (p == NULL) { - free(sp->fts_path); - sp->fts_path = NULL; - return false; - } - sp->fts_path = p; - return true; + /* + * See if fts_pathlen would overflow. + */ + if (new_len < sp->fts_pathlen) { + free(sp->fts_path); + sp->fts_path = NULL; + __set_errno (ENAMETOOLONG); + return false; + } + sp->fts_pathlen = new_len; + p = realloc(sp->fts_path, sp->fts_pathlen); + if (p == NULL) { + free(sp->fts_path); + sp->fts_path = NULL; + return false; + } + sp->fts_path = p; + return true; } /* @@ -1908,37 +1909,37 @@ static void internal_function fts_padjust (FTS *sp, FTSENT *head) { - FTSENT *p; - char *addr = sp->fts_path; + FTSENT *p; + char *addr = sp->fts_path; -#define ADJUST(p) do { \ - if ((p)->fts_accpath != (p)->fts_name) { \ - (p)->fts_accpath = \ - (char *)addr + ((p)->fts_accpath - (p)->fts_path); \ - } \ - (p)->fts_path = addr; \ +#define ADJUST(p) do { \ + if ((p)->fts_accpath != (p)->fts_name) { \ + (p)->fts_accpath = \ + (char *)addr + ((p)->fts_accpath - (p)->fts_path); \ + } \ + (p)->fts_path = addr; \ } while (0) - /* Adjust the current set of children. */ - for (p = sp->fts_child; p; p = p->fts_link) - ADJUST(p); + /* Adjust the current set of children. */ + for (p = sp->fts_child; p; p = p->fts_link) + ADJUST(p); - /* Adjust the rest of the tree, including the current level. */ - for (p = head; p->fts_level >= FTS_ROOTLEVEL;) { - ADJUST(p); - p = p->fts_link ? p->fts_link : p->fts_parent; - } + /* Adjust the rest of the tree, including the current level. */ + for (p = head; p->fts_level >= FTS_ROOTLEVEL;) { + ADJUST(p); + p = p->fts_link ? p->fts_link : p->fts_parent; + } } static size_t internal_function fts_maxarglen (char * const *argv) { - size_t len, max; + size_t len, max; - for (max = 0; *argv; ++argv) - if ((len = strlen(*argv)) > max) - max = len; - return (max + 1); + for (max = 0; *argv; ++argv) + if ((len = strlen(*argv)) > max) + max = len; + return (max + 1); } /* @@ -1954,84 +1955,84 @@ static int internal_function fts_safe_changedir (FTS *sp, FTSENT *p, int fd, char const *dir) { - int ret; - bool is_dotdot = dir && STREQ (dir, ".."); - int newfd; + int ret; + bool is_dotdot = dir && STREQ (dir, ".."); + int newfd; - /* This clause handles the unusual case in which FTS_NOCHDIR - is specified, along with FTS_CWDFD. In that case, there is - no need to change even the virtual cwd file descriptor. - However, if FD is non-negative, we do close it here. */ - if (ISSET (FTS_NOCHDIR)) - { - if (ISSET (FTS_CWDFD) && 0 <= fd) - close (fd); - return 0; - } + /* This clause handles the unusual case in which FTS_NOCHDIR + is specified, along with FTS_CWDFD. In that case, there is + no need to change even the virtual cwd file descriptor. + However, if FD is non-negative, we do close it here. */ + if (ISSET (FTS_NOCHDIR)) + { + if (ISSET (FTS_CWDFD) && 0 <= fd) + close (fd); + return 0; + } - if (fd < 0 && is_dotdot && ISSET (FTS_CWDFD)) - { - /* When possible, skip the diropen and subsequent fstat+dev/ino - comparison. I.e., when changing to parent directory - (chdir ("..")), use a file descriptor from the ring and - save the overhead of diropen+fstat, as well as avoiding - failure when we lack "x" access to the virtual cwd. */ - if ( ! i_ring_empty (&sp->fts_fd_ring)) - { - int parent_fd; - fd_ring_print (sp, stderr, "pre-pop"); - parent_fd = i_ring_pop (&sp->fts_fd_ring); - is_dotdot = true; - if (0 <= parent_fd) - { - fd = parent_fd; - dir = NULL; - } - } - } + if (fd < 0 && is_dotdot && ISSET (FTS_CWDFD)) + { + /* When possible, skip the diropen and subsequent fstat+dev/ino + comparison. I.e., when changing to parent directory + (chdir ("..")), use a file descriptor from the ring and + save the overhead of diropen+fstat, as well as avoiding + failure when we lack "x" access to the virtual cwd. */ + if ( ! i_ring_empty (&sp->fts_fd_ring)) + { + int parent_fd; + fd_ring_print (sp, stderr, "pre-pop"); + parent_fd = i_ring_pop (&sp->fts_fd_ring); + is_dotdot = true; + if (0 <= parent_fd) + { + fd = parent_fd; + dir = NULL; + } + } + } - newfd = fd; - if (fd < 0 && (newfd = diropen (sp, dir)) < 0) - return -1; + newfd = fd; + if (fd < 0 && (newfd = diropen (sp, dir)) < 0) + return -1; - /* The following dev/inode check is necessary if we're doing a - `logical' traversal (through symlinks, a la chown -L), if the - system lacks O_NOFOLLOW support, or if we're changing to ".." - (but not via a popped file descriptor). When changing to the - name "..", O_NOFOLLOW can't help. In general, when the target is - not "..", diropen's use of O_NOFOLLOW ensures we don't mistakenly - follow a symlink, so we can avoid the expense of this fstat. */ - if (ISSET(FTS_LOGICAL) || ! HAVE_WORKING_O_NOFOLLOW - || (dir && STREQ (dir, ".."))) - { - struct stat sb; - if (fstat(newfd, &sb)) - { - ret = -1; - goto bail; - } - if (p->fts_statp->st_dev != sb.st_dev - || p->fts_statp->st_ino != sb.st_ino) - { - __set_errno (ENOENT); /* disinformation */ - ret = -1; - goto bail; - } - } + /* The following dev/inode check is necessary if we're doing a + `logical' traversal (through symlinks, a la chown -L), if the + system lacks O_NOFOLLOW support, or if we're changing to ".." + (but not via a popped file descriptor). When changing to the + name "..", O_NOFOLLOW can't help. In general, when the target is + not "..", diropen's use of O_NOFOLLOW ensures we don't mistakenly + follow a symlink, so we can avoid the expense of this fstat. */ + if (ISSET(FTS_LOGICAL) || ! HAVE_WORKING_O_NOFOLLOW + || (dir && STREQ (dir, ".."))) + { + struct stat sb; + if (fstat(newfd, &sb)) + { + ret = -1; + goto bail; + } + if (p->fts_statp->st_dev != sb.st_dev + || p->fts_statp->st_ino != sb.st_ino) + { + __set_errno (ENOENT); /* disinformation */ + ret = -1; + goto bail; + } + } - if (ISSET(FTS_CWDFD)) - { - cwd_advance_fd (sp, newfd, ! is_dotdot); - return 0; - } + if (ISSET(FTS_CWDFD)) + { + cwd_advance_fd (sp, newfd, ! is_dotdot); + return 0; + } - ret = fchdir(newfd); + ret = fchdir(newfd); bail: - if (fd < 0) - { - int oerrno = errno; - (void)close(newfd); - __set_errno (oerrno); - } - return ret; + if (fd < 0) + { + int oerrno = errno; + (void)close(newfd); + __set_errno (oerrno); + } + return ret; } diff --git a/src/bin/coreutils/lib/fts_.h b/src/bin/coreutils/lib/fts_.h index 0e2d505aff..e1a8196af0 100644 --- a/src/bin/coreutils/lib/fts_.h +++ b/src/bin/coreutils/lib/fts_.h @@ -1,6 +1,6 @@ /* Traverse a file hierarchy. - Copyright (C) 2004-2009 Free Software Foundation, Inc. + Copyright (C) 2004-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,7 +17,7 @@ /* * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -43,10 +43,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)fts.h 8.3 (Berkeley) 8/14/94 + * @(#)fts.h 8.3 (Berkeley) 8/14/94 */ -#ifndef _FTS_H +#ifndef _FTS_H # define _FTS_H 1 # ifdef _LIBC @@ -66,27 +66,27 @@ # include "i-ring.h" typedef struct { - struct _ftsent *fts_cur; /* current node */ - struct _ftsent *fts_child; /* linked list of children */ - struct _ftsent **fts_array; /* sort array */ - dev_t fts_dev; /* starting device # */ - char *fts_path; /* file name for this descent */ - int fts_rfd; /* fd for root */ - int fts_cwd_fd; /* the file descriptor on which the - virtual cwd is open, or AT_FDCWD */ - size_t fts_pathlen; /* sizeof(path) */ - size_t fts_nitems; /* elements in the sort array */ - int (*fts_compar) (struct _ftsent const **, struct _ftsent const **); - /* compare fn */ + struct _ftsent *fts_cur; /* current node */ + struct _ftsent *fts_child; /* linked list of children */ + struct _ftsent **fts_array; /* sort array */ + dev_t fts_dev; /* starting device # */ + char *fts_path; /* file name for this descent */ + int fts_rfd; /* fd for root */ + int fts_cwd_fd; /* the file descriptor on which the + virtual cwd is open, or AT_FDCWD */ + size_t fts_pathlen; /* sizeof(path) */ + size_t fts_nitems; /* elements in the sort array */ + int (*fts_compar) (struct _ftsent const **, struct _ftsent const **); + /* compare fn */ -# define FTS_COMFOLLOW 0x0001 /* follow command line symlinks */ -# define FTS_LOGICAL 0x0002 /* logical walk */ -# define FTS_NOCHDIR 0x0004 /* don't change directories */ -# define FTS_NOSTAT 0x0008 /* don't get stat info */ -# define FTS_PHYSICAL 0x0010 /* physical walk */ -# define FTS_SEEDOT 0x0020 /* return dot and dot-dot */ -# define FTS_XDEV 0x0040 /* don't cross devices */ -# define FTS_WHITEOUT 0x0080 /* return whiteout information */ +# define FTS_COMFOLLOW 0x0001 /* follow command line symlinks */ +# define FTS_LOGICAL 0x0002 /* logical walk */ +# define FTS_NOCHDIR 0x0004 /* don't change directories */ +# define FTS_NOSTAT 0x0008 /* don't get stat info */ +# define FTS_PHYSICAL 0x0010 /* physical walk */ +# define FTS_SEEDOT 0x0020 /* return dot and dot-dot */ +# define FTS_XDEV 0x0040 /* don't cross devices */ +# define FTS_WHITEOUT 0x0080 /* return whiteout information */ /* There are two ways to detect cycles. The lazy way (which works only with FTS_PHYSICAL), @@ -111,7 +111,7 @@ typedef struct { slink -> dir So, when FTS_LOGICAL is selected, we have to use a different mode of cycle detection: FTS_TIGHT_CYCLE_CHECK. */ -# define FTS_TIGHT_CYCLE_CHECK 0x0100 +# define FTS_TIGHT_CYCLE_CHECK 0x0100 /* Use this flag to enable semantics with which the parent application may be made both more efficient and more robust. @@ -120,7 +120,7 @@ typedef struct { working directory is never changed. Instead, these functions perform the traversal via a virtual working directory, maintained through the file descriptor member, fts_cwd_fd. */ -# define FTS_CWDFD 0x0200 +# define FTS_CWDFD 0x0200 /* Historically, for each directory that fts initially encounters, it would open it, read all entries, and stat each entry, storing the results, and @@ -135,102 +135,102 @@ typedef struct { nonzero, the S_IFMT type bits are valid, with mapped dirent.d_type data. Of course, that happens only on file systems that provide useful dirent.d_type data. */ -# define FTS_DEFER_STAT 0x0400 +# define FTS_DEFER_STAT 0x0400 -# define FTS_OPTIONMASK 0x07ff /* valid user option mask */ +# define FTS_OPTIONMASK 0x07ff /* valid user option mask */ -# define FTS_NAMEONLY 0x1000 /* (private) child names only */ -# define FTS_STOP 0x2000 /* (private) unrecoverable error */ - int fts_options; /* fts_open options, global flags */ +# define FTS_NAMEONLY 0x1000 /* (private) child names only */ +# define FTS_STOP 0x2000 /* (private) unrecoverable error */ + int fts_options; /* fts_open options, global flags */ # if GNULIB_FTS - /* Map a directory's device number to a boolean. The boolean is - true if for that file system (type determined by a single fstatfs - call per FS) st_nlink can be used to calculate the number of - sub-directory entries in a directory. - Using this table is an optimization that permits us to look up - file system type on a per-inode basis at the minimal cost of - calling fstatfs only once per traversed device. */ - struct hash_table *fts_leaf_optimization_works_ht; + /* Map a directory's device number to a boolean. The boolean is + true if for that file system (type determined by a single fstatfs + call per FS) st_nlink can be used to calculate the number of + sub-directory entries in a directory. + Using this table is an optimization that permits us to look up + file system type on a per-inode basis at the minimal cost of + calling fstatfs only once per traversed device. */ + struct hash_table *fts_leaf_optimization_works_ht; - union { - /* This data structure is used if FTS_TIGHT_CYCLE_CHECK is - specified. It records the directories between a starting - point and the current directory. I.e., a directory is - recorded here IFF we have visited it once, but we have not - yet completed processing of all its entries. Every time we - visit a new directory, we add that directory to this set. - When we finish with a directory (usually by visiting it a - second time), we remove it from this set. Each entry in - this data structure is a device/inode pair. This data - structure is used to detect directory cycles efficiently and - promptly even when the depth of a hierarchy is in the tens - of thousands. */ - struct hash_table *ht; + union { + /* This data structure is used if FTS_TIGHT_CYCLE_CHECK is + specified. It records the directories between a starting + point and the current directory. I.e., a directory is + recorded here IFF we have visited it once, but we have not + yet completed processing of all its entries. Every time we + visit a new directory, we add that directory to this set. + When we finish with a directory (usually by visiting it a + second time), we remove it from this set. Each entry in + this data structure is a device/inode pair. This data + structure is used to detect directory cycles efficiently and + promptly even when the depth of a hierarchy is in the tens + of thousands. */ + struct hash_table *ht; - /* FIXME: rename these two members to have the fts_ prefix */ - /* This data structure uses a lazy cycle-detection algorithm, - as done by rm via cycle-check.c. It's the default, - but it's not appropriate for programs like du. */ - struct cycle_check_state *state; - } fts_cycle; + /* FIXME: rename these two members to have the fts_ prefix */ + /* This data structure uses a lazy cycle-detection algorithm, + as done by rm via cycle-check.c. It's the default, + but it's not appropriate for programs like du. */ + struct cycle_check_state *state; + } fts_cycle; # endif - /* A stack of the file descriptors corresponding to the - most-recently traversed parent directories. - Currently used only in FTS_CWDFD mode. */ - I_ring fts_fd_ring; + /* A stack of the file descriptors corresponding to the + most-recently traversed parent directories. + Currently used only in FTS_CWDFD mode. */ + I_ring fts_fd_ring; } FTS; typedef struct _ftsent { - struct _ftsent *fts_cycle; /* cycle node */ - struct _ftsent *fts_parent; /* parent directory */ - struct _ftsent *fts_link; /* next file in directory */ - long fts_number; /* local numeric value */ - void *fts_pointer; /* local address value */ - char *fts_accpath; /* access file name */ - char *fts_path; /* root name; == fts_fts->fts_path */ - int fts_errno; /* errno for this node */ - int fts_symfd; /* fd for symlink */ - size_t fts_pathlen; /* strlen(fts_path) */ + struct _ftsent *fts_cycle; /* cycle node */ + struct _ftsent *fts_parent; /* parent directory */ + struct _ftsent *fts_link; /* next file in directory */ + long fts_number; /* local numeric value */ + void *fts_pointer; /* local address value */ + char *fts_accpath; /* access file name */ + char *fts_path; /* root name; == fts_fts->fts_path */ + int fts_errno; /* errno for this node */ + int fts_symfd; /* fd for symlink */ + size_t fts_pathlen; /* strlen(fts_path) */ - FTS *fts_fts; /* the file hierarchy itself */ + FTS *fts_fts; /* the file hierarchy itself */ -# define FTS_ROOTPARENTLEVEL (-1) -# define FTS_ROOTLEVEL 0 - ptrdiff_t fts_level; /* depth (-1 to N) */ +# define FTS_ROOTPARENTLEVEL (-1) +# define FTS_ROOTLEVEL 0 + ptrdiff_t fts_level; /* depth (-1 to N) */ - size_t fts_namelen; /* strlen(fts_name) */ - nlink_t fts_n_dirs_remaining; /* count down from st_nlink */ + size_t fts_namelen; /* strlen(fts_name) */ + nlink_t fts_n_dirs_remaining; /* count down from st_nlink */ -# define FTS_D 1 /* preorder directory */ -# define FTS_DC 2 /* directory that causes cycles */ -# define FTS_DEFAULT 3 /* none of the above */ -# define FTS_DNR 4 /* unreadable directory */ -# define FTS_DOT 5 /* dot or dot-dot */ -# define FTS_DP 6 /* postorder directory */ -# define FTS_ERR 7 /* error; errno is set */ -# define FTS_F 8 /* regular file */ -# define FTS_INIT 9 /* initialized only */ -# define FTS_NS 10 /* stat(2) failed */ -# define FTS_NSOK 11 /* no stat(2) requested */ -# define FTS_SL 12 /* symbolic link */ -# define FTS_SLNONE 13 /* symbolic link without target */ -# define FTS_W 14 /* whiteout object */ - unsigned short int fts_info; /* user flags for FTSENT structure */ +# define FTS_D 1 /* preorder directory */ +# define FTS_DC 2 /* directory that causes cycles */ +# define FTS_DEFAULT 3 /* none of the above */ +# define FTS_DNR 4 /* unreadable directory */ +# define FTS_DOT 5 /* dot or dot-dot */ +# define FTS_DP 6 /* postorder directory */ +# define FTS_ERR 7 /* error; errno is set */ +# define FTS_F 8 /* regular file */ +# define FTS_INIT 9 /* initialized only */ +# define FTS_NS 10 /* stat(2) failed */ +# define FTS_NSOK 11 /* no stat(2) requested */ +# define FTS_SL 12 /* symbolic link */ +# define FTS_SLNONE 13 /* symbolic link without target */ +# define FTS_W 14 /* whiteout object */ + unsigned short int fts_info; /* user flags for FTSENT structure */ -# define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ -# define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ - unsigned short int fts_flags; /* private flags for FTSENT structure */ +# define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ +# define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ + unsigned short int fts_flags; /* private flags for FTSENT structure */ -# define FTS_AGAIN 1 /* read node again */ -# define FTS_FOLLOW 2 /* follow symbolic link */ -# define FTS_NOINSTR 3 /* no instructions */ -# define FTS_SKIP 4 /* discard node */ - unsigned short int fts_instr; /* fts_set() instructions */ +# define FTS_AGAIN 1 /* read node again */ +# define FTS_FOLLOW 2 /* follow symbolic link */ +# define FTS_NOINSTR 3 /* no instructions */ +# define FTS_SKIP 4 /* discard node */ + unsigned short int fts_instr; /* fts_set() instructions */ - struct stat fts_statp[1]; /* stat(2) information */ - char fts_name[1]; /* file name */ + struct stat fts_statp[1]; /* stat(2) information */ + char fts_name[1]; /* file name */ } FTSENT; #ifndef __GNUC_PREREQ @@ -251,13 +251,13 @@ typedef struct _ftsent { #endif __BEGIN_DECLS -FTSENT *fts_children (FTS *, int) __THROW __attribute_warn_unused_result__; -int fts_close (FTS *) __THROW __attribute_warn_unused_result__; -FTS *fts_open (char * const *, int, - int (*)(const FTSENT **, const FTSENT **)) +FTSENT *fts_children (FTS *, int) __THROW __attribute_warn_unused_result__; +int fts_close (FTS *) __THROW __attribute_warn_unused_result__; +FTS *fts_open (char * const *, int, + int (*)(const FTSENT **, const FTSENT **)) __THROW __attribute_warn_unused_result__; -FTSENT *fts_read (FTS *) __THROW __attribute_warn_unused_result__; -int fts_set (FTS *, FTSENT *, int) __THROW; +FTSENT *fts_read (FTS *) __THROW __attribute_warn_unused_result__; +int fts_set (FTS *, FTSENT *, int) __THROW; __END_DECLS #endif /* fts.h */ diff --git a/src/bin/coreutils/lib/full-read.c b/src/bin/coreutils/lib/full-read.c index fb7212bbec..e5de376017 100644 --- a/src/bin/coreutils/lib/full-read.c +++ b/src/bin/coreutils/lib/full-read.c @@ -1,5 +1,5 @@ /* An interface to read that retries after partial reads and interrupts. - Copyright (C) 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 2002-2003, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/full-read.h b/src/bin/coreutils/lib/full-read.h index a341ee0060..a41f617c11 100644 --- a/src/bin/coreutils/lib/full-read.h +++ b/src/bin/coreutils/lib/full-read.h @@ -1,6 +1,6 @@ /* An interface to read() that reads all it is asked to read. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/full-write.c b/src/bin/coreutils/lib/full-write.c index 51f2d3819b..5d9b7c33ce 100644 --- a/src/bin/coreutils/lib/full-write.c +++ b/src/bin/coreutils/lib/full-write.c @@ -1,7 +1,6 @@ /* An interface to read and write that retries (if necessary) until complete. - Copyright (C) 1993, 1994, 1997, 1998, 1999, 2000, 2001, 2002, 2003, - 2004, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 1993-1994, 1997-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -65,12 +64,12 @@ full_rw (int fd, const void *buf, size_t count) { size_t n_rw = safe_rw (fd, ptr, count); if (n_rw == (size_t) -1) - break; + break; if (n_rw == 0) - { - errno = ZERO_BYTE_TRANSFER_ERRNO; - break; - } + { + errno = ZERO_BYTE_TRANSFER_ERRNO; + break; + } total += n_rw; ptr += n_rw; count -= n_rw; diff --git a/src/bin/coreutils/lib/full-write.h b/src/bin/coreutils/lib/full-write.h index 9a80146445..15d61808ff 100644 --- a/src/bin/coreutils/lib/full-write.h +++ b/src/bin/coreutils/lib/full-write.h @@ -1,6 +1,6 @@ /* An interface to write() that writes all it is asked to write. - Copyright (C) 2002-2003 Free Software Foundation, Inc. + Copyright (C) 2002-2003, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/gai_strerror.c b/src/bin/coreutils/lib/gai_strerror.c index 86dfdfab5a..323517b77c 100644 --- a/src/bin/coreutils/lib/gai_strerror.c +++ b/src/bin/coreutils/lib/gai_strerror.c @@ -1,7 +1,8 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 -/* Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2008, 2009 Free Software Foundation, Inc. +/* Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2008, 2009, 2010 Free + Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Philip Blundell , 1997. diff --git a/src/bin/coreutils/lib/getaddrinfo.c b/src/bin/coreutils/lib/getaddrinfo.c index bd8d02388f..5d7bafc1bd 100644 --- a/src/bin/coreutils/lib/getaddrinfo.c +++ b/src/bin/coreutils/lib/getaddrinfo.c @@ -2,8 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Get address information (partial implementation). - Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2007, 2008 Free Software - Foundation, Inc. + Copyright (C) 1997, 2001-2002, 2004-2010 Free Software Foundation, Inc. Contributed by Simon Josefsson . This program is free software; you can redistribute it and/or modify @@ -22,6 +21,10 @@ #include +/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc + optimizes away the sa == NULL test below. */ +#define _GL_ARG_NONNULL(params) + #include #if HAVE_NETINET_IN_H @@ -61,12 +64,12 @@ #ifdef WIN32_NATIVE typedef int (WSAAPI *getaddrinfo_func) (const char*, const char*, - const struct addrinfo*, - struct addrinfo**); + const struct addrinfo*, + struct addrinfo**); typedef void (WSAAPI *freeaddrinfo_func) (struct addrinfo*); typedef int (WSAAPI *getnameinfo_func) (const struct sockaddr*, - socklen_t, char*, DWORD, - char*, DWORD, int); + socklen_t, char*, DWORD, + char*, DWORD, int); static getaddrinfo_func getaddrinfo_ptr = NULL; static freeaddrinfo_func freeaddrinfo_ptr = NULL; @@ -126,9 +129,9 @@ validate_family (int family) socket addresses. */ int getaddrinfo (const char *restrict nodename, - const char *restrict servname, - const struct addrinfo *restrict hints, - struct addrinfo **restrict res) + const char *restrict servname, + const struct addrinfo *restrict hints, + struct addrinfo **restrict res) { struct addrinfo *tmp; int port = 0; @@ -168,7 +171,7 @@ getaddrinfo (const char *restrict nodename, if (!nodename) { if (!(hints->ai_flags & AI_PASSIVE)) - return EAI_NONAME; + return EAI_NONAME; #ifdef HAVE_IPV6 nodename = (hints->ai_family == AF_INET6) ? "::" : "0.0.0.0"; @@ -181,24 +184,24 @@ getaddrinfo (const char *restrict nodename, { struct servent *se = NULL; const char *proto = - (hints && hints->ai_socktype == SOCK_DGRAM) ? "udp" : "tcp"; + (hints && hints->ai_socktype == SOCK_DGRAM) ? "udp" : "tcp"; if (hints == NULL || !(hints->ai_flags & AI_NUMERICSERV)) - /* FIXME: Use getservbyname_r if available. */ - se = getservbyname (servname, proto); + /* FIXME: Use getservbyname_r if available. */ + se = getservbyname (servname, proto); if (!se) - { - char *c; - if (!(*servname >= '0' && *servname <= '9')) - return EAI_NONAME; - port = strtoul (servname, &c, 10); - if (*c || port > 0xffff) - return EAI_NONAME; - port = htons (port); - } + { + char *c; + if (!(*servname >= '0' && *servname <= '9')) + return EAI_NONAME; + port = strtoul (servname, &c, 10); + if (*c || port > 0xffff) + return EAI_NONAME; + port = htons (port); + } else - port = se->s_port; + port = se->s_port; } /* FIXME: Use gethostbyname_r if available. */ @@ -233,23 +236,23 @@ getaddrinfo (const char *restrict nodename, #if HAVE_IPV6 case PF_INET6: { - struct v6_pair *p = storage; - struct sockaddr_in6 *sinp = &p->sockaddr_in6; - tmp = &p->addrinfo; + struct v6_pair *p = storage; + struct sockaddr_in6 *sinp = &p->sockaddr_in6; + tmp = &p->addrinfo; - if (port) - sinp->sin6_port = port; + if (port) + sinp->sin6_port = port; - if (he->h_length != sizeof (sinp->sin6_addr)) - { - free (storage); - return EAI_SYSTEM; /* FIXME: Better return code? Set errno? */ - } + if (he->h_length != sizeof (sinp->sin6_addr)) + { + free (storage); + return EAI_SYSTEM; /* FIXME: Better return code? Set errno? */ + } - memcpy (&sinp->sin6_addr, he->h_addr_list[0], sizeof sinp->sin6_addr); + memcpy (&sinp->sin6_addr, he->h_addr_list[0], sizeof sinp->sin6_addr); - tmp->ai_addr = (struct sockaddr *) sinp; - tmp->ai_addrlen = sizeof *sinp; + tmp->ai_addr = (struct sockaddr *) sinp; + tmp->ai_addrlen = sizeof *sinp; } break; #endif @@ -257,23 +260,23 @@ getaddrinfo (const char *restrict nodename, #if HAVE_IPV4 case PF_INET: { - struct v4_pair *p = storage; - struct sockaddr_in *sinp = &p->sockaddr_in; - tmp = &p->addrinfo; + struct v4_pair *p = storage; + struct sockaddr_in *sinp = &p->sockaddr_in; + tmp = &p->addrinfo; - if (port) - sinp->sin_port = port; + if (port) + sinp->sin_port = port; - if (he->h_length != sizeof (sinp->sin_addr)) - { - free (storage); - return EAI_SYSTEM; /* FIXME: Better return code? Set errno? */ - } + if (he->h_length != sizeof (sinp->sin_addr)) + { + free (storage); + return EAI_SYSTEM; /* FIXME: Better return code? Set errno? */ + } - memcpy (&sinp->sin_addr, he->h_addr_list[0], sizeof sinp->sin_addr); + memcpy (&sinp->sin_addr, he->h_addr_list[0], sizeof sinp->sin_addr); - tmp->ai_addr = (struct sockaddr *) sinp; - tmp->ai_addrlen = sizeof *sinp; + tmp->ai_addr = (struct sockaddr *) sinp; + tmp->ai_addrlen = sizeof *sinp; } break; #endif @@ -287,16 +290,16 @@ getaddrinfo (const char *restrict nodename, { const char *cn; if (he->h_name) - cn = he->h_name; + cn = he->h_name; else - cn = nodename; + cn = nodename; tmp->ai_canonname = strdup (cn); if (!tmp->ai_canonname) - { - free (storage); - return EAI_MEMORY; - } + { + free (storage); + return EAI_MEMORY; + } } tmp->ai_protocol = (hints) ? hints->ai_protocol : 0; @@ -352,14 +355,14 @@ freeaddrinfo (struct addrinfo *ai) } int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen, - char *restrict node, socklen_t nodelen, - char *restrict service, socklen_t servicelen, - int flags) + char *restrict node, socklen_t nodelen, + char *restrict service, socklen_t servicelen, + int flags) { #ifdef WIN32_NATIVE if (use_win32_p ()) return getnameinfo_ptr (sa, salen, node, nodelen, - service, servicelen, flags); + service, servicelen, flags); #endif /* FIXME: Support other flags. */ @@ -376,13 +379,13 @@ int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen, #if HAVE_IPV4 case AF_INET: if (salen < sizeof (struct sockaddr_in)) - return EAI_FAMILY; + return EAI_FAMILY; break; #endif #if HAVE_IPV6 case AF_INET6: if (salen < sizeof (struct sockaddr_in6)) - return EAI_FAMILY; + return EAI_FAMILY; break; #endif default: @@ -392,28 +395,28 @@ int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen, if (node && nodelen > 0 && flags & NI_NUMERICHOST) { switch (sa->sa_family) - { + { #if HAVE_IPV4 - case AF_INET: - if (!inet_ntop (AF_INET, - &(((const struct sockaddr_in *) sa)->sin_addr), - node, nodelen)) - return EAI_SYSTEM; - break; + case AF_INET: + if (!inet_ntop (AF_INET, + &(((const struct sockaddr_in *) sa)->sin_addr), + node, nodelen)) + return EAI_SYSTEM; + break; #endif #if HAVE_IPV6 - case AF_INET6: - if (!inet_ntop (AF_INET6, - &(((const struct sockaddr_in6 *) sa)->sin6_addr), - node, nodelen)) - return EAI_SYSTEM; - break; + case AF_INET6: + if (!inet_ntop (AF_INET6, + &(((const struct sockaddr_in6 *) sa)->sin6_addr), + node, nodelen)) + return EAI_SYSTEM; + break; #endif - default: - return EAI_FAMILY; - } + default: + return EAI_FAMILY; + } } if (service && servicelen > 0 && flags & NI_NUMERICSERV) @@ -425,13 +428,13 @@ int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen, #if HAVE_IPV6 case AF_INET6: #endif - { - unsigned short int port - = ntohs (((const struct sockaddr_in *) sa)->sin_port); - if (servicelen <= snprintf (service, servicelen, "%u", port)) - return EAI_OVERFLOW; - } - break; + { + unsigned short int port + = ntohs (((const struct sockaddr_in *) sa)->sin_port); + if (servicelen <= snprintf (service, servicelen, "%u", port)) + return EAI_OVERFLOW; + } + break; } return 0; diff --git a/src/bin/coreutils/lib/getcwd.c b/src/bin/coreutils/lib/getcwd.c index 6658ed58c0..1ba705c38c 100644 --- a/src/bin/coreutils/lib/getcwd.c +++ b/src/bin/coreutils/lib/getcwd.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-1999, 2004-2009 Free Software Foundation, Inc. +/* Copyright (C) 1991-1999, 2004-2010 Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software: you can redistribute it and/or modify @@ -67,7 +67,7 @@ #endif #ifndef PATH_MAX -# ifdef MAXPATHLEN +# ifdef MAXPATHLEN # define PATH_MAX MAXPATHLEN # else # define PATH_MAX 1024 @@ -157,10 +157,10 @@ __getcwd (char *buf, size_t size) if (size == 0) { if (buf != NULL) - { - __set_errno (EINVAL); - return NULL; - } + { + __set_errno (EINVAL); + return NULL; + } allocated = BIG_FILE_NAME_LENGTH + 1; } @@ -169,7 +169,7 @@ __getcwd (char *buf, size_t size) { dir = malloc (allocated); if (dir == NULL) - return NULL; + return NULL; } else dir = buf; @@ -202,7 +202,7 @@ __getcwd (char *buf, size_t size) #if HAVE_OPENAT_SUPPORT fd = openat (fd, "..", O_RDONLY); if (fd < 0) - goto lose; + goto lose; fd_needs_closing = true; parent_status = fstat (fd, &st); #else @@ -212,13 +212,13 @@ __getcwd (char *buf, size_t size) parent_status = __lstat (dotlist, &st); #endif if (parent_status != 0) - goto lose; + goto lose; if (dirstream && __closedir (dirstream) != 0) - { - dirstream = NULL; - goto lose; - } + { + dirstream = NULL; + goto lose; + } /* Figure out if this directory is a mount point. */ dotdev = st.st_dev; @@ -229,138 +229,138 @@ __getcwd (char *buf, size_t size) #if HAVE_OPENAT_SUPPORT dirstream = fdopendir (fd); if (dirstream == NULL) - goto lose; + goto lose; /* Reset fd. It may have been closed by fdopendir. */ fd = dirfd (dirstream); fd_needs_closing = false; #else dirstream = __opendir (dotlist); if (dirstream == NULL) - goto lose; + goto lose; dotlist[dotlen++] = '/'; #endif for (;;) - { - /* Clear errno to distinguish EOF from error if readdir returns - NULL. */ - __set_errno (0); - d = __readdir (dirstream); + { + /* Clear errno to distinguish EOF from error if readdir returns + NULL. */ + __set_errno (0); + d = __readdir (dirstream); - /* When we've iterated through all directory entries without finding - one with a matching d_ino, rewind the stream and consider each - name again, but this time, using lstat. This is necessary in a - chroot on at least one system (glibc-2.3.6 + linux 2.6.12), where - .., ../.., ../../.., etc. all had the same device number, yet the - d_ino values for entries in / did not match those obtained - via lstat. */ - if (d == NULL && errno == 0 && use_d_ino) - { - use_d_ino = false; - rewinddir (dirstream); - d = __readdir (dirstream); - } + /* When we've iterated through all directory entries without finding + one with a matching d_ino, rewind the stream and consider each + name again, but this time, using lstat. This is necessary in a + chroot on at least one system (glibc-2.3.6 + linux 2.6.12), where + .., ../.., ../../.., etc. all had the same device number, yet the + d_ino values for entries in / did not match those obtained + via lstat. */ + if (d == NULL && errno == 0 && use_d_ino) + { + use_d_ino = false; + rewinddir (dirstream); + d = __readdir (dirstream); + } - if (d == NULL) - { - if (errno == 0) - /* EOF on dirstream, which can mean e.g., that the current - directory has been removed. */ - __set_errno (ENOENT); - goto lose; - } - if (d->d_name[0] == '.' && - (d->d_name[1] == '\0' || - (d->d_name[1] == '.' && d->d_name[2] == '\0'))) - continue; + if (d == NULL) + { + if (errno == 0) + /* EOF on dirstream, which can mean e.g., that the current + directory has been removed. */ + __set_errno (ENOENT); + goto lose; + } + if (d->d_name[0] == '.' && + (d->d_name[1] == '\0' || + (d->d_name[1] == '.' && d->d_name[2] == '\0'))) + continue; - if (use_d_ino) - { - bool match = (MATCHING_INO (d, thisino) || mount_point); - if (! match) - continue; - } + if (use_d_ino) + { + bool match = (MATCHING_INO (d, thisino) || mount_point); + if (! match) + continue; + } - { - int entry_status; + { + int entry_status; #if HAVE_OPENAT_SUPPORT - entry_status = fstatat (fd, d->d_name, &st, AT_SYMLINK_NOFOLLOW); + entry_status = fstatat (fd, d->d_name, &st, AT_SYMLINK_NOFOLLOW); #else - /* Compute size needed for this file name, or for the file - name ".." in the same directory, whichever is larger. - Room for ".." might be needed the next time through - the outer loop. */ - size_t name_alloc = _D_ALLOC_NAMLEN (d); - size_t filesize = dotlen + MAX (sizeof "..", name_alloc); + /* Compute size needed for this file name, or for the file + name ".." in the same directory, whichever is larger. + Room for ".." might be needed the next time through + the outer loop. */ + size_t name_alloc = _D_ALLOC_NAMLEN (d); + size_t filesize = dotlen + MAX (sizeof "..", name_alloc); - if (filesize < dotlen) - goto memory_exhausted; + if (filesize < dotlen) + goto memory_exhausted; - if (dotsize < filesize) - { - /* My, what a deep directory tree you have, Grandma. */ - size_t newsize = MAX (filesize, dotsize * 2); - size_t i; - if (newsize < dotsize) - goto memory_exhausted; - if (dotlist != dots) - free (dotlist); - dotlist = malloc (newsize); - if (dotlist == NULL) - goto lose; - dotsize = newsize; + if (dotsize < filesize) + { + /* My, what a deep directory tree you have, Grandma. */ + size_t newsize = MAX (filesize, dotsize * 2); + size_t i; + if (newsize < dotsize) + goto memory_exhausted; + if (dotlist != dots) + free (dotlist); + dotlist = malloc (newsize); + if (dotlist == NULL) + goto lose; + dotsize = newsize; - i = 0; - do - { - dotlist[i++] = '.'; - dotlist[i++] = '.'; - dotlist[i++] = '/'; - } - while (i < dotlen); - } + i = 0; + do + { + dotlist[i++] = '.'; + dotlist[i++] = '.'; + dotlist[i++] = '/'; + } + while (i < dotlen); + } - memcpy (dotlist + dotlen, d->d_name, _D_ALLOC_NAMLEN (d)); - entry_status = __lstat (dotlist, &st); + memcpy (dotlist + dotlen, d->d_name, _D_ALLOC_NAMLEN (d)); + entry_status = __lstat (dotlist, &st); #endif - /* We don't fail here if we cannot stat() a directory entry. - This can happen when (network) file systems fail. If this - entry is in fact the one we are looking for we will find - out soon as we reach the end of the directory without - having found anything. */ - if (entry_status == 0 && S_ISDIR (st.st_mode) - && st.st_dev == thisdev && st.st_ino == thisino) - break; - } - } + /* We don't fail here if we cannot stat() a directory entry. + This can happen when (network) file systems fail. If this + entry is in fact the one we are looking for we will find + out soon as we reach the end of the directory without + having found anything. */ + if (entry_status == 0 && S_ISDIR (st.st_mode) + && st.st_dev == thisdev && st.st_ino == thisino) + break; + } + } dirroom = dirp - dir; namlen = _D_EXACT_NAMLEN (d); if (dirroom <= namlen) - { - if (size != 0) - { - __set_errno (ERANGE); - goto lose; - } - else - { - char *tmp; - size_t oldsize = allocated; + { + if (size != 0) + { + __set_errno (ERANGE); + goto lose; + } + else + { + char *tmp; + size_t oldsize = allocated; - allocated += MAX (allocated, namlen); - if (allocated < oldsize - || ! (tmp = realloc (dir, allocated))) - goto memory_exhausted; + allocated += MAX (allocated, namlen); + if (allocated < oldsize + || ! (tmp = realloc (dir, allocated))) + goto memory_exhausted; - /* Move current contents up to the end of the buffer. - This is guaranteed to be non-overlapping. */ - dirp = memcpy (tmp + allocated - (oldsize - dirroom), - tmp + dirroom, - oldsize - dirroom); - dir = tmp; - } - } + /* Move current contents up to the end of the buffer. + This is guaranteed to be non-overlapping. */ + dirp = memcpy (tmp + allocated - (oldsize - dirroom), + tmp + dirroom, + oldsize - dirroom); + dir = tmp; + } + } dirp -= namlen; memcpy (dirp, d->d_name, namlen); *--dirp = '/'; diff --git a/src/bin/coreutils/lib/getdate.c b/src/bin/coreutils/lib/getdate.c index 8c32594aae..e201024373 100644 --- a/src/bin/coreutils/lib/getdate.c +++ b/src/bin/coreutils/lib/getdate.c @@ -1,21 +1,20 @@ +/* A Bison parser, made by GNU Bison 2.4.460-505e. */ -/* A Bison parser, made by GNU Bison 2.4.1. */ +/* Implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009 Free Software Foundation, Inc. -/* Skeleton implementation for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. - This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -28,7 +27,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -46,7 +45,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.4.1" +#define YYBISON_VERSION "2.4.460-505e" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -66,14 +65,13 @@ /* Copy the first part of user declarations. */ - -/* Line 189 of yacc.c */ +/* Line 253 of yacc.c */ #line 1 "getdate.y" /* Parse a string into an internal time stamp. - Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 - Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, + 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -149,16 +147,6 @@ of `digit' even when the host does not conform to POSIX. */ #define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9) -#ifndef __attribute__ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__ -# define __attribute__(x) -# endif -#endif - -#ifndef ATTRIBUTE_UNUSED -# define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) -#endif - /* Shift A right by B bits portably, by dividing A by 2**B and truncating towards minus infinity. A and B should be free of side effects, and B should be in the range 0 <= B <= INT_BITS - 2, where @@ -169,9 +157,9 @@ implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift right in the usual way when A < 0, so SHR falls back on division if ordinary A >> B doesn't seem to be the usual signed shift. */ -#define SHR(a, b) \ - (-1 >> 1 == -1 \ - ? (a) >> (b) \ +#define SHR(a, b) \ + (-1 >> 1 == -1 \ + ? (a) >> (b) \ : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0)) #define EPOCH_YEAR 1970 @@ -179,12 +167,21 @@ #define HOUR(x) ((x) * 60) -/* Lots of this code assumes time_t and time_t-like values fit into - long int. It also assumes that signed integer overflow silently - wraps around, but there's no portable way to check for that at - compile-time. */ +/* long_time_t is a signed integer type that contains all time_t values. */ verify (TYPE_IS_INTEGER (time_t)); -verify (LONG_MIN <= TYPE_MINIMUM (time_t) && TYPE_MAXIMUM (time_t) <= LONG_MAX); +#if TIME_T_FITS_IN_LONG_INT +typedef long int long_time_t; +#else +typedef time_t long_time_t; +#endif + +/* Lots of this code assumes time_t and time_t-like values fit into + long_time_t. */ +verify (TYPE_MINIMUM (long_time_t) <= TYPE_MINIMUM (time_t) + && TYPE_MAXIMUM (time_t) <= TYPE_MAXIMUM (long_time_t)); + +/* FIXME: It also assumes that signed integer overflow silently wraps around, + but this is not true any more with recent versions of GCC 4. */ /* An integer value, and the number of digits in its textual representation. */ @@ -217,7 +214,7 @@ typedef struct long int day; long int hour; long int minutes; - long int seconds; + long_time_t seconds; long int ns; } relative_time; @@ -290,30 +287,30 @@ digits_to_date_time (parser_control *pc, textint text_int) else { if (4 < text_int.digits) - { - pc->dates_seen++; - pc->day = text_int.value % 100; - pc->month = (text_int.value / 100) % 100; - pc->year.value = text_int.value / 10000; - pc->year.digits = text_int.digits - 4; - } + { + pc->dates_seen++; + pc->day = text_int.value % 100; + pc->month = (text_int.value / 100) % 100; + pc->year.value = text_int.value / 10000; + pc->year.digits = text_int.digits - 4; + } else - { - pc->times_seen++; - if (text_int.digits <= 2) - { - pc->hour = text_int.value; - pc->minutes = 0; - } - else - { - pc->hour = text_int.value / 100; - pc->minutes = text_int.value % 100; - } - pc->seconds.tv_sec = 0; - pc->seconds.tv_nsec = 0; - pc->meridian = MER24; - } + { + pc->times_seen++; + if (text_int.digits <= 2) + { + pc->hour = text_int.value; + pc->minutes = 0; + } + else + { + pc->hour = text_int.value / 100; + pc->minutes = text_int.value % 100; + } + pc->seconds.tv_sec = 0; + pc->seconds.tv_nsec = 0; + pc->meridian = MER24; + } } } @@ -334,7 +331,7 @@ apply_relative_time (parser_control *pc, relative_time rel, int factor) /* Set PC-> hour, minutes, seconds and nanoseconds members from arguments. */ static void set_hhmmss (parser_control *pc, long int hour, long int minutes, - time_t sec, long int nsec) + time_t sec, long int nsec) { pc->hour = hour; pc->minutes = minutes; @@ -343,9 +340,8 @@ set_hhmmss (parser_control *pc, long int hour, long int minutes, } - -/* Line 189 of yacc.c */ -#line 349 "getdate.c" +/* Line 253 of yacc.c */ +#line 345 "getdate.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -422,9 +418,8 @@ set_hhmmss (parser_control *pc, long int hour, long int minutes, #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE { - -/* Line 214 of yacc.c */ -#line 286 "getdate.y" +/* Line 278 of yacc.c */ +#line 285 "getdate.y" long int intval; textint textintval; @@ -432,9 +427,8 @@ typedef union YYSTYPE relative_time rel; - -/* Line 214 of yacc.c */ -#line 438 "getdate.c" +/* Line 278 of yacc.c */ +#line 432 "getdate.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -444,9 +438,8 @@ typedef union YYSTYPE /* Copy the second part of user declarations. */ - -/* Line 264 of yacc.c */ -#line 450 "getdate.c" +/* Line 328 of yacc.c */ +#line 443 "getdate.c" #ifdef short # undef short @@ -496,7 +489,7 @@ typedef short int yytype_int16; #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if YYENABLE_NLS +# if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -669,17 +662,19 @@ union yyalloc #define YYNNTS 21 /* YYNRULES -- Number of rules. */ #define YYNRULES 82 -/* YYNRULES -- Number of states. */ +/* YYNSTATES -- Number of states. */ #define YYNSTATES 100 -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned + by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 277 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, without out-of-bounds checking. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -713,62 +708,18 @@ static const yytype_uint8 yytranslate[] = }; #if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const yytype_uint8 yyprhs[] = -{ - 0, 0, 3, 5, 7, 10, 11, 14, 16, 18, - 20, 22, 24, 26, 28, 30, 33, 38, 44, 51, - 59, 61, 64, 66, 69, 73, 75, 78, 80, 83, - 86, 89, 93, 99, 103, 107, 111, 114, 119, 122, - 126, 129, 131, 133, 136, 139, 141, 144, 147, 149, - 152, 155, 157, 160, 163, 165, 168, 171, 173, 176, - 179, 182, 185, 187, 189, 192, 195, 198, 201, 204, - 207, 209, 211, 213, 215, 217, 219, 221, 223, 226, - 227, 230, 231 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yytype_int8 yyrhs[] = -{ - 28, 0, -1, 29, -1, 30, -1, 23, 41, -1, - -1, 30, 31, -1, 32, -1, 33, -1, 34, -1, - 36, -1, 35, -1, 37, -1, 44, -1, 45, -1, - 20, 15, -1, 20, 24, 20, 47, -1, 20, 24, - 20, 19, 46, -1, 20, 24, 20, 24, 43, 47, - -1, 20, 24, 20, 24, 43, 19, 46, -1, 14, - -1, 14, 4, -1, 18, -1, 18, 39, -1, 18, - 19, 46, -1, 13, -1, 18, 4, -1, 12, -1, - 12, 25, -1, 17, 12, -1, 20, 12, -1, 20, - 26, 20, -1, 20, 26, 20, 26, 20, -1, 20, - 19, 19, -1, 20, 16, 19, -1, 16, 19, 19, - -1, 16, 20, -1, 16, 20, 25, 20, -1, 20, - 16, -1, 20, 16, 20, -1, 38, 3, -1, 38, - -1, 40, -1, 17, 5, -1, 20, 5, -1, 5, - -1, 17, 6, -1, 20, 6, -1, 6, -1, 17, - 10, -1, 20, 10, -1, 10, -1, 17, 7, -1, - 20, 7, -1, 7, -1, 17, 8, -1, 20, 8, - -1, 8, -1, 17, 9, -1, 20, 9, -1, 21, - 9, -1, 22, 9, -1, 9, -1, 39, -1, 19, - 5, -1, 19, 6, -1, 19, 10, -1, 19, 7, - -1, 19, 8, -1, 19, 9, -1, 11, -1, 42, - -1, 43, -1, 21, -1, 19, -1, 22, -1, 20, - -1, 20, -1, 20, 39, -1, -1, 24, 20, -1, - -1, 15, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ + /* YYRLINEYYN -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 312, 312, 313, 317, 324, 326, 330, 332, 334, - 336, 338, 340, 341, 342, 346, 351, 356, 363, 368, - 378, 383, 391, 393, 396, 398, 400, 405, 410, 415, - 420, 428, 433, 453, 460, 468, 476, 481, 487, 492, - 501, 503, 505, 510, 512, 514, 516, 518, 520, 522, - 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, - 544, 546, 548, 550, 554, 556, 558, 560, 562, 564, - 569, 573, 573, 576, 577, 582, 583, 588, 593, 604, - 605, 611, 612 + 0, 311, 311, 312, 316, 323, 325, 329, 331, 333, + 335, 337, 339, 340, 341, 345, 350, 355, 362, 367, + 377, 382, 390, 392, 395, 397, 399, 404, 409, 414, + 419, 427, 432, 452, 459, 467, 475, 480, 486, 491, + 500, 502, 504, 509, 511, 513, 515, 517, 519, 521, + 523, 525, 527, 529, 531, 533, 535, 537, 539, 541, + 543, 545, 547, 549, 553, 555, 557, 559, 561, 563, + 568, 572, 572, 575, 576, 581, 582, 587, 592, 603, + 604, 610, 611 }; #endif @@ -790,8 +741,8 @@ static const char *const yytname[] = #endif # ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ +/* YYTOKNUM[NUM] -- (External) token number corresponding to the + (internal) symbol number NUM (which must be that of a token). */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, @@ -800,62 +751,18 @@ static const yytype_uint16 yytoknum[] = }; # endif -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = -{ - 0, 27, 28, 28, 29, 30, 30, 31, 31, 31, - 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, - 33, 33, 34, 34, 34, 34, 34, 35, 35, 35, - 35, 36, 36, 36, 36, 36, 36, 36, 36, 36, - 37, 37, 37, 38, 38, 38, 38, 38, 38, 38, - 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, - 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, - 40, 41, 41, 42, 42, 43, 43, 44, 45, 46, - 46, 47, 47 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = -{ - 0, 2, 1, 1, 2, 0, 2, 1, 1, 1, - 1, 1, 1, 1, 1, 2, 4, 5, 6, 7, - 1, 2, 1, 2, 3, 1, 2, 1, 2, 2, - 2, 3, 5, 3, 3, 3, 2, 4, 2, 3, - 2, 1, 1, 2, 2, 1, 2, 2, 1, 2, - 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, - 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, - 2, 0, 1 -}; - -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const yytype_uint8 yydefact[] = -{ - 5, 0, 0, 2, 3, 74, 76, 73, 75, 4, - 71, 72, 1, 45, 48, 54, 57, 62, 51, 70, - 27, 25, 20, 0, 0, 22, 0, 77, 0, 0, - 6, 7, 8, 9, 11, 10, 12, 41, 63, 42, - 13, 14, 28, 21, 0, 36, 43, 46, 52, 55, - 58, 49, 29, 26, 79, 23, 64, 65, 67, 68, - 69, 66, 44, 47, 53, 56, 59, 50, 30, 15, - 38, 0, 0, 0, 78, 60, 61, 40, 35, 0, - 0, 24, 34, 39, 33, 81, 31, 37, 80, 82, - 79, 0, 16, 0, 17, 81, 32, 79, 18, 19 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int8 yydefgoto[] = -{ - -1, 2, 3, 4, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 9, 10, 11, 40, 41, 81, - 92 -}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ #define YYPACT_NINF -82 + +#define yypact_value_is_default(yystate) \ + ((yystate) == (-82)) + +#define YYTABLE_NINF -1 + +#define yytable_value_is_error(yytable_value) \ + YYID (0) + + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ static const yytype_int8 yypact[] = { -17, 56, 15, -82, 26, -82, -82, -82, -82, -82, @@ -870,7 +777,24 @@ static const yytype_int8 yypact[] = 74, -2, -82, 75, -82, 55, -82, 74, -82, -82 }; -/* YYPGOTO[NTERM-NUM]. */ + /* YYDEFACT[S] -- default reduction number in state S. Performed when + YYTABLE does not specify something else to do. Zero means the default + is an error. */ +static const yytype_uint8 yydefact[] = +{ + 5, 0, 0, 2, 3, 74, 76, 73, 75, 4, + 71, 72, 1, 45, 48, 54, 57, 62, 51, 70, + 27, 25, 20, 0, 0, 22, 0, 77, 0, 0, + 6, 7, 8, 9, 11, 10, 12, 41, 63, 42, + 13, 14, 28, 21, 0, 36, 43, 46, 52, 55, + 58, 49, 29, 26, 79, 23, 64, 65, 67, 68, + 69, 66, 44, 47, 53, 56, 59, 50, 30, 15, + 38, 0, 0, 0, 78, 60, 61, 40, 35, 0, + 0, 24, 34, 39, 33, 81, 31, 37, 80, 82, + 79, 0, 16, 0, 17, 81, 32, 79, 18, 19 +}; + + /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { -82, -82, -82, -82, -82, -82, -82, -82, -82, -82, @@ -878,11 +802,17 @@ static const yytype_int8 yypgoto[] = -3 }; -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -1 + /* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 2, 3, 4, 30, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 9, 10, 11, 40, 41, 81, + 92 +}; + + /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_uint8 yytable[] = { 62, 63, 64, 65, 66, 67, 1, 68, 89, 94, @@ -911,8 +841,8 @@ static const yytype_int8 yycheck[] = 20, 20, 95, -1, -1, 20, -1, -1, 24 }; -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ + /* STOS_[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { 0, 23, 28, 29, 30, 19, 20, 21, 22, 41, @@ -927,6 +857,35 @@ static const yytype_uint8 yystos[] = 19, 24, 47, 26, 46, 43, 20, 19, 47, 46 }; + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 27, 28, 28, 29, 30, 30, 31, 31, 31, + 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, + 33, 33, 34, 34, 34, 34, 34, 35, 35, 35, + 35, 36, 36, 36, 36, 36, 36, 36, 36, 36, + 37, 37, 37, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, + 40, 41, 41, 42, 42, 43, 43, 44, 45, 46, + 46, 47, 47 +}; + + /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 1, 2, 0, 2, 1, 1, 1, + 1, 1, 1, 1, 1, 2, 4, 5, 6, 7, + 1, 2, 1, 2, 3, 1, 2, 1, 2, 2, + 2, 3, 5, 3, 3, 3, 2, 4, 2, 3, + 2, 1, 1, 2, 2, 1, 2, 2, 1, 2, + 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, + 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, + 2, 0, 1 +}; + + #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) @@ -939,9 +898,18 @@ static const yytype_uint8 yystos[] = /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ + Once GCC version 2 has supplanted version 1, this can go. However, + YYFAIL appears to be in use. Nevertheless, it is formally deprecated + in Bison 2.4.2's NEWS entry, where a plan to phase it out is + discussed. */ #define YYFAIL goto yyerrlab +#if defined YYFAIL + /* This is here to suppress warnings from the GCC cpp's + -Wunused-macros. Normally we don't worry about that warning, but + some users do, and we want to make it easy for users to remove + YYFAIL uses, which will produce warnings from Bison 2.5. */ +#endif #define YYRECOVERING() (!!yyerrstatus) @@ -951,7 +919,6 @@ do \ { \ yychar = (Token); \ yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK (1); \ goto yybackup; \ } \ @@ -993,19 +960,10 @@ while (YYID (0)) #endif -/* YY_LOCATION_PRINT -- Print the location on the stream. - This macro was not mandated originally: define only if we know - we won't break user code: when these are the locations we know. */ +/* This macro is provided for backward compatibility. */ #ifndef YY_LOCATION_PRINT -# if YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ - fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) -# else -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) #endif @@ -1143,27 +1101,29 @@ do { \ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_reduce_print (YYSTYPE *yyvsp, int yyrule, parser_control *pc) +yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, parser_control *pc) #else static void -yy_reduce_print (yyvsp, yyrule, pc) +yy_reduce_print (yyssp, yyvsp, yyrule, pc) + yytype_int16 *yyssp; YYSTYPE *yyvsp; int yyrule; parser_control *pc; #endif { + unsigned long int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; - unsigned long int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); + yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], - &(yyvsp[(yyi + 1) - (yynrhs)]) - , pc); + yy_symbol_print (stderr, + yystos[yyssp[yyi + 1 - yynrhs]], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , pc); YYFPRINTF (stderr, "\n"); } } @@ -1171,7 +1131,7 @@ yy_reduce_print (yyvsp, yyrule, pc) # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ - yy_reduce_print (yyvsp, Rule, pc); \ + yy_reduce_print (yyssp, yyvsp, Rule, pc); \ } while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that @@ -1304,111 +1264,121 @@ yytnamerr (char *yyres, const char *yystr) } # endif -/* Copy into YYRESULT an error message about the unexpected token - YYCHAR while in state YYSTATE. Return the number of bytes copied, - including the terminating null byte. If YYRESULT is null, do not - copy anything; just return the number of bytes that would be - copied. As a special case, return 0 if an ordinary "syntax error" - message will do. Return YYSIZE_MAXIMUM if overflow occurs during - size calculation. */ -static YYSIZE_T -yysyntax_error (char *yyresult, int yystate, int yychar) +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message + about the unexpected token YYTOKEN while in state YYSTATE. + + Return 0 if *YYMSG was successfully written. Return 1 if an ordinary + "syntax error" message will suffice instead. Return 2 if *YYMSG is + not large enough to hold the message. In the last case, also set + *YYMSG_ALLOC to either (a) the required number of bytes or (b) zero + if the required number of bytes is too large to store. */ +static int +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + int yystate, int yytoken) { int yyn = yypact[yystate]; if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) - return 0; + return 1; else { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); YYSIZE_T yysize = yysize0; YYSIZE_T yysize1; - int yysize_overflow = 0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = 0; + /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; - -# if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -# endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ + YYCHECK. In other words, skip the first -YYN actions for this + state because they are default actions. */ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ int yychecklim = YYLAST - yyn + 1; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ + int yycount = 0; + int yyx; - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); + yyarg[yycount++] = yytname[yytoken]; for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR + && !yytable_value_is_error (yytable[yyx + yyn])) { if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { yycount = 1; yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; break; } yyarg[yycount++] = yytname[yyx]; yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= (yysize1 < yysize); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + { + /* Overflow. */ + *yymsg_alloc = 0; + return 2; + } yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; } - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= (yysize1 < yysize); + switch (yycount) + { +#define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +#undef YYCASE_ + } + + yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + { + /* Overflow. */ + *yymsg_alloc = 0; + return 2; + } yysize = yysize1; - if (yysize_overflow) - return YYSIZE_MAXIMUM; + if (*yymsg_alloc < yysize) + { + *yymsg_alloc = 2 * yysize; + if (! (yysize <= *yymsg_alloc + && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) + *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; + return 2; + } - if (yyresult) - { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yyresult; - int yyi = 0; - while ((*yyp = *yyf) != '\0') - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } - } - } - return yysize; + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + { + char *yyp = *yymsg; + int yyi = 0; + while ((*yyp = *yyformat) != '\0') + if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyformat += 2; + } + else + { + yyp++; + yyformat++; + } + } + return 0; } } #endif /* YYERROR_VERBOSE */ @@ -1441,21 +1411,23 @@ yydestruct (yymsg, yytype, yyvaluep, pc) switch (yytype) { - default: break; } } + /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) int yyparse (void *YYPARSE_PARAM); #else int yyparse (); #endif #else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) int yyparse (parser_control *pc); #else int yyparse (); @@ -1463,12 +1435,9 @@ int yyparse (); #endif /* ! YYPARSE_PARAM */ - - - -/*-------------------------. -| yyparse or yypush_parse. | -`-------------------------*/ +/*----------. +| yyparse. | +`----------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ @@ -1655,7 +1624,7 @@ yybackup: /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) + if (yypact_value_is_default (yyn)) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ @@ -1686,7 +1655,7 @@ yybackup: yyn = yytable[yyn]; if (yyn <= 0) { - if (yyn == 0 || yyn == YYTABLE_NINF) + if (yytable_value_is_error (yyn)) goto yyerrlab; yyn = -yyn; goto yyreduce; @@ -1741,592 +1710,671 @@ yyreduce: switch (yyn) { case 4: - -/* Line 1455 of yacc.c */ -#line 318 "getdate.y" +/* Line 1428 of yacc.c */ +#line 317 "getdate.y" { - pc->seconds = (yyvsp[(2) - (2)].timespec); - pc->timespec_seen = true; + pc->seconds = (yyvsp[0].timespec); + pc->timespec_seen = true; } +/* Line 1428 of yacc.c */ +#line 1721 "getdate.c" break; case 7: - -/* Line 1455 of yacc.c */ -#line 331 "getdate.y" +/* Line 1428 of yacc.c */ +#line 330 "getdate.y" { pc->times_seen++; } +/* Line 1428 of yacc.c */ +#line 1729 "getdate.c" break; case 8: - -/* Line 1455 of yacc.c */ -#line 333 "getdate.y" +/* Line 1428 of yacc.c */ +#line 332 "getdate.y" { pc->local_zones_seen++; } +/* Line 1428 of yacc.c */ +#line 1737 "getdate.c" break; case 9: - -/* Line 1455 of yacc.c */ -#line 335 "getdate.y" +/* Line 1428 of yacc.c */ +#line 334 "getdate.y" { pc->zones_seen++; } +/* Line 1428 of yacc.c */ +#line 1745 "getdate.c" break; case 10: - -/* Line 1455 of yacc.c */ -#line 337 "getdate.y" +/* Line 1428 of yacc.c */ +#line 336 "getdate.y" { pc->dates_seen++; } +/* Line 1428 of yacc.c */ +#line 1753 "getdate.c" break; case 11: - -/* Line 1455 of yacc.c */ -#line 339 "getdate.y" +/* Line 1428 of yacc.c */ +#line 338 "getdate.y" { pc->days_seen++; } +/* Line 1428 of yacc.c */ +#line 1761 "getdate.c" break; case 15: - -/* Line 1455 of yacc.c */ -#line 347 "getdate.y" +/* Line 1428 of yacc.c */ +#line 346 "getdate.y" { - set_hhmmss (pc, (yyvsp[(1) - (2)].textintval).value, 0, 0, 0); - pc->meridian = (yyvsp[(2) - (2)].intval); + set_hhmmss (pc, (yyvsp[-1].textintval).value, 0, 0, 0); + pc->meridian = (yyvsp[0].intval); } +/* Line 1428 of yacc.c */ +#line 1772 "getdate.c" break; case 16: - -/* Line 1455 of yacc.c */ -#line 352 "getdate.y" +/* Line 1428 of yacc.c */ +#line 351 "getdate.y" { - set_hhmmss (pc, (yyvsp[(1) - (4)].textintval).value, (yyvsp[(3) - (4)].textintval).value, 0, 0); - pc->meridian = (yyvsp[(4) - (4)].intval); + set_hhmmss (pc, (yyvsp[-3].textintval).value, (yyvsp[-1].textintval).value, 0, 0); + pc->meridian = (yyvsp[0].intval); } +/* Line 1428 of yacc.c */ +#line 1783 "getdate.c" break; case 17: - -/* Line 1455 of yacc.c */ -#line 357 "getdate.y" +/* Line 1428 of yacc.c */ +#line 356 "getdate.y" { - set_hhmmss (pc, (yyvsp[(1) - (5)].textintval).value, (yyvsp[(3) - (5)].textintval).value, 0, 0); - pc->meridian = MER24; - pc->zones_seen++; - pc->time_zone = time_zone_hhmm (pc, (yyvsp[(4) - (5)].textintval), (yyvsp[(5) - (5)].intval)); + set_hhmmss (pc, (yyvsp[-4].textintval).value, (yyvsp[-2].textintval).value, 0, 0); + pc->meridian = MER24; + pc->zones_seen++; + pc->time_zone = time_zone_hhmm (pc, (yyvsp[-1].textintval), (yyvsp[0].intval)); } +/* Line 1428 of yacc.c */ +#line 1796 "getdate.c" break; case 18: - -/* Line 1455 of yacc.c */ -#line 364 "getdate.y" +/* Line 1428 of yacc.c */ +#line 363 "getdate.y" { - set_hhmmss (pc, (yyvsp[(1) - (6)].textintval).value, (yyvsp[(3) - (6)].textintval).value, (yyvsp[(5) - (6)].timespec).tv_sec, (yyvsp[(5) - (6)].timespec).tv_nsec); - pc->meridian = (yyvsp[(6) - (6)].intval); + set_hhmmss (pc, (yyvsp[-5].textintval).value, (yyvsp[-3].textintval).value, (yyvsp[-1].timespec).tv_sec, (yyvsp[-1].timespec).tv_nsec); + pc->meridian = (yyvsp[0].intval); } +/* Line 1428 of yacc.c */ +#line 1807 "getdate.c" break; case 19: - -/* Line 1455 of yacc.c */ -#line 369 "getdate.y" +/* Line 1428 of yacc.c */ +#line 368 "getdate.y" { - set_hhmmss (pc, (yyvsp[(1) - (7)].textintval).value, (yyvsp[(3) - (7)].textintval).value, (yyvsp[(5) - (7)].timespec).tv_sec, (yyvsp[(5) - (7)].timespec).tv_nsec); - pc->meridian = MER24; - pc->zones_seen++; - pc->time_zone = time_zone_hhmm (pc, (yyvsp[(6) - (7)].textintval), (yyvsp[(7) - (7)].intval)); + set_hhmmss (pc, (yyvsp[-6].textintval).value, (yyvsp[-4].textintval).value, (yyvsp[-2].timespec).tv_sec, (yyvsp[-2].timespec).tv_nsec); + pc->meridian = MER24; + pc->zones_seen++; + pc->time_zone = time_zone_hhmm (pc, (yyvsp[-1].textintval), (yyvsp[0].intval)); } +/* Line 1428 of yacc.c */ +#line 1820 "getdate.c" break; case 20: - -/* Line 1455 of yacc.c */ -#line 379 "getdate.y" +/* Line 1428 of yacc.c */ +#line 378 "getdate.y" { - pc->local_isdst = (yyvsp[(1) - (1)].intval); - pc->dsts_seen += (0 < (yyvsp[(1) - (1)].intval)); + pc->local_isdst = (yyvsp[0].intval); + pc->dsts_seen += (0 < (yyvsp[0].intval)); } +/* Line 1428 of yacc.c */ +#line 1831 "getdate.c" break; case 21: - -/* Line 1455 of yacc.c */ -#line 384 "getdate.y" +/* Line 1428 of yacc.c */ +#line 383 "getdate.y" { - pc->local_isdst = 1; - pc->dsts_seen += (0 < (yyvsp[(1) - (2)].intval)) + 1; + pc->local_isdst = 1; + pc->dsts_seen += (0 < (yyvsp[-1].intval)) + 1; } +/* Line 1428 of yacc.c */ +#line 1842 "getdate.c" break; case 22: - -/* Line 1455 of yacc.c */ -#line 392 "getdate.y" - { pc->time_zone = (yyvsp[(1) - (1)].intval); } +/* Line 1428 of yacc.c */ +#line 391 "getdate.y" + { pc->time_zone = (yyvsp[0].intval); } +/* Line 1428 of yacc.c */ +#line 1850 "getdate.c" break; case 23: - -/* Line 1455 of yacc.c */ -#line 394 "getdate.y" - { pc->time_zone = (yyvsp[(1) - (2)].intval); - apply_relative_time (pc, (yyvsp[(2) - (2)].rel), 1); } +/* Line 1428 of yacc.c */ +#line 393 "getdate.y" + { pc->time_zone = (yyvsp[-1].intval); + apply_relative_time (pc, (yyvsp[0].rel), 1); } +/* Line 1428 of yacc.c */ +#line 1859 "getdate.c" break; case 24: - -/* Line 1455 of yacc.c */ -#line 397 "getdate.y" - { pc->time_zone = (yyvsp[(1) - (3)].intval) + time_zone_hhmm (pc, (yyvsp[(2) - (3)].textintval), (yyvsp[(3) - (3)].intval)); } +/* Line 1428 of yacc.c */ +#line 396 "getdate.y" + { pc->time_zone = (yyvsp[-2].intval) + time_zone_hhmm (pc, (yyvsp[-1].textintval), (yyvsp[0].intval)); } +/* Line 1428 of yacc.c */ +#line 1867 "getdate.c" break; case 25: - -/* Line 1455 of yacc.c */ -#line 399 "getdate.y" - { pc->time_zone = (yyvsp[(1) - (1)].intval) + 60; } +/* Line 1428 of yacc.c */ +#line 398 "getdate.y" + { pc->time_zone = (yyvsp[0].intval) + 60; } +/* Line 1428 of yacc.c */ +#line 1875 "getdate.c" break; case 26: - -/* Line 1455 of yacc.c */ -#line 401 "getdate.y" - { pc->time_zone = (yyvsp[(1) - (2)].intval) + 60; } +/* Line 1428 of yacc.c */ +#line 400 "getdate.y" + { pc->time_zone = (yyvsp[-1].intval) + 60; } +/* Line 1428 of yacc.c */ +#line 1883 "getdate.c" break; case 27: - -/* Line 1455 of yacc.c */ -#line 406 "getdate.y" +/* Line 1428 of yacc.c */ +#line 405 "getdate.y" { - pc->day_ordinal = 0; - pc->day_number = (yyvsp[(1) - (1)].intval); + pc->day_ordinal = 0; + pc->day_number = (yyvsp[0].intval); } +/* Line 1428 of yacc.c */ +#line 1894 "getdate.c" break; case 28: - -/* Line 1455 of yacc.c */ -#line 411 "getdate.y" +/* Line 1428 of yacc.c */ +#line 410 "getdate.y" { - pc->day_ordinal = 0; - pc->day_number = (yyvsp[(1) - (2)].intval); + pc->day_ordinal = 0; + pc->day_number = (yyvsp[-1].intval); } +/* Line 1428 of yacc.c */ +#line 1905 "getdate.c" break; case 29: - -/* Line 1455 of yacc.c */ -#line 416 "getdate.y" +/* Line 1428 of yacc.c */ +#line 415 "getdate.y" { - pc->day_ordinal = (yyvsp[(1) - (2)].intval); - pc->day_number = (yyvsp[(2) - (2)].intval); + pc->day_ordinal = (yyvsp[-1].intval); + pc->day_number = (yyvsp[0].intval); } +/* Line 1428 of yacc.c */ +#line 1916 "getdate.c" break; case 30: - -/* Line 1455 of yacc.c */ -#line 421 "getdate.y" +/* Line 1428 of yacc.c */ +#line 420 "getdate.y" { - pc->day_ordinal = (yyvsp[(1) - (2)].textintval).value; - pc->day_number = (yyvsp[(2) - (2)].intval); + pc->day_ordinal = (yyvsp[-1].textintval).value; + pc->day_number = (yyvsp[0].intval); } +/* Line 1428 of yacc.c */ +#line 1927 "getdate.c" break; case 31: - -/* Line 1455 of yacc.c */ -#line 429 "getdate.y" +/* Line 1428 of yacc.c */ +#line 428 "getdate.y" { - pc->month = (yyvsp[(1) - (3)].textintval).value; - pc->day = (yyvsp[(3) - (3)].textintval).value; + pc->month = (yyvsp[-2].textintval).value; + pc->day = (yyvsp[0].textintval).value; } +/* Line 1428 of yacc.c */ +#line 1938 "getdate.c" break; case 32: - -/* Line 1455 of yacc.c */ -#line 434 "getdate.y" +/* Line 1428 of yacc.c */ +#line 433 "getdate.y" { - /* Interpret as YYYY/MM/DD if the first value has 4 or more digits, - otherwise as MM/DD/YY. - The goal in recognizing YYYY/MM/DD is solely to support legacy - machine-generated dates like those in an RCS log listing. If - you want portability, use the ISO 8601 format. */ - if (4 <= (yyvsp[(1) - (5)].textintval).digits) - { - pc->year = (yyvsp[(1) - (5)].textintval); - pc->month = (yyvsp[(3) - (5)].textintval).value; - pc->day = (yyvsp[(5) - (5)].textintval).value; - } - else - { - pc->month = (yyvsp[(1) - (5)].textintval).value; - pc->day = (yyvsp[(3) - (5)].textintval).value; - pc->year = (yyvsp[(5) - (5)].textintval); - } + /* Interpret as YYYY/MM/DD if the first value has 4 or more digits, + otherwise as MM/DD/YY. + The goal in recognizing YYYY/MM/DD is solely to support legacy + machine-generated dates like those in an RCS log listing. If + you want portability, use the ISO 8601 format. */ + if (4 <= (yyvsp[-4].textintval).digits) + { + pc->year = (yyvsp[-4].textintval); + pc->month = (yyvsp[-2].textintval).value; + pc->day = (yyvsp[0].textintval).value; + } + else + { + pc->month = (yyvsp[-4].textintval).value; + pc->day = (yyvsp[-2].textintval).value; + pc->year = (yyvsp[0].textintval); + } } +/* Line 1428 of yacc.c */ +#line 1964 "getdate.c" break; case 33: - -/* Line 1455 of yacc.c */ -#line 454 "getdate.y" +/* Line 1428 of yacc.c */ +#line 453 "getdate.y" { - /* ISO 8601 format. YYYY-MM-DD. */ - pc->year = (yyvsp[(1) - (3)].textintval); - pc->month = -(yyvsp[(2) - (3)].textintval).value; - pc->day = -(yyvsp[(3) - (3)].textintval).value; + /* ISO 8601 format. YYYY-MM-DD. */ + pc->year = (yyvsp[-2].textintval); + pc->month = -(yyvsp[-1].textintval).value; + pc->day = -(yyvsp[0].textintval).value; } +/* Line 1428 of yacc.c */ +#line 1977 "getdate.c" break; case 34: - -/* Line 1455 of yacc.c */ -#line 461 "getdate.y" +/* Line 1428 of yacc.c */ +#line 460 "getdate.y" { - /* e.g. 17-JUN-1992. */ - pc->day = (yyvsp[(1) - (3)].textintval).value; - pc->month = (yyvsp[(2) - (3)].intval); - pc->year.value = -(yyvsp[(3) - (3)].textintval).value; - pc->year.digits = (yyvsp[(3) - (3)].textintval).digits; + /* e.g. 17-JUN-1992. */ + pc->day = (yyvsp[-2].textintval).value; + pc->month = (yyvsp[-1].intval); + pc->year.value = -(yyvsp[0].textintval).value; + pc->year.digits = (yyvsp[0].textintval).digits; } +/* Line 1428 of yacc.c */ +#line 1991 "getdate.c" break; case 35: - -/* Line 1455 of yacc.c */ -#line 469 "getdate.y" +/* Line 1428 of yacc.c */ +#line 468 "getdate.y" { - /* e.g. JUN-17-1992. */ - pc->month = (yyvsp[(1) - (3)].intval); - pc->day = -(yyvsp[(2) - (3)].textintval).value; - pc->year.value = -(yyvsp[(3) - (3)].textintval).value; - pc->year.digits = (yyvsp[(3) - (3)].textintval).digits; + /* e.g. JUN-17-1992. */ + pc->month = (yyvsp[-2].intval); + pc->day = -(yyvsp[-1].textintval).value; + pc->year.value = -(yyvsp[0].textintval).value; + pc->year.digits = (yyvsp[0].textintval).digits; } +/* Line 1428 of yacc.c */ +#line 2005 "getdate.c" break; case 36: - -/* Line 1455 of yacc.c */ -#line 477 "getdate.y" +/* Line 1428 of yacc.c */ +#line 476 "getdate.y" { - pc->month = (yyvsp[(1) - (2)].intval); - pc->day = (yyvsp[(2) - (2)].textintval).value; + pc->month = (yyvsp[-1].intval); + pc->day = (yyvsp[0].textintval).value; } +/* Line 1428 of yacc.c */ +#line 2016 "getdate.c" break; case 37: - -/* Line 1455 of yacc.c */ -#line 482 "getdate.y" +/* Line 1428 of yacc.c */ +#line 481 "getdate.y" { - pc->month = (yyvsp[(1) - (4)].intval); - pc->day = (yyvsp[(2) - (4)].textintval).value; - pc->year = (yyvsp[(4) - (4)].textintval); + pc->month = (yyvsp[-3].intval); + pc->day = (yyvsp[-2].textintval).value; + pc->year = (yyvsp[0].textintval); } +/* Line 1428 of yacc.c */ +#line 2028 "getdate.c" break; case 38: - -/* Line 1455 of yacc.c */ -#line 488 "getdate.y" +/* Line 1428 of yacc.c */ +#line 487 "getdate.y" { - pc->day = (yyvsp[(1) - (2)].textintval).value; - pc->month = (yyvsp[(2) - (2)].intval); + pc->day = (yyvsp[-1].textintval).value; + pc->month = (yyvsp[0].intval); } +/* Line 1428 of yacc.c */ +#line 2039 "getdate.c" break; case 39: - -/* Line 1455 of yacc.c */ -#line 493 "getdate.y" +/* Line 1428 of yacc.c */ +#line 492 "getdate.y" { - pc->day = (yyvsp[(1) - (3)].textintval).value; - pc->month = (yyvsp[(2) - (3)].intval); - pc->year = (yyvsp[(3) - (3)].textintval); + pc->day = (yyvsp[-2].textintval).value; + pc->month = (yyvsp[-1].intval); + pc->year = (yyvsp[0].textintval); } +/* Line 1428 of yacc.c */ +#line 2051 "getdate.c" break; case 40: - -/* Line 1455 of yacc.c */ -#line 502 "getdate.y" - { apply_relative_time (pc, (yyvsp[(1) - (2)].rel), -1); } +/* Line 1428 of yacc.c */ +#line 501 "getdate.y" + { apply_relative_time (pc, (yyvsp[-1].rel), -1); } +/* Line 1428 of yacc.c */ +#line 2059 "getdate.c" break; case 41: - -/* Line 1455 of yacc.c */ -#line 504 "getdate.y" - { apply_relative_time (pc, (yyvsp[(1) - (1)].rel), 1); } +/* Line 1428 of yacc.c */ +#line 503 "getdate.y" + { apply_relative_time (pc, (yyvsp[0].rel), 1); } +/* Line 1428 of yacc.c */ +#line 2067 "getdate.c" break; case 42: - -/* Line 1455 of yacc.c */ -#line 506 "getdate.y" - { apply_relative_time (pc, (yyvsp[(1) - (1)].rel), 1); } +/* Line 1428 of yacc.c */ +#line 505 "getdate.y" + { apply_relative_time (pc, (yyvsp[0].rel), 1); } +/* Line 1428 of yacc.c */ +#line 2075 "getdate.c" break; case 43: - -/* Line 1455 of yacc.c */ -#line 511 "getdate.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[(1) - (2)].intval); } +/* Line 1428 of yacc.c */ +#line 510 "getdate.y" + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[-1].intval); } +/* Line 1428 of yacc.c */ +#line 2083 "getdate.c" break; case 44: - -/* Line 1455 of yacc.c */ -#line 513 "getdate.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[(1) - (2)].textintval).value; } +/* Line 1428 of yacc.c */ +#line 512 "getdate.y" + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[-1].textintval).value; } +/* Line 1428 of yacc.c */ +#line 2091 "getdate.c" break; case 45: - -/* Line 1455 of yacc.c */ -#line 515 "getdate.y" +/* Line 1428 of yacc.c */ +#line 514 "getdate.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = 1; } +/* Line 1428 of yacc.c */ +#line 2099 "getdate.c" break; case 46: - -/* Line 1455 of yacc.c */ -#line 517 "getdate.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[(1) - (2)].intval); } +/* Line 1428 of yacc.c */ +#line 516 "getdate.y" + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[-1].intval); } +/* Line 1428 of yacc.c */ +#line 2107 "getdate.c" break; case 47: - -/* Line 1455 of yacc.c */ -#line 519 "getdate.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[(1) - (2)].textintval).value; } +/* Line 1428 of yacc.c */ +#line 518 "getdate.y" + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[-1].textintval).value; } +/* Line 1428 of yacc.c */ +#line 2115 "getdate.c" break; case 48: - -/* Line 1455 of yacc.c */ -#line 521 "getdate.y" +/* Line 1428 of yacc.c */ +#line 520 "getdate.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = 1; } +/* Line 1428 of yacc.c */ +#line 2123 "getdate.c" break; case 49: - -/* Line 1455 of yacc.c */ -#line 523 "getdate.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (2)].intval) * (yyvsp[(2) - (2)].intval); } +/* Line 1428 of yacc.c */ +#line 522 "getdate.y" + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[-1].intval) * (yyvsp[0].intval); } +/* Line 1428 of yacc.c */ +#line 2131 "getdate.c" break; case 50: - -/* Line 1455 of yacc.c */ -#line 525 "getdate.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); } +/* Line 1428 of yacc.c */ +#line 524 "getdate.y" + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[-1].textintval).value * (yyvsp[0].intval); } +/* Line 1428 of yacc.c */ +#line 2139 "getdate.c" break; case 51: - -/* Line 1455 of yacc.c */ -#line 527 "getdate.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (1)].intval); } +/* Line 1428 of yacc.c */ +#line 526 "getdate.y" + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[0].intval); } +/* Line 1428 of yacc.c */ +#line 2147 "getdate.c" break; case 52: - -/* Line 1455 of yacc.c */ -#line 529 "getdate.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[(1) - (2)].intval); } +/* Line 1428 of yacc.c */ +#line 528 "getdate.y" + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[-1].intval); } +/* Line 1428 of yacc.c */ +#line 2155 "getdate.c" break; case 53: - -/* Line 1455 of yacc.c */ -#line 531 "getdate.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[(1) - (2)].textintval).value; } +/* Line 1428 of yacc.c */ +#line 530 "getdate.y" + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[-1].textintval).value; } +/* Line 1428 of yacc.c */ +#line 2163 "getdate.c" break; case 54: - -/* Line 1455 of yacc.c */ -#line 533 "getdate.y" +/* Line 1428 of yacc.c */ +#line 532 "getdate.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = 1; } +/* Line 1428 of yacc.c */ +#line 2171 "getdate.c" break; case 55: - -/* Line 1455 of yacc.c */ -#line 535 "getdate.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[(1) - (2)].intval); } +/* Line 1428 of yacc.c */ +#line 534 "getdate.y" + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[-1].intval); } +/* Line 1428 of yacc.c */ +#line 2179 "getdate.c" break; case 56: - -/* Line 1455 of yacc.c */ -#line 537 "getdate.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[(1) - (2)].textintval).value; } +/* Line 1428 of yacc.c */ +#line 536 "getdate.y" + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[-1].textintval).value; } +/* Line 1428 of yacc.c */ +#line 2187 "getdate.c" break; case 57: - -/* Line 1455 of yacc.c */ -#line 539 "getdate.y" +/* Line 1428 of yacc.c */ +#line 538 "getdate.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = 1; } +/* Line 1428 of yacc.c */ +#line 2195 "getdate.c" break; case 58: - -/* Line 1455 of yacc.c */ -#line 541 "getdate.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].intval); } +/* Line 1428 of yacc.c */ +#line 540 "getdate.y" + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[-1].intval); } +/* Line 1428 of yacc.c */ +#line 2203 "getdate.c" break; case 59: - -/* Line 1455 of yacc.c */ -#line 543 "getdate.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].textintval).value; } +/* Line 1428 of yacc.c */ +#line 542 "getdate.y" + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[-1].textintval).value; } +/* Line 1428 of yacc.c */ +#line 2211 "getdate.c" break; case 60: - -/* Line 1455 of yacc.c */ -#line 545 "getdate.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].timespec).tv_sec; (yyval.rel).ns = (yyvsp[(1) - (2)].timespec).tv_nsec; } +/* Line 1428 of yacc.c */ +#line 544 "getdate.y" + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[-1].timespec).tv_sec; (yyval.rel).ns = (yyvsp[-1].timespec).tv_nsec; } +/* Line 1428 of yacc.c */ +#line 2219 "getdate.c" break; case 61: - -/* Line 1455 of yacc.c */ -#line 547 "getdate.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].timespec).tv_sec; (yyval.rel).ns = (yyvsp[(1) - (2)].timespec).tv_nsec; } +/* Line 1428 of yacc.c */ +#line 546 "getdate.y" + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[-1].timespec).tv_sec; (yyval.rel).ns = (yyvsp[-1].timespec).tv_nsec; } +/* Line 1428 of yacc.c */ +#line 2227 "getdate.c" break; case 62: - -/* Line 1455 of yacc.c */ -#line 549 "getdate.y" +/* Line 1428 of yacc.c */ +#line 548 "getdate.y" { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = 1; } +/* Line 1428 of yacc.c */ +#line 2235 "getdate.c" break; case 64: - -/* Line 1455 of yacc.c */ -#line 555 "getdate.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[(1) - (2)].textintval).value; } +/* Line 1428 of yacc.c */ +#line 554 "getdate.y" + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[-1].textintval).value; } +/* Line 1428 of yacc.c */ +#line 2243 "getdate.c" break; case 65: - -/* Line 1455 of yacc.c */ -#line 557 "getdate.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[(1) - (2)].textintval).value; } +/* Line 1428 of yacc.c */ +#line 556 "getdate.y" + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[-1].textintval).value; } +/* Line 1428 of yacc.c */ +#line 2251 "getdate.c" break; case 66: - -/* Line 1455 of yacc.c */ -#line 559 "getdate.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); } +/* Line 1428 of yacc.c */ +#line 558 "getdate.y" + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[-1].textintval).value * (yyvsp[0].intval); } +/* Line 1428 of yacc.c */ +#line 2259 "getdate.c" break; case 67: - -/* Line 1455 of yacc.c */ -#line 561 "getdate.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[(1) - (2)].textintval).value; } +/* Line 1428 of yacc.c */ +#line 560 "getdate.y" + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[-1].textintval).value; } +/* Line 1428 of yacc.c */ +#line 2267 "getdate.c" break; case 68: - -/* Line 1455 of yacc.c */ -#line 563 "getdate.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[(1) - (2)].textintval).value; } +/* Line 1428 of yacc.c */ +#line 562 "getdate.y" + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[-1].textintval).value; } +/* Line 1428 of yacc.c */ +#line 2275 "getdate.c" break; case 69: - -/* Line 1455 of yacc.c */ -#line 565 "getdate.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].textintval).value; } +/* Line 1428 of yacc.c */ +#line 564 "getdate.y" + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[-1].textintval).value; } +/* Line 1428 of yacc.c */ +#line 2283 "getdate.c" break; case 70: - -/* Line 1455 of yacc.c */ -#line 570 "getdate.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (1)].intval); } +/* Line 1428 of yacc.c */ +#line 569 "getdate.y" + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[0].intval); } +/* Line 1428 of yacc.c */ +#line 2291 "getdate.c" break; case 74: - -/* Line 1455 of yacc.c */ -#line 578 "getdate.y" - { (yyval.timespec).tv_sec = (yyvsp[(1) - (1)].textintval).value; (yyval.timespec).tv_nsec = 0; } +/* Line 1428 of yacc.c */ +#line 577 "getdate.y" + { (yyval.timespec).tv_sec = (yyvsp[0].textintval).value; (yyval.timespec).tv_nsec = 0; } +/* Line 1428 of yacc.c */ +#line 2299 "getdate.c" break; case 76: - -/* Line 1455 of yacc.c */ -#line 584 "getdate.y" - { (yyval.timespec).tv_sec = (yyvsp[(1) - (1)].textintval).value; (yyval.timespec).tv_nsec = 0; } +/* Line 1428 of yacc.c */ +#line 583 "getdate.y" + { (yyval.timespec).tv_sec = (yyvsp[0].textintval).value; (yyval.timespec).tv_nsec = 0; } +/* Line 1428 of yacc.c */ +#line 2307 "getdate.c" break; case 77: - -/* Line 1455 of yacc.c */ -#line 589 "getdate.y" - { digits_to_date_time (pc, (yyvsp[(1) - (1)].textintval)); } +/* Line 1428 of yacc.c */ +#line 588 "getdate.y" + { digits_to_date_time (pc, (yyvsp[0].textintval)); } +/* Line 1428 of yacc.c */ +#line 2315 "getdate.c" break; case 78: - -/* Line 1455 of yacc.c */ -#line 594 "getdate.y" +/* Line 1428 of yacc.c */ +#line 593 "getdate.y" { - /* Hybrid all-digit and relative offset, so that we accept e.g., - "YYYYMMDD +N days" as well as "YYYYMMDD N days". */ - digits_to_date_time (pc, (yyvsp[(1) - (2)].textintval)); - apply_relative_time (pc, (yyvsp[(2) - (2)].rel), 1); + /* Hybrid all-digit and relative offset, so that we accept e.g., + "YYYYMMDD +N days" as well as "YYYYMMDD N days". */ + digits_to_date_time (pc, (yyvsp[-1].textintval)); + apply_relative_time (pc, (yyvsp[0].rel), 1); } +/* Line 1428 of yacc.c */ +#line 2328 "getdate.c" break; case 79: - -/* Line 1455 of yacc.c */ -#line 604 "getdate.y" +/* Line 1428 of yacc.c */ +#line 603 "getdate.y" { (yyval.intval) = -1; } +/* Line 1428 of yacc.c */ +#line 2336 "getdate.c" break; case 80: - -/* Line 1455 of yacc.c */ -#line 606 "getdate.y" - { (yyval.intval) = (yyvsp[(2) - (2)].textintval).value; } +/* Line 1428 of yacc.c */ +#line 605 "getdate.y" + { (yyval.intval) = (yyvsp[0].textintval).value; } +/* Line 1428 of yacc.c */ +#line 2344 "getdate.c" break; case 81: - -/* Line 1455 of yacc.c */ -#line 611 "getdate.y" +/* Line 1428 of yacc.c */ +#line 610 "getdate.y" { (yyval.intval) = MER24; } +/* Line 1428 of yacc.c */ +#line 2352 "getdate.c" break; case 82: - -/* Line 1455 of yacc.c */ -#line 613 "getdate.y" - { (yyval.intval) = (yyvsp[(1) - (1)].intval); } +/* Line 1428 of yacc.c */ +#line 612 "getdate.y" + { (yyval.intval) = (yyvsp[0].intval); } +/* Line 1428 of yacc.c */ +#line 2360 "getdate.c" break; - -/* Line 1455 of yacc.c */ -#line 2328 "getdate.c" +/* Line 1428 of yacc.c */ +#line 2365 "getdate.c" default: break; } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); @@ -2354,6 +2402,10 @@ yyreduce: | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { @@ -2361,37 +2413,28 @@ yyerrlab: #if ! YYERROR_VERBOSE yyerror (pc, YY_("syntax error")); #else - { - YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); - if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) - { - YYSIZE_T yyalloc = 2 * yysize; - if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) - yyalloc = YYSTACK_ALLOC_MAXIMUM; - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yyalloc); - if (yymsg) - yymsg_alloc = yyalloc; - else - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - } - } - - if (0 < yysize && yysize <= yymsg_alloc) - { - (void) yysyntax_error (yymsg, yystate, yychar); - yyerror (pc, yymsg); - } - else - { - yyerror (pc, YY_("syntax error")); - if (yysize != 0) - goto yyexhaustedlab; - } - } + while (1) + { + int yysyntax_error_status = + yysyntax_error (&yymsg_alloc, &yymsg, yystate, yytoken); + if (yysyntax_error_status == 2 && 0 < yymsg_alloc) + { + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (yymsg) + continue; + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + if (yysyntax_error_status == 0) + yyerror (pc, yymsg); + else + yyerror (pc, YY_("syntax error")); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; + break; + } #endif } @@ -2450,7 +2493,7 @@ yyerrlab1: for (;;) { yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) + if (!yypact_value_is_default (yyn)) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) @@ -2509,8 +2552,13 @@ yyexhaustedlab: yyreturn: if (yychar != YYEMPTY) - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval, pc); + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, pc); + } /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); @@ -2533,10 +2581,8 @@ yyreturn: return YYID (yyresult); } - - -/* Line 1675 of yacc.c */ -#line 616 "getdate.y" +/* Line 1658 of yacc.c */ +#line 615 "getdate.y" static table const meridian_table[] = @@ -2555,71 +2601,71 @@ static table const dst_table[] = static table const month_and_day_table[] = { - { "JANUARY", tMONTH, 1 }, - { "FEBRUARY", tMONTH, 2 }, - { "MARCH", tMONTH, 3 }, - { "APRIL", tMONTH, 4 }, - { "MAY", tMONTH, 5 }, - { "JUNE", tMONTH, 6 }, - { "JULY", tMONTH, 7 }, - { "AUGUST", tMONTH, 8 }, - { "SEPTEMBER",tMONTH, 9 }, - { "SEPT", tMONTH, 9 }, - { "OCTOBER", tMONTH, 10 }, - { "NOVEMBER", tMONTH, 11 }, - { "DECEMBER", tMONTH, 12 }, - { "SUNDAY", tDAY, 0 }, - { "MONDAY", tDAY, 1 }, - { "TUESDAY", tDAY, 2 }, - { "TUES", tDAY, 2 }, - { "WEDNESDAY",tDAY, 3 }, - { "WEDNES", tDAY, 3 }, - { "THURSDAY", tDAY, 4 }, - { "THUR", tDAY, 4 }, - { "THURS", tDAY, 4 }, - { "FRIDAY", tDAY, 5 }, - { "SATURDAY", tDAY, 6 }, + { "JANUARY", tMONTH, 1 }, + { "FEBRUARY", tMONTH, 2 }, + { "MARCH", tMONTH, 3 }, + { "APRIL", tMONTH, 4 }, + { "MAY", tMONTH, 5 }, + { "JUNE", tMONTH, 6 }, + { "JULY", tMONTH, 7 }, + { "AUGUST", tMONTH, 8 }, + { "SEPTEMBER",tMONTH, 9 }, + { "SEPT", tMONTH, 9 }, + { "OCTOBER", tMONTH, 10 }, + { "NOVEMBER", tMONTH, 11 }, + { "DECEMBER", tMONTH, 12 }, + { "SUNDAY", tDAY, 0 }, + { "MONDAY", tDAY, 1 }, + { "TUESDAY", tDAY, 2 }, + { "TUES", tDAY, 2 }, + { "WEDNESDAY",tDAY, 3 }, + { "WEDNES", tDAY, 3 }, + { "THURSDAY", tDAY, 4 }, + { "THUR", tDAY, 4 }, + { "THURS", tDAY, 4 }, + { "FRIDAY", tDAY, 5 }, + { "SATURDAY", tDAY, 6 }, { NULL, 0, 0 } }; static table const time_units_table[] = { - { "YEAR", tYEAR_UNIT, 1 }, - { "MONTH", tMONTH_UNIT, 1 }, - { "FORTNIGHT",tDAY_UNIT, 14 }, - { "WEEK", tDAY_UNIT, 7 }, - { "DAY", tDAY_UNIT, 1 }, - { "HOUR", tHOUR_UNIT, 1 }, - { "MINUTE", tMINUTE_UNIT, 1 }, - { "MIN", tMINUTE_UNIT, 1 }, - { "SECOND", tSEC_UNIT, 1 }, - { "SEC", tSEC_UNIT, 1 }, + { "YEAR", tYEAR_UNIT, 1 }, + { "MONTH", tMONTH_UNIT, 1 }, + { "FORTNIGHT",tDAY_UNIT, 14 }, + { "WEEK", tDAY_UNIT, 7 }, + { "DAY", tDAY_UNIT, 1 }, + { "HOUR", tHOUR_UNIT, 1 }, + { "MINUTE", tMINUTE_UNIT, 1 }, + { "MIN", tMINUTE_UNIT, 1 }, + { "SECOND", tSEC_UNIT, 1 }, + { "SEC", tSEC_UNIT, 1 }, { NULL, 0, 0 } }; /* Assorted relative-time words. */ static table const relative_time_table[] = { - { "TOMORROW", tDAY_SHIFT, 1 }, - { "YESTERDAY",tDAY_SHIFT, -1 }, - { "TODAY", tDAY_SHIFT, 0 }, - { "NOW", tDAY_SHIFT, 0 }, - { "LAST", tORDINAL, -1 }, - { "THIS", tORDINAL, 0 }, - { "NEXT", tORDINAL, 1 }, - { "FIRST", tORDINAL, 1 }, -/*{ "SECOND", tORDINAL, 2 }, */ - { "THIRD", tORDINAL, 3 }, - { "FOURTH", tORDINAL, 4 }, - { "FIFTH", tORDINAL, 5 }, - { "SIXTH", tORDINAL, 6 }, - { "SEVENTH", tORDINAL, 7 }, - { "EIGHTH", tORDINAL, 8 }, - { "NINTH", tORDINAL, 9 }, - { "TENTH", tORDINAL, 10 }, - { "ELEVENTH", tORDINAL, 11 }, - { "TWELFTH", tORDINAL, 12 }, - { "AGO", tAGO, 1 }, + { "TOMORROW", tDAY_SHIFT, 1 }, + { "YESTERDAY",tDAY_SHIFT, -1 }, + { "TODAY", tDAY_SHIFT, 0 }, + { "NOW", tDAY_SHIFT, 0 }, + { "LAST", tORDINAL, -1 }, + { "THIS", tORDINAL, 0 }, + { "NEXT", tORDINAL, 1 }, + { "FIRST", tORDINAL, 1 }, +/*{ "SECOND", tORDINAL, 2 }, */ + { "THIRD", tORDINAL, 3 }, + { "FOURTH", tORDINAL, 4 }, + { "FIFTH", tORDINAL, 5 }, + { "SIXTH", tORDINAL, 6 }, + { "SEVENTH", tORDINAL, 7 }, + { "EIGHTH", tORDINAL, 8 }, + { "NINTH", tORDINAL, 9 }, + { "TENTH", tORDINAL, 10 }, + { "ELEVENTH", tORDINAL, 11 }, + { "TWELFTH", tORDINAL, 12 }, + { "AGO", tAGO, 1 }, { NULL, 0, 0 } }; @@ -2628,9 +2674,9 @@ static table const relative_time_table[] = stamps in London during summer. */ static table const universal_time_zone_table[] = { - { "GMT", tZONE, HOUR ( 0) }, /* Greenwich Mean */ - { "UT", tZONE, HOUR ( 0) }, /* Universal (Coordinated) */ - { "UTC", tZONE, HOUR ( 0) }, + { "GMT", tZONE, HOUR ( 0) }, /* Greenwich Mean */ + { "UT", tZONE, HOUR ( 0) }, /* Universal (Coordinated) */ + { "UTC", tZONE, HOUR ( 0) }, { NULL, 0, 0 } }; @@ -2641,84 +2687,84 @@ static table const universal_time_zone_table[] = abbreviations; use numeric abbreviations like `-0500' instead. */ static table const time_zone_table[] = { - { "WET", tZONE, HOUR ( 0) }, /* Western European */ - { "WEST", tDAYZONE, HOUR ( 0) }, /* Western European Summer */ - { "BST", tDAYZONE, HOUR ( 0) }, /* British Summer */ - { "ART", tZONE, -HOUR ( 3) }, /* Argentina */ - { "BRT", tZONE, -HOUR ( 3) }, /* Brazil */ - { "BRST", tDAYZONE, -HOUR ( 3) }, /* Brazil Summer */ - { "NST", tZONE, -(HOUR ( 3) + 30) }, /* Newfoundland Standard */ - { "NDT", tDAYZONE,-(HOUR ( 3) + 30) }, /* Newfoundland Daylight */ - { "AST", tZONE, -HOUR ( 4) }, /* Atlantic Standard */ - { "ADT", tDAYZONE, -HOUR ( 4) }, /* Atlantic Daylight */ - { "CLT", tZONE, -HOUR ( 4) }, /* Chile */ - { "CLST", tDAYZONE, -HOUR ( 4) }, /* Chile Summer */ - { "EST", tZONE, -HOUR ( 5) }, /* Eastern Standard */ - { "EDT", tDAYZONE, -HOUR ( 5) }, /* Eastern Daylight */ - { "CST", tZONE, -HOUR ( 6) }, /* Central Standard */ - { "CDT", tDAYZONE, -HOUR ( 6) }, /* Central Daylight */ - { "MST", tZONE, -HOUR ( 7) }, /* Mountain Standard */ - { "MDT", tDAYZONE, -HOUR ( 7) }, /* Mountain Daylight */ - { "PST", tZONE, -HOUR ( 8) }, /* Pacific Standard */ - { "PDT", tDAYZONE, -HOUR ( 8) }, /* Pacific Daylight */ - { "AKST", tZONE, -HOUR ( 9) }, /* Alaska Standard */ - { "AKDT", tDAYZONE, -HOUR ( 9) }, /* Alaska Daylight */ - { "HST", tZONE, -HOUR (10) }, /* Hawaii Standard */ - { "HAST", tZONE, -HOUR (10) }, /* Hawaii-Aleutian Standard */ - { "HADT", tDAYZONE, -HOUR (10) }, /* Hawaii-Aleutian Daylight */ - { "SST", tZONE, -HOUR (12) }, /* Samoa Standard */ - { "WAT", tZONE, HOUR ( 1) }, /* West Africa */ - { "CET", tZONE, HOUR ( 1) }, /* Central European */ - { "CEST", tDAYZONE, HOUR ( 1) }, /* Central European Summer */ - { "MET", tZONE, HOUR ( 1) }, /* Middle European */ - { "MEZ", tZONE, HOUR ( 1) }, /* Middle European */ - { "MEST", tDAYZONE, HOUR ( 1) }, /* Middle European Summer */ - { "MESZ", tDAYZONE, HOUR ( 1) }, /* Middle European Summer */ - { "EET", tZONE, HOUR ( 2) }, /* Eastern European */ - { "EEST", tDAYZONE, HOUR ( 2) }, /* Eastern European Summer */ - { "CAT", tZONE, HOUR ( 2) }, /* Central Africa */ - { "SAST", tZONE, HOUR ( 2) }, /* South Africa Standard */ - { "EAT", tZONE, HOUR ( 3) }, /* East Africa */ - { "MSK", tZONE, HOUR ( 3) }, /* Moscow */ - { "MSD", tDAYZONE, HOUR ( 3) }, /* Moscow Daylight */ - { "IST", tZONE, (HOUR ( 5) + 30) }, /* India Standard */ - { "SGT", tZONE, HOUR ( 8) }, /* Singapore */ - { "KST", tZONE, HOUR ( 9) }, /* Korea Standard */ - { "JST", tZONE, HOUR ( 9) }, /* Japan Standard */ - { "GST", tZONE, HOUR (10) }, /* Guam Standard */ - { "NZST", tZONE, HOUR (12) }, /* New Zealand Standard */ - { "NZDT", tDAYZONE, HOUR (12) }, /* New Zealand Daylight */ + { "WET", tZONE, HOUR ( 0) }, /* Western European */ + { "WEST", tDAYZONE, HOUR ( 0) }, /* Western European Summer */ + { "BST", tDAYZONE, HOUR ( 0) }, /* British Summer */ + { "ART", tZONE, -HOUR ( 3) }, /* Argentina */ + { "BRT", tZONE, -HOUR ( 3) }, /* Brazil */ + { "BRST", tDAYZONE, -HOUR ( 3) }, /* Brazil Summer */ + { "NST", tZONE, -(HOUR ( 3) + 30) }, /* Newfoundland Standard */ + { "NDT", tDAYZONE,-(HOUR ( 3) + 30) }, /* Newfoundland Daylight */ + { "AST", tZONE, -HOUR ( 4) }, /* Atlantic Standard */ + { "ADT", tDAYZONE, -HOUR ( 4) }, /* Atlantic Daylight */ + { "CLT", tZONE, -HOUR ( 4) }, /* Chile */ + { "CLST", tDAYZONE, -HOUR ( 4) }, /* Chile Summer */ + { "EST", tZONE, -HOUR ( 5) }, /* Eastern Standard */ + { "EDT", tDAYZONE, -HOUR ( 5) }, /* Eastern Daylight */ + { "CST", tZONE, -HOUR ( 6) }, /* Central Standard */ + { "CDT", tDAYZONE, -HOUR ( 6) }, /* Central Daylight */ + { "MST", tZONE, -HOUR ( 7) }, /* Mountain Standard */ + { "MDT", tDAYZONE, -HOUR ( 7) }, /* Mountain Daylight */ + { "PST", tZONE, -HOUR ( 8) }, /* Pacific Standard */ + { "PDT", tDAYZONE, -HOUR ( 8) }, /* Pacific Daylight */ + { "AKST", tZONE, -HOUR ( 9) }, /* Alaska Standard */ + { "AKDT", tDAYZONE, -HOUR ( 9) }, /* Alaska Daylight */ + { "HST", tZONE, -HOUR (10) }, /* Hawaii Standard */ + { "HAST", tZONE, -HOUR (10) }, /* Hawaii-Aleutian Standard */ + { "HADT", tDAYZONE, -HOUR (10) }, /* Hawaii-Aleutian Daylight */ + { "SST", tZONE, -HOUR (12) }, /* Samoa Standard */ + { "WAT", tZONE, HOUR ( 1) }, /* West Africa */ + { "CET", tZONE, HOUR ( 1) }, /* Central European */ + { "CEST", tDAYZONE, HOUR ( 1) }, /* Central European Summer */ + { "MET", tZONE, HOUR ( 1) }, /* Middle European */ + { "MEZ", tZONE, HOUR ( 1) }, /* Middle European */ + { "MEST", tDAYZONE, HOUR ( 1) }, /* Middle European Summer */ + { "MESZ", tDAYZONE, HOUR ( 1) }, /* Middle European Summer */ + { "EET", tZONE, HOUR ( 2) }, /* Eastern European */ + { "EEST", tDAYZONE, HOUR ( 2) }, /* Eastern European Summer */ + { "CAT", tZONE, HOUR ( 2) }, /* Central Africa */ + { "SAST", tZONE, HOUR ( 2) }, /* South Africa Standard */ + { "EAT", tZONE, HOUR ( 3) }, /* East Africa */ + { "MSK", tZONE, HOUR ( 3) }, /* Moscow */ + { "MSD", tDAYZONE, HOUR ( 3) }, /* Moscow Daylight */ + { "IST", tZONE, (HOUR ( 5) + 30) }, /* India Standard */ + { "SGT", tZONE, HOUR ( 8) }, /* Singapore */ + { "KST", tZONE, HOUR ( 9) }, /* Korea Standard */ + { "JST", tZONE, HOUR ( 9) }, /* Japan Standard */ + { "GST", tZONE, HOUR (10) }, /* Guam Standard */ + { "NZST", tZONE, HOUR (12) }, /* New Zealand Standard */ + { "NZDT", tDAYZONE, HOUR (12) }, /* New Zealand Daylight */ { NULL, 0, 0 } }; /* Military time zone table. */ static table const military_table[] = { - { "A", tZONE, -HOUR ( 1) }, - { "B", tZONE, -HOUR ( 2) }, - { "C", tZONE, -HOUR ( 3) }, - { "D", tZONE, -HOUR ( 4) }, - { "E", tZONE, -HOUR ( 5) }, - { "F", tZONE, -HOUR ( 6) }, - { "G", tZONE, -HOUR ( 7) }, - { "H", tZONE, -HOUR ( 8) }, - { "I", tZONE, -HOUR ( 9) }, - { "K", tZONE, -HOUR (10) }, - { "L", tZONE, -HOUR (11) }, - { "M", tZONE, -HOUR (12) }, - { "N", tZONE, HOUR ( 1) }, - { "O", tZONE, HOUR ( 2) }, - { "P", tZONE, HOUR ( 3) }, - { "Q", tZONE, HOUR ( 4) }, - { "R", tZONE, HOUR ( 5) }, - { "S", tZONE, HOUR ( 6) }, - { "T", tZONE, HOUR ( 7) }, - { "U", tZONE, HOUR ( 8) }, - { "V", tZONE, HOUR ( 9) }, - { "W", tZONE, HOUR (10) }, - { "X", tZONE, HOUR (11) }, - { "Y", tZONE, HOUR (12) }, - { "Z", tZONE, HOUR ( 0) }, + { "A", tZONE, -HOUR ( 1) }, + { "B", tZONE, -HOUR ( 2) }, + { "C", tZONE, -HOUR ( 3) }, + { "D", tZONE, -HOUR ( 4) }, + { "E", tZONE, -HOUR ( 5) }, + { "F", tZONE, -HOUR ( 6) }, + { "G", tZONE, -HOUR ( 7) }, + { "H", tZONE, -HOUR ( 8) }, + { "I", tZONE, -HOUR ( 9) }, + { "K", tZONE, -HOUR (10) }, + { "L", tZONE, -HOUR (11) }, + { "M", tZONE, -HOUR (12) }, + { "N", tZONE, HOUR ( 1) }, + { "O", tZONE, HOUR ( 2) }, + { "P", tZONE, HOUR ( 3) }, + { "Q", tZONE, HOUR ( 4) }, + { "R", tZONE, HOUR ( 5) }, + { "S", tZONE, HOUR ( 6) }, + { "T", tZONE, HOUR ( 7) }, + { "U", tZONE, HOUR ( 8) }, + { "V", tZONE, HOUR ( 9) }, + { "W", tZONE, HOUR (10) }, + { "X", tZONE, HOUR (11) }, + { "Y", tZONE, HOUR (12) }, + { "Z", tZONE, HOUR ( 0) }, { NULL, 0, 0 } }; @@ -2828,10 +2874,10 @@ tm_diff (struct tm const *a, struct tm const *b) long int ayear = a->tm_year; long int years = ayear - b->tm_year; long int days = (365 * years + intervening_leap_days - + (a->tm_yday - b->tm_yday)); + + (a->tm_yday - b->tm_yday)); return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour)) - + (a->tm_min - b->tm_min)) - + (a->tm_sec - b->tm_sec)); + + (a->tm_min - b->tm_min)) + + (a->tm_sec - b->tm_sec)); } #endif /* ! HAVE_TM_GMTOFF */ @@ -2879,9 +2925,9 @@ lookup_word (parser_control const *pc, char *word) { word[wordlen - 1] = '\0'; for (tp = time_units_table; tp->name; tp++) - if (strcmp (word, tp->name) == 0) - return tp; - word[wordlen - 1] = 'S'; /* For "this" in relative_time_table. */ + if (strcmp (word, tp->name) == 0) + return tp; + word[wordlen - 1] = 'S'; /* For "this" in relative_time_table. */ } for (tp = relative_time_table; tp->name; tp++) @@ -2892,7 +2938,7 @@ lookup_word (parser_control const *pc, char *word) if (wordlen == 1) for (tp = military_table; tp->name; tp++) if (word[0] == tp->name[0]) - return tp; + return tp; /* Drop out any periods and try the time zone table again. */ for (period_found = false, p = q = word; (*p = *q); q++) @@ -2915,163 +2961,163 @@ yylex (YYSTYPE *lvalp, parser_control *pc) for (;;) { while (c = *pc->input, c_isspace (c)) - pc->input++; + pc->input++; if (ISDIGIT (c) || c == '-' || c == '+') - { - char const *p; - int sign; - unsigned long int value; - if (c == '-' || c == '+') - { - sign = c == '-' ? -1 : 1; - while (c = *++pc->input, c_isspace (c)) - continue; - if (! ISDIGIT (c)) - /* skip the '-' sign */ - continue; - } - else - sign = 0; - p = pc->input; - for (value = 0; ; value *= 10) - { - unsigned long int value1 = value + (c - '0'); - if (value1 < value) - return '?'; - value = value1; - c = *++p; - if (! ISDIGIT (c)) - break; - if (ULONG_MAX / 10 < value) - return '?'; - } - if ((c == '.' || c == ',') && ISDIGIT (p[1])) - { - time_t s; - int ns; - int digits; - unsigned long int value1; + { + char const *p; + int sign; + unsigned long int value; + if (c == '-' || c == '+') + { + sign = c == '-' ? -1 : 1; + while (c = *++pc->input, c_isspace (c)) + continue; + if (! ISDIGIT (c)) + /* skip the '-' sign */ + continue; + } + else + sign = 0; + p = pc->input; + for (value = 0; ; value *= 10) + { + unsigned long int value1 = value + (c - '0'); + if (value1 < value) + return '?'; + value = value1; + c = *++p; + if (! ISDIGIT (c)) + break; + if (ULONG_MAX / 10 < value) + return '?'; + } + if ((c == '.' || c == ',') && ISDIGIT (p[1])) + { + time_t s; + int ns; + int digits; + unsigned long int value1; - /* Check for overflow when converting value to time_t. */ - if (sign < 0) - { - s = - value; - if (0 < s) - return '?'; - value1 = -s; - } - else - { - s = value; - if (s < 0) - return '?'; - value1 = s; - } - if (value != value1) - return '?'; + /* Check for overflow when converting value to time_t. */ + if (sign < 0) + { + s = - value; + if (0 < s) + return '?'; + value1 = -s; + } + else + { + s = value; + if (s < 0) + return '?'; + value1 = s; + } + if (value != value1) + return '?'; - /* Accumulate fraction, to ns precision. */ - p++; - ns = *p++ - '0'; - for (digits = 2; digits <= LOG10_BILLION; digits++) - { - ns *= 10; - if (ISDIGIT (*p)) - ns += *p++ - '0'; - } + /* Accumulate fraction, to ns precision. */ + p++; + ns = *p++ - '0'; + for (digits = 2; digits <= LOG10_BILLION; digits++) + { + ns *= 10; + if (ISDIGIT (*p)) + ns += *p++ - '0'; + } - /* Skip excess digits, truncating toward -Infinity. */ - if (sign < 0) - for (; ISDIGIT (*p); p++) - if (*p != '0') - { - ns++; - break; - } - while (ISDIGIT (*p)) - p++; + /* Skip excess digits, truncating toward -Infinity. */ + if (sign < 0) + for (; ISDIGIT (*p); p++) + if (*p != '0') + { + ns++; + break; + } + while (ISDIGIT (*p)) + p++; - /* Adjust to the timespec convention, which is that - tv_nsec is always a positive offset even if tv_sec is - negative. */ - if (sign < 0 && ns) - { - s--; - if (! (s < 0)) - return '?'; - ns = BILLION - ns; - } + /* Adjust to the timespec convention, which is that + tv_nsec is always a positive offset even if tv_sec is + negative. */ + if (sign < 0 && ns) + { + s--; + if (! (s < 0)) + return '?'; + ns = BILLION - ns; + } - lvalp->timespec.tv_sec = s; - lvalp->timespec.tv_nsec = ns; - pc->input = p; - return sign ? tSDECIMAL_NUMBER : tUDECIMAL_NUMBER; - } - else - { - lvalp->textintval.negative = sign < 0; - if (sign < 0) - { - lvalp->textintval.value = - value; - if (0 < lvalp->textintval.value) - return '?'; - } - else - { - lvalp->textintval.value = value; - if (lvalp->textintval.value < 0) - return '?'; - } - lvalp->textintval.digits = p - pc->input; - pc->input = p; - return sign ? tSNUMBER : tUNUMBER; - } - } + lvalp->timespec.tv_sec = s; + lvalp->timespec.tv_nsec = ns; + pc->input = p; + return sign ? tSDECIMAL_NUMBER : tUDECIMAL_NUMBER; + } + else + { + lvalp->textintval.negative = sign < 0; + if (sign < 0) + { + lvalp->textintval.value = - value; + if (0 < lvalp->textintval.value) + return '?'; + } + else + { + lvalp->textintval.value = value; + if (lvalp->textintval.value < 0) + return '?'; + } + lvalp->textintval.digits = p - pc->input; + pc->input = p; + return sign ? tSNUMBER : tUNUMBER; + } + } if (c_isalpha (c)) - { - char buff[20]; - char *p = buff; - table const *tp; + { + char buff[20]; + char *p = buff; + table const *tp; - do - { - if (p < buff + sizeof buff - 1) - *p++ = c; - c = *++pc->input; - } - while (c_isalpha (c) || c == '.'); + do + { + if (p < buff + sizeof buff - 1) + *p++ = c; + c = *++pc->input; + } + while (c_isalpha (c) || c == '.'); - *p = '\0'; - tp = lookup_word (pc, buff); - if (! tp) - return '?'; - lvalp->intval = tp->value; - return tp->type; - } + *p = '\0'; + tp = lookup_word (pc, buff); + if (! tp) + return '?'; + lvalp->intval = tp->value; + return tp->type; + } if (c != '(') - return *pc->input++; + return *pc->input++; count = 0; do - { - c = *pc->input++; - if (c == '\0') - return c; - if (c == '(') - count++; - else if (c == ')') - count--; - } + { + c = *pc->input++; + if (c == '\0') + return c; + if (c == '(') + count++; + else if (c == ')') + count--; + } while (count != 0); } } /* Do nothing if the parser reports an error. */ static int -yyerror (parser_control const *pc ATTRIBUTE_UNUSED, - char const *s ATTRIBUTE_UNUSED) +yyerror (parser_control const *pc _GL_UNUSED, + char const *s _GL_UNUSED) { return 0; } @@ -3086,19 +3132,19 @@ mktime_ok (struct tm const *tm0, struct tm const *tm1, time_t t) if (t == (time_t) -1) { /* Guard against falsely reporting an error when parsing a time - stamp that happens to equal (time_t) -1, on a host that - supports such a time stamp. */ + stamp that happens to equal (time_t) -1, on a host that + supports such a time stamp. */ tm1 = localtime (&t); if (!tm1) - return false; + return false; } return ! ((tm0->tm_sec ^ tm1->tm_sec) - | (tm0->tm_min ^ tm1->tm_min) - | (tm0->tm_hour ^ tm1->tm_hour) - | (tm0->tm_mday ^ tm1->tm_mday) - | (tm0->tm_mon ^ tm1->tm_mon) - | (tm0->tm_year ^ tm1->tm_year)); + | (tm0->tm_min ^ tm1->tm_min) + | (tm0->tm_hour ^ tm1->tm_hour) + | (tm0->tm_mday ^ tm1->tm_mday) + | (tm0->tm_mon ^ tm1->tm_mon) + | (tm0->tm_year ^ tm1->tm_year)); } /* A reasonable upper bound for the size of ordinary TZ strings. @@ -3115,8 +3161,8 @@ get_tz (char tzbuf[TZBUFSIZE]) { size_t tzsize = strlen (tz) + 1; tz = (tzsize <= TZBUFSIZE - ? memcpy (tzbuf, tz, tzsize) - : xmemdup (tz, tzsize)); + ? memcpy (tzbuf, tz, tzsize) + : xmemdup (tz, tzsize)); } return tz; } @@ -3164,32 +3210,32 @@ get_date (struct timespec *result, char const *p, struct timespec const *now) char const *s; for (s = tzbase; *s; s++, tzsize++) - if (*s == '\\') - { - s++; - if (! (*s == '\\' || *s == '"')) - break; - } - else if (*s == '"') - { - char *z; - char *tz1; - char tz1buf[TZBUFSIZE]; - bool large_tz = TZBUFSIZE < tzsize; - bool setenv_ok; - tz0 = get_tz (tz0buf); - z = tz1 = large_tz ? xmalloc (tzsize) : tz1buf; - for (s = tzbase; *s != '"'; s++) - *z++ = *(s += *s == '\\'); - *z = '\0'; - setenv_ok = setenv ("TZ", tz1, 1) == 0; - if (large_tz) - free (tz1); - if (!setenv_ok) - goto fail; - tz_was_altered = true; - p = s + 1; - } + if (*s == '\\') + { + s++; + if (! (*s == '\\' || *s == '"')) + break; + } + else if (*s == '"') + { + char *z; + char *tz1; + char tz1buf[TZBUFSIZE]; + bool large_tz = TZBUFSIZE < tzsize; + bool setenv_ok; + tz0 = get_tz (tz0buf); + z = tz1 = large_tz ? xmalloc (tzsize) : tz1buf; + for (s = tzbase; *s != '"'; s++) + *z++ = *(s += *s == '\\'); + *z = '\0'; + setenv_ok = setenv ("TZ", tz1, 1) == 0; + if (large_tz) + free (tz1); + if (!setenv_ok) + goto fail; + tz_was_altered = true; + p = s + 1; + } } /* As documented, be careful to treat the empty string just like @@ -3233,19 +3279,19 @@ get_date (struct timespec *result, char const *p, struct timespec const *now) int quarter; for (quarter = 1; quarter <= 3; quarter++) { - time_t probe = Start + quarter * (90 * 24 * 60 * 60); - struct tm const *probe_tm = localtime (&probe); - if (probe_tm && probe_tm->tm_zone - && probe_tm->tm_isdst != pc.local_time_zone_table[0].value) - { - { - pc.local_time_zone_table[1].name = probe_tm->tm_zone; - pc.local_time_zone_table[1].type = tLOCAL_ZONE; - pc.local_time_zone_table[1].value = probe_tm->tm_isdst; - pc.local_time_zone_table[2].name = NULL; - } - break; - } + time_t probe = Start + quarter * (90 * 24 * 60 * 60); + struct tm const *probe_tm = localtime (&probe); + if (probe_tm && probe_tm->tm_zone + && probe_tm->tm_isdst != pc.local_time_zone_table[0].value) + { + { + pc.local_time_zone_table[1].name = probe_tm->tm_zone; + pc.local_time_zone_table[1].type = tLOCAL_ZONE; + pc.local_time_zone_table[1].value = probe_tm->tm_isdst; + pc.local_time_zone_table[2].name = NULL; + } + break; + } } } #else @@ -3257,9 +3303,9 @@ get_date (struct timespec *result, char const *p, struct timespec const *now) int i; for (i = 0; i < 2; i++) { - pc.local_time_zone_table[i].name = tzname[i]; - pc.local_time_zone_table[i].type = tLOCAL_ZONE; - pc.local_time_zone_table[i].value = i; + pc.local_time_zone_table[i].name = tzname[i]; + pc.local_time_zone_table[i].type = tLOCAL_ZONE; + pc.local_time_zone_table[i].value = i; } pc.local_time_zone_table[i].name = NULL; } @@ -3270,11 +3316,11 @@ get_date (struct timespec *result, char const *p, struct timespec const *now) if (pc.local_time_zone_table[0].name && pc.local_time_zone_table[1].name && ! strcmp (pc.local_time_zone_table[0].name, - pc.local_time_zone_table[1].name)) + pc.local_time_zone_table[1].name)) { /* This locale uses the same abbrevation for standard and - daylight times. So if we see that abbreviation, we don't - know whether it's daylight time. */ + daylight times. So if we see that abbreviation, we don't + know whether it's daylight time. */ pc.local_time_zone_table[0].value = -1; pc.local_time_zone_table[1].name = NULL; } @@ -3287,160 +3333,162 @@ get_date (struct timespec *result, char const *p, struct timespec const *now) else { if (1 < (pc.times_seen | pc.dates_seen | pc.days_seen | pc.dsts_seen - | (pc.local_zones_seen + pc.zones_seen))) - goto fail; + | (pc.local_zones_seen + pc.zones_seen))) + goto fail; tm.tm_year = to_year (pc.year) - TM_YEAR_BASE; tm.tm_mon = pc.month - 1; tm.tm_mday = pc.day; if (pc.times_seen || (pc.rels_seen && ! pc.dates_seen && ! pc.days_seen)) - { - tm.tm_hour = to_hour (pc.hour, pc.meridian); - if (tm.tm_hour < 0) - goto fail; - tm.tm_min = pc.minutes; - tm.tm_sec = pc.seconds.tv_sec; - } + { + tm.tm_hour = to_hour (pc.hour, pc.meridian); + if (tm.tm_hour < 0) + goto fail; + tm.tm_min = pc.minutes; + tm.tm_sec = pc.seconds.tv_sec; + } else - { - tm.tm_hour = tm.tm_min = tm.tm_sec = 0; - pc.seconds.tv_nsec = 0; - } + { + tm.tm_hour = tm.tm_min = tm.tm_sec = 0; + pc.seconds.tv_nsec = 0; + } /* Let mktime deduce tm_isdst if we have an absolute time stamp. */ if (pc.dates_seen | pc.days_seen | pc.times_seen) - tm.tm_isdst = -1; + tm.tm_isdst = -1; /* But if the input explicitly specifies local time with or without - DST, give mktime that information. */ + DST, give mktime that information. */ if (pc.local_zones_seen) - tm.tm_isdst = pc.local_isdst; + tm.tm_isdst = pc.local_isdst; tm0 = tm; Start = mktime (&tm); if (! mktime_ok (&tm0, &tm, Start)) - { - if (! pc.zones_seen) - goto fail; - else - { - /* Guard against falsely reporting errors near the time_t - boundaries when parsing times in other time zones. For - example, suppose the input string "1969-12-31 23:00:00 -0100", - the current time zone is 8 hours ahead of UTC, and the min - time_t value is 1970-01-01 00:00:00 UTC. Then the min - localtime value is 1970-01-01 08:00:00, and mktime will - therefore fail on 1969-12-31 23:00:00. To work around the - problem, set the time zone to 1 hour behind UTC temporarily - by setting TZ="XXX1:00" and try mktime again. */ + { + if (! pc.zones_seen) + goto fail; + else + { + /* Guard against falsely reporting errors near the time_t + boundaries when parsing times in other time zones. For + example, suppose the input string "1969-12-31 23:00:00 -0100", + the current time zone is 8 hours ahead of UTC, and the min + time_t value is 1970-01-01 00:00:00 UTC. Then the min + localtime value is 1970-01-01 08:00:00, and mktime will + therefore fail on 1969-12-31 23:00:00. To work around the + problem, set the time zone to 1 hour behind UTC temporarily + by setting TZ="XXX1:00" and try mktime again. */ - long int time_zone = pc.time_zone; - long int abs_time_zone = time_zone < 0 ? - time_zone : time_zone; - long int abs_time_zone_hour = abs_time_zone / 60; - int abs_time_zone_min = abs_time_zone % 60; - char tz1buf[sizeof "XXX+0:00" - + sizeof pc.time_zone * CHAR_BIT / 3]; - if (!tz_was_altered) - tz0 = get_tz (tz0buf); - sprintf (tz1buf, "XXX%s%ld:%02d", "-" + (time_zone < 0), - abs_time_zone_hour, abs_time_zone_min); - if (setenv ("TZ", tz1buf, 1) != 0) - goto fail; - tz_was_altered = true; - tm = tm0; - Start = mktime (&tm); - if (! mktime_ok (&tm0, &tm, Start)) - goto fail; - } - } + long int time_zone = pc.time_zone; + long int abs_time_zone = time_zone < 0 ? - time_zone : time_zone; + long int abs_time_zone_hour = abs_time_zone / 60; + int abs_time_zone_min = abs_time_zone % 60; + char tz1buf[sizeof "XXX+0:00" + + sizeof pc.time_zone * CHAR_BIT / 3]; + if (!tz_was_altered) + tz0 = get_tz (tz0buf); + sprintf (tz1buf, "XXX%s%ld:%02d", "-" + (time_zone < 0), + abs_time_zone_hour, abs_time_zone_min); + if (setenv ("TZ", tz1buf, 1) != 0) + goto fail; + tz_was_altered = true; + tm = tm0; + Start = mktime (&tm); + if (! mktime_ok (&tm0, &tm, Start)) + goto fail; + } + } if (pc.days_seen && ! pc.dates_seen) - { - tm.tm_mday += ((pc.day_number - tm.tm_wday + 7) % 7 - + 7 * (pc.day_ordinal - - (0 < pc.day_ordinal - && tm.tm_wday != pc.day_number))); - tm.tm_isdst = -1; - Start = mktime (&tm); - if (Start == (time_t) -1) - goto fail; - } + { + tm.tm_mday += ((pc.day_number - tm.tm_wday + 7) % 7 + + 7 * (pc.day_ordinal + - (0 < pc.day_ordinal + && tm.tm_wday != pc.day_number))); + tm.tm_isdst = -1; + Start = mktime (&tm); + if (Start == (time_t) -1) + goto fail; + } /* Add relative date. */ if (pc.rel.year | pc.rel.month | pc.rel.day) - { - int year = tm.tm_year + pc.rel.year; - int month = tm.tm_mon + pc.rel.month; - int day = tm.tm_mday + pc.rel.day; - if (((year < tm.tm_year) ^ (pc.rel.year < 0)) - | ((month < tm.tm_mon) ^ (pc.rel.month < 0)) - | ((day < tm.tm_mday) ^ (pc.rel.day < 0))) - goto fail; - tm.tm_year = year; - tm.tm_mon = month; - tm.tm_mday = day; - tm.tm_hour = tm0.tm_hour; - tm.tm_min = tm0.tm_min; - tm.tm_sec = tm0.tm_sec; - tm.tm_isdst = tm0.tm_isdst; - Start = mktime (&tm); - if (Start == (time_t) -1) - goto fail; - } + { + int year = tm.tm_year + pc.rel.year; + int month = tm.tm_mon + pc.rel.month; + int day = tm.tm_mday + pc.rel.day; + if (((year < tm.tm_year) ^ (pc.rel.year < 0)) + | ((month < tm.tm_mon) ^ (pc.rel.month < 0)) + | ((day < tm.tm_mday) ^ (pc.rel.day < 0))) + goto fail; + tm.tm_year = year; + tm.tm_mon = month; + tm.tm_mday = day; + tm.tm_hour = tm0.tm_hour; + tm.tm_min = tm0.tm_min; + tm.tm_sec = tm0.tm_sec; + tm.tm_isdst = tm0.tm_isdst; + Start = mktime (&tm); + if (Start == (time_t) -1) + goto fail; + } /* The only "output" of this if-block is an updated Start value, - so this block must follow others that clobber Start. */ + so this block must follow others that clobber Start. */ if (pc.zones_seen) - { - long int delta = pc.time_zone * 60; - time_t t1; + { + long int delta = pc.time_zone * 60; + time_t t1; #ifdef HAVE_TM_GMTOFF - delta -= tm.tm_gmtoff; + delta -= tm.tm_gmtoff; #else - time_t t = Start; - struct tm const *gmt = gmtime (&t); - if (! gmt) - goto fail; - delta -= tm_diff (&tm, gmt); + time_t t = Start; + struct tm const *gmt = gmtime (&t); + if (! gmt) + goto fail; + delta -= tm_diff (&tm, gmt); #endif - t1 = Start - delta; - if ((Start < t1) != (delta < 0)) - goto fail; /* time_t overflow */ - Start = t1; - } + t1 = Start - delta; + if ((Start < t1) != (delta < 0)) + goto fail; /* time_t overflow */ + Start = t1; + } /* Add relative hours, minutes, and seconds. On hosts that support - leap seconds, ignore the possibility of leap seconds; e.g., - "+ 10 minutes" adds 600 seconds, even if one of them is a - leap second. Typically this is not what the user wants, but it's - too hard to do it the other way, because the time zone indicator - must be applied before relative times, and if mktime is applied - again the time zone will be lost. */ + leap seconds, ignore the possibility of leap seconds; e.g., + "+ 10 minutes" adds 600 seconds, even if one of them is a + leap second. Typically this is not what the user wants, but it's + too hard to do it the other way, because the time zone indicator + must be applied before relative times, and if mktime is applied + again the time zone will be lost. */ { - long int sum_ns = pc.seconds.tv_nsec + pc.rel.ns; - long int normalized_ns = (sum_ns % BILLION + BILLION) % BILLION; - time_t t0 = Start; - long int d1 = 60 * 60 * pc.rel.hour; - time_t t1 = t0 + d1; - long int d2 = 60 * pc.rel.minutes; - time_t t2 = t1 + d2; - long int d3 = pc.rel.seconds; - time_t t3 = t2 + d3; - long int d4 = (sum_ns - normalized_ns) / BILLION; - time_t t4 = t3 + d4; + long int sum_ns = pc.seconds.tv_nsec + pc.rel.ns; + long int normalized_ns = (sum_ns % BILLION + BILLION) % BILLION; + time_t t0 = Start; + long int d1 = 60 * 60 * pc.rel.hour; + time_t t1 = t0 + d1; + long int d2 = 60 * pc.rel.minutes; + time_t t2 = t1 + d2; + long_time_t d3 = pc.rel.seconds; + long_time_t t3 = t2 + d3; + long int d4 = (sum_ns - normalized_ns) / BILLION; + long_time_t t4 = t3 + d4; + time_t t5 = t4; - if ((d1 / (60 * 60) ^ pc.rel.hour) - | (d2 / 60 ^ pc.rel.minutes) - | ((t1 < t0) ^ (d1 < 0)) - | ((t2 < t1) ^ (d2 < 0)) - | ((t3 < t2) ^ (d3 < 0)) - | ((t4 < t3) ^ (d4 < 0))) - goto fail; + if ((d1 / (60 * 60) ^ pc.rel.hour) + | (d2 / 60 ^ pc.rel.minutes) + | ((t1 < t0) ^ (d1 < 0)) + | ((t2 < t1) ^ (d2 < 0)) + | ((t3 < t2) ^ (d3 < 0)) + | ((t4 < t3) ^ (d4 < 0)) + | (t5 != t4)) + goto fail; - result->tv_sec = t4; - result->tv_nsec = normalized_ns; + result->tv_sec = t5; + result->tv_nsec = normalized_ns; } } @@ -3472,23 +3520,22 @@ main (int ac, char **av) struct timespec d; struct tm const *tm; if (! get_date (&d, buff, NULL)) - printf ("Bad format - couldn't convert.\n"); + printf ("Bad format - couldn't convert.\n"); else if (! (tm = localtime (&d.tv_sec))) - { - long int sec = d.tv_sec; - printf ("localtime (%ld) failed\n", sec); - } + { + long int sec = d.tv_sec; + printf ("localtime (%ld) failed\n", sec); + } else - { - int ns = d.tv_nsec; - printf ("%04ld-%02d-%02d %02d:%02d:%02d.%09d\n", - tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec, ns); - } + { + int ns = d.tv_nsec; + printf ("%04ld-%02d-%02d %02d:%02d:%02d.%09d\n", + tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec, ns); + } printf ("\t> "); fflush (stdout); } return 0; } #endif /* TEST */ - diff --git a/src/bin/coreutils/lib/getdate.h b/src/bin/coreutils/lib/getdate.h index 73b6188392..22cc2c02a3 100644 --- a/src/bin/coreutils/lib/getdate.h +++ b/src/bin/coreutils/lib/getdate.h @@ -1,6 +1,6 @@ /* Parse a string into an internal time stamp. - Copyright (C) 1995, 1997, 1998, 2003, 2004, 2007 Free Software + Copyright (C) 1995, 1997, 1998, 2003, 2004, 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/src/bin/coreutils/lib/getdate.y b/src/bin/coreutils/lib/getdate.y index 2f3c924134..e8c5233588 100644 --- a/src/bin/coreutils/lib/getdate.y +++ b/src/bin/coreutils/lib/getdate.y @@ -1,8 +1,8 @@ %{ /* Parse a string into an internal time stamp. - Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 - Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, + 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -78,16 +78,6 @@ of `digit' even when the host does not conform to POSIX. */ #define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9) -#ifndef __attribute__ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__ -# define __attribute__(x) -# endif -#endif - -#ifndef ATTRIBUTE_UNUSED -# define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) -#endif - /* Shift A right by B bits portably, by dividing A by 2**B and truncating towards minus infinity. A and B should be free of side effects, and B should be in the range 0 <= B <= INT_BITS - 2, where @@ -98,9 +88,9 @@ implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift right in the usual way when A < 0, so SHR falls back on division if ordinary A >> B doesn't seem to be the usual signed shift. */ -#define SHR(a, b) \ - (-1 >> 1 == -1 \ - ? (a) >> (b) \ +#define SHR(a, b) \ + (-1 >> 1 == -1 \ + ? (a) >> (b) \ : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0)) #define EPOCH_YEAR 1970 @@ -108,12 +98,21 @@ #define HOUR(x) ((x) * 60) -/* Lots of this code assumes time_t and time_t-like values fit into - long int. It also assumes that signed integer overflow silently - wraps around, but there's no portable way to check for that at - compile-time. */ +/* long_time_t is a signed integer type that contains all time_t values. */ verify (TYPE_IS_INTEGER (time_t)); -verify (LONG_MIN <= TYPE_MINIMUM (time_t) && TYPE_MAXIMUM (time_t) <= LONG_MAX); +#if TIME_T_FITS_IN_LONG_INT +typedef long int long_time_t; +#else +typedef time_t long_time_t; +#endif + +/* Lots of this code assumes time_t and time_t-like values fit into + long_time_t. */ +verify (TYPE_MINIMUM (long_time_t) <= TYPE_MINIMUM (time_t) + && TYPE_MAXIMUM (time_t) <= TYPE_MAXIMUM (long_time_t)); + +/* FIXME: It also assumes that signed integer overflow silently wraps around, + but this is not true any more with recent versions of GCC 4. */ /* An integer value, and the number of digits in its textual representation. */ @@ -146,7 +145,7 @@ typedef struct long int day; long int hour; long int minutes; - long int seconds; + long_time_t seconds; long int ns; } relative_time; @@ -219,30 +218,30 @@ digits_to_date_time (parser_control *pc, textint text_int) else { if (4 < text_int.digits) - { - pc->dates_seen++; - pc->day = text_int.value % 100; - pc->month = (text_int.value / 100) % 100; - pc->year.value = text_int.value / 10000; - pc->year.digits = text_int.digits - 4; - } + { + pc->dates_seen++; + pc->day = text_int.value % 100; + pc->month = (text_int.value / 100) % 100; + pc->year.value = text_int.value / 10000; + pc->year.digits = text_int.digits - 4; + } else - { - pc->times_seen++; - if (text_int.digits <= 2) - { - pc->hour = text_int.value; - pc->minutes = 0; - } - else - { - pc->hour = text_int.value / 100; - pc->minutes = text_int.value % 100; - } - pc->seconds.tv_sec = 0; - pc->seconds.tv_nsec = 0; - pc->meridian = MER24; - } + { + pc->times_seen++; + if (text_int.digits <= 2) + { + pc->hour = text_int.value; + pc->minutes = 0; + } + else + { + pc->hour = text_int.value / 100; + pc->minutes = text_int.value % 100; + } + pc->seconds.tv_sec = 0; + pc->seconds.tv_nsec = 0; + pc->meridian = MER24; + } } } @@ -263,7 +262,7 @@ apply_relative_time (parser_control *pc, relative_time rel, int factor) /* Set PC-> hour, minutes, seconds and nanoseconds members from arguments. */ static void set_hhmmss (parser_control *pc, long int hour, long int minutes, - time_t sec, long int nsec) + time_t sec, long int nsec) { pc->hour = hour; pc->minutes = minutes; @@ -316,8 +315,8 @@ spec: timespec: '@' seconds { - pc->seconds = $2; - pc->timespec_seen = true; + pc->seconds = $2; + pc->timespec_seen = true; } ; @@ -345,45 +344,45 @@ item: time: tUNUMBER tMERIDIAN { - set_hhmmss (pc, $1.value, 0, 0, 0); - pc->meridian = $2; + set_hhmmss (pc, $1.value, 0, 0, 0); + pc->meridian = $2; } | tUNUMBER ':' tUNUMBER o_merid { - set_hhmmss (pc, $1.value, $3.value, 0, 0); - pc->meridian = $4; + set_hhmmss (pc, $1.value, $3.value, 0, 0); + pc->meridian = $4; } | tUNUMBER ':' tUNUMBER tSNUMBER o_colon_minutes { - set_hhmmss (pc, $1.value, $3.value, 0, 0); - pc->meridian = MER24; - pc->zones_seen++; - pc->time_zone = time_zone_hhmm (pc, $4, $5); + set_hhmmss (pc, $1.value, $3.value, 0, 0); + pc->meridian = MER24; + pc->zones_seen++; + pc->time_zone = time_zone_hhmm (pc, $4, $5); } | tUNUMBER ':' tUNUMBER ':' unsigned_seconds o_merid { - set_hhmmss (pc, $1.value, $3.value, $5.tv_sec, $5.tv_nsec); - pc->meridian = $6; + set_hhmmss (pc, $1.value, $3.value, $5.tv_sec, $5.tv_nsec); + pc->meridian = $6; } | tUNUMBER ':' tUNUMBER ':' unsigned_seconds tSNUMBER o_colon_minutes { - set_hhmmss (pc, $1.value, $3.value, $5.tv_sec, $5.tv_nsec); - pc->meridian = MER24; - pc->zones_seen++; - pc->time_zone = time_zone_hhmm (pc, $6, $7); + set_hhmmss (pc, $1.value, $3.value, $5.tv_sec, $5.tv_nsec); + pc->meridian = MER24; + pc->zones_seen++; + pc->time_zone = time_zone_hhmm (pc, $6, $7); } ; local_zone: tLOCAL_ZONE { - pc->local_isdst = $1; - pc->dsts_seen += (0 < $1); + pc->local_isdst = $1; + pc->dsts_seen += (0 < $1); } | tLOCAL_ZONE tDST { - pc->local_isdst = 1; - pc->dsts_seen += (0 < $1) + 1; + pc->local_isdst = 1; + pc->dsts_seen += (0 < $1) + 1; } ; @@ -392,7 +391,7 @@ zone: { pc->time_zone = $1; } | tZONE relunit_snumber { pc->time_zone = $1; - apply_relative_time (pc, $2, 1); } + apply_relative_time (pc, $2, 1); } | tZONE tSNUMBER o_colon_minutes { pc->time_zone = $1 + time_zone_hhmm (pc, $2, $3); } | tDAYZONE @@ -404,96 +403,96 @@ zone: day: tDAY { - pc->day_ordinal = 0; - pc->day_number = $1; + pc->day_ordinal = 0; + pc->day_number = $1; } | tDAY ',' { - pc->day_ordinal = 0; - pc->day_number = $1; + pc->day_ordinal = 0; + pc->day_number = $1; } | tORDINAL tDAY { - pc->day_ordinal = $1; - pc->day_number = $2; + pc->day_ordinal = $1; + pc->day_number = $2; } | tUNUMBER tDAY { - pc->day_ordinal = $1.value; - pc->day_number = $2; + pc->day_ordinal = $1.value; + pc->day_number = $2; } ; date: tUNUMBER '/' tUNUMBER { - pc->month = $1.value; - pc->day = $3.value; + pc->month = $1.value; + pc->day = $3.value; } | tUNUMBER '/' tUNUMBER '/' tUNUMBER { - /* Interpret as YYYY/MM/DD if the first value has 4 or more digits, - otherwise as MM/DD/YY. - The goal in recognizing YYYY/MM/DD is solely to support legacy - machine-generated dates like those in an RCS log listing. If - you want portability, use the ISO 8601 format. */ - if (4 <= $1.digits) - { - pc->year = $1; - pc->month = $3.value; - pc->day = $5.value; - } - else - { - pc->month = $1.value; - pc->day = $3.value; - pc->year = $5; - } + /* Interpret as YYYY/MM/DD if the first value has 4 or more digits, + otherwise as MM/DD/YY. + The goal in recognizing YYYY/MM/DD is solely to support legacy + machine-generated dates like those in an RCS log listing. If + you want portability, use the ISO 8601 format. */ + if (4 <= $1.digits) + { + pc->year = $1; + pc->month = $3.value; + pc->day = $5.value; + } + else + { + pc->month = $1.value; + pc->day = $3.value; + pc->year = $5; + } } | tUNUMBER tSNUMBER tSNUMBER { - /* ISO 8601 format. YYYY-MM-DD. */ - pc->year = $1; - pc->month = -$2.value; - pc->day = -$3.value; + /* ISO 8601 format. YYYY-MM-DD. */ + pc->year = $1; + pc->month = -$2.value; + pc->day = -$3.value; } | tUNUMBER tMONTH tSNUMBER { - /* e.g. 17-JUN-1992. */ - pc->day = $1.value; - pc->month = $2; - pc->year.value = -$3.value; - pc->year.digits = $3.digits; + /* e.g. 17-JUN-1992. */ + pc->day = $1.value; + pc->month = $2; + pc->year.value = -$3.value; + pc->year.digits = $3.digits; } | tMONTH tSNUMBER tSNUMBER { - /* e.g. JUN-17-1992. */ - pc->month = $1; - pc->day = -$2.value; - pc->year.value = -$3.value; - pc->year.digits = $3.digits; + /* e.g. JUN-17-1992. */ + pc->month = $1; + pc->day = -$2.value; + pc->year.value = -$3.value; + pc->year.digits = $3.digits; } | tMONTH tUNUMBER { - pc->month = $1; - pc->day = $2.value; + pc->month = $1; + pc->day = $2.value; } | tMONTH tUNUMBER ',' tUNUMBER { - pc->month = $1; - pc->day = $2.value; - pc->year = $4; + pc->month = $1; + pc->day = $2.value; + pc->year = $4; } | tUNUMBER tMONTH { - pc->day = $1.value; - pc->month = $2; + pc->day = $1.value; + pc->month = $2; } | tUNUMBER tMONTH tUNUMBER { - pc->day = $1.value; - pc->month = $2; - pc->year = $3; + pc->day = $1.value; + pc->month = $2; + pc->year = $3; } ; @@ -592,10 +591,10 @@ number: hybrid: tUNUMBER relunit_snumber { - /* Hybrid all-digit and relative offset, so that we accept e.g., - "YYYYMMDD +N days" as well as "YYYYMMDD N days". */ - digits_to_date_time (pc, $1); - apply_relative_time (pc, $2, 1); + /* Hybrid all-digit and relative offset, so that we accept e.g., + "YYYYMMDD +N days" as well as "YYYYMMDD N days". */ + digits_to_date_time (pc, $1); + apply_relative_time (pc, $2, 1); } ; @@ -631,71 +630,71 @@ static table const dst_table[] = static table const month_and_day_table[] = { - { "JANUARY", tMONTH, 1 }, - { "FEBRUARY", tMONTH, 2 }, - { "MARCH", tMONTH, 3 }, - { "APRIL", tMONTH, 4 }, - { "MAY", tMONTH, 5 }, - { "JUNE", tMONTH, 6 }, - { "JULY", tMONTH, 7 }, - { "AUGUST", tMONTH, 8 }, - { "SEPTEMBER",tMONTH, 9 }, - { "SEPT", tMONTH, 9 }, - { "OCTOBER", tMONTH, 10 }, - { "NOVEMBER", tMONTH, 11 }, - { "DECEMBER", tMONTH, 12 }, - { "SUNDAY", tDAY, 0 }, - { "MONDAY", tDAY, 1 }, - { "TUESDAY", tDAY, 2 }, - { "TUES", tDAY, 2 }, - { "WEDNESDAY",tDAY, 3 }, - { "WEDNES", tDAY, 3 }, - { "THURSDAY", tDAY, 4 }, - { "THUR", tDAY, 4 }, - { "THURS", tDAY, 4 }, - { "FRIDAY", tDAY, 5 }, - { "SATURDAY", tDAY, 6 }, + { "JANUARY", tMONTH, 1 }, + { "FEBRUARY", tMONTH, 2 }, + { "MARCH", tMONTH, 3 }, + { "APRIL", tMONTH, 4 }, + { "MAY", tMONTH, 5 }, + { "JUNE", tMONTH, 6 }, + { "JULY", tMONTH, 7 }, + { "AUGUST", tMONTH, 8 }, + { "SEPTEMBER",tMONTH, 9 }, + { "SEPT", tMONTH, 9 }, + { "OCTOBER", tMONTH, 10 }, + { "NOVEMBER", tMONTH, 11 }, + { "DECEMBER", tMONTH, 12 }, + { "SUNDAY", tDAY, 0 }, + { "MONDAY", tDAY, 1 }, + { "TUESDAY", tDAY, 2 }, + { "TUES", tDAY, 2 }, + { "WEDNESDAY",tDAY, 3 }, + { "WEDNES", tDAY, 3 }, + { "THURSDAY", tDAY, 4 }, + { "THUR", tDAY, 4 }, + { "THURS", tDAY, 4 }, + { "FRIDAY", tDAY, 5 }, + { "SATURDAY", tDAY, 6 }, { NULL, 0, 0 } }; static table const time_units_table[] = { - { "YEAR", tYEAR_UNIT, 1 }, - { "MONTH", tMONTH_UNIT, 1 }, - { "FORTNIGHT",tDAY_UNIT, 14 }, - { "WEEK", tDAY_UNIT, 7 }, - { "DAY", tDAY_UNIT, 1 }, - { "HOUR", tHOUR_UNIT, 1 }, - { "MINUTE", tMINUTE_UNIT, 1 }, - { "MIN", tMINUTE_UNIT, 1 }, - { "SECOND", tSEC_UNIT, 1 }, - { "SEC", tSEC_UNIT, 1 }, + { "YEAR", tYEAR_UNIT, 1 }, + { "MONTH", tMONTH_UNIT, 1 }, + { "FORTNIGHT",tDAY_UNIT, 14 }, + { "WEEK", tDAY_UNIT, 7 }, + { "DAY", tDAY_UNIT, 1 }, + { "HOUR", tHOUR_UNIT, 1 }, + { "MINUTE", tMINUTE_UNIT, 1 }, + { "MIN", tMINUTE_UNIT, 1 }, + { "SECOND", tSEC_UNIT, 1 }, + { "SEC", tSEC_UNIT, 1 }, { NULL, 0, 0 } }; /* Assorted relative-time words. */ static table const relative_time_table[] = { - { "TOMORROW", tDAY_SHIFT, 1 }, - { "YESTERDAY",tDAY_SHIFT, -1 }, - { "TODAY", tDAY_SHIFT, 0 }, - { "NOW", tDAY_SHIFT, 0 }, - { "LAST", tORDINAL, -1 }, - { "THIS", tORDINAL, 0 }, - { "NEXT", tORDINAL, 1 }, - { "FIRST", tORDINAL, 1 }, -/*{ "SECOND", tORDINAL, 2 }, */ - { "THIRD", tORDINAL, 3 }, - { "FOURTH", tORDINAL, 4 }, - { "FIFTH", tORDINAL, 5 }, - { "SIXTH", tORDINAL, 6 }, - { "SEVENTH", tORDINAL, 7 }, - { "EIGHTH", tORDINAL, 8 }, - { "NINTH", tORDINAL, 9 }, - { "TENTH", tORDINAL, 10 }, - { "ELEVENTH", tORDINAL, 11 }, - { "TWELFTH", tORDINAL, 12 }, - { "AGO", tAGO, 1 }, + { "TOMORROW", tDAY_SHIFT, 1 }, + { "YESTERDAY",tDAY_SHIFT, -1 }, + { "TODAY", tDAY_SHIFT, 0 }, + { "NOW", tDAY_SHIFT, 0 }, + { "LAST", tORDINAL, -1 }, + { "THIS", tORDINAL, 0 }, + { "NEXT", tORDINAL, 1 }, + { "FIRST", tORDINAL, 1 }, +/*{ "SECOND", tORDINAL, 2 }, */ + { "THIRD", tORDINAL, 3 }, + { "FOURTH", tORDINAL, 4 }, + { "FIFTH", tORDINAL, 5 }, + { "SIXTH", tORDINAL, 6 }, + { "SEVENTH", tORDINAL, 7 }, + { "EIGHTH", tORDINAL, 8 }, + { "NINTH", tORDINAL, 9 }, + { "TENTH", tORDINAL, 10 }, + { "ELEVENTH", tORDINAL, 11 }, + { "TWELFTH", tORDINAL, 12 }, + { "AGO", tAGO, 1 }, { NULL, 0, 0 } }; @@ -704,9 +703,9 @@ static table const relative_time_table[] = stamps in London during summer. */ static table const universal_time_zone_table[] = { - { "GMT", tZONE, HOUR ( 0) }, /* Greenwich Mean */ - { "UT", tZONE, HOUR ( 0) }, /* Universal (Coordinated) */ - { "UTC", tZONE, HOUR ( 0) }, + { "GMT", tZONE, HOUR ( 0) }, /* Greenwich Mean */ + { "UT", tZONE, HOUR ( 0) }, /* Universal (Coordinated) */ + { "UTC", tZONE, HOUR ( 0) }, { NULL, 0, 0 } }; @@ -717,84 +716,84 @@ static table const universal_time_zone_table[] = abbreviations; use numeric abbreviations like `-0500' instead. */ static table const time_zone_table[] = { - { "WET", tZONE, HOUR ( 0) }, /* Western European */ - { "WEST", tDAYZONE, HOUR ( 0) }, /* Western European Summer */ - { "BST", tDAYZONE, HOUR ( 0) }, /* British Summer */ - { "ART", tZONE, -HOUR ( 3) }, /* Argentina */ - { "BRT", tZONE, -HOUR ( 3) }, /* Brazil */ - { "BRST", tDAYZONE, -HOUR ( 3) }, /* Brazil Summer */ - { "NST", tZONE, -(HOUR ( 3) + 30) }, /* Newfoundland Standard */ - { "NDT", tDAYZONE,-(HOUR ( 3) + 30) }, /* Newfoundland Daylight */ - { "AST", tZONE, -HOUR ( 4) }, /* Atlantic Standard */ - { "ADT", tDAYZONE, -HOUR ( 4) }, /* Atlantic Daylight */ - { "CLT", tZONE, -HOUR ( 4) }, /* Chile */ - { "CLST", tDAYZONE, -HOUR ( 4) }, /* Chile Summer */ - { "EST", tZONE, -HOUR ( 5) }, /* Eastern Standard */ - { "EDT", tDAYZONE, -HOUR ( 5) }, /* Eastern Daylight */ - { "CST", tZONE, -HOUR ( 6) }, /* Central Standard */ - { "CDT", tDAYZONE, -HOUR ( 6) }, /* Central Daylight */ - { "MST", tZONE, -HOUR ( 7) }, /* Mountain Standard */ - { "MDT", tDAYZONE, -HOUR ( 7) }, /* Mountain Daylight */ - { "PST", tZONE, -HOUR ( 8) }, /* Pacific Standard */ - { "PDT", tDAYZONE, -HOUR ( 8) }, /* Pacific Daylight */ - { "AKST", tZONE, -HOUR ( 9) }, /* Alaska Standard */ - { "AKDT", tDAYZONE, -HOUR ( 9) }, /* Alaska Daylight */ - { "HST", tZONE, -HOUR (10) }, /* Hawaii Standard */ - { "HAST", tZONE, -HOUR (10) }, /* Hawaii-Aleutian Standard */ - { "HADT", tDAYZONE, -HOUR (10) }, /* Hawaii-Aleutian Daylight */ - { "SST", tZONE, -HOUR (12) }, /* Samoa Standard */ - { "WAT", tZONE, HOUR ( 1) }, /* West Africa */ - { "CET", tZONE, HOUR ( 1) }, /* Central European */ - { "CEST", tDAYZONE, HOUR ( 1) }, /* Central European Summer */ - { "MET", tZONE, HOUR ( 1) }, /* Middle European */ - { "MEZ", tZONE, HOUR ( 1) }, /* Middle European */ - { "MEST", tDAYZONE, HOUR ( 1) }, /* Middle European Summer */ - { "MESZ", tDAYZONE, HOUR ( 1) }, /* Middle European Summer */ - { "EET", tZONE, HOUR ( 2) }, /* Eastern European */ - { "EEST", tDAYZONE, HOUR ( 2) }, /* Eastern European Summer */ - { "CAT", tZONE, HOUR ( 2) }, /* Central Africa */ - { "SAST", tZONE, HOUR ( 2) }, /* South Africa Standard */ - { "EAT", tZONE, HOUR ( 3) }, /* East Africa */ - { "MSK", tZONE, HOUR ( 3) }, /* Moscow */ - { "MSD", tDAYZONE, HOUR ( 3) }, /* Moscow Daylight */ - { "IST", tZONE, (HOUR ( 5) + 30) }, /* India Standard */ - { "SGT", tZONE, HOUR ( 8) }, /* Singapore */ - { "KST", tZONE, HOUR ( 9) }, /* Korea Standard */ - { "JST", tZONE, HOUR ( 9) }, /* Japan Standard */ - { "GST", tZONE, HOUR (10) }, /* Guam Standard */ - { "NZST", tZONE, HOUR (12) }, /* New Zealand Standard */ - { "NZDT", tDAYZONE, HOUR (12) }, /* New Zealand Daylight */ + { "WET", tZONE, HOUR ( 0) }, /* Western European */ + { "WEST", tDAYZONE, HOUR ( 0) }, /* Western European Summer */ + { "BST", tDAYZONE, HOUR ( 0) }, /* British Summer */ + { "ART", tZONE, -HOUR ( 3) }, /* Argentina */ + { "BRT", tZONE, -HOUR ( 3) }, /* Brazil */ + { "BRST", tDAYZONE, -HOUR ( 3) }, /* Brazil Summer */ + { "NST", tZONE, -(HOUR ( 3) + 30) }, /* Newfoundland Standard */ + { "NDT", tDAYZONE,-(HOUR ( 3) + 30) }, /* Newfoundland Daylight */ + { "AST", tZONE, -HOUR ( 4) }, /* Atlantic Standard */ + { "ADT", tDAYZONE, -HOUR ( 4) }, /* Atlantic Daylight */ + { "CLT", tZONE, -HOUR ( 4) }, /* Chile */ + { "CLST", tDAYZONE, -HOUR ( 4) }, /* Chile Summer */ + { "EST", tZONE, -HOUR ( 5) }, /* Eastern Standard */ + { "EDT", tDAYZONE, -HOUR ( 5) }, /* Eastern Daylight */ + { "CST", tZONE, -HOUR ( 6) }, /* Central Standard */ + { "CDT", tDAYZONE, -HOUR ( 6) }, /* Central Daylight */ + { "MST", tZONE, -HOUR ( 7) }, /* Mountain Standard */ + { "MDT", tDAYZONE, -HOUR ( 7) }, /* Mountain Daylight */ + { "PST", tZONE, -HOUR ( 8) }, /* Pacific Standard */ + { "PDT", tDAYZONE, -HOUR ( 8) }, /* Pacific Daylight */ + { "AKST", tZONE, -HOUR ( 9) }, /* Alaska Standard */ + { "AKDT", tDAYZONE, -HOUR ( 9) }, /* Alaska Daylight */ + { "HST", tZONE, -HOUR (10) }, /* Hawaii Standard */ + { "HAST", tZONE, -HOUR (10) }, /* Hawaii-Aleutian Standard */ + { "HADT", tDAYZONE, -HOUR (10) }, /* Hawaii-Aleutian Daylight */ + { "SST", tZONE, -HOUR (12) }, /* Samoa Standard */ + { "WAT", tZONE, HOUR ( 1) }, /* West Africa */ + { "CET", tZONE, HOUR ( 1) }, /* Central European */ + { "CEST", tDAYZONE, HOUR ( 1) }, /* Central European Summer */ + { "MET", tZONE, HOUR ( 1) }, /* Middle European */ + { "MEZ", tZONE, HOUR ( 1) }, /* Middle European */ + { "MEST", tDAYZONE, HOUR ( 1) }, /* Middle European Summer */ + { "MESZ", tDAYZONE, HOUR ( 1) }, /* Middle European Summer */ + { "EET", tZONE, HOUR ( 2) }, /* Eastern European */ + { "EEST", tDAYZONE, HOUR ( 2) }, /* Eastern European Summer */ + { "CAT", tZONE, HOUR ( 2) }, /* Central Africa */ + { "SAST", tZONE, HOUR ( 2) }, /* South Africa Standard */ + { "EAT", tZONE, HOUR ( 3) }, /* East Africa */ + { "MSK", tZONE, HOUR ( 3) }, /* Moscow */ + { "MSD", tDAYZONE, HOUR ( 3) }, /* Moscow Daylight */ + { "IST", tZONE, (HOUR ( 5) + 30) }, /* India Standard */ + { "SGT", tZONE, HOUR ( 8) }, /* Singapore */ + { "KST", tZONE, HOUR ( 9) }, /* Korea Standard */ + { "JST", tZONE, HOUR ( 9) }, /* Japan Standard */ + { "GST", tZONE, HOUR (10) }, /* Guam Standard */ + { "NZST", tZONE, HOUR (12) }, /* New Zealand Standard */ + { "NZDT", tDAYZONE, HOUR (12) }, /* New Zealand Daylight */ { NULL, 0, 0 } }; /* Military time zone table. */ static table const military_table[] = { - { "A", tZONE, -HOUR ( 1) }, - { "B", tZONE, -HOUR ( 2) }, - { "C", tZONE, -HOUR ( 3) }, - { "D", tZONE, -HOUR ( 4) }, - { "E", tZONE, -HOUR ( 5) }, - { "F", tZONE, -HOUR ( 6) }, - { "G", tZONE, -HOUR ( 7) }, - { "H", tZONE, -HOUR ( 8) }, - { "I", tZONE, -HOUR ( 9) }, - { "K", tZONE, -HOUR (10) }, - { "L", tZONE, -HOUR (11) }, - { "M", tZONE, -HOUR (12) }, - { "N", tZONE, HOUR ( 1) }, - { "O", tZONE, HOUR ( 2) }, - { "P", tZONE, HOUR ( 3) }, - { "Q", tZONE, HOUR ( 4) }, - { "R", tZONE, HOUR ( 5) }, - { "S", tZONE, HOUR ( 6) }, - { "T", tZONE, HOUR ( 7) }, - { "U", tZONE, HOUR ( 8) }, - { "V", tZONE, HOUR ( 9) }, - { "W", tZONE, HOUR (10) }, - { "X", tZONE, HOUR (11) }, - { "Y", tZONE, HOUR (12) }, - { "Z", tZONE, HOUR ( 0) }, + { "A", tZONE, -HOUR ( 1) }, + { "B", tZONE, -HOUR ( 2) }, + { "C", tZONE, -HOUR ( 3) }, + { "D", tZONE, -HOUR ( 4) }, + { "E", tZONE, -HOUR ( 5) }, + { "F", tZONE, -HOUR ( 6) }, + { "G", tZONE, -HOUR ( 7) }, + { "H", tZONE, -HOUR ( 8) }, + { "I", tZONE, -HOUR ( 9) }, + { "K", tZONE, -HOUR (10) }, + { "L", tZONE, -HOUR (11) }, + { "M", tZONE, -HOUR (12) }, + { "N", tZONE, HOUR ( 1) }, + { "O", tZONE, HOUR ( 2) }, + { "P", tZONE, HOUR ( 3) }, + { "Q", tZONE, HOUR ( 4) }, + { "R", tZONE, HOUR ( 5) }, + { "S", tZONE, HOUR ( 6) }, + { "T", tZONE, HOUR ( 7) }, + { "U", tZONE, HOUR ( 8) }, + { "V", tZONE, HOUR ( 9) }, + { "W", tZONE, HOUR (10) }, + { "X", tZONE, HOUR (11) }, + { "Y", tZONE, HOUR (12) }, + { "Z", tZONE, HOUR ( 0) }, { NULL, 0, 0 } }; @@ -904,10 +903,10 @@ tm_diff (struct tm const *a, struct tm const *b) long int ayear = a->tm_year; long int years = ayear - b->tm_year; long int days = (365 * years + intervening_leap_days - + (a->tm_yday - b->tm_yday)); + + (a->tm_yday - b->tm_yday)); return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour)) - + (a->tm_min - b->tm_min)) - + (a->tm_sec - b->tm_sec)); + + (a->tm_min - b->tm_min)) + + (a->tm_sec - b->tm_sec)); } #endif /* ! HAVE_TM_GMTOFF */ @@ -955,9 +954,9 @@ lookup_word (parser_control const *pc, char *word) { word[wordlen - 1] = '\0'; for (tp = time_units_table; tp->name; tp++) - if (strcmp (word, tp->name) == 0) - return tp; - word[wordlen - 1] = 'S'; /* For "this" in relative_time_table. */ + if (strcmp (word, tp->name) == 0) + return tp; + word[wordlen - 1] = 'S'; /* For "this" in relative_time_table. */ } for (tp = relative_time_table; tp->name; tp++) @@ -968,7 +967,7 @@ lookup_word (parser_control const *pc, char *word) if (wordlen == 1) for (tp = military_table; tp->name; tp++) if (word[0] == tp->name[0]) - return tp; + return tp; /* Drop out any periods and try the time zone table again. */ for (period_found = false, p = q = word; (*p = *q); q++) @@ -991,163 +990,163 @@ yylex (YYSTYPE *lvalp, parser_control *pc) for (;;) { while (c = *pc->input, c_isspace (c)) - pc->input++; + pc->input++; if (ISDIGIT (c) || c == '-' || c == '+') - { - char const *p; - int sign; - unsigned long int value; - if (c == '-' || c == '+') - { - sign = c == '-' ? -1 : 1; - while (c = *++pc->input, c_isspace (c)) - continue; - if (! ISDIGIT (c)) - /* skip the '-' sign */ - continue; - } - else - sign = 0; - p = pc->input; - for (value = 0; ; value *= 10) - { - unsigned long int value1 = value + (c - '0'); - if (value1 < value) - return '?'; - value = value1; - c = *++p; - if (! ISDIGIT (c)) - break; - if (ULONG_MAX / 10 < value) - return '?'; - } - if ((c == '.' || c == ',') && ISDIGIT (p[1])) - { - time_t s; - int ns; - int digits; - unsigned long int value1; + { + char const *p; + int sign; + unsigned long int value; + if (c == '-' || c == '+') + { + sign = c == '-' ? -1 : 1; + while (c = *++pc->input, c_isspace (c)) + continue; + if (! ISDIGIT (c)) + /* skip the '-' sign */ + continue; + } + else + sign = 0; + p = pc->input; + for (value = 0; ; value *= 10) + { + unsigned long int value1 = value + (c - '0'); + if (value1 < value) + return '?'; + value = value1; + c = *++p; + if (! ISDIGIT (c)) + break; + if (ULONG_MAX / 10 < value) + return '?'; + } + if ((c == '.' || c == ',') && ISDIGIT (p[1])) + { + time_t s; + int ns; + int digits; + unsigned long int value1; - /* Check for overflow when converting value to time_t. */ - if (sign < 0) - { - s = - value; - if (0 < s) - return '?'; - value1 = -s; - } - else - { - s = value; - if (s < 0) - return '?'; - value1 = s; - } - if (value != value1) - return '?'; + /* Check for overflow when converting value to time_t. */ + if (sign < 0) + { + s = - value; + if (0 < s) + return '?'; + value1 = -s; + } + else + { + s = value; + if (s < 0) + return '?'; + value1 = s; + } + if (value != value1) + return '?'; - /* Accumulate fraction, to ns precision. */ - p++; - ns = *p++ - '0'; - for (digits = 2; digits <= LOG10_BILLION; digits++) - { - ns *= 10; - if (ISDIGIT (*p)) - ns += *p++ - '0'; - } + /* Accumulate fraction, to ns precision. */ + p++; + ns = *p++ - '0'; + for (digits = 2; digits <= LOG10_BILLION; digits++) + { + ns *= 10; + if (ISDIGIT (*p)) + ns += *p++ - '0'; + } - /* Skip excess digits, truncating toward -Infinity. */ - if (sign < 0) - for (; ISDIGIT (*p); p++) - if (*p != '0') - { - ns++; - break; - } - while (ISDIGIT (*p)) - p++; + /* Skip excess digits, truncating toward -Infinity. */ + if (sign < 0) + for (; ISDIGIT (*p); p++) + if (*p != '0') + { + ns++; + break; + } + while (ISDIGIT (*p)) + p++; - /* Adjust to the timespec convention, which is that - tv_nsec is always a positive offset even if tv_sec is - negative. */ - if (sign < 0 && ns) - { - s--; - if (! (s < 0)) - return '?'; - ns = BILLION - ns; - } + /* Adjust to the timespec convention, which is that + tv_nsec is always a positive offset even if tv_sec is + negative. */ + if (sign < 0 && ns) + { + s--; + if (! (s < 0)) + return '?'; + ns = BILLION - ns; + } - lvalp->timespec.tv_sec = s; - lvalp->timespec.tv_nsec = ns; - pc->input = p; - return sign ? tSDECIMAL_NUMBER : tUDECIMAL_NUMBER; - } - else - { - lvalp->textintval.negative = sign < 0; - if (sign < 0) - { - lvalp->textintval.value = - value; - if (0 < lvalp->textintval.value) - return '?'; - } - else - { - lvalp->textintval.value = value; - if (lvalp->textintval.value < 0) - return '?'; - } - lvalp->textintval.digits = p - pc->input; - pc->input = p; - return sign ? tSNUMBER : tUNUMBER; - } - } + lvalp->timespec.tv_sec = s; + lvalp->timespec.tv_nsec = ns; + pc->input = p; + return sign ? tSDECIMAL_NUMBER : tUDECIMAL_NUMBER; + } + else + { + lvalp->textintval.negative = sign < 0; + if (sign < 0) + { + lvalp->textintval.value = - value; + if (0 < lvalp->textintval.value) + return '?'; + } + else + { + lvalp->textintval.value = value; + if (lvalp->textintval.value < 0) + return '?'; + } + lvalp->textintval.digits = p - pc->input; + pc->input = p; + return sign ? tSNUMBER : tUNUMBER; + } + } if (c_isalpha (c)) - { - char buff[20]; - char *p = buff; - table const *tp; + { + char buff[20]; + char *p = buff; + table const *tp; - do - { - if (p < buff + sizeof buff - 1) - *p++ = c; - c = *++pc->input; - } - while (c_isalpha (c) || c == '.'); + do + { + if (p < buff + sizeof buff - 1) + *p++ = c; + c = *++pc->input; + } + while (c_isalpha (c) || c == '.'); - *p = '\0'; - tp = lookup_word (pc, buff); - if (! tp) - return '?'; - lvalp->intval = tp->value; - return tp->type; - } + *p = '\0'; + tp = lookup_word (pc, buff); + if (! tp) + return '?'; + lvalp->intval = tp->value; + return tp->type; + } if (c != '(') - return *pc->input++; + return *pc->input++; count = 0; do - { - c = *pc->input++; - if (c == '\0') - return c; - if (c == '(') - count++; - else if (c == ')') - count--; - } + { + c = *pc->input++; + if (c == '\0') + return c; + if (c == '(') + count++; + else if (c == ')') + count--; + } while (count != 0); } } /* Do nothing if the parser reports an error. */ static int -yyerror (parser_control const *pc ATTRIBUTE_UNUSED, - char const *s ATTRIBUTE_UNUSED) +yyerror (parser_control const *pc _GL_UNUSED, + char const *s _GL_UNUSED) { return 0; } @@ -1162,19 +1161,19 @@ mktime_ok (struct tm const *tm0, struct tm const *tm1, time_t t) if (t == (time_t) -1) { /* Guard against falsely reporting an error when parsing a time - stamp that happens to equal (time_t) -1, on a host that - supports such a time stamp. */ + stamp that happens to equal (time_t) -1, on a host that + supports such a time stamp. */ tm1 = localtime (&t); if (!tm1) - return false; + return false; } return ! ((tm0->tm_sec ^ tm1->tm_sec) - | (tm0->tm_min ^ tm1->tm_min) - | (tm0->tm_hour ^ tm1->tm_hour) - | (tm0->tm_mday ^ tm1->tm_mday) - | (tm0->tm_mon ^ tm1->tm_mon) - | (tm0->tm_year ^ tm1->tm_year)); + | (tm0->tm_min ^ tm1->tm_min) + | (tm0->tm_hour ^ tm1->tm_hour) + | (tm0->tm_mday ^ tm1->tm_mday) + | (tm0->tm_mon ^ tm1->tm_mon) + | (tm0->tm_year ^ tm1->tm_year)); } /* A reasonable upper bound for the size of ordinary TZ strings. @@ -1191,8 +1190,8 @@ get_tz (char tzbuf[TZBUFSIZE]) { size_t tzsize = strlen (tz) + 1; tz = (tzsize <= TZBUFSIZE - ? memcpy (tzbuf, tz, tzsize) - : xmemdup (tz, tzsize)); + ? memcpy (tzbuf, tz, tzsize) + : xmemdup (tz, tzsize)); } return tz; } @@ -1240,32 +1239,32 @@ get_date (struct timespec *result, char const *p, struct timespec const *now) char const *s; for (s = tzbase; *s; s++, tzsize++) - if (*s == '\\') - { - s++; - if (! (*s == '\\' || *s == '"')) - break; - } - else if (*s == '"') - { - char *z; - char *tz1; - char tz1buf[TZBUFSIZE]; - bool large_tz = TZBUFSIZE < tzsize; - bool setenv_ok; - tz0 = get_tz (tz0buf); - z = tz1 = large_tz ? xmalloc (tzsize) : tz1buf; - for (s = tzbase; *s != '"'; s++) - *z++ = *(s += *s == '\\'); - *z = '\0'; - setenv_ok = setenv ("TZ", tz1, 1) == 0; - if (large_tz) - free (tz1); - if (!setenv_ok) - goto fail; - tz_was_altered = true; - p = s + 1; - } + if (*s == '\\') + { + s++; + if (! (*s == '\\' || *s == '"')) + break; + } + else if (*s == '"') + { + char *z; + char *tz1; + char tz1buf[TZBUFSIZE]; + bool large_tz = TZBUFSIZE < tzsize; + bool setenv_ok; + tz0 = get_tz (tz0buf); + z = tz1 = large_tz ? xmalloc (tzsize) : tz1buf; + for (s = tzbase; *s != '"'; s++) + *z++ = *(s += *s == '\\'); + *z = '\0'; + setenv_ok = setenv ("TZ", tz1, 1) == 0; + if (large_tz) + free (tz1); + if (!setenv_ok) + goto fail; + tz_was_altered = true; + p = s + 1; + } } /* As documented, be careful to treat the empty string just like @@ -1309,19 +1308,19 @@ get_date (struct timespec *result, char const *p, struct timespec const *now) int quarter; for (quarter = 1; quarter <= 3; quarter++) { - time_t probe = Start + quarter * (90 * 24 * 60 * 60); - struct tm const *probe_tm = localtime (&probe); - if (probe_tm && probe_tm->tm_zone - && probe_tm->tm_isdst != pc.local_time_zone_table[0].value) - { - { - pc.local_time_zone_table[1].name = probe_tm->tm_zone; - pc.local_time_zone_table[1].type = tLOCAL_ZONE; - pc.local_time_zone_table[1].value = probe_tm->tm_isdst; - pc.local_time_zone_table[2].name = NULL; - } - break; - } + time_t probe = Start + quarter * (90 * 24 * 60 * 60); + struct tm const *probe_tm = localtime (&probe); + if (probe_tm && probe_tm->tm_zone + && probe_tm->tm_isdst != pc.local_time_zone_table[0].value) + { + { + pc.local_time_zone_table[1].name = probe_tm->tm_zone; + pc.local_time_zone_table[1].type = tLOCAL_ZONE; + pc.local_time_zone_table[1].value = probe_tm->tm_isdst; + pc.local_time_zone_table[2].name = NULL; + } + break; + } } } #else @@ -1333,9 +1332,9 @@ get_date (struct timespec *result, char const *p, struct timespec const *now) int i; for (i = 0; i < 2; i++) { - pc.local_time_zone_table[i].name = tzname[i]; - pc.local_time_zone_table[i].type = tLOCAL_ZONE; - pc.local_time_zone_table[i].value = i; + pc.local_time_zone_table[i].name = tzname[i]; + pc.local_time_zone_table[i].type = tLOCAL_ZONE; + pc.local_time_zone_table[i].value = i; } pc.local_time_zone_table[i].name = NULL; } @@ -1346,11 +1345,11 @@ get_date (struct timespec *result, char const *p, struct timespec const *now) if (pc.local_time_zone_table[0].name && pc.local_time_zone_table[1].name && ! strcmp (pc.local_time_zone_table[0].name, - pc.local_time_zone_table[1].name)) + pc.local_time_zone_table[1].name)) { /* This locale uses the same abbrevation for standard and - daylight times. So if we see that abbreviation, we don't - know whether it's daylight time. */ + daylight times. So if we see that abbreviation, we don't + know whether it's daylight time. */ pc.local_time_zone_table[0].value = -1; pc.local_time_zone_table[1].name = NULL; } @@ -1363,160 +1362,162 @@ get_date (struct timespec *result, char const *p, struct timespec const *now) else { if (1 < (pc.times_seen | pc.dates_seen | pc.days_seen | pc.dsts_seen - | (pc.local_zones_seen + pc.zones_seen))) - goto fail; + | (pc.local_zones_seen + pc.zones_seen))) + goto fail; tm.tm_year = to_year (pc.year) - TM_YEAR_BASE; tm.tm_mon = pc.month - 1; tm.tm_mday = pc.day; if (pc.times_seen || (pc.rels_seen && ! pc.dates_seen && ! pc.days_seen)) - { - tm.tm_hour = to_hour (pc.hour, pc.meridian); - if (tm.tm_hour < 0) - goto fail; - tm.tm_min = pc.minutes; - tm.tm_sec = pc.seconds.tv_sec; - } + { + tm.tm_hour = to_hour (pc.hour, pc.meridian); + if (tm.tm_hour < 0) + goto fail; + tm.tm_min = pc.minutes; + tm.tm_sec = pc.seconds.tv_sec; + } else - { - tm.tm_hour = tm.tm_min = tm.tm_sec = 0; - pc.seconds.tv_nsec = 0; - } + { + tm.tm_hour = tm.tm_min = tm.tm_sec = 0; + pc.seconds.tv_nsec = 0; + } /* Let mktime deduce tm_isdst if we have an absolute time stamp. */ if (pc.dates_seen | pc.days_seen | pc.times_seen) - tm.tm_isdst = -1; + tm.tm_isdst = -1; /* But if the input explicitly specifies local time with or without - DST, give mktime that information. */ + DST, give mktime that information. */ if (pc.local_zones_seen) - tm.tm_isdst = pc.local_isdst; + tm.tm_isdst = pc.local_isdst; tm0 = tm; Start = mktime (&tm); if (! mktime_ok (&tm0, &tm, Start)) - { - if (! pc.zones_seen) - goto fail; - else - { - /* Guard against falsely reporting errors near the time_t - boundaries when parsing times in other time zones. For - example, suppose the input string "1969-12-31 23:00:00 -0100", - the current time zone is 8 hours ahead of UTC, and the min - time_t value is 1970-01-01 00:00:00 UTC. Then the min - localtime value is 1970-01-01 08:00:00, and mktime will - therefore fail on 1969-12-31 23:00:00. To work around the - problem, set the time zone to 1 hour behind UTC temporarily - by setting TZ="XXX1:00" and try mktime again. */ + { + if (! pc.zones_seen) + goto fail; + else + { + /* Guard against falsely reporting errors near the time_t + boundaries when parsing times in other time zones. For + example, suppose the input string "1969-12-31 23:00:00 -0100", + the current time zone is 8 hours ahead of UTC, and the min + time_t value is 1970-01-01 00:00:00 UTC. Then the min + localtime value is 1970-01-01 08:00:00, and mktime will + therefore fail on 1969-12-31 23:00:00. To work around the + problem, set the time zone to 1 hour behind UTC temporarily + by setting TZ="XXX1:00" and try mktime again. */ - long int time_zone = pc.time_zone; - long int abs_time_zone = time_zone < 0 ? - time_zone : time_zone; - long int abs_time_zone_hour = abs_time_zone / 60; - int abs_time_zone_min = abs_time_zone % 60; - char tz1buf[sizeof "XXX+0:00" - + sizeof pc.time_zone * CHAR_BIT / 3]; - if (!tz_was_altered) - tz0 = get_tz (tz0buf); - sprintf (tz1buf, "XXX%s%ld:%02d", "-" + (time_zone < 0), - abs_time_zone_hour, abs_time_zone_min); - if (setenv ("TZ", tz1buf, 1) != 0) - goto fail; - tz_was_altered = true; - tm = tm0; - Start = mktime (&tm); - if (! mktime_ok (&tm0, &tm, Start)) - goto fail; - } - } + long int time_zone = pc.time_zone; + long int abs_time_zone = time_zone < 0 ? - time_zone : time_zone; + long int abs_time_zone_hour = abs_time_zone / 60; + int abs_time_zone_min = abs_time_zone % 60; + char tz1buf[sizeof "XXX+0:00" + + sizeof pc.time_zone * CHAR_BIT / 3]; + if (!tz_was_altered) + tz0 = get_tz (tz0buf); + sprintf (tz1buf, "XXX%s%ld:%02d", "-" + (time_zone < 0), + abs_time_zone_hour, abs_time_zone_min); + if (setenv ("TZ", tz1buf, 1) != 0) + goto fail; + tz_was_altered = true; + tm = tm0; + Start = mktime (&tm); + if (! mktime_ok (&tm0, &tm, Start)) + goto fail; + } + } if (pc.days_seen && ! pc.dates_seen) - { - tm.tm_mday += ((pc.day_number - tm.tm_wday + 7) % 7 - + 7 * (pc.day_ordinal - - (0 < pc.day_ordinal - && tm.tm_wday != pc.day_number))); - tm.tm_isdst = -1; - Start = mktime (&tm); - if (Start == (time_t) -1) - goto fail; - } + { + tm.tm_mday += ((pc.day_number - tm.tm_wday + 7) % 7 + + 7 * (pc.day_ordinal + - (0 < pc.day_ordinal + && tm.tm_wday != pc.day_number))); + tm.tm_isdst = -1; + Start = mktime (&tm); + if (Start == (time_t) -1) + goto fail; + } /* Add relative date. */ if (pc.rel.year | pc.rel.month | pc.rel.day) - { - int year = tm.tm_year + pc.rel.year; - int month = tm.tm_mon + pc.rel.month; - int day = tm.tm_mday + pc.rel.day; - if (((year < tm.tm_year) ^ (pc.rel.year < 0)) - | ((month < tm.tm_mon) ^ (pc.rel.month < 0)) - | ((day < tm.tm_mday) ^ (pc.rel.day < 0))) - goto fail; - tm.tm_year = year; - tm.tm_mon = month; - tm.tm_mday = day; - tm.tm_hour = tm0.tm_hour; - tm.tm_min = tm0.tm_min; - tm.tm_sec = tm0.tm_sec; - tm.tm_isdst = tm0.tm_isdst; - Start = mktime (&tm); - if (Start == (time_t) -1) - goto fail; - } + { + int year = tm.tm_year + pc.rel.year; + int month = tm.tm_mon + pc.rel.month; + int day = tm.tm_mday + pc.rel.day; + if (((year < tm.tm_year) ^ (pc.rel.year < 0)) + | ((month < tm.tm_mon) ^ (pc.rel.month < 0)) + | ((day < tm.tm_mday) ^ (pc.rel.day < 0))) + goto fail; + tm.tm_year = year; + tm.tm_mon = month; + tm.tm_mday = day; + tm.tm_hour = tm0.tm_hour; + tm.tm_min = tm0.tm_min; + tm.tm_sec = tm0.tm_sec; + tm.tm_isdst = tm0.tm_isdst; + Start = mktime (&tm); + if (Start == (time_t) -1) + goto fail; + } /* The only "output" of this if-block is an updated Start value, - so this block must follow others that clobber Start. */ + so this block must follow others that clobber Start. */ if (pc.zones_seen) - { - long int delta = pc.time_zone * 60; - time_t t1; + { + long int delta = pc.time_zone * 60; + time_t t1; #ifdef HAVE_TM_GMTOFF - delta -= tm.tm_gmtoff; + delta -= tm.tm_gmtoff; #else - time_t t = Start; - struct tm const *gmt = gmtime (&t); - if (! gmt) - goto fail; - delta -= tm_diff (&tm, gmt); + time_t t = Start; + struct tm const *gmt = gmtime (&t); + if (! gmt) + goto fail; + delta -= tm_diff (&tm, gmt); #endif - t1 = Start - delta; - if ((Start < t1) != (delta < 0)) - goto fail; /* time_t overflow */ - Start = t1; - } + t1 = Start - delta; + if ((Start < t1) != (delta < 0)) + goto fail; /* time_t overflow */ + Start = t1; + } /* Add relative hours, minutes, and seconds. On hosts that support - leap seconds, ignore the possibility of leap seconds; e.g., - "+ 10 minutes" adds 600 seconds, even if one of them is a - leap second. Typically this is not what the user wants, but it's - too hard to do it the other way, because the time zone indicator - must be applied before relative times, and if mktime is applied - again the time zone will be lost. */ + leap seconds, ignore the possibility of leap seconds; e.g., + "+ 10 minutes" adds 600 seconds, even if one of them is a + leap second. Typically this is not what the user wants, but it's + too hard to do it the other way, because the time zone indicator + must be applied before relative times, and if mktime is applied + again the time zone will be lost. */ { - long int sum_ns = pc.seconds.tv_nsec + pc.rel.ns; - long int normalized_ns = (sum_ns % BILLION + BILLION) % BILLION; - time_t t0 = Start; - long int d1 = 60 * 60 * pc.rel.hour; - time_t t1 = t0 + d1; - long int d2 = 60 * pc.rel.minutes; - time_t t2 = t1 + d2; - long int d3 = pc.rel.seconds; - time_t t3 = t2 + d3; - long int d4 = (sum_ns - normalized_ns) / BILLION; - time_t t4 = t3 + d4; + long int sum_ns = pc.seconds.tv_nsec + pc.rel.ns; + long int normalized_ns = (sum_ns % BILLION + BILLION) % BILLION; + time_t t0 = Start; + long int d1 = 60 * 60 * pc.rel.hour; + time_t t1 = t0 + d1; + long int d2 = 60 * pc.rel.minutes; + time_t t2 = t1 + d2; + long_time_t d3 = pc.rel.seconds; + long_time_t t3 = t2 + d3; + long int d4 = (sum_ns - normalized_ns) / BILLION; + long_time_t t4 = t3 + d4; + time_t t5 = t4; - if ((d1 / (60 * 60) ^ pc.rel.hour) - | (d2 / 60 ^ pc.rel.minutes) - | ((t1 < t0) ^ (d1 < 0)) - | ((t2 < t1) ^ (d2 < 0)) - | ((t3 < t2) ^ (d3 < 0)) - | ((t4 < t3) ^ (d4 < 0))) - goto fail; + if ((d1 / (60 * 60) ^ pc.rel.hour) + | (d2 / 60 ^ pc.rel.minutes) + | ((t1 < t0) ^ (d1 < 0)) + | ((t2 < t1) ^ (d2 < 0)) + | ((t3 < t2) ^ (d3 < 0)) + | ((t4 < t3) ^ (d4 < 0)) + | (t5 != t4)) + goto fail; - result->tv_sec = t4; - result->tv_nsec = normalized_ns; + result->tv_sec = t5; + result->tv_nsec = normalized_ns; } } @@ -1548,19 +1549,19 @@ main (int ac, char **av) struct timespec d; struct tm const *tm; if (! get_date (&d, buff, NULL)) - printf ("Bad format - couldn't convert.\n"); + printf ("Bad format - couldn't convert.\n"); else if (! (tm = localtime (&d.tv_sec))) - { - long int sec = d.tv_sec; - printf ("localtime (%ld) failed\n", sec); - } + { + long int sec = d.tv_sec; + printf ("localtime (%ld) failed\n", sec); + } else - { - int ns = d.tv_nsec; - printf ("%04ld-%02d-%02d %02d:%02d:%02d.%09d\n", - tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec, ns); - } + { + int ns = d.tv_nsec; + printf ("%04ld-%02d-%02d %02d:%02d:%02d.%09d\n", + tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec, ns); + } printf ("\t> "); fflush (stdout); } diff --git a/src/bin/coreutils/lib/getdelim.c b/src/bin/coreutils/lib/getdelim.c index 727f8b0ec5..6ca87d4802 100644 --- a/src/bin/coreutils/lib/getdelim.c +++ b/src/bin/coreutils/lib/getdelim.c @@ -2,8 +2,8 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* getdelim.c --- Implementation of replacement getdelim function. - Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005, 2006, 2007, - 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005, 2006, 2007, 2008, + 2009, 2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -24,6 +24,10 @@ #include +/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc + optimizes away the lineptr == NULL || n == NULL || fp == NULL tests below. */ +#define _GL_ARG_NONNULL(params) + #include #include @@ -37,15 +41,15 @@ #if USE_UNLOCKED_IO # include "unlocked-io.h" -# define getc_maybe_unlocked(fp) getc(fp) +# define getc_maybe_unlocked(fp) getc(fp) #elif !HAVE_FLOCKFILE || !HAVE_FUNLOCKFILE || !HAVE_DECL_GETC_UNLOCKED # undef flockfile # undef funlockfile # define flockfile(x) ((void) 0) # define funlockfile(x) ((void) 0) -# define getc_maybe_unlocked(fp) getc(fp) +# define getc_maybe_unlocked(fp) getc(fp) #else -# define getc_maybe_unlocked(fp) getc_unlocked(fp) +# define getc_maybe_unlocked(fp) getc_unlocked(fp) #endif /* Read up to (and including) a DELIMITER from FP into *LINEPTR (and @@ -74,10 +78,10 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp) *n = 120; new_lineptr = (char *) realloc (*lineptr, *n); if (new_lineptr == NULL) - { - result = -1; - goto unlock_return; - } + { + result = -1; + goto unlock_return; + } *lineptr = new_lineptr; } @@ -87,44 +91,44 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp) i = getc_maybe_unlocked (fp); if (i == EOF) - { - result = -1; - break; - } + { + result = -1; + break; + } /* Make enough space for len+1 (for final NUL) bytes. */ if (cur_len + 1 >= *n) - { - size_t needed_max = - SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX; - size_t needed = 2 * *n + 1; /* Be generous. */ - char *new_lineptr; + { + size_t needed_max = + SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX; + size_t needed = 2 * *n + 1; /* Be generous. */ + char *new_lineptr; - if (needed_max < needed) - needed = needed_max; - if (cur_len + 1 >= needed) - { - result = -1; - errno = EOVERFLOW; - goto unlock_return; - } + if (needed_max < needed) + needed = needed_max; + if (cur_len + 1 >= needed) + { + result = -1; + errno = EOVERFLOW; + goto unlock_return; + } - new_lineptr = (char *) realloc (*lineptr, needed); - if (new_lineptr == NULL) - { - result = -1; - goto unlock_return; - } + new_lineptr = (char *) realloc (*lineptr, needed); + if (new_lineptr == NULL) + { + result = -1; + goto unlock_return; + } - *lineptr = new_lineptr; - *n = needed; - } + *lineptr = new_lineptr; + *n = needed; + } (*lineptr)[cur_len] = i; cur_len++; if (i == delimiter) - break; + break; } (*lineptr)[cur_len] = '\0'; result = cur_len ? cur_len : result; diff --git a/src/bin/coreutils/lib/getfilecon.c b/src/bin/coreutils/lib/getfilecon.c new file mode 100644 index 0000000000..d0d0f91da3 --- /dev/null +++ b/src/bin/coreutils/lib/getfilecon.c @@ -0,0 +1,87 @@ +/* wrap getfilecon, lgetfilecon, and fgetfilecon + Copyright (C) 2009-2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* written by Jim Meyering */ + +#include + +#include + +#include +#include +#include + +/* FIXME: remove this once there is an errno-gnu module + that guarantees the definition of ENODATA. */ +#ifndef ENODATA +# define ENODATA ENOTSUP +#endif + +#undef getfilecon +#undef lgetfilecon +#undef fgetfilecon +int getfilecon (char const *file, security_context_t *con); +int lgetfilecon (char const *file, security_context_t *con); +int fgetfilecon (int fd, security_context_t *con); + +/* getfilecon, lgetfilecon, and fgetfilecon can all misbehave, be it + via an old version of libselinux where these would return 0 and set the + result context to NULL, or via a modern kernel+lib operating on a file + from a disk whose attributes were set by a kernel from around 2006. + In that latter case, the functions return a length of 10 for the + "unlabeled" context. Map both failures to a return value of -1, and + set errno to ENOTSUP in the first case, and ENODATA in the latter. */ + +static inline int +map_to_failure (int ret, security_context_t *con) +{ + if (ret == 0) + { + errno = ENOTSUP; + return -1; + } + + if (ret == 10 && strcmp (*con, "unlabeled") == 0) + { + freecon (*con); + errno = ENODATA; + return -1; + } + + return ret; +} + +int +rpl_getfilecon (char const *file, security_context_t *con) +{ + int ret = getfilecon (file, con); + return map_to_failure (ret, con); +} + +int +rpl_lgetfilecon (char const *file, security_context_t *con) +{ + int ret = lgetfilecon (file, con); + return map_to_failure (ret, con); +} + +int +rpl_fgetfilecon (int fd, security_context_t *con) +{ + int ret = fgetfilecon (fd, con); + return map_to_failure (ret, con); +} diff --git a/src/bin/coreutils/lib/getgroups.c b/src/bin/coreutils/lib/getgroups.c index 1e9cbc6495..c9661d6a65 100644 --- a/src/bin/coreutils/lib/getgroups.c +++ b/src/bin/coreutils/lib/getgroups.c @@ -1,7 +1,6 @@ /* provide consistent interface to getgroups for systems that don't allow N==0 - Copyright (C) 1996, 1999, 2003, 2006, 2007, 2008 Free Software - Foundation, Inc. + Copyright (C) 1996, 1999, 2003, 2006-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,43 +19,91 @@ #include -#undef getgroups - -#include -#include -#include -#include #include -#include "xalloc.h" +#include +#include +#include -/* On at least Ultrix 4.3 and NextStep 3.2, getgroups (0, 0) always fails. - On other systems, it returns the number of supplemental groups for the - process. This function handles that special case and lets the system- - provided function handle all others. */ +#if !HAVE_GETGROUPS + +/* Provide a stub that fails with ENOSYS, since there is no group + information available on mingw. */ +int +getgroups (int n _GL_UNUSED, GETGROUPS_T *groups _GL_UNUSED) +{ + errno = ENOSYS; + return -1; +} + +#else /* HAVE_GETGROUPS */ + +# undef getgroups +# ifndef GETGROUPS_ZERO_BUG +# define GETGROUPS_ZERO_BUG 0 +# endif + +/* On at least Ultrix 4.3 and NextStep 3.2, getgroups (0, NULL) always + fails. On other systems, it returns the number of supplemental + groups for the process. This function handles that special case + and lets the system-provided function handle all others. However, + it can fail with ENOMEM if memory is tight. It is unspecified + whether the effective group id is included in the list. */ int -rpl_getgroups (int n, GETGROUPS_T *group) +rpl_getgroups (int n, gid_t *group) { int n_groups; GETGROUPS_T *gbuf; int saved_errno; - if (n != 0) - return getgroups (n, group); + if (n < 0) + { + errno = EINVAL; + return -1; + } + + if (n != 0 || !GETGROUPS_ZERO_BUG) + { + int result; + if (sizeof *group == sizeof *gbuf) + return getgroups (n, (GETGROUPS_T *) group); + + if (SIZE_MAX / sizeof *gbuf <= n) + { + errno = ENOMEM; + return -1; + } + gbuf = malloc (n * sizeof *gbuf); + if (!gbuf) + return -1; + result = getgroups (n, gbuf); + if (0 <= result) + { + n = result; + while (n--) + group[n] = gbuf[n]; + } + saved_errno = errno; + free (gbuf); + errno == saved_errno; + return result; + } n = 20; while (1) { /* No need to worry about address arithmetic overflow here, - since the ancient systems that we're running on have low - limits on the number of secondary groups. */ - gbuf = xmalloc (n * sizeof *gbuf); + since the ancient systems that we're running on have low + limits on the number of secondary groups. */ + gbuf = malloc (n * sizeof *gbuf); + if (!gbuf) + return -1; n_groups = getgroups (n, gbuf); - if (n_groups < n) - break; + if (n_groups == -1 ? errno != EINVAL : n_groups < n) + break; free (gbuf); - n += 10; + n *= 2; } saved_errno = errno; @@ -65,3 +112,5 @@ rpl_getgroups (int n, GETGROUPS_T *group) return n_groups; } + +#endif /* HAVE_GETGROUPS */ diff --git a/src/bin/coreutils/lib/gethostname.c b/src/bin/coreutils/lib/gethostname.c index 35d8206858..b0da748ff0 100644 --- a/src/bin/coreutils/lib/gethostname.c +++ b/src/bin/coreutils/lib/gethostname.c @@ -1,6 +1,7 @@ /* gethostname emulation for SysV and POSIX.1. - Copyright (C) 1992, 2003, 2006, 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 1992, 2003, 2006, 2008, 2009, 2010 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -54,7 +55,7 @@ gethostname (char *name, size_t len) } strncpy (name, uts.nodename, len); #else - strcpy (name, ""); /* Hardcode your system name if you want. */ + strcpy (name, ""); /* Hardcode your system name if you want. */ #endif return 0; } diff --git a/src/bin/coreutils/lib/gethrxtime.c b/src/bin/coreutils/lib/gethrxtime.c index 7aa648455b..8436746624 100644 --- a/src/bin/coreutils/lib/gethrxtime.c +++ b/src/bin/coreutils/lib/gethrxtime.c @@ -1,6 +1,6 @@ /* gethrxtime -- get high resolution real time - Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/gethrxtime.h b/src/bin/coreutils/lib/gethrxtime.h index bd54f95688..c25b801f37 100644 --- a/src/bin/coreutils/lib/gethrxtime.h +++ b/src/bin/coreutils/lib/gethrxtime.h @@ -1,6 +1,6 @@ /* gethrxtime -- get high resolution real time - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/getline.c b/src/bin/coreutils/lib/getline.c index 7bf8544420..85103a9768 100644 --- a/src/bin/coreutils/lib/getline.c +++ b/src/bin/coreutils/lib/getline.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* getline.c --- Implementation of replacement getline function. - Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/src/bin/coreutils/lib/getloadavg.c b/src/bin/coreutils/lib/getloadavg.c index a7bac49035..c6d782b4e2 100644 --- a/src/bin/coreutils/lib/getloadavg.c +++ b/src/bin/coreutils/lib/getloadavg.c @@ -1,8 +1,7 @@ /* Get the system load averages. - Copyright (C) 1985, 1986, 1987, 1988, 1989, 1991, 1992, 1993, 1994, - 1995, 1997, 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free - Software Foundation, Inc. + Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2010 Free Software + Foundation, Inc. NOTE: The canonical source of this file is maintained with gnulib. Bugs can be reported to bug-gnulib@gnu.org. @@ -22,58 +21,58 @@ /* Compile-time symbols that this file uses: - HAVE_PSTAT_GETDYNAMIC Define this if your system has the + HAVE_PSTAT_GETDYNAMIC Define this if your system has the pstat_getdynamic function. I think it - is unique to HPUX9. The best way to get the - definition is through the AC_FUNC_GETLOADAVG - macro that comes with autoconf 2.13 or newer. - If that isn't an option, then just put - AC_CHECK_FUNCS(pstat_getdynamic) in your - configure.in file. + is unique to HPUX9. The best way to get the + definition is through the AC_FUNC_GETLOADAVG + macro that comes with autoconf 2.13 or newer. + If that isn't an option, then just put + AC_CHECK_FUNCS(pstat_getdynamic) in your + configure.in file. HAVE_LIBPERFSTAT Define this if your system has the - perfstat_cpu_total function in libperfstat (AIX). - FIXUP_KERNEL_SYMBOL_ADDR() Adjust address in returned struct nlist. - KERNEL_FILE Name of the kernel file to nlist. - LDAV_CVT() Scale the load average from the kernel. - Returns a double. - LDAV_SYMBOL Name of kernel symbol giving load average. - LOAD_AVE_TYPE Type of the load average array in the kernel. - Must be defined unless one of - apollo, DGUX, NeXT, or UMAX is defined; + perfstat_cpu_total function in libperfstat (AIX). + FIXUP_KERNEL_SYMBOL_ADDR() Adjust address in returned struct nlist. + KERNEL_FILE Name of the kernel file to nlist. + LDAV_CVT() Scale the load average from the kernel. + Returns a double. + LDAV_SYMBOL Name of kernel symbol giving load average. + LOAD_AVE_TYPE Type of the load average array in the kernel. + Must be defined unless one of + apollo, DGUX, NeXT, or UMAX is defined; or we have libkstat; - otherwise, no load average is available. + otherwise, no load average is available. HAVE_NLIST_H nlist.h is available. NLIST_STRUCT defaults to this. - NLIST_STRUCT Include nlist.h, not a.out.h. - N_NAME_POINTER The nlist n_name element is a pointer, - not an array. + NLIST_STRUCT Include nlist.h, not a.out.h. + N_NAME_POINTER The nlist n_name element is a pointer, + not an array. HAVE_STRUCT_NLIST_N_UN_N_NAME `n_un.n_name' is member of `struct nlist'. - LINUX_LDAV_FILE [__linux__, __CYGWIN__]: File containing - load averages. + LINUX_LDAV_FILE [__linux__, __CYGWIN__]: File containing + load averages. Specific system predefines this file uses, aside from setting default values if not emacs: apollo - BSD Real BSD, not just BSD-like. + BSD Real BSD, not just BSD-like. convex DGUX - eunice UNIX emulator under VMS. + eunice UNIX emulator under VMS. hpux - __MSDOS__ No-op for MSDOS. + __MSDOS__ No-op for MSDOS. NeXT sgi - sequent Sequent Dynix 3.x.x (BSD) - _SEQUENT_ Sequent DYNIX/ptx 1.x.x (SYSV) + sequent Sequent Dynix 3.x.x (BSD) + _SEQUENT_ Sequent DYNIX/ptx 1.x.x (SYSV) sony_news NEWS-OS (works at least for 4.1C) UMAX UMAX4_3 VMS - WINDOWS32 No-op for Windows95/NT. - __linux__ Linux: assumes /proc file system mounted. - Support from Michael K. Johnson. - __CYGWIN__ Cygwin emulates linux /proc/loadavg. - __NetBSD__ NetBSD: assumes /kern file system mounted. + WINDOWS32 No-op for Windows95/NT. + __linux__ Linux: assumes /proc file system mounted. + Support from Michael K. Johnson. + __CYGWIN__ Cygwin emulates linux /proc/loadavg. + __NetBSD__ NetBSD: assumes /kern file system mounted. In addition, to avoid nesting many #ifdefs, we internally set LDAV_DONE to indicate that the load average has been computed. @@ -112,7 +111,6 @@ # include "c-strtod.h" # include "cloexec.h" # include "intprops.h" -# include "xalloc.h" /* The existing Emacs configuration files define a macro called LOAD_AVE_CVT, which accepts a value of type LOAD_AVE_TYPE, and @@ -203,7 +201,7 @@ default, but _MACH_IND_SYS_TYPES is defined in . Combine that with a couple of other things and we'll have a unique match. */ # if !defined (tek4300) && defined (unix) && defined (m68k) && defined (mc68000) && defined (mc68020) && defined (_MACH_IND_SYS_TYPES) -# define tek4300 /* Define by emacs, but not by other users. */ +# define tek4300 /* Define by emacs, but not by other users. */ # endif @@ -317,7 +315,7 @@ # define FSCALE 65536.0 # endif -# endif /* Not FSCALE. */ +# endif /* Not FSCALE. */ # if !defined (LDAV_CVT) && defined (FSCALE) # define LDAV_CVT(n) (((double) (n)) / FSCALE) @@ -478,7 +476,7 @@ static unsigned int samples; # endif /* UMAX */ # ifdef DGUX -static struct dg_sys_info_load_info load_info; /* what-a-mouthful! */ +static struct dg_sys_info_load_info load_info; /* what-a-mouthful! */ # endif /* DGUX */ # if !defined (HAVE_LIBKSTAT) && defined (LOAD_AVE_TYPE) @@ -507,7 +505,7 @@ static kvm_t *kd; int getloadavg (double loadavg[], int nelem) { - int elem = 0; /* Return value. */ + int elem = 0; /* Return value. */ # ifdef NO_GET_LOAD_AVG # define LDAV_DONE @@ -549,16 +547,16 @@ getloadavg (double loadavg[], int nelem) { kn = kstat_data_lookup (ksp, "avenrun_5min"); if (kn != 0) - { - loadavg[elem++] = (double) kn->value.ul / FSCALE; + { + loadavg[elem++] = (double) kn->value.ul / FSCALE; - if (nelem >= 3) - { - kn = kstat_data_lookup (ksp, "avenrun_15min"); - if (kn != 0) - loadavg[elem++] = (double) kn->value.ul / FSCALE; - } - } + if (nelem >= 3) + { + kn = kstat_data_lookup (ksp, "avenrun_15min"); + if (kn != 0) + loadavg[elem++] = (double) kn->value.ul / FSCALE; + } + } } kstat_close (kc); @@ -626,11 +624,11 @@ getloadavg (double loadavg[], int nelem) errno = 0; d = c_strtod (ptr, &endptr); if (ptr == endptr || (d == 0 && errno != 0)) - { - if (elem == 0) - return -1; - break; - } + { + if (elem == 0) + return -1; + break; + } loadavg[elem] = d; ptr = endptr; } @@ -655,8 +653,8 @@ getloadavg (double loadavg[], int nelem) if (fp == NULL) return -1; count = fscanf (fp, "%lu %lu %lu %lu\n", - &load_ave[0], &load_ave[1], &load_ave[2], - &scale); + &load_ave[0], &load_ave[1], &load_ave[2], + &scale); (void) fclose (fp); if (count != 4) return -1; @@ -682,21 +680,21 @@ getloadavg (double loadavg[], int nelem) if (!getloadavg_initialized) { if (processor_set_default (host_self (), &default_set) == KERN_SUCCESS) - getloadavg_initialized = true; + getloadavg_initialized = true; } if (getloadavg_initialized) { info_count = PROCESSOR_SET_BASIC_INFO_COUNT; if (processor_set_info (default_set, PROCESSOR_SET_BASIC_INFO, &host, - (processor_set_info_t) &info, &info_count) - != KERN_SUCCESS) - getloadavg_initialized = false; + (processor_set_info_t) &info, &info_count) + != KERN_SUCCESS) + getloadavg_initialized = false; else - { - if (nelem > 0) - loadavg[elem++] = (double) info.load_average / LOAD_SCALE; - } + { + if (nelem > 0) + loadavg[elem++] = (double) info.load_average / LOAD_SCALE; + } } if (!getloadavg_initialized) @@ -728,24 +726,24 @@ getloadavg (double loadavg[], int nelem) desc.sd_size = sizeof conf; if (inq_stats (1, &desc)) - return -1; + return -1; c = 0; for (i = 0; i < conf.config_maxclass; ++i) - { - struct class_stats stats; - bzero ((char *) &stats, sizeof stats); + { + struct class_stats stats; + bzero ((char *) &stats, sizeof stats); - desc.sd_type = CPUTYPE_CLASS; - desc.sd_objid = i; - desc.sd_addr = (char *) &stats; - desc.sd_size = sizeof stats; + desc.sd_type = CPUTYPE_CLASS; + desc.sd_objid = i; + desc.sd_addr = (char *) &stats; + desc.sd_size = sizeof stats; - if (inq_stats (1, &desc)) - return -1; + if (inq_stats (1, &desc)) + return -1; - c += stats.class_numcpus; - } + c += stats.class_numcpus; + } cpus = c; samples = cpus < 2 ? 3 : (2 * cpus / 3); } @@ -766,7 +764,7 @@ getloadavg (double loadavg[], int nelem) { load += proc_sum_data.ps_nrun[j]; if (j++ == PS_NRUNSIZE) - j = 0; + j = 0; } if (nelem > 0) @@ -779,8 +777,8 @@ getloadavg (double loadavg[], int nelem) it's not supposed to fail. The first argument is for no apparent reason of type `long int *'. */ dg_sys_info ((long int *) &load_info, - DG_SYS_INFO_LOAD_INFO_TYPE, - DG_SYS_INFO_LOAD_VERSION_0); + DG_SYS_INFO_LOAD_INFO_TYPE, + DG_SYS_INFO_LOAD_VERSION_0); if (nelem > 0) loadavg[elem++] = load_info.one_minute; @@ -824,7 +822,7 @@ getloadavg (double loadavg[], int nelem) = (load_ave.tl_lscale == 0 ? load_ave.tl_avenrun.d[0] : (load_ave.tl_avenrun.l[0] / (double) load_ave.tl_lscale)); -# endif /* OSF_MIPS */ +# endif /* OSF_MIPS */ # if !defined (LDAV_DONE) && (defined (__MSDOS__) || defined (WINDOWS32)) # define LDAV_DONE @@ -844,8 +842,8 @@ getloadavg (double loadavg[], int nelem) for (elem = 0; elem < nelem; elem++) loadavg[elem] = (load_ave.tl_lscale == 0 - ? load_ave.tl_avenrun.d[elem] - : (load_ave.tl_avenrun.l[elem] / (double) load_ave.tl_lscale)); + ? load_ave.tl_avenrun.d[elem] + : (load_ave.tl_avenrun.l[elem] / (double) load_ave.tl_lscale)); # endif /* OSF_ALPHA */ # if ! defined LDAV_DONE && defined __VMS @@ -872,13 +870,13 @@ getloadavg (double loadavg[], int nelem) $DESCRIPTOR (descriptor, "LAV0:"); # endif if (sys$assign (&descriptor, &channel, 0, 0) & 1) - getloadavg_initialized = true; + getloadavg_initialized = true; } /* Read the load average vector. */ if (getloadavg_initialized && !(sys$qiow (0, channel, IO$_READVBLK, 0, 0, 0, - load_ave, 12, 0, 0, 0, 0) & 1)) + load_ave, 12, 0, 0, 0, 0) & 1)) { sys$dassgn (channel); getloadavg_initialized = false; @@ -892,7 +890,7 @@ getloadavg (double loadavg[], int nelem) /* UNIX-specific code -- read the average from /dev/kmem. */ -# define LDAV_PRIVILEGED /* This code requires special installation. */ +# define LDAV_PRIVILEGED /* This code requires special installation. */ LOAD_AVE_TYPE load_ave[3]; @@ -916,25 +914,25 @@ getloadavg (double loadavg[], int nelem) # ifndef SUNOS_5 if ( # if !(defined (_AIX) && !defined (ps2)) - nlist (KERNEL_FILE, nl) + nlist (KERNEL_FILE, nl) # else /* _AIX */ - knlist (nl, 1, sizeof (nl[0])) + knlist (nl, 1, sizeof (nl[0])) # endif - >= 0) - /* Omit "&& nl[0].n_type != 0 " -- it breaks on Sun386i. */ - { + >= 0) + /* Omit "&& nl[0].n_type != 0 " -- it breaks on Sun386i. */ + { # ifdef FIXUP_KERNEL_SYMBOL_ADDR - FIXUP_KERNEL_SYMBOL_ADDR (nl); + FIXUP_KERNEL_SYMBOL_ADDR (nl); # endif - offset = nl[0].n_value; - } + offset = nl[0].n_value; + } # endif /* !SUNOS_5 */ # else /* sgi */ int ldav_off; ldav_off = sysmp (MP_KERNADDR, MPKA_AVENRUN); if (ldav_off != -1) - offset = (long int) ldav_off & 0x7fffffff; + offset = (long int) ldav_off & 0x7fffffff; # endif /* sgi */ } @@ -944,23 +942,23 @@ getloadavg (double loadavg[], int nelem) # ifndef SUNOS_5 channel = open ("/dev/kmem", O_RDONLY); if (channel >= 0) - { - /* Set the channel to close on exec, so it does not - litter any child's descriptor table. */ - set_cloexec_flag (channel, true); - getloadavg_initialized = true; - } + { + /* Set the channel to close on exec, so it does not + litter any child's descriptor table. */ + set_cloexec_flag (channel, true); + getloadavg_initialized = true; + } # else /* SUNOS_5 */ /* We pass 0 for the kernel, corefile, and swapfile names - to use the currently running kernel. */ + to use the currently running kernel. */ kd = kvm_open (0, 0, 0, O_RDONLY, 0); if (kd != 0) - { - /* nlist the currently running kernel. */ - kvm_nlist (kd, nl); - offset = nl[0].n_value; - getloadavg_initialized = true; - } + { + /* nlist the currently running kernel. */ + kvm_nlist (kd, nl); + offset = nl[0].n_value; + getloadavg_initialized = true; + } # endif /* SUNOS_5 */ } @@ -970,19 +968,19 @@ getloadavg (double loadavg[], int nelem) /* Try to read the load. */ # ifndef SUNOS_5 if (lseek (channel, offset, 0) == -1L - || read (channel, (char *) load_ave, sizeof (load_ave)) - != sizeof (load_ave)) - { - close (channel); - getloadavg_initialized = false; - } + || read (channel, (char *) load_ave, sizeof (load_ave)) + != sizeof (load_ave)) + { + close (channel); + getloadavg_initialized = false; + } # else /* SUNOS_5 */ if (kvm_read (kd, offset, (char *) load_ave, sizeof (load_ave)) - != sizeof (load_ave)) - { - kvm_close (kd); - getloadavg_initialized = false; - } + != sizeof (load_ave)) + { + kvm_close (kd); + getloadavg_initialized = false; + } # endif /* SUNOS_5 */ } @@ -1026,24 +1024,24 @@ main (int argc, char **argv) double avg[3]; int loads; - errno = 0; /* Don't be misled if it doesn't set errno. */ + errno = 0; /* Don't be misled if it doesn't set errno. */ loads = getloadavg (avg, 3); if (loads == -1) - { - perror ("Error getting load average"); - return EXIT_FAILURE; - } + { + perror ("Error getting load average"); + return EXIT_FAILURE; + } if (loads > 0) - printf ("1-minute: %f ", avg[0]); + printf ("1-minute: %f ", avg[0]); if (loads > 1) - printf ("5-minute: %f ", avg[1]); + printf ("5-minute: %f ", avg[1]); if (loads > 2) - printf ("15-minute: %f ", avg[2]); + printf ("15-minute: %f ", avg[2]); if (loads > 0) - putchar ('\n'); + putchar ('\n'); if (naptime == 0) - break; + break; sleep (naptime); } diff --git a/src/bin/coreutils/lib/getndelim2.c b/src/bin/coreutils/lib/getndelim2.c index 9dcb9feb46..161ee81607 100644 --- a/src/bin/coreutils/lib/getndelim2.c +++ b/src/bin/coreutils/lib/getndelim2.c @@ -1,8 +1,8 @@ /* getndelim2 - Read a line from a stream, stopping at one of 2 delimiters, with bounded memory allocation. - Copyright (C) 1993, 1996, 1997, 1998, 2000, 2003, 2004, 2006, 2008 Free - Software Foundation, Inc. + Copyright (C) 1993, 1996, 1997, 1998, 2000, 2003, 2004, 2006, 2008, 2009, + 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -71,8 +71,8 @@ ssize_t getndelim2 (char **lineptr, size_t *linesize, size_t offset, size_t nmax, int delim1, int delim2, FILE *stream) { - size_t nbytes_avail; /* Allocated but unused bytes in *LINEPTR. */ - char *read_pos; /* Where we're reading into *LINEPTR. */ + size_t nbytes_avail; /* Allocated but unused bytes in *LINEPTR. */ + char *read_pos; /* Where we're reading into *LINEPTR. */ ssize_t bytes_stored = -1; char *ptr = *lineptr; size_t size = *linesize; @@ -83,7 +83,7 @@ getndelim2 (char **lineptr, size_t *linesize, size_t offset, size_t nmax, size = nmax < MIN_CHUNK ? nmax : MIN_CHUNK; ptr = malloc (size); if (!ptr) - return -1; + return -1; } if (size < offset) @@ -107,7 +107,7 @@ getndelim2 (char **lineptr, size_t *linesize, size_t offset, size_t nmax, do { /* Here always ptr + size == read_pos + nbytes_avail. - Also nbytes_avail > 0 || size < nmax. */ + Also nbytes_avail > 0 || size < nmax. */ int c IF_LINT (= 0); const char *buffer; @@ -115,89 +115,89 @@ getndelim2 (char **lineptr, size_t *linesize, size_t offset, size_t nmax, buffer = freadptr (stream, &buffer_len); if (buffer) - { - if (delim1 != EOF) - { - const char *end = memchr2 (buffer, delim1, delim2, buffer_len); - if (end) - { - buffer_len = end - buffer + 1; - found_delimiter = true; - } - } - } + { + if (delim1 != EOF) + { + const char *end = memchr2 (buffer, delim1, delim2, buffer_len); + if (end) + { + buffer_len = end - buffer + 1; + found_delimiter = true; + } + } + } else - { - c = getc (stream); - if (c == EOF) - { - /* Return partial line, if any. */ - if (read_pos == ptr) - goto unlock_done; - else - break; - } - if (c == delim1 || c == delim2) - found_delimiter = true; - buffer_len = 1; - } + { + c = getc (stream); + if (c == EOF) + { + /* Return partial line, if any. */ + if (read_pos == ptr) + goto unlock_done; + else + break; + } + if (c == delim1 || c == delim2) + found_delimiter = true; + buffer_len = 1; + } /* We always want at least one byte left in the buffer, since we - always (unless we get an error while reading the first byte) - NUL-terminate the line buffer. */ + always (unless we get an error while reading the first byte) + NUL-terminate the line buffer. */ if (nbytes_avail < buffer_len + 1 && size < nmax) - { - /* Grow size proportionally, not linearly, to avoid O(n^2) - running time. */ - size_t newsize = size < MIN_CHUNK ? size + MIN_CHUNK : 2 * size; - char *newptr; + { + /* Grow size proportionally, not linearly, to avoid O(n^2) + running time. */ + size_t newsize = size < MIN_CHUNK ? size + MIN_CHUNK : 2 * size; + char *newptr; - /* Increase newsize so that it becomes - >= (read_pos - ptr) + buffer_len. */ - if (newsize - (read_pos - ptr) < buffer_len + 1) - newsize = (read_pos - ptr) + buffer_len + 1; - /* Respect nmax. This handles possible integer overflow. */ - if (! (size < newsize && newsize <= nmax)) - newsize = nmax; + /* Increase newsize so that it becomes + >= (read_pos - ptr) + buffer_len. */ + if (newsize - (read_pos - ptr) < buffer_len + 1) + newsize = (read_pos - ptr) + buffer_len + 1; + /* Respect nmax. This handles possible integer overflow. */ + if (! (size < newsize && newsize <= nmax)) + newsize = nmax; - if (GETNDELIM2_MAXIMUM < newsize - offset) - { - size_t newsizemax = offset + GETNDELIM2_MAXIMUM + 1; - if (size == newsizemax) - goto unlock_done; - newsize = newsizemax; - } + if (GETNDELIM2_MAXIMUM < newsize - offset) + { + size_t newsizemax = offset + GETNDELIM2_MAXIMUM + 1; + if (size == newsizemax) + goto unlock_done; + newsize = newsizemax; + } - nbytes_avail = newsize - (read_pos - ptr); - newptr = realloc (ptr, newsize); - if (!newptr) - goto unlock_done; - ptr = newptr; - size = newsize; - read_pos = size - nbytes_avail + ptr; - } + nbytes_avail = newsize - (read_pos - ptr); + newptr = realloc (ptr, newsize); + if (!newptr) + goto unlock_done; + ptr = newptr; + size = newsize; + read_pos = size - nbytes_avail + ptr; + } /* Here, if size < nmax, nbytes_avail >= buffer_len + 1. - If size == nmax, nbytes_avail > 0. */ + If size == nmax, nbytes_avail > 0. */ if (1 < nbytes_avail) - { - size_t copy_len = nbytes_avail - 1; - if (buffer_len < copy_len) - copy_len = buffer_len; - if (buffer) - memcpy (read_pos, buffer, copy_len); - else - *read_pos = c; - read_pos += copy_len; - nbytes_avail -= copy_len; - } + { + size_t copy_len = nbytes_avail - 1; + if (buffer_len < copy_len) + copy_len = buffer_len; + if (buffer) + memcpy (read_pos, buffer, copy_len); + else + *read_pos = c; + read_pos += copy_len; + nbytes_avail -= copy_len; + } /* Here still nbytes_avail > 0. */ if (buffer && freadseek (stream, buffer_len)) - goto unlock_done; + goto unlock_done; } while (!found_delimiter); diff --git a/src/bin/coreutils/lib/getndelim2.h b/src/bin/coreutils/lib/getndelim2.h index c1c8375810..6d7819a03c 100644 --- a/src/bin/coreutils/lib/getndelim2.h +++ b/src/bin/coreutils/lib/getndelim2.h @@ -1,7 +1,7 @@ /* getndelim2 - Read a line from a stream, stopping at one of 2 delimiters, with bounded memory allocation. - Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2006, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/getopt.c b/src/bin/coreutils/lib/getopt.c index f1e6d1f7c7..406d5b71a3 100644 --- a/src/bin/coreutils/lib/getopt.c +++ b/src/bin/coreutils/lib/getopt.c @@ -1,9 +1,9 @@ /* Getopt for GNU. - NOTE: getopt is now part of the C library, so if you don't know what + NOTE: getopt is part of the C library, so if you don't know what "Keep this file name-space clean" means, talk to drepper@gnu.org before changing it! - Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002,2003,2004,2006,2008 - Free Software Foundation, Inc. + Copyright (C) 1987-1996, 1998-2004, 2006, 2008-2010 Free Software + Foundation, Inc. This file is part of the GNU C Library. This program is free software: you can redistribute it and/or modify @@ -45,8 +45,9 @@ # define attribute_hidden #endif -/* Unlike standard Unix `getopt', functions like `getopt_long' - let the user intersperse the options with the other arguments. +/* This version of `getopt' appears to the caller like standard Unix `getopt' + but it behaves differently for the user, since it allows the user + to intersperse the options with the other arguments. As `getopt_long' works, it permutes the elements of ARGV so that, when it is done, all the options precede everything else. Thus @@ -54,7 +55,7 @@ Using `getopt' or setting the environment variable POSIXLY_CORRECT disables permutation. - Then the application's behavior is completely standard. + Then the behavior is completely standard. GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ @@ -121,18 +122,18 @@ extern char *__getopt_nonoption_flags; # ifdef USE_NONOPTION_FLAGS # define SWAP_FLAGS(ch1, ch2) \ - if (d->__nonoption_flags_len > 0) \ - { \ - char __tmp = __getopt_nonoption_flags[ch1]; \ - __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ - __getopt_nonoption_flags[ch2] = __tmp; \ + if (d->__nonoption_flags_len > 0) \ + { \ + char __tmp = __getopt_nonoption_flags[ch1]; \ + __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ + __getopt_nonoption_flags[ch2] = __tmp; \ } # else # define SWAP_FLAGS(ch1, ch2) # endif -#else /* !_LIBC */ +#else /* !_LIBC */ # define SWAP_FLAGS(ch1, ch2) -#endif /* _LIBC */ +#endif /* _LIBC */ /* Exchange two adjacent subsequences of ARGV. One subsequence is elements [first_nonopt,last_nonopt) @@ -163,57 +164,57 @@ exchange (char **argv, struct _getopt_data *d) if (d->__nonoption_flags_len > 0 && top >= d->__nonoption_flags_max_len) { /* We must extend the array. The user plays games with us and - presents new arguments. */ + presents new arguments. */ char *new_str = malloc (top + 1); if (new_str == NULL) - d->__nonoption_flags_len = d->__nonoption_flags_max_len = 0; + d->__nonoption_flags_len = d->__nonoption_flags_max_len = 0; else - { - memset (__mempcpy (new_str, __getopt_nonoption_flags, - d->__nonoption_flags_max_len), - '\0', top + 1 - d->__nonoption_flags_max_len); - d->__nonoption_flags_max_len = top + 1; - __getopt_nonoption_flags = new_str; - } + { + memset (__mempcpy (new_str, __getopt_nonoption_flags, + d->__nonoption_flags_max_len), + '\0', top + 1 - d->__nonoption_flags_max_len); + d->__nonoption_flags_max_len = top + 1; + __getopt_nonoption_flags = new_str; + } } #endif while (top > middle && middle > bottom) { if (top - middle > middle - bottom) - { - /* Bottom segment is the short one. */ - int len = middle - bottom; - register int i; + { + /* Bottom segment is the short one. */ + int len = middle - bottom; + register int i; - /* Swap it with the top part of the top segment. */ - for (i = 0; i < len; i++) - { - tem = argv[bottom + i]; - argv[bottom + i] = argv[top - (middle - bottom) + i]; - argv[top - (middle - bottom) + i] = tem; - SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); - } - /* Exclude the moved bottom segment from further swapping. */ - top -= len; - } + /* Swap it with the top part of the top segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[top - (middle - bottom) + i]; + argv[top - (middle - bottom) + i] = tem; + SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); + } + /* Exclude the moved bottom segment from further swapping. */ + top -= len; + } else - { - /* Top segment is the short one. */ - int len = top - middle; - register int i; + { + /* Top segment is the short one. */ + int len = top - middle; + register int i; - /* Swap it with the bottom part of the bottom segment. */ - for (i = 0; i < len; i++) - { - tem = argv[bottom + i]; - argv[bottom + i] = argv[middle + i]; - argv[middle + i] = tem; - SWAP_FLAGS (bottom + i, middle + i); - } - /* Exclude the moved top segment from further swapping. */ - bottom += len; - } + /* Swap it with the bottom part of the bottom segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[middle + i]; + argv[middle + i] = tem; + SWAP_FLAGS (bottom + i, middle + i); + } + /* Exclude the moved top segment from further swapping. */ + bottom += len; + } } /* Update records for the slots the non-options now occupy. */ @@ -225,8 +226,9 @@ exchange (char **argv, struct _getopt_data *d) /* Initialize the internal data when the first call is made. */ static const char * -_getopt_initialize (int argc, char **argv, const char *optstring, - int posixly_correct, struct _getopt_data *d) +_getopt_initialize (int argc _GL_UNUSED, + char **argv _GL_UNUSED, const char *optstring, + struct _getopt_data *d, int posixly_correct) { /* Start processing options with ARGV-element 1 (since ARGV-element 0 is the program name); the sequence of previously skipped @@ -260,25 +262,25 @@ _getopt_initialize (int argc, char **argv, const char *optstring, && argc == __libc_argc && argv == __libc_argv) { if (d->__nonoption_flags_max_len == 0) - { - if (__getopt_nonoption_flags == NULL - || __getopt_nonoption_flags[0] == '\0') - d->__nonoption_flags_max_len = -1; - else - { - const char *orig_str = __getopt_nonoption_flags; - int len = d->__nonoption_flags_max_len = strlen (orig_str); - if (d->__nonoption_flags_max_len < argc) - d->__nonoption_flags_max_len = argc; - __getopt_nonoption_flags = - (char *) malloc (d->__nonoption_flags_max_len); - if (__getopt_nonoption_flags == NULL) - d->__nonoption_flags_max_len = -1; - else - memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), - '\0', d->__nonoption_flags_max_len - len); - } - } + { + if (__getopt_nonoption_flags == NULL + || __getopt_nonoption_flags[0] == '\0') + d->__nonoption_flags_max_len = -1; + else + { + const char *orig_str = __getopt_nonoption_flags; + int len = d->__nonoption_flags_max_len = strlen (orig_str); + if (d->__nonoption_flags_max_len < argc) + d->__nonoption_flags_max_len = argc; + __getopt_nonoption_flags = + (char *) malloc (d->__nonoption_flags_max_len); + if (__getopt_nonoption_flags == NULL) + d->__nonoption_flags_max_len = -1; + else + memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), + '\0', d->__nonoption_flags_max_len - len); + } + } d->__nonoption_flags_len = d->__nonoption_flags_max_len; } else @@ -330,6 +332,10 @@ _getopt_initialize (int argc, char **argv, const char *optstring, `flag' field is nonzero, the value of the option's `val' field if the `flag' field is zero. + The elements of ARGV aren't really const, because we permute them. + But we pretend they're const in the prototype to be compatible + with other systems. + LONGOPTS is a vector of `struct option' terminated by an element containing a name which is zero. @@ -338,15 +344,12 @@ _getopt_initialize (int argc, char **argv, const char *optstring, recent call. If LONG_ONLY is nonzero, '-' as well as '--' can introduce - long-named options. - - If POSIXLY_CORRECT is nonzero, behave as if the POSIXLY_CORRECT - environment variable were set. */ + long-named options. */ int _getopt_internal_r (int argc, char **argv, const char *optstring, - const struct option *longopts, int *longind, - int long_only, int posixly_correct, struct _getopt_data *d) + const struct option *longopts, int *longind, + int long_only, struct _getopt_data *d, int posixly_correct) { int print_errors = d->opterr; if (optstring[0] == ':') @@ -360,9 +363,9 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, if (d->optind == 0 || !d->__initialized) { if (d->optind == 0) - d->optind = 1; /* Don't scan ARGV[0], the program name. */ - optstring = _getopt_initialize (argc, argv, optstring, - posixly_correct, d); + d->optind = 1; /* Don't scan ARGV[0], the program name. */ + optstring = _getopt_initialize (argc, argv, optstring, d, + posixly_correct); d->__initialized = 1; } @@ -372,8 +375,8 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, is only used when the used in the GNU libc. */ #if defined _LIBC && defined USE_NONOPTION_FLAGS # define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0' \ - || (d->optind < d->__nonoption_flags_len \ - && __getopt_nonoption_flags[d->optind] == '1')) + || (d->optind < d->__nonoption_flags_len \ + && __getopt_nonoption_flags[d->optind] == '1')) #else # define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0') #endif @@ -383,78 +386,78 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, /* Advance to the next ARGV-element. */ /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been - moved back by the user (who may also have changed the arguments). */ + moved back by the user (who may also have changed the arguments). */ if (d->__last_nonopt > d->optind) - d->__last_nonopt = d->optind; + d->__last_nonopt = d->optind; if (d->__first_nonopt > d->optind) - d->__first_nonopt = d->optind; + d->__first_nonopt = d->optind; if (d->__ordering == PERMUTE) - { - /* If we have just processed some options following some non-options, - exchange them so that the options come first. */ + { + /* If we have just processed some options following some non-options, + exchange them so that the options come first. */ - if (d->__first_nonopt != d->__last_nonopt - && d->__last_nonopt != d->optind) - exchange ((char **) argv, d); - else if (d->__last_nonopt != d->optind) - d->__first_nonopt = d->optind; + if (d->__first_nonopt != d->__last_nonopt + && d->__last_nonopt != d->optind) + exchange ((char **) argv, d); + else if (d->__last_nonopt != d->optind) + d->__first_nonopt = d->optind; - /* Skip any additional non-options - and extend the range of non-options previously skipped. */ + /* Skip any additional non-options + and extend the range of non-options previously skipped. */ - while (d->optind < argc && NONOPTION_P) - d->optind++; - d->__last_nonopt = d->optind; - } + while (d->optind < argc && NONOPTION_P) + d->optind++; + d->__last_nonopt = d->optind; + } /* The special ARGV-element `--' means premature end of options. - Skip it like a null option, - then exchange with previous non-options as if it were an option, - then skip everything else like a non-option. */ + Skip it like a null option, + then exchange with previous non-options as if it were an option, + then skip everything else like a non-option. */ if (d->optind != argc && !strcmp (argv[d->optind], "--")) - { - d->optind++; + { + d->optind++; - if (d->__first_nonopt != d->__last_nonopt - && d->__last_nonopt != d->optind) - exchange ((char **) argv, d); - else if (d->__first_nonopt == d->__last_nonopt) - d->__first_nonopt = d->optind; - d->__last_nonopt = argc; + if (d->__first_nonopt != d->__last_nonopt + && d->__last_nonopt != d->optind) + exchange ((char **) argv, d); + else if (d->__first_nonopt == d->__last_nonopt) + d->__first_nonopt = d->optind; + d->__last_nonopt = argc; - d->optind = argc; - } + d->optind = argc; + } /* If we have done all the ARGV-elements, stop the scan - and back over any non-options that we skipped and permuted. */ + and back over any non-options that we skipped and permuted. */ if (d->optind == argc) - { - /* Set the next-arg-index to point at the non-options - that we previously skipped, so the caller will digest them. */ - if (d->__first_nonopt != d->__last_nonopt) - d->optind = d->__first_nonopt; - return -1; - } + { + /* Set the next-arg-index to point at the non-options + that we previously skipped, so the caller will digest them. */ + if (d->__first_nonopt != d->__last_nonopt) + d->optind = d->__first_nonopt; + return -1; + } /* If we have come to a non-option and did not permute it, - either stop the scan or describe it to the caller and pass it by. */ + either stop the scan or describe it to the caller and pass it by. */ if (NONOPTION_P) - { - if (d->__ordering == REQUIRE_ORDER) - return -1; - d->optarg = argv[d->optind++]; - return 1; - } + { + if (d->__ordering == REQUIRE_ORDER) + return -1; + d->optarg = argv[d->optind++]; + return 1; + } /* We have found another option-ARGV-element. - Skip the initial punctuation. */ + Skip the initial punctuation. */ d->__nextchar = (argv[d->optind] + 1 - + (longopts != NULL && argv[d->optind][1] == '-')); + + (longopts != NULL && argv[d->optind][1] == '-')); } /* Decode the current option-ARGV-element. */ @@ -474,8 +477,8 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, if (longopts != NULL && (argv[d->optind][1] == '-' - || (long_only && (argv[d->optind][2] - || !strchr (optstring, argv[d->optind][1]))))) + || (long_only && (argv[d->optind][2] + || !strchr (optstring, argv[d->optind][1]))))) { char *nameend; const struct option *p; @@ -486,251 +489,251 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, int option_index; for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++) - /* Do nothing. */ ; + /* Do nothing. */ ; /* Test all long options for either exact match - or abbreviated matches. */ + or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar)) - { - if ((unsigned int) (nameend - d->__nextchar) - == (unsigned int) strlen (p->name)) - { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else if (long_only - || pfound->has_arg != p->has_arg - || pfound->flag != p->flag - || pfound->val != p->val) - /* Second or later nonexact match found. */ - ambig = 1; - } + if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar)) + { + if ((unsigned int) (nameend - d->__nextchar) + == (unsigned int) strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else if (long_only + || pfound->has_arg != p->has_arg + || pfound->flag != p->flag + || pfound->val != p->val) + /* Second or later nonexact match found. */ + ambig = 1; + } if (ambig && !exact) - { - if (print_errors) - { + { + if (print_errors) + { #if defined _LIBC && defined USE_IN_LIBIO - char *buf; + char *buf; - if (__asprintf (&buf, _("%s: option `%s' is ambiguous\n"), - argv[0], argv[d->optind]) >= 0) - { - _IO_flockfile (stderr); + if (__asprintf (&buf, _("%s: option '%s' is ambiguous\n"), + argv[0], argv[d->optind]) >= 0) + { + _IO_flockfile (stderr); - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - __fxprintf (NULL, "%s", buf); + __fxprintf (NULL, "%s", buf); - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); - free (buf); - } + free (buf); + } #else - fprintf (stderr, _("%s: option `%s' is ambiguous\n"), - argv[0], argv[d->optind]); + fprintf (stderr, _("%s: option '%s' is ambiguous\n"), + argv[0], argv[d->optind]); #endif - } - d->__nextchar += strlen (d->__nextchar); - d->optind++; - d->optopt = 0; - return '?'; - } + } + d->__nextchar += strlen (d->__nextchar); + d->optind++; + d->optopt = 0; + return '?'; + } if (pfound != NULL) - { - option_index = indfound; - d->optind++; - if (*nameend) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - d->optarg = nameend + 1; - else - { - if (print_errors) - { + { + option_index = indfound; + d->optind++; + if (*nameend) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + d->optarg = nameend + 1; + else + { + if (print_errors) + { #if defined _LIBC && defined USE_IN_LIBIO - char *buf; - int n; + char *buf; + int n; #endif - if (argv[d->optind - 1][1] == '-') - { - /* --option */ + if (argv[d->optind - 1][1] == '-') + { + /* --option */ #if defined _LIBC && defined USE_IN_LIBIO - n = __asprintf (&buf, _("\ -%s: option `--%s' doesn't allow an argument\n"), - argv[0], pfound->name); + n = __asprintf (&buf, _("\ +%s: option '--%s' doesn't allow an argument\n"), + argv[0], pfound->name); #else - fprintf (stderr, _("\ -%s: option `--%s' doesn't allow an argument\n"), - argv[0], pfound->name); + fprintf (stderr, _("\ +%s: option '--%s' doesn't allow an argument\n"), + argv[0], pfound->name); #endif - } - else - { - /* +option or -option */ + } + else + { + /* +option or -option */ #if defined _LIBC && defined USE_IN_LIBIO - n = __asprintf (&buf, _("\ -%s: option `%c%s' doesn't allow an argument\n"), - argv[0], argv[d->optind - 1][0], - pfound->name); + n = __asprintf (&buf, _("\ +%s: option '%c%s' doesn't allow an argument\n"), + argv[0], argv[d->optind - 1][0], + pfound->name); #else - fprintf (stderr, _("\ -%s: option `%c%s' doesn't allow an argument\n"), - argv[0], argv[d->optind - 1][0], - pfound->name); + fprintf (stderr, _("\ +%s: option '%c%s' doesn't allow an argument\n"), + argv[0], argv[d->optind - 1][0], + pfound->name); #endif - } + } #if defined _LIBC && defined USE_IN_LIBIO - if (n >= 0) - { - _IO_flockfile (stderr); + if (n >= 0) + { + _IO_flockfile (stderr); - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 - |= _IO_FLAGS2_NOTCANCEL; + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 + |= _IO_FLAGS2_NOTCANCEL; - __fxprintf (NULL, "%s", buf); + __fxprintf (NULL, "%s", buf); - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); - free (buf); - } + free (buf); + } #endif - } + } - d->__nextchar += strlen (d->__nextchar); + d->__nextchar += strlen (d->__nextchar); - d->optopt = pfound->val; - return '?'; - } - } - else if (pfound->has_arg == 1) - { - if (d->optind < argc) - d->optarg = argv[d->optind++]; - else - { - if (print_errors) - { + d->optopt = pfound->val; + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (d->optind < argc) + d->optarg = argv[d->optind++]; + else + { + if (print_errors) + { #if defined _LIBC && defined USE_IN_LIBIO - char *buf; + char *buf; - if (__asprintf (&buf, _("\ -%s: option `%s' requires an argument\n"), - argv[0], argv[d->optind - 1]) >= 0) - { - _IO_flockfile (stderr); + if (__asprintf (&buf, _("\ +%s: option '%s' requires an argument\n"), + argv[0], argv[d->optind - 1]) >= 0) + { + _IO_flockfile (stderr); - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 - |= _IO_FLAGS2_NOTCANCEL; + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 + |= _IO_FLAGS2_NOTCANCEL; - __fxprintf (NULL, "%s", buf); + __fxprintf (NULL, "%s", buf); - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); - free (buf); - } + free (buf); + } #else - fprintf (stderr, - _("%s: option `%s' requires an argument\n"), - argv[0], argv[d->optind - 1]); + fprintf (stderr, + _("%s: option '%s' requires an argument\n"), + argv[0], argv[d->optind - 1]); #endif - } - d->__nextchar += strlen (d->__nextchar); - d->optopt = pfound->val; - return optstring[0] == ':' ? ':' : '?'; - } - } - d->__nextchar += strlen (d->__nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } + } + d->__nextchar += strlen (d->__nextchar); + d->optopt = pfound->val; + return optstring[0] == ':' ? ':' : '?'; + } + } + d->__nextchar += strlen (d->__nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } /* Can't find it as a long option. If this is not getopt_long_only, - or the option starts with '--' or is not a valid short - option, then it's an error. - Otherwise interpret it as a short option. */ + or the option starts with '--' or is not a valid short + option, then it's an error. + Otherwise interpret it as a short option. */ if (!long_only || argv[d->optind][1] == '-' - || strchr (optstring, *d->__nextchar) == NULL) - { - if (print_errors) - { + || strchr (optstring, *d->__nextchar) == NULL) + { + if (print_errors) + { #if defined _LIBC && defined USE_IN_LIBIO - char *buf; - int n; + char *buf; + int n; #endif - if (argv[d->optind][1] == '-') - { - /* --option */ + if (argv[d->optind][1] == '-') + { + /* --option */ #if defined _LIBC && defined USE_IN_LIBIO - n = __asprintf (&buf, _("%s: unrecognized option `--%s'\n"), - argv[0], d->__nextchar); + n = __asprintf (&buf, _("%s: unrecognized option '--%s'\n"), + argv[0], d->__nextchar); #else - fprintf (stderr, _("%s: unrecognized option `--%s'\n"), - argv[0], d->__nextchar); + fprintf (stderr, _("%s: unrecognized option '--%s'\n"), + argv[0], d->__nextchar); #endif - } - else - { - /* +option or -option */ + } + else + { + /* +option or -option */ #if defined _LIBC && defined USE_IN_LIBIO - n = __asprintf (&buf, _("%s: unrecognized option `%c%s'\n"), - argv[0], argv[d->optind][0], d->__nextchar); + n = __asprintf (&buf, _("%s: unrecognized option '%c%s'\n"), + argv[0], argv[d->optind][0], d->__nextchar); #else - fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), - argv[0], argv[d->optind][0], d->__nextchar); + fprintf (stderr, _("%s: unrecognized option '%c%s'\n"), + argv[0], argv[d->optind][0], d->__nextchar); #endif - } + } #if defined _LIBC && defined USE_IN_LIBIO - if (n >= 0) - { - _IO_flockfile (stderr); + if (n >= 0) + { + _IO_flockfile (stderr); - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - __fxprintf (NULL, "%s", buf); + __fxprintf (NULL, "%s", buf); - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); - free (buf); - } + free (buf); + } #endif - } - d->__nextchar = (char *) ""; - d->optind++; - d->optopt = 0; - return '?'; - } + } + d->__nextchar = (char *) ""; + d->optind++; + d->optopt = 0; + return '?'; + } } /* Look at and handle the next short option-character. */ @@ -745,335 +748,321 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, if (temp == NULL || c == ':') { - if (print_errors) - { + if (print_errors) + { #if defined _LIBC && defined USE_IN_LIBIO - char *buf; - int n; + char *buf; + int n; #endif - if (d->__posixly_correct) - { - /* 1003.2 specifies the format of this message. */ #if defined _LIBC && defined USE_IN_LIBIO - n = __asprintf (&buf, _("%s: illegal option -- %c\n"), - argv[0], c); + n = __asprintf (&buf, _("%s: invalid option -- '%c'\n"), + argv[0], c); #else - fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c); + fprintf (stderr, _("%s: invalid option -- '%c'\n"), argv[0], c); #endif - } - else - { -#if defined _LIBC && defined USE_IN_LIBIO - n = __asprintf (&buf, _("%s: invalid option -- %c\n"), - argv[0], c); -#else - fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c); -#endif - } #if defined _LIBC && defined USE_IN_LIBIO - if (n >= 0) - { - _IO_flockfile (stderr); + if (n >= 0) + { + _IO_flockfile (stderr); - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - __fxprintf (NULL, "%s", buf); + __fxprintf (NULL, "%s", buf); - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); - free (buf); - } + free (buf); + } #endif - } - d->optopt = c; - return '?'; + } + d->optopt = c; + return '?'; } /* Convenience. Treat POSIX -W foo same as long option --foo */ if (temp[0] == 'W' && temp[1] == ';') { - char *nameend; - const struct option *p; - const struct option *pfound = NULL; - int exact = 0; - int ambig = 0; - int indfound = 0; - int option_index; + char *nameend; + const struct option *p; + const struct option *pfound = NULL; + int exact = 0; + int ambig = 0; + int indfound = 0; + int option_index; - /* This is an option that requires an argument. */ - if (*d->__nextchar != '\0') - { - d->optarg = d->__nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - d->optind++; - } - else if (d->optind == argc) - { - if (print_errors) - { - /* 1003.2 specifies the format of this message. */ + /* This is an option that requires an argument. */ + if (*d->__nextchar != '\0') + { + d->optarg = d->__nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + d->optind++; + } + else if (d->optind == argc) + { + if (print_errors) + { #if defined _LIBC && defined USE_IN_LIBIO - char *buf; + char *buf; - if (__asprintf (&buf, - _("%s: option requires an argument -- %c\n"), - argv[0], c) >= 0) - { - _IO_flockfile (stderr); + if (__asprintf (&buf, + _("%s: option requires an argument -- '%c'\n"), + argv[0], c) >= 0) + { + _IO_flockfile (stderr); - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - __fxprintf (NULL, "%s", buf); + __fxprintf (NULL, "%s", buf); - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); - free (buf); - } + free (buf); + } #else - fprintf (stderr, _("%s: option requires an argument -- %c\n"), - argv[0], c); + fprintf (stderr, + _("%s: option requires an argument -- '%c'\n"), + argv[0], c); #endif - } - d->optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - return c; - } - else - /* We already incremented `d->optind' once; - increment it again when taking next ARGV-elt as argument. */ - d->optarg = argv[d->optind++]; + } + d->optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + return c; + } + else + /* We already incremented `d->optind' once; + increment it again when taking next ARGV-elt as argument. */ + d->optarg = argv[d->optind++]; - /* optarg is now the argument, see if it's in the - table of longopts. */ + /* optarg is now the argument, see if it's in the + table of longopts. */ - for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != '='; - nameend++) - /* Do nothing. */ ; + for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != '='; + nameend++) + /* Do nothing. */ ; - /* Test all long options for either exact match - or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar)) - { - if ((unsigned int) (nameend - d->__nextchar) == strlen (p->name)) - { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else - /* Second or later nonexact match found. */ - ambig = 1; - } - if (ambig && !exact) - { - if (print_errors) - { + /* Test all long options for either exact match + or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar)) + { + if ((unsigned int) (nameend - d->__nextchar) == strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else + /* Second or later nonexact match found. */ + ambig = 1; + } + if (ambig && !exact) + { + if (print_errors) + { #if defined _LIBC && defined USE_IN_LIBIO - char *buf; + char *buf; - if (__asprintf (&buf, _("%s: option `-W %s' is ambiguous\n"), - argv[0], argv[d->optind]) >= 0) - { - _IO_flockfile (stderr); + if (__asprintf (&buf, _("%s: option '-W %s' is ambiguous\n"), + argv[0], argv[d->optind]) >= 0) + { + _IO_flockfile (stderr); - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - __fxprintf (NULL, "%s", buf); + __fxprintf (NULL, "%s", buf); - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); - free (buf); - } + free (buf); + } #else - fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), - argv[0], argv[d->optind]); + fprintf (stderr, _("%s: option '-W %s' is ambiguous\n"), + argv[0], argv[d->optind]); #endif - } - d->__nextchar += strlen (d->__nextchar); - d->optind++; - return '?'; - } - if (pfound != NULL) - { - option_index = indfound; - if (*nameend) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - d->optarg = nameend + 1; - else - { - if (print_errors) - { + } + d->__nextchar += strlen (d->__nextchar); + d->optind++; + return '?'; + } + if (pfound != NULL) + { + option_index = indfound; + if (*nameend) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + d->optarg = nameend + 1; + else + { + if (print_errors) + { #if defined _LIBC && defined USE_IN_LIBIO - char *buf; + char *buf; - if (__asprintf (&buf, _("\ -%s: option `-W %s' doesn't allow an argument\n"), - argv[0], pfound->name) >= 0) - { - _IO_flockfile (stderr); + if (__asprintf (&buf, _("\ +%s: option '-W %s' doesn't allow an argument\n"), + argv[0], pfound->name) >= 0) + { + _IO_flockfile (stderr); - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 - |= _IO_FLAGS2_NOTCANCEL; + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 + |= _IO_FLAGS2_NOTCANCEL; - __fxprintf (NULL, "%s", buf); + __fxprintf (NULL, "%s", buf); - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); - free (buf); - } + free (buf); + } #else - fprintf (stderr, _("\ -%s: option `-W %s' doesn't allow an argument\n"), - argv[0], pfound->name); + fprintf (stderr, _("\ +%s: option '-W %s' doesn't allow an argument\n"), + argv[0], pfound->name); #endif - } + } - d->__nextchar += strlen (d->__nextchar); - return '?'; - } - } - else if (pfound->has_arg == 1) - { - if (d->optind < argc) - d->optarg = argv[d->optind++]; - else - { - if (print_errors) - { + d->__nextchar += strlen (d->__nextchar); + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (d->optind < argc) + d->optarg = argv[d->optind++]; + else + { + if (print_errors) + { #if defined _LIBC && defined USE_IN_LIBIO - char *buf; + char *buf; - if (__asprintf (&buf, _("\ -%s: option `%s' requires an argument\n"), - argv[0], argv[d->optind - 1]) >= 0) - { - _IO_flockfile (stderr); + if (__asprintf (&buf, _("\ +%s: option '%s' requires an argument\n"), + argv[0], argv[d->optind - 1]) >= 0) + { + _IO_flockfile (stderr); - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 - |= _IO_FLAGS2_NOTCANCEL; + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 + |= _IO_FLAGS2_NOTCANCEL; - __fxprintf (NULL, "%s", buf); + __fxprintf (NULL, "%s", buf); - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); - free (buf); - } + free (buf); + } #else - fprintf (stderr, - _("%s: option `%s' requires an argument\n"), - argv[0], argv[d->optind - 1]); + fprintf (stderr, + _("%s: option '%s' requires an argument\n"), + argv[0], argv[d->optind - 1]); #endif - } - d->__nextchar += strlen (d->__nextchar); - return optstring[0] == ':' ? ':' : '?'; - } - } - d->__nextchar += strlen (d->__nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - d->__nextchar = NULL; - return 'W'; /* Let the application handle it. */ + } + d->__nextchar += strlen (d->__nextchar); + return optstring[0] == ':' ? ':' : '?'; + } + } + d->__nextchar += strlen (d->__nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + d->__nextchar = NULL; + return 'W'; /* Let the application handle it. */ } if (temp[1] == ':') { - if (temp[2] == ':') - { - /* This is an option that accepts an argument optionally. */ - if (*d->__nextchar != '\0') - { - d->optarg = d->__nextchar; - d->optind++; - } - else - d->optarg = NULL; - d->__nextchar = NULL; - } - else - { - /* This is an option that requires an argument. */ - if (*d->__nextchar != '\0') - { - d->optarg = d->__nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - d->optind++; - } - else if (d->optind == argc) - { - if (print_errors) - { - /* 1003.2 specifies the format of this message. */ + if (temp[2] == ':') + { + /* This is an option that accepts an argument optionally. */ + if (*d->__nextchar != '\0') + { + d->optarg = d->__nextchar; + d->optind++; + } + else + d->optarg = NULL; + d->__nextchar = NULL; + } + else + { + /* This is an option that requires an argument. */ + if (*d->__nextchar != '\0') + { + d->optarg = d->__nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + d->optind++; + } + else if (d->optind == argc) + { + if (print_errors) + { #if defined _LIBC && defined USE_IN_LIBIO - char *buf; + char *buf; - if (__asprintf (&buf, _("\ -%s: option requires an argument -- %c\n"), - argv[0], c) >= 0) - { - _IO_flockfile (stderr); + if (__asprintf (&buf, _("\ +%s: option requires an argument -- '%c'\n"), + argv[0], c) >= 0) + { + _IO_flockfile (stderr); - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; - __fxprintf (NULL, "%s", buf); + __fxprintf (NULL, "%s", buf); - ((_IO_FILE *) stderr)->_flags2 = old_flags2; - _IO_funlockfile (stderr); + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); - free (buf); - } + free (buf); + } #else - fprintf (stderr, - _("%s: option requires an argument -- %c\n"), - argv[0], c); + fprintf (stderr, + _("%s: option requires an argument -- '%c'\n"), + argv[0], c); #endif - } - d->optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - } - else - /* We already incremented `optind' once; - increment it again when taking next ARGV-elt as argument. */ - d->optarg = argv[d->optind++]; - d->__nextchar = NULL; - } + } + d->optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + d->optarg = argv[d->optind++]; + d->__nextchar = NULL; + } } return c; } @@ -1081,16 +1070,17 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, int _getopt_internal (int argc, char **argv, const char *optstring, - const struct option *longopts, int *longind, - int long_only, int posixly_correct) + const struct option *longopts, int *longind, int long_only, + int posixly_correct) { int result; getopt_data.optind = optind; getopt_data.opterr = opterr; - result = _getopt_internal_r (argc, argv, optstring, longopts, longind, - long_only, posixly_correct, &getopt_data); + result = _getopt_internal_r (argc, argv, optstring, longopts, + longind, long_only, &getopt_data, + posixly_correct); optind = getopt_data.optind; optarg = getopt_data.optarg; @@ -1110,10 +1100,23 @@ enum { POSIXLY_CORRECT = 1 }; int getopt (int argc, char *const *argv, const char *optstring) { - return _getopt_internal (argc, (char **) argv, optstring, NULL, NULL, 0, - POSIXLY_CORRECT); + return _getopt_internal (argc, (char **) argv, optstring, + (const struct option *) 0, + (int *) 0, + 0, POSIXLY_CORRECT); } +#ifdef _LIBC +int +__posix_getopt (int argc, char *const *argv, const char *optstring) +{ + return _getopt_internal (argc, argv, optstring, + (const struct option *) 0, + (int *) 0, + 0, 1); +} +#endif + #ifdef TEST @@ -1132,51 +1135,51 @@ main (int argc, char **argv) c = getopt (argc, argv, "abc:d:0123456789"); if (c == -1) - break; + break; switch (c) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; - case 'a': - printf ("option a\n"); - break; + case 'a': + printf ("option a\n"); + break; - case 'b': - printf ("option b\n"); - break; + case 'b': + printf ("option b\n"); + break; - case 'c': - printf ("option c with value `%s'\n", optarg); - break; + case 'c': + printf ("option c with value '%s'\n", optarg); + break; - case '?': - break; + case '?': + break; - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) - printf ("%s ", argv[optind++]); + printf ("%s ", argv[optind++]); printf ("\n"); } diff --git a/src/bin/coreutils/lib/getopt.in.h b/src/bin/coreutils/lib/getopt.in.h index d2d3e6e63b..57a8e8992d 100644 --- a/src/bin/coreutils/lib/getopt.in.h +++ b/src/bin/coreutils/lib/getopt.in.h @@ -1,6 +1,6 @@ /* Declarations for getopt. - Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2005,2006,2007 - Free Software Foundation, Inc. + Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2010 Free Software + Foundation, Inc. This file is part of the GNU C Library. This program is free software: you can redistribute it and/or modify @@ -16,24 +16,42 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef _GETOPT_H +#ifndef _GL_GETOPT_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif + +/* The include_next requires a split double-inclusion guard. We must + also inform the replacement unistd.h to not recursively use + ; our definitions will be present soon enough. */ +#if @HAVE_GETOPT_H@ +# define _GL_SYSTEM_GETOPT +# @INCLUDE_NEXT@ @NEXT_GETOPT_H@ +# undef _GL_SYSTEM_GETOPT +#endif + +#ifndef _GL_GETOPT_H #ifndef __need_getopt -# define _GETOPT_H 1 +# define _GL_GETOPT_H 1 #endif /* Standalone applications should #define __GETOPT_PREFIX to an identifier that prefixes the external functions and variables defined in this header. When this happens, include the headers that might declare getopt so that they will not cause - confusion if included after this file. Then systematically rename + confusion if included after this file (if the system had , + we have already included it). Then systematically rename identifiers so that they do not collide with the system functions and variables. Renaming avoids problems with some compilers and linkers. */ #if defined __GETOPT_PREFIX && !defined __need_getopt -# include -# include -# include +# if !@HAVE_GETOPT_H@ +# include +# include +# include +# endif # undef __need_getopt # undef getopt # undef getopt_long @@ -42,6 +60,7 @@ # undef opterr # undef optind # undef optopt +# undef option # define __GETOPT_CONCAT(x, y) x ## y # define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y) # define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y) @@ -52,6 +71,8 @@ # define opterr __GETOPT_ID (opterr) # define optind __GETOPT_ID (optind) # define optopt __GETOPT_ID (optopt) +# define option __GETOPT_ID (option) +# define _getopt_internal __GETOPT_ID (getopt_internal) #endif /* Standalone applications get correct prototypes for getopt_long and @@ -94,12 +115,14 @@ # define __GNUC_PREREQ(maj, min) (0) # endif # if defined __cplusplus && __GNUC_PREREQ (2,8) -# define __THROW throw () +# define __THROW throw () # else # define __THROW # endif #endif +/* The definition of _GL_ARG_NONNULL is copied here. */ + #ifdef __cplusplus extern "C" { #endif @@ -142,9 +165,9 @@ extern int optopt; zero. The field `has_arg' is: - no_argument (or 0) if the option does not take an argument, - required_argument (or 1) if the option requires an argument, - optional_argument (or 2) if the option takes an optional argument. + no_argument (or 0) if the option does not take an argument, + required_argument (or 1) if the option requires an argument, + optional_argument (or 2) if the option takes an optional argument. If the field `flag' is not NULL, it points to a variable that is set to the value given in the field `val' when the option is found, but @@ -169,10 +192,10 @@ struct option /* Names for the values of the `has_arg' field of `struct option'. */ -# define no_argument 0 -# define required_argument 1 -# define optional_argument 2 -#endif /* need getopt */ +# define no_argument 0 +# define required_argument 1 +# define optional_argument 2 +#endif /* need getopt */ /* Get definitions and prototypes for functions to process the @@ -201,17 +224,17 @@ struct option the environment, then do not permute arguments. */ extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) - __THROW; + __THROW _GL_ARG_NONNULL ((2, 3)); #ifndef __need_getopt extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv, - const char *__shortopts, - const struct option *__longopts, int *__longind) - __THROW; + const char *__shortopts, + const struct option *__longopts, int *__longind) + __THROW _GL_ARG_NONNULL ((2, 3)); extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv, - const char *__shortopts, - const struct option *__longopts, int *__longind) - __THROW; + const char *__shortopts, + const struct option *__longopts, int *__longind) + __THROW _GL_ARG_NONNULL ((2, 3)); #endif @@ -223,3 +246,4 @@ extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv, #undef __need_getopt #endif /* getopt.h */ +#endif /* getopt.h */ diff --git a/src/bin/coreutils/lib/getopt1.c b/src/bin/coreutils/lib/getopt1.c index ba115c472e..046d69f940 100644 --- a/src/bin/coreutils/lib/getopt1.c +++ b/src/bin/coreutils/lib/getopt1.c @@ -1,6 +1,6 @@ /* getopt_long and getopt_long_only entry points for GNU getopt. - Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98,2004,2006,2009 - Free Software Foundation, Inc. + Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, + 1998, 2004, 2006, 2009, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software: you can redistribute it and/or modify @@ -32,25 +32,25 @@ #include #endif -#ifndef NULL +#ifndef NULL #define NULL 0 #endif int getopt_long (int argc, char *__getopt_argv_const *argv, const char *options, - const struct option *long_options, int *opt_index) + const struct option *long_options, int *opt_index) { return _getopt_internal (argc, (char **) argv, options, long_options, - opt_index, 0, 0); + opt_index, 0, 0); } int _getopt_long_r (int argc, char **argv, const char *options, - const struct option *long_options, int *opt_index, - struct _getopt_data *d) + const struct option *long_options, int *opt_index, + struct _getopt_data *d) { return _getopt_internal_r (argc, argv, options, long_options, opt_index, - 0, 0, d); + 0, d, 0); } /* Like getopt_long, but '-' as well as '--' can indicate a long option. @@ -60,20 +60,20 @@ _getopt_long_r (int argc, char **argv, const char *options, int getopt_long_only (int argc, char *__getopt_argv_const *argv, - const char *options, - const struct option *long_options, int *opt_index) + const char *options, + const struct option *long_options, int *opt_index) { return _getopt_internal (argc, (char **) argv, options, long_options, - opt_index, 1, 0); + opt_index, 1, 0); } int _getopt_long_only_r (int argc, char **argv, const char *options, - const struct option *long_options, int *opt_index, - struct _getopt_data *d) + const struct option *long_options, int *opt_index, + struct _getopt_data *d) { return _getopt_internal_r (argc, argv, options, long_options, opt_index, - 1, 0, d); + 1, d, 0); } @@ -93,74 +93,74 @@ main (int argc, char **argv) int option_index = 0; static const struct option long_options[] = { - {"add", 1, 0, 0}, - {"append", 0, 0, 0}, - {"delete", 1, 0, 0}, - {"verbose", 0, 0, 0}, - {"create", 0, 0, 0}, - {"file", 1, 0, 0}, - {0, 0, 0, 0} + {"add", 1, 0, 0}, + {"append", 0, 0, 0}, + {"delete", 1, 0, 0}, + {"verbose", 0, 0, 0}, + {"create", 0, 0, 0}, + {"file", 1, 0, 0}, + {0, 0, 0, 0} }; c = getopt_long (argc, argv, "abc:d:0123456789", - long_options, &option_index); + long_options, &option_index); if (c == -1) - break; + break; switch (c) - { - case 0: - printf ("option %s", long_options[option_index].name); - if (optarg) - printf (" with arg %s", optarg); - printf ("\n"); - break; + { + case 0: + printf ("option %s", long_options[option_index].name); + if (optarg) + printf (" with arg %s", optarg); + printf ("\n"); + break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; - case 'a': - printf ("option a\n"); - break; + case 'a': + printf ("option a\n"); + break; - case 'b': - printf ("option b\n"); - break; + case 'b': + printf ("option b\n"); + break; - case 'c': - printf ("option c with value `%s'\n", optarg); - break; + case 'c': + printf ("option c with value `%s'\n", optarg); + break; - case 'd': - printf ("option d with value `%s'\n", optarg); - break; + case 'd': + printf ("option d with value `%s'\n", optarg); + break; - case '?': - break; + case '?': + break; - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) - printf ("%s ", argv[optind++]); + printf ("%s ", argv[optind++]); printf ("\n"); } diff --git a/src/bin/coreutils/lib/getopt_int.h b/src/bin/coreutils/lib/getopt_int.h index 3c6628bb94..169def5b26 100644 --- a/src/bin/coreutils/lib/getopt_int.h +++ b/src/bin/coreutils/lib/getopt_int.h @@ -1,6 +1,6 @@ /* Internal declarations for getopt. - Copyright (C) 1989-1994,1996-1999,2001,2003,2004 - Free Software Foundation, Inc. + Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2010 Free Software + Foundation, Inc. This file is part of the GNU C Library. This program is free software: you can redistribute it and/or modify @@ -17,12 +17,14 @@ along with this program. If not, see . */ #ifndef _GETOPT_INT_H -#define _GETOPT_INT_H 1 +#define _GETOPT_INT_H 1 + +#include extern int _getopt_internal (int ___argc, char **___argv, - const char *__shortopts, - const struct option *__longopts, int *__longind, - int __long_only, int __posixly_correct); + const char *__shortopts, + const struct option *__longopts, int *__longind, + int __long_only, int __posixly_correct); /* Reentrant versions which can handle parsing multiple argument @@ -108,23 +110,23 @@ struct _getopt_data /* The initializer is necessary to set OPTIND and OPTERR to their default values and to clear the initialization flag. */ -#define _GETOPT_DATA_INITIALIZER { 1, 1 } +#define _GETOPT_DATA_INITIALIZER { 1, 1 } extern int _getopt_internal_r (int ___argc, char **___argv, - const char *__shortopts, - const struct option *__longopts, int *__longind, - int __long_only, int __posixly_correct, - struct _getopt_data *__data); + const char *__shortopts, + const struct option *__longopts, int *__longind, + int __long_only, struct _getopt_data *__data, + int __posixly_correct); extern int _getopt_long_r (int ___argc, char **___argv, - const char *__shortopts, - const struct option *__longopts, int *__longind, - struct _getopt_data *__data); + const char *__shortopts, + const struct option *__longopts, int *__longind, + struct _getopt_data *__data); extern int _getopt_long_only_r (int ___argc, char **___argv, - const char *__shortopts, - const struct option *__longopts, - int *__longind, - struct _getopt_data *__data); + const char *__shortopts, + const struct option *__longopts, + int *__longind, + struct _getopt_data *__data); #endif /* getopt_int.h */ diff --git a/src/bin/coreutils/lib/getpagesize.c b/src/bin/coreutils/lib/getpagesize.c index 5498aa9483..cc2526870f 100644 --- a/src/bin/coreutils/lib/getpagesize.c +++ b/src/bin/coreutils/lib/getpagesize.c @@ -1,6 +1,6 @@ /* getpagesize emulation for systems where it cannot be done in a C macro. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/getpass.c b/src/bin/coreutils/lib/getpass.c index e144eff621..64c4acaf2c 100644 --- a/src/bin/coreutils/lib/getpass.c +++ b/src/bin/coreutils/lib/getpass.c @@ -1,8 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 -/* Copyright (C) 1992-2001, 2003, 2004, 2005, 2006, 2007 Free Software - Foundation, Inc. +/* Copyright (C) 1992-2001, 2003-2007, 2009-2010 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -37,7 +36,7 @@ # include # endif #else -# define __fsetlocking(stream, type) /* empty */ +# define __fsetlocking(stream, type) /* empty */ #endif #if HAVE_TERMIOS_H @@ -148,17 +147,17 @@ getpass (const char *prompt) if (buf != NULL) { if (nread < 0) - buf[0] = '\0'; + buf[0] = '\0'; else if (buf[nread - 1] == '\n') - { - /* Remove the newline. */ - buf[nread - 1] = '\0'; - if (tty_changed) - { - /* Write the newline that was not echoed. */ - putc_unlocked ('\n', out); - } - } + { + /* Remove the newline. */ + buf[nread - 1] = '\0'; + if (tty_changed) + { + /* Write the newline that was not echoed. */ + putc_unlocked ('\n', out); + } + } } /* Restore the original setting. */ @@ -207,20 +206,20 @@ getpass (const char *prompt) { c = _getch (); if (c == '\r') - { - getpassbuf[i] = '\0'; - break; - } + { + getpassbuf[i] = '\0'; + break; + } else if (i < PASS_MAX) - { - getpassbuf[i++] = c; - } + { + getpassbuf[i++] = c; + } if (i >= PASS_MAX) - { - getpassbuf[i] = '\0'; - break; - } + { + getpassbuf[i] = '\0'; + break; + } } if (prompt) diff --git a/src/bin/coreutils/lib/getpass.h b/src/bin/coreutils/lib/getpass.h index cb987ea9c1..175d7f0e01 100644 --- a/src/bin/coreutils/lib/getpass.h +++ b/src/bin/coreutils/lib/getpass.h @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* getpass.h -- Read a password of arbitrary length from /dev/tty or stdin. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2009-2010 Free Software Foundation, Inc. Contributed by Simon Josefsson , 2004. This program is free software; you can redistribute it and/or modify diff --git a/src/bin/coreutils/lib/gettext.h b/src/bin/coreutils/lib/gettext.h index 34edd9d0c5..191263d34f 100644 --- a/src/bin/coreutils/lib/gettext.h +++ b/src/bin/coreutils/lib/gettext.h @@ -2,7 +2,8 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Convenience header for conditional use of GNU . - Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009 Free Software Foundation, Inc. + Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2010 Free Software + Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -143,8 +144,8 @@ inline #endif static const char * pgettext_aux (const char *domain, - const char *msg_ctxt_id, const char *msgid, - int category) + const char *msg_ctxt_id, const char *msgid, + int category) { const char *translation = dcgettext (domain, msg_ctxt_id, category); if (translation == msg_ctxt_id) @@ -162,9 +163,9 @@ inline #endif static const char * npgettext_aux (const char *domain, - const char *msg_ctxt_id, const char *msgid, - const char *msgid_plural, unsigned long int n, - int category) + const char *msg_ctxt_id, const char *msgid, + const char *msgid_plural, unsigned long int n, + int category) { const char *translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); @@ -202,8 +203,8 @@ inline #endif static const char * dcpgettext_expr (const char *domain, - const char *msgctxt, const char *msgid, - int category) + const char *msgctxt, const char *msgid, + int category) { size_t msgctxt_len = strlen (msgctxt) + 1; size_t msgid_len = strlen (msgid) + 1; @@ -225,10 +226,10 @@ dcpgettext_expr (const char *domain, translation = dcgettext (domain, msg_ctxt_id, category); #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS if (msg_ctxt_id != buf) - free (msg_ctxt_id); + free (msg_ctxt_id); #endif if (translation != msg_ctxt_id) - return translation; + return translation; } return msgid; } @@ -247,9 +248,9 @@ inline #endif static const char * dcnpgettext_expr (const char *domain, - const char *msgctxt, const char *msgid, - const char *msgid_plural, unsigned long int n, - int category) + const char *msgctxt, const char *msgid, + const char *msgid_plural, unsigned long int n, + int category) { size_t msgctxt_len = strlen (msgctxt) + 1; size_t msgid_len = strlen (msgid) + 1; @@ -271,10 +272,10 @@ dcnpgettext_expr (const char *domain, translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS if (msg_ctxt_id != buf) - free (msg_ctxt_id); + free (msg_ctxt_id); #endif if (!(translation == msg_ctxt_id || translation == msgid_plural)) - return translation; + return translation; } return (n == 1 ? msgid : msgid_plural); } diff --git a/src/bin/coreutils/lib/gettime.c b/src/bin/coreutils/lib/gettime.c index 1b8533637d..044b26f0f3 100644 --- a/src/bin/coreutils/lib/gettime.c +++ b/src/bin/coreutils/lib/gettime.c @@ -1,6 +1,6 @@ /* gettime -- get the system clock - Copyright (C) 2002, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2002, 2004-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/gettimeofday.c b/src/bin/coreutils/lib/gettimeofday.c index 440bd3d955..092501b82e 100644 --- a/src/bin/coreutils/lib/gettimeofday.c +++ b/src/bin/coreutils/lib/gettimeofday.c @@ -3,8 +3,7 @@ #line 1 /* Provide gettimeofday for systems that don't have it or for which it's broken. - Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007, 2009 Free Software - Foundation, Inc. + Copyright (C) 2001-2003, 2005-2007, 2009-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/getugroups.c b/src/bin/coreutils/lib/getugroups.c index 2207b85a17..4a5a69ddce 100644 --- a/src/bin/coreutils/lib/getugroups.c +++ b/src/bin/coreutils/lib/getugroups.c @@ -1,6 +1,6 @@ /* getugroups.c -- return a list of the groups a user is in - Copyright (C) 1990, 1991, 1998-2000, 2003-2009 Free Software Foundation. + Copyright (C) 1990-1991, 1998-2000, 2003-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,22 +21,31 @@ #include "getugroups.h" +#include #include #include /* grp.h on alpha OSF1 V2.0 uses "FILE *". */ -#include - +#include #include -#include +#if !HAVE_GRP_H -/* Some old header files might not declare setgrent, getgrent, and endgrent. - If you don't have them at all, we can't implement this function. - You lose! */ -struct group *getgrent (void); +/* Mingw lacks all things related to group management. The best we + can do is fail with ENOSYS. */ -#include +int +getugroups (int maxcount _GL_UNUSED, + gid_t *grouplist _GL_UNUSED, + char const *username _GL_UNUSED, + gid_t gid _GL_UNUSED) +{ + errno = ENOSYS; + return -1; +} -#define STREQ(s1, s2) (strcmp (s1, s2) == 0) +#else /* HAVE_GRP_H */ +# include + +# define STREQ(s1, s2) (strcmp (s1, s2) == 0) /* Like `getgroups', but for user USERNAME instead of for the current process. Store at most MAXCOUNT group IDs in the GROUPLIST array. @@ -46,15 +55,15 @@ struct group *getgrent (void); Otherwise, return the number of IDs we've written into GROUPLIST. */ int -getugroups (int maxcount, GETGROUPS_T *grouplist, char const *username, - gid_t gid) +getugroups (int maxcount, gid_t *grouplist, char const *username, + gid_t gid) { int count = 0; if (gid != (gid_t) -1) { if (maxcount != 0) - grouplist[count] = gid; + grouplist[count] = gid; ++count; } @@ -67,37 +76,37 @@ getugroups (int maxcount, GETGROUPS_T *grouplist, char const *username, errno = 0; grp = getgrent (); if (grp == NULL) - break; + break; for (cp = grp->gr_mem; *cp; ++cp) - { - int n; + { + int n; - if ( ! STREQ (username, *cp)) - continue; + if ( ! STREQ (username, *cp)) + continue; - /* See if this group number is already on the list. */ - for (n = 0; n < count; ++n) - if (grouplist && grouplist[n] == grp->gr_gid) - break; + /* See if this group number is already on the list. */ + for (n = 0; n < count; ++n) + if (grouplist && grouplist[n] == grp->gr_gid) + break; - /* If it's a new group number, then try to add it to the list. */ - if (n == count) - { - if (maxcount != 0) - { - if (count >= maxcount) - goto done; - grouplist[count] = grp->gr_gid; - } - if (count == INT_MAX) - { - errno = EOVERFLOW; - goto done; - } - count++; - } - } + /* If it's a new group number, then try to add it to the list. */ + if (n == count) + { + if (maxcount != 0) + { + if (count >= maxcount) + goto done; + grouplist[count] = grp->gr_gid; + } + if (count == INT_MAX) + { + errno = EOVERFLOW; + goto done; + } + count++; + } + } } if (errno != 0) @@ -112,3 +121,5 @@ getugroups (int maxcount, GETGROUPS_T *grouplist, char const *username, return count; } + +#endif /* HAVE_GRP_H */ diff --git a/src/bin/coreutils/lib/getugroups.h b/src/bin/coreutils/lib/getugroups.h index f2914add7f..7ed78ddee3 100644 --- a/src/bin/coreutils/lib/getugroups.h +++ b/src/bin/coreutils/lib/getugroups.h @@ -1,5 +1,5 @@ /* Get a list of group IDs associated with a specified user ID. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,5 +15,5 @@ along with this program. If not, see . */ #include -int getugroups (int maxcount, GETGROUPS_T *grouplist, char const *username, - gid_t gid); +int getugroups (int maxcount, gid_t *grouplist, char const *username, + gid_t gid); diff --git a/src/bin/coreutils/lib/getusershell.c b/src/bin/coreutils/lib/getusershell.c index bea62a07af..a97b34ab89 100644 --- a/src/bin/coreutils/lib/getusershell.c +++ b/src/bin/coreutils/lib/getusershell.c @@ -1,7 +1,7 @@ /* getusershell.c -- Return names of valid user shells. - Copyright (C) 1991, 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 Free - Software Foundation, Inc. + Copyright (C) 1991, 1997, 2000-2001, 2003-2006, 2008-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -83,8 +83,8 @@ getusershell (void) if (default_index > 0) { if (default_shells[default_index]) - /* Not at the end of the list yet. */ - return xstrdup (default_shells[default_index++]); + /* Not at the end of the list yet. */ + return xstrdup (default_shells[default_index++]); return NULL; } @@ -92,19 +92,19 @@ getusershell (void) { shellstream = fopen (SHELLS_FILE, "r"); if (shellstream == NULL) - { - /* No shells file. Use the default list. */ - default_index = 1; - return xstrdup (default_shells[0]); - } + { + /* No shells file. Use the default list. */ + default_index = 1; + return xstrdup (default_shells[0]); + } } while (readname (&line, &line_size, shellstream)) { if (*line != '#') - return line; + return line; } - return NULL; /* End of file. */ + return NULL; /* End of file. */ } /* Rewind the shells file. */ @@ -150,9 +150,9 @@ readname (char **name, size_t *size, FILE *stream) for (;;) { if (*size <= name_index) - *name = x2nrealloc (*name, size, sizeof **name); + *name = x2nrealloc (*name, size, sizeof **name); if (c == EOF || isspace (c)) - break; + break; (*name)[name_index++] = c; c = getc (stream); } diff --git a/src/bin/coreutils/lib/glthread/lock.c b/src/bin/coreutils/lib/glthread/lock.c new file mode 100644 index 0000000000..dcf2a68d55 --- /dev/null +++ b/src/bin/coreutils/lib/glthread/lock.c @@ -0,0 +1,1061 @@ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +#line 1 +/* Locking in multithreaded situations. + Copyright (C) 2005-2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h, + gthr-win32.h. */ + +#include + +#include "glthread/lock.h" + +/* ========================================================================= */ + +#if USE_POSIX_THREADS + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +# if HAVE_PTHREAD_RWLOCK + +# if !defined PTHREAD_RWLOCK_INITIALIZER + +int +glthread_rwlock_init_multithreaded (gl_rwlock_t *lock) +{ + int err; + + err = pthread_rwlock_init (&lock->rwlock, NULL); + if (err != 0) + return err; + lock->initialized = 1; + return 0; +} + +int +glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock) +{ + if (!lock->initialized) + { + int err; + + err = pthread_mutex_lock (&lock->guard); + if (err != 0) + return err; + if (!lock->initialized) + { + err = glthread_rwlock_init_multithreaded (lock); + if (err != 0) + { + pthread_mutex_unlock (&lock->guard); + return err; + } + } + err = pthread_mutex_unlock (&lock->guard); + if (err != 0) + return err; + } + return pthread_rwlock_rdlock (&lock->rwlock); +} + +int +glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock) +{ + if (!lock->initialized) + { + int err; + + err = pthread_mutex_lock (&lock->guard); + if (err != 0) + return err; + if (!lock->initialized) + { + err = glthread_rwlock_init_multithreaded (lock); + if (err != 0) + { + pthread_mutex_unlock (&lock->guard); + return err; + } + } + err = pthread_mutex_unlock (&lock->guard); + if (err != 0) + return err; + } + return pthread_rwlock_wrlock (&lock->rwlock); +} + +int +glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock) +{ + if (!lock->initialized) + return EINVAL; + return pthread_rwlock_unlock (&lock->rwlock); +} + +int +glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock) +{ + int err; + + if (!lock->initialized) + return EINVAL; + err = pthread_rwlock_destroy (&lock->rwlock); + if (err != 0) + return err; + lock->initialized = 0; + return 0; +} + +# endif + +# else + +int +glthread_rwlock_init_multithreaded (gl_rwlock_t *lock) +{ + int err; + + err = pthread_mutex_init (&lock->lock, NULL); + if (err != 0) + return err; + err = pthread_cond_init (&lock->waiting_readers, NULL); + if (err != 0) + return err; + err = pthread_cond_init (&lock->waiting_writers, NULL); + if (err != 0) + return err; + lock->waiting_writers_count = 0; + lock->runcount = 0; + return 0; +} + +int +glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock) +{ + int err; + + err = pthread_mutex_lock (&lock->lock); + if (err != 0) + return err; + /* Test whether only readers are currently running, and whether the runcount + field will not overflow. */ + /* POSIX says: "It is implementation-defined whether the calling thread + acquires the lock when a writer does not hold the lock and there are + writers blocked on the lock." Let's say, no: give the writers a higher + priority. */ + while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0)) + { + /* This thread has to wait for a while. Enqueue it among the + waiting_readers. */ + err = pthread_cond_wait (&lock->waiting_readers, &lock->lock); + if (err != 0) + { + pthread_mutex_unlock (&lock->lock); + return err; + } + } + lock->runcount++; + return pthread_mutex_unlock (&lock->lock); +} + +int +glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock) +{ + int err; + + err = pthread_mutex_lock (&lock->lock); + if (err != 0) + return err; + /* Test whether no readers or writers are currently running. */ + while (!(lock->runcount == 0)) + { + /* This thread has to wait for a while. Enqueue it among the + waiting_writers. */ + lock->waiting_writers_count++; + err = pthread_cond_wait (&lock->waiting_writers, &lock->lock); + if (err != 0) + { + lock->waiting_writers_count--; + pthread_mutex_unlock (&lock->lock); + return err; + } + lock->waiting_writers_count--; + } + lock->runcount--; /* runcount becomes -1 */ + return pthread_mutex_unlock (&lock->lock); +} + +int +glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock) +{ + int err; + + err = pthread_mutex_lock (&lock->lock); + if (err != 0) + return err; + if (lock->runcount < 0) + { + /* Drop a writer lock. */ + if (!(lock->runcount == -1)) + { + pthread_mutex_unlock (&lock->lock); + return EINVAL; + } + lock->runcount = 0; + } + else + { + /* Drop a reader lock. */ + if (!(lock->runcount > 0)) + { + pthread_mutex_unlock (&lock->lock); + return EINVAL; + } + lock->runcount--; + } + if (lock->runcount == 0) + { + /* POSIX recommends that "write locks shall take precedence over read + locks", to avoid "writer starvation". */ + if (lock->waiting_writers_count > 0) + { + /* Wake up one of the waiting writers. */ + err = pthread_cond_signal (&lock->waiting_writers); + if (err != 0) + { + pthread_mutex_unlock (&lock->lock); + return err; + } + } + else + { + /* Wake up all waiting readers. */ + err = pthread_cond_broadcast (&lock->waiting_readers); + if (err != 0) + { + pthread_mutex_unlock (&lock->lock); + return err; + } + } + } + return pthread_mutex_unlock (&lock->lock); +} + +int +glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock) +{ + int err; + + err = pthread_mutex_destroy (&lock->lock); + if (err != 0) + return err; + err = pthread_cond_destroy (&lock->waiting_readers); + if (err != 0) + return err; + err = pthread_cond_destroy (&lock->waiting_writers); + if (err != 0) + return err; + return 0; +} + +# endif + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +# if HAVE_PTHREAD_MUTEX_RECURSIVE + +# if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP + +int +glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock) +{ + pthread_mutexattr_t attributes; + int err; + + err = pthread_mutexattr_init (&attributes); + if (err != 0) + return err; + err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE); + if (err != 0) + { + pthread_mutexattr_destroy (&attributes); + return err; + } + err = pthread_mutex_init (lock, &attributes); + if (err != 0) + { + pthread_mutexattr_destroy (&attributes); + return err; + } + err = pthread_mutexattr_destroy (&attributes); + if (err != 0) + return err; + return 0; +} + +# else + +int +glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock) +{ + pthread_mutexattr_t attributes; + int err; + + err = pthread_mutexattr_init (&attributes); + if (err != 0) + return err; + err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE); + if (err != 0) + { + pthread_mutexattr_destroy (&attributes); + return err; + } + err = pthread_mutex_init (&lock->recmutex, &attributes); + if (err != 0) + { + pthread_mutexattr_destroy (&attributes); + return err; + } + err = pthread_mutexattr_destroy (&attributes); + if (err != 0) + return err; + lock->initialized = 1; + return 0; +} + +int +glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock) +{ + if (!lock->initialized) + { + int err; + + err = pthread_mutex_lock (&lock->guard); + if (err != 0) + return err; + if (!lock->initialized) + { + err = glthread_recursive_lock_init_multithreaded (lock); + if (err != 0) + { + pthread_mutex_unlock (&lock->guard); + return err; + } + } + err = pthread_mutex_unlock (&lock->guard); + if (err != 0) + return err; + } + return pthread_mutex_lock (&lock->recmutex); +} + +int +glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock) +{ + if (!lock->initialized) + return EINVAL; + return pthread_mutex_unlock (&lock->recmutex); +} + +int +glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock) +{ + int err; + + if (!lock->initialized) + return EINVAL; + err = pthread_mutex_destroy (&lock->recmutex); + if (err != 0) + return err; + lock->initialized = 0; + return 0; +} + +# endif + +# else + +int +glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock) +{ + int err; + + err = pthread_mutex_init (&lock->mutex, NULL); + if (err != 0) + return err; + lock->owner = (pthread_t) 0; + lock->depth = 0; + return 0; +} + +int +glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock) +{ + pthread_t self = pthread_self (); + if (lock->owner != self) + { + int err; + + err = pthread_mutex_lock (&lock->mutex); + if (err != 0) + return err; + lock->owner = self; + } + if (++(lock->depth) == 0) /* wraparound? */ + { + lock->depth--; + return EAGAIN; + } + return 0; +} + +int +glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock) +{ + if (lock->owner != pthread_self ()) + return EPERM; + if (lock->depth == 0) + return EINVAL; + if (--(lock->depth) == 0) + { + lock->owner = (pthread_t) 0; + return pthread_mutex_unlock (&lock->mutex); + } + else + return 0; +} + +int +glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock) +{ + if (lock->owner != (pthread_t) 0) + return EBUSY; + return pthread_mutex_destroy (&lock->mutex); +} + +# endif + +/* -------------------------- gl_once_t datatype -------------------------- */ + +static const pthread_once_t fresh_once = PTHREAD_ONCE_INIT; + +int +glthread_once_singlethreaded (pthread_once_t *once_control) +{ + /* We don't know whether pthread_once_t is an integer type, a floating-point + type, a pointer type, or a structure type. */ + char *firstbyte = (char *)once_control; + if (*firstbyte == *(const char *)&fresh_once) + { + /* First time use of once_control. Invert the first byte. */ + *firstbyte = ~ *(const char *)&fresh_once; + return 1; + } + else + return 0; +} + +#endif + +/* ========================================================================= */ + +#if USE_PTH_THREADS + +/* Use the GNU Pth threads library. */ + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +/* -------------------------- gl_once_t datatype -------------------------- */ + +static void +glthread_once_call (void *arg) +{ + void (**gl_once_temp_addr) (void) = (void (**) (void)) arg; + void (*initfunction) (void) = *gl_once_temp_addr; + initfunction (); +} + +int +glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void)) +{ + void (*temp) (void) = initfunction; + return (!pth_once (once_control, glthread_once_call, &temp) ? errno : 0); +} + +int +glthread_once_singlethreaded (pth_once_t *once_control) +{ + /* We know that pth_once_t is an integer type. */ + if (*once_control == PTH_ONCE_INIT) + { + /* First time use of once_control. Invert the marker. */ + *once_control = ~ PTH_ONCE_INIT; + return 1; + } + else + return 0; +} + +#endif + +/* ========================================================================= */ + +#if USE_SOLARIS_THREADS + +/* Use the old Solaris threads library. */ + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +int +glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock) +{ + int err; + + err = mutex_init (&lock->mutex, USYNC_THREAD, NULL); + if (err != 0) + return err; + lock->owner = (thread_t) 0; + lock->depth = 0; + return 0; +} + +int +glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock) +{ + thread_t self = thr_self (); + if (lock->owner != self) + { + int err; + + err = mutex_lock (&lock->mutex); + if (err != 0) + return err; + lock->owner = self; + } + if (++(lock->depth) == 0) /* wraparound? */ + { + lock->depth--; + return EAGAIN; + } + return 0; +} + +int +glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock) +{ + if (lock->owner != thr_self ()) + return EPERM; + if (lock->depth == 0) + return EINVAL; + if (--(lock->depth) == 0) + { + lock->owner = (thread_t) 0; + return mutex_unlock (&lock->mutex); + } + else + return 0; +} + +int +glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock) +{ + if (lock->owner != (thread_t) 0) + return EBUSY; + return mutex_destroy (&lock->mutex); +} + +/* -------------------------- gl_once_t datatype -------------------------- */ + +int +glthread_once_multithreaded (gl_once_t *once_control, void (*initfunction) (void)) +{ + if (!once_control->inited) + { + int err; + + /* Use the mutex to guarantee that if another thread is already calling + the initfunction, this thread waits until it's finished. */ + err = mutex_lock (&once_control->mutex); + if (err != 0) + return err; + if (!once_control->inited) + { + once_control->inited = 1; + initfunction (); + } + return mutex_unlock (&once_control->mutex); + } + else + return 0; +} + +int +glthread_once_singlethreaded (gl_once_t *once_control) +{ + /* We know that gl_once_t contains an integer type. */ + if (!once_control->inited) + { + /* First time use of once_control. Invert the marker. */ + once_control->inited = ~ 0; + return 1; + } + else + return 0; +} + +#endif + +/* ========================================================================= */ + +#if USE_WIN32_THREADS + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +void +glthread_lock_init_func (gl_lock_t *lock) +{ + InitializeCriticalSection (&lock->lock); + lock->guard.done = 1; +} + +int +glthread_lock_lock_func (gl_lock_t *lock) +{ + if (!lock->guard.done) + { + if (InterlockedIncrement (&lock->guard.started) == 0) + /* This thread is the first one to need this lock. Initialize it. */ + glthread_lock_init (lock); + else + /* Yield the CPU while waiting for another thread to finish + initializing this lock. */ + while (!lock->guard.done) + Sleep (0); + } + EnterCriticalSection (&lock->lock); + return 0; +} + +int +glthread_lock_unlock_func (gl_lock_t *lock) +{ + if (!lock->guard.done) + return EINVAL; + LeaveCriticalSection (&lock->lock); + return 0; +} + +int +glthread_lock_destroy_func (gl_lock_t *lock) +{ + if (!lock->guard.done) + return EINVAL; + DeleteCriticalSection (&lock->lock); + lock->guard.done = 0; + return 0; +} + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +/* In this file, the waitqueues are implemented as circular arrays. */ +#define gl_waitqueue_t gl_carray_waitqueue_t + +static inline void +gl_waitqueue_init (gl_waitqueue_t *wq) +{ + wq->array = NULL; + wq->count = 0; + wq->alloc = 0; + wq->offset = 0; +} + +/* Enqueues the current thread, represented by an event, in a wait queue. + Returns INVALID_HANDLE_VALUE if an allocation failure occurs. */ +static HANDLE +gl_waitqueue_add (gl_waitqueue_t *wq) +{ + HANDLE event; + unsigned int index; + + if (wq->count == wq->alloc) + { + unsigned int new_alloc = 2 * wq->alloc + 1; + HANDLE *new_array = + (HANDLE *) realloc (wq->array, new_alloc * sizeof (HANDLE)); + if (new_array == NULL) + /* No more memory. */ + return INVALID_HANDLE_VALUE; + /* Now is a good opportunity to rotate the array so that its contents + starts at offset 0. */ + if (wq->offset > 0) + { + unsigned int old_count = wq->count; + unsigned int old_alloc = wq->alloc; + unsigned int old_offset = wq->offset; + unsigned int i; + if (old_offset + old_count > old_alloc) + { + unsigned int limit = old_offset + old_count - old_alloc; + for (i = 0; i < limit; i++) + new_array[old_alloc + i] = new_array[i]; + } + for (i = 0; i < old_count; i++) + new_array[i] = new_array[old_offset + i]; + wq->offset = 0; + } + wq->array = new_array; + wq->alloc = new_alloc; + } + /* Whether the created event is a manual-reset one or an auto-reset one, + does not matter, since we will wait on it only once. */ + event = CreateEvent (NULL, TRUE, FALSE, NULL); + if (event == INVALID_HANDLE_VALUE) + /* No way to allocate an event. */ + return INVALID_HANDLE_VALUE; + index = wq->offset + wq->count; + if (index >= wq->alloc) + index -= wq->alloc; + wq->array[index] = event; + wq->count++; + return event; +} + +/* Notifies the first thread from a wait queue and dequeues it. */ +static inline void +gl_waitqueue_notify_first (gl_waitqueue_t *wq) +{ + SetEvent (wq->array[wq->offset + 0]); + wq->offset++; + wq->count--; + if (wq->count == 0 || wq->offset == wq->alloc) + wq->offset = 0; +} + +/* Notifies all threads from a wait queue and dequeues them all. */ +static inline void +gl_waitqueue_notify_all (gl_waitqueue_t *wq) +{ + unsigned int i; + + for (i = 0; i < wq->count; i++) + { + unsigned int index = wq->offset + i; + if (index >= wq->alloc) + index -= wq->alloc; + SetEvent (wq->array[index]); + } + wq->count = 0; + wq->offset = 0; +} + +void +glthread_rwlock_init_func (gl_rwlock_t *lock) +{ + InitializeCriticalSection (&lock->lock); + gl_waitqueue_init (&lock->waiting_readers); + gl_waitqueue_init (&lock->waiting_writers); + lock->runcount = 0; + lock->guard.done = 1; +} + +int +glthread_rwlock_rdlock_func (gl_rwlock_t *lock) +{ + if (!lock->guard.done) + { + if (InterlockedIncrement (&lock->guard.started) == 0) + /* This thread is the first one to need this lock. Initialize it. */ + glthread_rwlock_init (lock); + else + /* Yield the CPU while waiting for another thread to finish + initializing this lock. */ + while (!lock->guard.done) + Sleep (0); + } + EnterCriticalSection (&lock->lock); + /* Test whether only readers are currently running, and whether the runcount + field will not overflow. */ + if (!(lock->runcount + 1 > 0)) + { + /* This thread has to wait for a while. Enqueue it among the + waiting_readers. */ + HANDLE event = gl_waitqueue_add (&lock->waiting_readers); + if (event != INVALID_HANDLE_VALUE) + { + DWORD result; + LeaveCriticalSection (&lock->lock); + /* Wait until another thread signals this event. */ + result = WaitForSingleObject (event, INFINITE); + if (result == WAIT_FAILED || result == WAIT_TIMEOUT) + abort (); + CloseHandle (event); + /* The thread which signalled the event already did the bookkeeping: + removed us from the waiting_readers, incremented lock->runcount. */ + if (!(lock->runcount > 0)) + abort (); + return 0; + } + else + { + /* Allocation failure. Weird. */ + do + { + LeaveCriticalSection (&lock->lock); + Sleep (1); + EnterCriticalSection (&lock->lock); + } + while (!(lock->runcount + 1 > 0)); + } + } + lock->runcount++; + LeaveCriticalSection (&lock->lock); + return 0; +} + +int +glthread_rwlock_wrlock_func (gl_rwlock_t *lock) +{ + if (!lock->guard.done) + { + if (InterlockedIncrement (&lock->guard.started) == 0) + /* This thread is the first one to need this lock. Initialize it. */ + glthread_rwlock_init (lock); + else + /* Yield the CPU while waiting for another thread to finish + initializing this lock. */ + while (!lock->guard.done) + Sleep (0); + } + EnterCriticalSection (&lock->lock); + /* Test whether no readers or writers are currently running. */ + if (!(lock->runcount == 0)) + { + /* This thread has to wait for a while. Enqueue it among the + waiting_writers. */ + HANDLE event = gl_waitqueue_add (&lock->waiting_writers); + if (event != INVALID_HANDLE_VALUE) + { + DWORD result; + LeaveCriticalSection (&lock->lock); + /* Wait until another thread signals this event. */ + result = WaitForSingleObject (event, INFINITE); + if (result == WAIT_FAILED || result == WAIT_TIMEOUT) + abort (); + CloseHandle (event); + /* The thread which signalled the event already did the bookkeeping: + removed us from the waiting_writers, set lock->runcount = -1. */ + if (!(lock->runcount == -1)) + abort (); + return 0; + } + else + { + /* Allocation failure. Weird. */ + do + { + LeaveCriticalSection (&lock->lock); + Sleep (1); + EnterCriticalSection (&lock->lock); + } + while (!(lock->runcount == 0)); + } + } + lock->runcount--; /* runcount becomes -1 */ + LeaveCriticalSection (&lock->lock); + return 0; +} + +int +glthread_rwlock_unlock_func (gl_rwlock_t *lock) +{ + if (!lock->guard.done) + return EINVAL; + EnterCriticalSection (&lock->lock); + if (lock->runcount < 0) + { + /* Drop a writer lock. */ + if (!(lock->runcount == -1)) + abort (); + lock->runcount = 0; + } + else + { + /* Drop a reader lock. */ + if (!(lock->runcount > 0)) + { + LeaveCriticalSection (&lock->lock); + return EPERM; + } + lock->runcount--; + } + if (lock->runcount == 0) + { + /* POSIX recommends that "write locks shall take precedence over read + locks", to avoid "writer starvation". */ + if (lock->waiting_writers.count > 0) + { + /* Wake up one of the waiting writers. */ + lock->runcount--; + gl_waitqueue_notify_first (&lock->waiting_writers); + } + else + { + /* Wake up all waiting readers. */ + lock->runcount += lock->waiting_readers.count; + gl_waitqueue_notify_all (&lock->waiting_readers); + } + } + LeaveCriticalSection (&lock->lock); + return 0; +} + +int +glthread_rwlock_destroy_func (gl_rwlock_t *lock) +{ + if (!lock->guard.done) + return EINVAL; + if (lock->runcount != 0) + return EBUSY; + DeleteCriticalSection (&lock->lock); + if (lock->waiting_readers.array != NULL) + free (lock->waiting_readers.array); + if (lock->waiting_writers.array != NULL) + free (lock->waiting_writers.array); + lock->guard.done = 0; + return 0; +} + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +void +glthread_recursive_lock_init_func (gl_recursive_lock_t *lock) +{ + lock->owner = 0; + lock->depth = 0; + InitializeCriticalSection (&lock->lock); + lock->guard.done = 1; +} + +int +glthread_recursive_lock_lock_func (gl_recursive_lock_t *lock) +{ + if (!lock->guard.done) + { + if (InterlockedIncrement (&lock->guard.started) == 0) + /* This thread is the first one to need this lock. Initialize it. */ + glthread_recursive_lock_init (lock); + else + /* Yield the CPU while waiting for another thread to finish + initializing this lock. */ + while (!lock->guard.done) + Sleep (0); + } + { + DWORD self = GetCurrentThreadId (); + if (lock->owner != self) + { + EnterCriticalSection (&lock->lock); + lock->owner = self; + } + if (++(lock->depth) == 0) /* wraparound? */ + { + lock->depth--; + return EAGAIN; + } + } + return 0; +} + +int +glthread_recursive_lock_unlock_func (gl_recursive_lock_t *lock) +{ + if (lock->owner != GetCurrentThreadId ()) + return EPERM; + if (lock->depth == 0) + return EINVAL; + if (--(lock->depth) == 0) + { + lock->owner = 0; + LeaveCriticalSection (&lock->lock); + } + return 0; +} + +int +glthread_recursive_lock_destroy_func (gl_recursive_lock_t *lock) +{ + if (lock->owner != 0) + return EBUSY; + DeleteCriticalSection (&lock->lock); + lock->guard.done = 0; + return 0; +} + +/* -------------------------- gl_once_t datatype -------------------------- */ + +void +glthread_once_func (gl_once_t *once_control, void (*initfunction) (void)) +{ + if (once_control->inited <= 0) + { + if (InterlockedIncrement (&once_control->started) == 0) + { + /* This thread is the first one to come to this once_control. */ + InitializeCriticalSection (&once_control->lock); + EnterCriticalSection (&once_control->lock); + once_control->inited = 0; + initfunction (); + once_control->inited = 1; + LeaveCriticalSection (&once_control->lock); + } + else + { + /* Undo last operation. */ + InterlockedDecrement (&once_control->started); + /* Some other thread has already started the initialization. + Yield the CPU while waiting for the other thread to finish + initializing and taking the lock. */ + while (once_control->inited < 0) + Sleep (0); + if (once_control->inited <= 0) + { + /* Take the lock. This blocks until the other thread has + finished calling the initfunction. */ + EnterCriticalSection (&once_control->lock); + LeaveCriticalSection (&once_control->lock); + if (!(once_control->inited > 0)) + abort (); + } + } + } +} + +#endif + +/* ========================================================================= */ diff --git a/src/bin/coreutils/lib/glthread/lock.h b/src/bin/coreutils/lib/glthread/lock.h new file mode 100644 index 0000000000..ec887e0ea3 --- /dev/null +++ b/src/bin/coreutils/lib/glthread/lock.h @@ -0,0 +1,930 @@ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +#line 1 +/* Locking in multithreaded situations. + Copyright (C) 2005-2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Bruno Haible , 2005. + Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h, + gthr-win32.h. */ + +/* This file contains locking primitives for use with a given thread library. + It does not contain primitives for creating threads or for other + synchronization primitives. + + Normal (non-recursive) locks: + Type: gl_lock_t + Declaration: gl_lock_define(extern, name) + Initializer: gl_lock_define_initialized(, name) + Initialization: gl_lock_init (name); + Taking the lock: gl_lock_lock (name); + Releasing the lock: gl_lock_unlock (name); + De-initialization: gl_lock_destroy (name); + Equivalent functions with control of error handling: + Initialization: err = glthread_lock_init (&name); + Taking the lock: err = glthread_lock_lock (&name); + Releasing the lock: err = glthread_lock_unlock (&name); + De-initialization: err = glthread_lock_destroy (&name); + + Read-Write (non-recursive) locks: + Type: gl_rwlock_t + Declaration: gl_rwlock_define(extern, name) + Initializer: gl_rwlock_define_initialized(, name) + Initialization: gl_rwlock_init (name); + Taking the lock: gl_rwlock_rdlock (name); + gl_rwlock_wrlock (name); + Releasing the lock: gl_rwlock_unlock (name); + De-initialization: gl_rwlock_destroy (name); + Equivalent functions with control of error handling: + Initialization: err = glthread_rwlock_init (&name); + Taking the lock: err = glthread_rwlock_rdlock (&name); + err = glthread_rwlock_wrlock (&name); + Releasing the lock: err = glthread_rwlock_unlock (&name); + De-initialization: err = glthread_rwlock_destroy (&name); + + Recursive locks: + Type: gl_recursive_lock_t + Declaration: gl_recursive_lock_define(extern, name) + Initializer: gl_recursive_lock_define_initialized(, name) + Initialization: gl_recursive_lock_init (name); + Taking the lock: gl_recursive_lock_lock (name); + Releasing the lock: gl_recursive_lock_unlock (name); + De-initialization: gl_recursive_lock_destroy (name); + Equivalent functions with control of error handling: + Initialization: err = glthread_recursive_lock_init (&name); + Taking the lock: err = glthread_recursive_lock_lock (&name); + Releasing the lock: err = glthread_recursive_lock_unlock (&name); + De-initialization: err = glthread_recursive_lock_destroy (&name); + + Once-only execution: + Type: gl_once_t + Initializer: gl_once_define(extern, name) + Execution: gl_once (name, initfunction); + Equivalent functions with control of error handling: + Execution: err = glthread_once (&name, initfunction); +*/ + + +#ifndef _LOCK_H +#define _LOCK_H + +#include +#include + +/* ========================================================================= */ + +#if USE_POSIX_THREADS + +/* Use the POSIX threads library. */ + +# include + +# ifdef __cplusplus +extern "C" { +# endif + +# if PTHREAD_IN_USE_DETECTION_HARD + +/* The pthread_in_use() detection needs to be done at runtime. */ +# define pthread_in_use() \ + glthread_in_use () +extern int glthread_in_use (void); + +# endif + +# if USE_POSIX_THREADS_WEAK + +/* Use weak references to the POSIX threads library. */ + +/* Weak references avoid dragging in external libraries if the other parts + of the program don't use them. Here we use them, because we don't want + every program that uses libintl to depend on libpthread. This assumes + that libpthread would not be loaded after libintl; i.e. if libintl is + loaded first, by an executable that does not depend on libpthread, and + then a module is dynamically loaded that depends on libpthread, libintl + will not be multithread-safe. */ + +/* The way to test at runtime whether libpthread is present is to test + whether a function pointer's value, such as &pthread_mutex_init, is + non-NULL. However, some versions of GCC have a bug through which, in + PIC mode, &foo != NULL always evaluates to true if there is a direct + call to foo(...) in the same function. To avoid this, we test the + address of a function in libpthread that we don't use. */ + +# pragma weak pthread_mutex_init +# pragma weak pthread_mutex_lock +# pragma weak pthread_mutex_unlock +# pragma weak pthread_mutex_destroy +# pragma weak pthread_rwlock_init +# pragma weak pthread_rwlock_rdlock +# pragma weak pthread_rwlock_wrlock +# pragma weak pthread_rwlock_unlock +# pragma weak pthread_rwlock_destroy +# pragma weak pthread_once +# pragma weak pthread_cond_init +# pragma weak pthread_cond_wait +# pragma weak pthread_cond_signal +# pragma weak pthread_cond_broadcast +# pragma weak pthread_cond_destroy +# pragma weak pthread_mutexattr_init +# pragma weak pthread_mutexattr_settype +# pragma weak pthread_mutexattr_destroy +# ifndef pthread_self +# pragma weak pthread_self +# endif + +# if !PTHREAD_IN_USE_DETECTION_HARD +# pragma weak pthread_cancel +# define pthread_in_use() (pthread_cancel != NULL) +# endif + +# else + +# if !PTHREAD_IN_USE_DETECTION_HARD +# define pthread_in_use() 1 +# endif + +# endif + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +typedef pthread_mutex_t gl_lock_t; +# define gl_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS pthread_mutex_t NAME; +# define gl_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS pthread_mutex_t NAME = gl_lock_initializer; +# define gl_lock_initializer \ + PTHREAD_MUTEX_INITIALIZER +# define glthread_lock_init(LOCK) \ + (pthread_in_use () ? pthread_mutex_init (LOCK, NULL) : 0) +# define glthread_lock_lock(LOCK) \ + (pthread_in_use () ? pthread_mutex_lock (LOCK) : 0) +# define glthread_lock_unlock(LOCK) \ + (pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0) +# define glthread_lock_destroy(LOCK) \ + (pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0) + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +# if HAVE_PTHREAD_RWLOCK + +# ifdef PTHREAD_RWLOCK_INITIALIZER + +typedef pthread_rwlock_t gl_rwlock_t; +# define gl_rwlock_define(STORAGECLASS, NAME) \ + STORAGECLASS pthread_rwlock_t NAME; +# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS pthread_rwlock_t NAME = gl_rwlock_initializer; +# define gl_rwlock_initializer \ + PTHREAD_RWLOCK_INITIALIZER +# define glthread_rwlock_init(LOCK) \ + (pthread_in_use () ? pthread_rwlock_init (LOCK, NULL) : 0) +# define glthread_rwlock_rdlock(LOCK) \ + (pthread_in_use () ? pthread_rwlock_rdlock (LOCK) : 0) +# define glthread_rwlock_wrlock(LOCK) \ + (pthread_in_use () ? pthread_rwlock_wrlock (LOCK) : 0) +# define glthread_rwlock_unlock(LOCK) \ + (pthread_in_use () ? pthread_rwlock_unlock (LOCK) : 0) +# define glthread_rwlock_destroy(LOCK) \ + (pthread_in_use () ? pthread_rwlock_destroy (LOCK) : 0) + +# else + +typedef struct + { + int initialized; + pthread_mutex_t guard; /* protects the initialization */ + pthread_rwlock_t rwlock; /* read-write lock */ + } + gl_rwlock_t; +# define gl_rwlock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_rwlock_t NAME; +# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; +# define gl_rwlock_initializer \ + { 0, PTHREAD_MUTEX_INITIALIZER } +# define glthread_rwlock_init(LOCK) \ + (pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0) +# define glthread_rwlock_rdlock(LOCK) \ + (pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0) +# define glthread_rwlock_wrlock(LOCK) \ + (pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0) +# define glthread_rwlock_unlock(LOCK) \ + (pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0) +# define glthread_rwlock_destroy(LOCK) \ + (pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0) +extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock); +extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock); +extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock); +extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock); +extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock); + +# endif + +# else + +typedef struct + { + pthread_mutex_t lock; /* protects the remaining fields */ + pthread_cond_t waiting_readers; /* waiting readers */ + pthread_cond_t waiting_writers; /* waiting writers */ + unsigned int waiting_writers_count; /* number of waiting writers */ + int runcount; /* number of readers running, or -1 when a writer runs */ + } + gl_rwlock_t; +# define gl_rwlock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_rwlock_t NAME; +# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; +# define gl_rwlock_initializer \ + { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0 } +# define glthread_rwlock_init(LOCK) \ + (pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0) +# define glthread_rwlock_rdlock(LOCK) \ + (pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0) +# define glthread_rwlock_wrlock(LOCK) \ + (pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0) +# define glthread_rwlock_unlock(LOCK) \ + (pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0) +# define glthread_rwlock_destroy(LOCK) \ + (pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0) +extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock); +extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock); +extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock); +extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock); +extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock); + +# endif + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +# if HAVE_PTHREAD_MUTEX_RECURSIVE + +# if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP + +typedef pthread_mutex_t gl_recursive_lock_t; +# define gl_recursive_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS pthread_mutex_t NAME; +# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS pthread_mutex_t NAME = gl_recursive_lock_initializer; +# ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER +# define gl_recursive_lock_initializer \ + PTHREAD_RECURSIVE_MUTEX_INITIALIZER +# else +# define gl_recursive_lock_initializer \ + PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP +# endif +# define glthread_recursive_lock_init(LOCK) \ + (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0) +# define glthread_recursive_lock_lock(LOCK) \ + (pthread_in_use () ? pthread_mutex_lock (LOCK) : 0) +# define glthread_recursive_lock_unlock(LOCK) \ + (pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0) +# define glthread_recursive_lock_destroy(LOCK) \ + (pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0) +extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock); + +# else + +typedef struct + { + pthread_mutex_t recmutex; /* recursive mutex */ + pthread_mutex_t guard; /* protects the initialization */ + int initialized; + } + gl_recursive_lock_t; +# define gl_recursive_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_recursive_lock_t NAME; +# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; +# define gl_recursive_lock_initializer \ + { PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, 0 } +# define glthread_recursive_lock_init(LOCK) \ + (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0) +# define glthread_recursive_lock_lock(LOCK) \ + (pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0) +# define glthread_recursive_lock_unlock(LOCK) \ + (pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0) +# define glthread_recursive_lock_destroy(LOCK) \ + (pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0) +extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock); +extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock); +extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock); +extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock); + +# endif + +# else + +/* Old versions of POSIX threads on Solaris did not have recursive locks. + We have to implement them ourselves. */ + +typedef struct + { + pthread_mutex_t mutex; + pthread_t owner; + unsigned long depth; + } + gl_recursive_lock_t; +# define gl_recursive_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_recursive_lock_t NAME; +# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; +# define gl_recursive_lock_initializer \ + { PTHREAD_MUTEX_INITIALIZER, (pthread_t) 0, 0 } +# define glthread_recursive_lock_init(LOCK) \ + (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0) +# define glthread_recursive_lock_lock(LOCK) \ + (pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0) +# define glthread_recursive_lock_unlock(LOCK) \ + (pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0) +# define glthread_recursive_lock_destroy(LOCK) \ + (pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0) +extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock); +extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock); +extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock); +extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock); + +# endif + +/* -------------------------- gl_once_t datatype -------------------------- */ + +typedef pthread_once_t gl_once_t; +# define gl_once_define(STORAGECLASS, NAME) \ + STORAGECLASS pthread_once_t NAME = PTHREAD_ONCE_INIT; +# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ + (pthread_in_use () \ + ? pthread_once (ONCE_CONTROL, INITFUNCTION) \ + : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) +extern int glthread_once_singlethreaded (pthread_once_t *once_control); + +# ifdef __cplusplus +} +# endif + +#endif + +/* ========================================================================= */ + +#if USE_PTH_THREADS + +/* Use the GNU Pth threads library. */ + +# include + +# ifdef __cplusplus +extern "C" { +# endif + +# if USE_PTH_THREADS_WEAK + +/* Use weak references to the GNU Pth threads library. */ + +# pragma weak pth_mutex_init +# pragma weak pth_mutex_acquire +# pragma weak pth_mutex_release +# pragma weak pth_rwlock_init +# pragma weak pth_rwlock_acquire +# pragma weak pth_rwlock_release +# pragma weak pth_once + +# pragma weak pth_cancel +# define pth_in_use() (pth_cancel != NULL) + +# else + +# define pth_in_use() 1 + +# endif + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +typedef pth_mutex_t gl_lock_t; +# define gl_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS pth_mutex_t NAME; +# define gl_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS pth_mutex_t NAME = gl_lock_initializer; +# define gl_lock_initializer \ + PTH_MUTEX_INIT +# define glthread_lock_init(LOCK) \ + (pth_in_use() && !pth_mutex_init (LOCK) ? errno : 0) +# define glthread_lock_lock(LOCK) \ + (pth_in_use() && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0) +# define glthread_lock_unlock(LOCK) \ + (pth_in_use() && !pth_mutex_release (LOCK) ? errno : 0) +# define glthread_lock_destroy(LOCK) \ + ((void)(LOCK), 0) + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +typedef pth_rwlock_t gl_rwlock_t; +# define gl_rwlock_define(STORAGECLASS, NAME) \ + STORAGECLASS pth_rwlock_t NAME; +# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS pth_rwlock_t NAME = gl_rwlock_initializer; +# define gl_rwlock_initializer \ + PTH_RWLOCK_INIT +# define glthread_rwlock_init(LOCK) \ + (pth_in_use() && !pth_rwlock_init (LOCK) ? errno : 0) +# define glthread_rwlock_rdlock(LOCK) \ + (pth_in_use() && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RD, 0, NULL) ? errno : 0) +# define glthread_rwlock_wrlock(LOCK) \ + (pth_in_use() && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RW, 0, NULL) ? errno : 0) +# define glthread_rwlock_unlock(LOCK) \ + (pth_in_use() && !pth_rwlock_release (LOCK) ? errno : 0) +# define glthread_rwlock_destroy(LOCK) \ + ((void)(LOCK), 0) + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +/* In Pth, mutexes are recursive by default. */ +typedef pth_mutex_t gl_recursive_lock_t; +# define gl_recursive_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS pth_mutex_t NAME; +# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS pth_mutex_t NAME = gl_recursive_lock_initializer; +# define gl_recursive_lock_initializer \ + PTH_MUTEX_INIT +# define glthread_recursive_lock_init(LOCK) \ + (pth_in_use() && !pth_mutex_init (LOCK) ? errno : 0) +# define glthread_recursive_lock_lock(LOCK) \ + (pth_in_use() && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0) +# define glthread_recursive_lock_unlock(LOCK) \ + (pth_in_use() && !pth_mutex_release (LOCK) ? errno : 0) +# define glthread_recursive_lock_destroy(LOCK) \ + ((void)(LOCK), 0) + +/* -------------------------- gl_once_t datatype -------------------------- */ + +typedef pth_once_t gl_once_t; +# define gl_once_define(STORAGECLASS, NAME) \ + STORAGECLASS pth_once_t NAME = PTH_ONCE_INIT; +# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ + (pth_in_use () \ + ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \ + : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) +extern int glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void)); +extern int glthread_once_singlethreaded (pth_once_t *once_control); + +# ifdef __cplusplus +} +# endif + +#endif + +/* ========================================================================= */ + +#if USE_SOLARIS_THREADS + +/* Use the old Solaris threads library. */ + +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + +# if USE_SOLARIS_THREADS_WEAK + +/* Use weak references to the old Solaris threads library. */ + +# pragma weak mutex_init +# pragma weak mutex_lock +# pragma weak mutex_unlock +# pragma weak mutex_destroy +# pragma weak rwlock_init +# pragma weak rw_rdlock +# pragma weak rw_wrlock +# pragma weak rw_unlock +# pragma weak rwlock_destroy +# pragma weak thr_self + +# pragma weak thr_suspend +# define thread_in_use() (thr_suspend != NULL) + +# else + +# define thread_in_use() 1 + +# endif + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +typedef mutex_t gl_lock_t; +# define gl_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS mutex_t NAME; +# define gl_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS mutex_t NAME = gl_lock_initializer; +# define gl_lock_initializer \ + DEFAULTMUTEX +# define glthread_lock_init(LOCK) \ + (thread_in_use () ? mutex_init (LOCK, USYNC_THREAD, NULL) : 0) +# define glthread_lock_lock(LOCK) \ + (thread_in_use () ? mutex_lock (LOCK) : 0) +# define glthread_lock_unlock(LOCK) \ + (thread_in_use () ? mutex_unlock (LOCK) : 0) +# define glthread_lock_destroy(LOCK) \ + (thread_in_use () ? mutex_destroy (LOCK) : 0) + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +typedef rwlock_t gl_rwlock_t; +# define gl_rwlock_define(STORAGECLASS, NAME) \ + STORAGECLASS rwlock_t NAME; +# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS rwlock_t NAME = gl_rwlock_initializer; +# define gl_rwlock_initializer \ + DEFAULTRWLOCK +# define glthread_rwlock_init(LOCK) \ + (thread_in_use () ? rwlock_init (LOCK, USYNC_THREAD, NULL) : 0) +# define glthread_rwlock_rdlock(LOCK) \ + (thread_in_use () ? rw_rdlock (LOCK) : 0) +# define glthread_rwlock_wrlock(LOCK) \ + (thread_in_use () ? rw_wrlock (LOCK) : 0) +# define glthread_rwlock_unlock(LOCK) \ + (thread_in_use () ? rw_unlock (LOCK) : 0) +# define glthread_rwlock_destroy(LOCK) \ + (thread_in_use () ? rwlock_destroy (LOCK) : 0) + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +/* Old Solaris threads did not have recursive locks. + We have to implement them ourselves. */ + +typedef struct + { + mutex_t mutex; + thread_t owner; + unsigned long depth; + } + gl_recursive_lock_t; +# define gl_recursive_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_recursive_lock_t NAME; +# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; +# define gl_recursive_lock_initializer \ + { DEFAULTMUTEX, (thread_t) 0, 0 } +# define glthread_recursive_lock_init(LOCK) \ + (thread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0) +# define glthread_recursive_lock_lock(LOCK) \ + (thread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0) +# define glthread_recursive_lock_unlock(LOCK) \ + (thread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0) +# define glthread_recursive_lock_destroy(LOCK) \ + (thread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0) +extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock); +extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock); +extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock); +extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock); + +/* -------------------------- gl_once_t datatype -------------------------- */ + +typedef struct + { + volatile int inited; + mutex_t mutex; + } + gl_once_t; +# define gl_once_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_once_t NAME = { 0, DEFAULTMUTEX }; +# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ + (thread_in_use () \ + ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \ + : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) +extern int glthread_once_multithreaded (gl_once_t *once_control, void (*initfunction) (void)); +extern int glthread_once_singlethreaded (gl_once_t *once_control); + +# ifdef __cplusplus +} +# endif + +#endif + +/* ========================================================================= */ + +#if USE_WIN32_THREADS + +# include + +# ifdef __cplusplus +extern "C" { +# endif + +/* We can use CRITICAL_SECTION directly, rather than the Win32 Event, Mutex, + Semaphore types, because + - we need only to synchronize inside a single process (address space), + not inter-process locking, + - we don't need to support trylock operations. (TryEnterCriticalSection + does not work on Windows 95/98/ME. Packages that need trylock usually + define their own mutex type.) */ + +/* There is no way to statically initialize a CRITICAL_SECTION. It needs + to be done lazily, once only. For this we need spinlocks. */ + +typedef struct { volatile int done; volatile long started; } gl_spinlock_t; + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +typedef struct + { + gl_spinlock_t guard; /* protects the initialization */ + CRITICAL_SECTION lock; + } + gl_lock_t; +# define gl_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_lock_t NAME; +# define gl_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_lock_t NAME = gl_lock_initializer; +# define gl_lock_initializer \ + { { 0, -1 } } +# define glthread_lock_init(LOCK) \ + (glthread_lock_init_func (LOCK), 0) +# define glthread_lock_lock(LOCK) \ + glthread_lock_lock_func (LOCK) +# define glthread_lock_unlock(LOCK) \ + glthread_lock_unlock_func (LOCK) +# define glthread_lock_destroy(LOCK) \ + glthread_lock_destroy_func (LOCK) +extern void glthread_lock_init_func (gl_lock_t *lock); +extern int glthread_lock_lock_func (gl_lock_t *lock); +extern int glthread_lock_unlock_func (gl_lock_t *lock); +extern int glthread_lock_destroy_func (gl_lock_t *lock); + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +/* It is impossible to implement read-write locks using plain locks, without + introducing an extra thread dedicated to managing read-write locks. + Therefore here we need to use the low-level Event type. */ + +typedef struct + { + HANDLE *array; /* array of waiting threads, each represented by an event */ + unsigned int count; /* number of waiting threads */ + unsigned int alloc; /* length of allocated array */ + unsigned int offset; /* index of first waiting thread in array */ + } + gl_carray_waitqueue_t; +typedef struct + { + gl_spinlock_t guard; /* protects the initialization */ + CRITICAL_SECTION lock; /* protects the remaining fields */ + gl_carray_waitqueue_t waiting_readers; /* waiting readers */ + gl_carray_waitqueue_t waiting_writers; /* waiting writers */ + int runcount; /* number of readers running, or -1 when a writer runs */ + } + gl_rwlock_t; +# define gl_rwlock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_rwlock_t NAME; +# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; +# define gl_rwlock_initializer \ + { { 0, -1 } } +# define glthread_rwlock_init(LOCK) \ + (glthread_rwlock_init_func (LOCK), 0) +# define glthread_rwlock_rdlock(LOCK) \ + glthread_rwlock_rdlock_func (LOCK) +# define glthread_rwlock_wrlock(LOCK) \ + glthread_rwlock_wrlock_func (LOCK) +# define glthread_rwlock_unlock(LOCK) \ + glthread_rwlock_unlock_func (LOCK) +# define glthread_rwlock_destroy(LOCK) \ + glthread_rwlock_destroy_func (LOCK) +extern void glthread_rwlock_init_func (gl_rwlock_t *lock); +extern int glthread_rwlock_rdlock_func (gl_rwlock_t *lock); +extern int glthread_rwlock_wrlock_func (gl_rwlock_t *lock); +extern int glthread_rwlock_unlock_func (gl_rwlock_t *lock); +extern int glthread_rwlock_destroy_func (gl_rwlock_t *lock); + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +/* The Win32 documentation says that CRITICAL_SECTION already implements a + recursive lock. But we need not rely on it: It's easy to implement a + recursive lock without this assumption. */ + +typedef struct + { + gl_spinlock_t guard; /* protects the initialization */ + DWORD owner; + unsigned long depth; + CRITICAL_SECTION lock; + } + gl_recursive_lock_t; +# define gl_recursive_lock_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_recursive_lock_t NAME; +# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ + STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; +# define gl_recursive_lock_initializer \ + { { 0, -1 }, 0, 0 } +# define glthread_recursive_lock_init(LOCK) \ + (glthread_recursive_lock_init_func (LOCK), 0) +# define glthread_recursive_lock_lock(LOCK) \ + glthread_recursive_lock_lock_func (LOCK) +# define glthread_recursive_lock_unlock(LOCK) \ + glthread_recursive_lock_unlock_func (LOCK) +# define glthread_recursive_lock_destroy(LOCK) \ + glthread_recursive_lock_destroy_func (LOCK) +extern void glthread_recursive_lock_init_func (gl_recursive_lock_t *lock); +extern int glthread_recursive_lock_lock_func (gl_recursive_lock_t *lock); +extern int glthread_recursive_lock_unlock_func (gl_recursive_lock_t *lock); +extern int glthread_recursive_lock_destroy_func (gl_recursive_lock_t *lock); + +/* -------------------------- gl_once_t datatype -------------------------- */ + +typedef struct + { + volatile int inited; + volatile long started; + CRITICAL_SECTION lock; + } + gl_once_t; +# define gl_once_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_once_t NAME = { -1, -1 }; +# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ + (glthread_once_func (ONCE_CONTROL, INITFUNCTION), 0) +extern void glthread_once_func (gl_once_t *once_control, void (*initfunction) (void)); + +# ifdef __cplusplus +} +# endif + +#endif + +/* ========================================================================= */ + +#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WIN32_THREADS) + +/* Provide dummy implementation if threads are not supported. */ + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +typedef int gl_lock_t; +# define gl_lock_define(STORAGECLASS, NAME) +# define gl_lock_define_initialized(STORAGECLASS, NAME) +# define glthread_lock_init(NAME) 0 +# define glthread_lock_lock(NAME) 0 +# define glthread_lock_unlock(NAME) 0 +# define glthread_lock_destroy(NAME) 0 + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +typedef int gl_rwlock_t; +# define gl_rwlock_define(STORAGECLASS, NAME) +# define gl_rwlock_define_initialized(STORAGECLASS, NAME) +# define glthread_rwlock_init(NAME) 0 +# define glthread_rwlock_rdlock(NAME) 0 +# define glthread_rwlock_wrlock(NAME) 0 +# define glthread_rwlock_unlock(NAME) 0 +# define glthread_rwlock_destroy(NAME) 0 + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +typedef int gl_recursive_lock_t; +# define gl_recursive_lock_define(STORAGECLASS, NAME) +# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) +# define glthread_recursive_lock_init(NAME) 0 +# define glthread_recursive_lock_lock(NAME) 0 +# define glthread_recursive_lock_unlock(NAME) 0 +# define glthread_recursive_lock_destroy(NAME) 0 + +/* -------------------------- gl_once_t datatype -------------------------- */ + +typedef int gl_once_t; +# define gl_once_define(STORAGECLASS, NAME) \ + STORAGECLASS gl_once_t NAME = 0; +# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ + (*(ONCE_CONTROL) == 0 ? (*(ONCE_CONTROL) = ~ 0, INITFUNCTION (), 0) : 0) + +#endif + +/* ========================================================================= */ + +/* Macros with built-in error handling. */ + +/* -------------------------- gl_lock_t datatype -------------------------- */ + +#define gl_lock_init(NAME) \ + do \ + { \ + if (glthread_lock_init (&NAME)) \ + abort (); \ + } \ + while (0) +#define gl_lock_lock(NAME) \ + do \ + { \ + if (glthread_lock_lock (&NAME)) \ + abort (); \ + } \ + while (0) +#define gl_lock_unlock(NAME) \ + do \ + { \ + if (glthread_lock_unlock (&NAME)) \ + abort (); \ + } \ + while (0) +#define gl_lock_destroy(NAME) \ + do \ + { \ + if (glthread_lock_destroy (&NAME)) \ + abort (); \ + } \ + while (0) + +/* ------------------------- gl_rwlock_t datatype ------------------------- */ + +#define gl_rwlock_init(NAME) \ + do \ + { \ + if (glthread_rwlock_init (&NAME)) \ + abort (); \ + } \ + while (0) +#define gl_rwlock_rdlock(NAME) \ + do \ + { \ + if (glthread_rwlock_rdlock (&NAME)) \ + abort (); \ + } \ + while (0) +#define gl_rwlock_wrlock(NAME) \ + do \ + { \ + if (glthread_rwlock_wrlock (&NAME)) \ + abort (); \ + } \ + while (0) +#define gl_rwlock_unlock(NAME) \ + do \ + { \ + if (glthread_rwlock_unlock (&NAME)) \ + abort (); \ + } \ + while (0) +#define gl_rwlock_destroy(NAME) \ + do \ + { \ + if (glthread_rwlock_destroy (&NAME)) \ + abort (); \ + } \ + while (0) + +/* --------------------- gl_recursive_lock_t datatype --------------------- */ + +#define gl_recursive_lock_init(NAME) \ + do \ + { \ + if (glthread_recursive_lock_init (&NAME)) \ + abort (); \ + } \ + while (0) +#define gl_recursive_lock_lock(NAME) \ + do \ + { \ + if (glthread_recursive_lock_lock (&NAME)) \ + abort (); \ + } \ + while (0) +#define gl_recursive_lock_unlock(NAME) \ + do \ + { \ + if (glthread_recursive_lock_unlock (&NAME)) \ + abort (); \ + } \ + while (0) +#define gl_recursive_lock_destroy(NAME) \ + do \ + { \ + if (glthread_recursive_lock_destroy (&NAME)) \ + abort (); \ + } \ + while (0) + +/* -------------------------- gl_once_t datatype -------------------------- */ + +#define gl_once(NAME, INITFUNCTION) \ + do \ + { \ + if (glthread_once (&NAME, INITFUNCTION)) \ + abort (); \ + } \ + while (0) + +/* ========================================================================= */ + +#endif /* _LOCK_H */ diff --git a/src/bin/coreutils/lib/glthread/threadlib.c b/src/bin/coreutils/lib/glthread/threadlib.c new file mode 100644 index 0000000000..e5243480e1 --- /dev/null +++ b/src/bin/coreutils/lib/glthread/threadlib.c @@ -0,0 +1,77 @@ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +#line 1 +/* Multithreading primitives. + Copyright (C) 2005-2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Bruno Haible , 2005. */ + +#include + +/* ========================================================================= */ + +#if USE_POSIX_THREADS + +/* Use the POSIX threads library. */ + +# include +# include + +# if PTHREAD_IN_USE_DETECTION_HARD + +/* The function to be executed by a dummy thread. */ +static void * +dummy_thread_func (void *arg) +{ + return arg; +} + +int +glthread_in_use (void) +{ + static int tested; + static int result; /* 1: linked with -lpthread, 0: only with libc */ + + if (!tested) + { + pthread_t thread; + + if (pthread_create (&thread, NULL, dummy_thread_func, NULL) != 0) + /* Thread creation failed. */ + result = 0; + else + { + /* Thread creation works. */ + void *retval; + if (pthread_join (thread, &retval) != 0) + abort (); + result = 1; + } + tested = 1; + } + return result; +} + +# endif + +#endif + +/* ========================================================================= */ + +/* This declaration is solely to ensure that after preprocessing + this file is never empty. */ +typedef int dummy; diff --git a/src/bin/coreutils/lib/glthread/tls.c b/src/bin/coreutils/lib/glthread/tls.c new file mode 100644 index 0000000000..6618884b1b --- /dev/null +++ b/src/bin/coreutils/lib/glthread/tls.c @@ -0,0 +1,61 @@ +/* Thread-local storage in multithreaded situations. + Copyright (C) 2005-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2005. */ + +#include + +#include "glthread/tls.h" + +/* ========================================================================= */ + +#if USE_POSIX_THREADS + +#endif + +/* ========================================================================= */ + +#if USE_PTH_THREADS + +#endif + +/* ========================================================================= */ + +#if USE_SOLARIS_THREADS + +/* Use the old Solaris threads library. */ + +/* ------------------------- gl_tls_key_t datatype ------------------------- */ + +void * +glthread_tls_get_multithreaded (thread_key_t key) +{ + void *value; + + if (thr_getspecific (key, &value) != 0) + abort (); + return value; +} + +#endif + +/* ========================================================================= */ + +#if USE_WIN32_THREADS + +#endif + +/* ========================================================================= */ diff --git a/src/bin/coreutils/lib/glthread/tls.h b/src/bin/coreutils/lib/glthread/tls.h new file mode 100644 index 0000000000..e39623f70f --- /dev/null +++ b/src/bin/coreutils/lib/glthread/tls.h @@ -0,0 +1,298 @@ +/* Thread-local storage in multithreaded situations. + Copyright (C) 2005, 2007-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Bruno Haible , 2005. */ + +/* This file contains thread-local storage primitives for use with a given + thread library. It does not contain primitives for creating threads or + for other multithreading primitives. + + Type: gl_tls_key_t + Initialization: gl_tls_key_init (name, destructor); + Getting per-thread value: gl_tls_get (name) + Setting per-thread value: gl_tls_set (name, pointer); + De-initialization: gl_tls_key_destroy (name); + Equivalent functions with control of error handling: + Initialization: err = glthread_tls_key_init (&name, destructor); + Setting per-thread value: err = glthread_tls_set (&name, pointer); + De-initialization: err = glthread_tls_key_destroy (&name); + + A per-thread value is of type 'void *'. + + A destructor is a function pointer of type 'void (*) (void *)', called + when a thread exits, and taking the last per-thread value as argument. It + is unspecified whether the destructor function is called when the last + per-thread value is NULL. On some platforms, the destructor function is + not called at all. +*/ + + +#ifndef _TLS_H +#define _TLS_H + +#include +#include + +/* ========================================================================= */ + +#if USE_POSIX_THREADS + +/* Use the POSIX threads library. */ + +# include + +# if PTHREAD_IN_USE_DETECTION_HARD + +/* The pthread_in_use() detection needs to be done at runtime. */ +# define pthread_in_use() \ + glthread_in_use () +extern int glthread_in_use (void); + +# endif + +# if USE_POSIX_THREADS_WEAK + +/* Use weak references to the POSIX threads library. */ + +# pragma weak pthread_key_create +# pragma weak pthread_getspecific +# pragma weak pthread_setspecific +# pragma weak pthread_key_delete +# ifndef pthread_self +# pragma weak pthread_self +# endif + +# if !PTHREAD_IN_USE_DETECTION_HARD +# pragma weak pthread_cancel +# define pthread_in_use() (pthread_cancel != NULL) +# endif + +# else + +# if !PTHREAD_IN_USE_DETECTION_HARD +# define pthread_in_use() 1 +# endif + +# endif + +/* ------------------------- gl_tls_key_t datatype ------------------------- */ + +typedef union + { + void *singlethread_value; + pthread_key_t key; + } + gl_tls_key_t; +# define glthread_tls_key_init(KEY, DESTRUCTOR) \ + (pthread_in_use () \ + ? pthread_key_create (&(KEY)->key, DESTRUCTOR) \ + : ((KEY)->singlethread_value = NULL, 0)) +# define gl_tls_get(NAME) \ + (pthread_in_use () \ + ? pthread_getspecific ((NAME).key) \ + : (NAME).singlethread_value) +# define glthread_tls_set(KEY, POINTER) \ + (pthread_in_use () \ + ? pthread_setspecific ((KEY)->key, (POINTER)) \ + : ((KEY)->singlethread_value = (POINTER), 0)) +# define glthread_tls_key_destroy(KEY) \ + (pthread_in_use () ? pthread_key_delete ((KEY)->key) : 0) + +#endif + +/* ========================================================================= */ + +#if USE_PTH_THREADS + +/* Use the GNU Pth threads library. */ + +# include + +# if USE_PTH_THREADS_WEAK + +/* Use weak references to the GNU Pth threads library. */ + +# pragma weak pth_key_create +# pragma weak pth_key_getdata +# pragma weak pth_key_setdata +# pragma weak pth_key_delete + +# pragma weak pth_cancel +# define pth_in_use() (pth_cancel != NULL) + +# else + +# define pth_in_use() 1 + +# endif + +/* ------------------------- gl_tls_key_t datatype ------------------------- */ + +typedef union + { + void *singlethread_value; + pth_key_t key; + } + gl_tls_key_t; +# define glthread_tls_key_init(KEY, DESTRUCTOR) \ + (pth_in_use () \ + ? (!pth_key_create (&(KEY)->key, DESTRUCTOR) ? errno : 0) \ + : ((KEY)->singlethread_value = NULL, 0)) +# define gl_tls_get(NAME) \ + (pth_in_use () \ + ? pth_key_getdata ((NAME).key) \ + : (NAME).singlethread_value) +# define glthread_tls_set(KEY, POINTER) \ + (pth_in_use () \ + ? (!pth_key_setdata ((KEY)->key, (POINTER)) ? errno : 0) \ + : ((KEY)->singlethread_value = (POINTER), 0)) +# define glthread_tls_key_destroy(KEY) \ + (pth_in_use () \ + ? (!pth_key_delete ((KEY)->key) ? errno : 0) \ + : 0) + +#endif + +/* ========================================================================= */ + +#if USE_SOLARIS_THREADS + +/* Use the old Solaris threads library. */ + +# include + +# if USE_SOLARIS_THREADS_WEAK + +/* Use weak references to the old Solaris threads library. */ + +# pragma weak thr_keycreate +# pragma weak thr_getspecific +# pragma weak thr_setspecific + +# pragma weak thr_suspend +# define thread_in_use() (thr_suspend != NULL) + +# else + +# define thread_in_use() 1 + +# endif + +/* ------------------------- gl_tls_key_t datatype ------------------------- */ + +typedef union + { + void *singlethread_value; + thread_key_t key; + } + gl_tls_key_t; +# define glthread_tls_key_init(KEY, DESTRUCTOR) \ + (thread_in_use () \ + ? thr_keycreate (&(KEY)->key, DESTRUCTOR) \ + : ((KEY)->singlethread_value = NULL, 0)) +# define gl_tls_get(NAME) \ + (thread_in_use () \ + ? glthread_tls_get_multithreaded ((NAME).key) \ + : (NAME).singlethread_value) +extern void *glthread_tls_get_multithreaded (thread_key_t key); +# define glthread_tls_set(KEY, POINTER) \ + (thread_in_use () \ + ? thr_setspecific ((KEY)->key, (POINTER)) \ + : ((KEY)->singlethread_value = (POINTER), 0)) +# define glthread_tls_key_destroy(KEY) \ + /* Unsupported. */ \ + 0 + +#endif + +/* ========================================================================= */ + +#if USE_WIN32_THREADS + +# include + +/* ------------------------- gl_tls_key_t datatype ------------------------- */ + +typedef DWORD gl_tls_key_t; +# define glthread_tls_key_init(KEY, DESTRUCTOR) \ + /* The destructor is unsupported. */ \ + ((*(KEY) = TlsAlloc ()) == (DWORD)-1 ? EAGAIN : ((void) (DESTRUCTOR), 0)) +# define gl_tls_get(NAME) \ + TlsGetValue (NAME) +# define glthread_tls_set(KEY, POINTER) \ + (!TlsSetValue (*(KEY), POINTER) ? EINVAL : 0) +# define glthread_tls_key_destroy(KEY) \ + (!TlsFree (*(KEY)) ? EINVAL : 0) + +#endif + +/* ========================================================================= */ + +#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WIN32_THREADS) + +/* Provide dummy implementation if threads are not supported. */ + +/* ------------------------- gl_tls_key_t datatype ------------------------- */ + +typedef struct + { + void *singlethread_value; + } + gl_tls_key_t; +# define glthread_tls_key_init(KEY, DESTRUCTOR) \ + ((KEY)->singlethread_value = NULL, \ + (void) (DESTRUCTOR), \ + 0) +# define gl_tls_get(NAME) \ + (NAME).singlethread_value +# define glthread_tls_set(KEY, POINTER) \ + ((KEY)->singlethread_value = (POINTER), 0) +# define glthread_tls_key_destroy(KEY) \ + 0 + +#endif + +/* ========================================================================= */ + +/* Macros with built-in error handling. */ + +/* ------------------------- gl_tls_key_t datatype ------------------------- */ + +#define gl_tls_key_init(NAME, DESTRUCTOR) \ + do \ + { \ + if (glthread_tls_key_init (&NAME, DESTRUCTOR)) \ + abort (); \ + } \ + while (0) +#define gl_tls_set(NAME, POINTER) \ + do \ + { \ + if (glthread_tls_set (&NAME, POINTER)) \ + abort (); \ + } \ + while (0) +#define gl_tls_key_destroy(NAME) \ + do \ + { \ + if (glthread_tls_key_destroy (&NAME)) \ + abort (); \ + } \ + while (0) + +/* ========================================================================= */ + +#endif /* _TLS_H */ diff --git a/src/bin/coreutils/lib/gnulib.mk b/src/bin/coreutils/lib/gnulib.mk index 699d6df74f..8ed30f8cf1 100644 --- a/src/bin/coreutils/lib/gnulib.mk +++ b/src/bin/coreutils/lib/gnulib.mk @@ -1,6 +1,6 @@ ## DO NOT EDIT! GENERATED AUTOMATICALLY! ## Process this file with automake to produce Makefile.in. -# Copyright (C) 2002-2009 Free Software Foundation, Inc. +# Copyright (C) 2002-2010 Free Software Foundation, Inc. # # This file is free software, distributed under the terms of the GNU # General Public License. As a special exception to the GNU General @@ -9,7 +9,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl --lib=libcoreutils --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=gnulib-tests --aux-dir=build-aux --with-tests --avoid=canonicalize-lgpl --avoid=dummy --avoid=lock --no-libtool --macro-prefix=gl acl alloca announce-gen areadlink-with-size argmatch argv-iter assert atexit autobuild backupfile base64 c-strcase c-strtod c-strtold calloc canon-host canonicalize chown cloexec closein closeout config-h configmake crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 cycle-check d-ino d-type diacrit dirfd dirname dup2 error euidaccess exclude exitfail fchdir fcntl fcntl-safer fdl file-type fileblocks filemode filenamecat filevercmp fnmatch-gnu fopen-safer fprintftime fseeko fsusage ftello ftruncate fts gendocs getdate getgroups gethrxtime getline getloadavg getndelim2 getopt-gnu getpagesize getpass-gnu gettext gettime gettimeofday getugroups getusershell git-version-gen gitlog-to-changelog gnu-make gnumakefile gnupload group-member hard-locale hash hash-pjw host-os human idcache ignore-value inttostr inttypes isapipe lchmod lchown lib-ignore linebuffer link link-follow long-options lstat maintainer-makefile malloc manywarnings mbrtowc mbsalign mbswidth memcasecmp memchr memcmp memcmp2 memcpy memmove mempcpy memrchr memset mgetgroups mkancesdirs mkdir mkdir-p mkstemp mktime modechange mountlist mpsort obstack pathmax perl physmem posix-shell posixtm posixver priv-set progname propername putenv quote quotearg raise randint randperm readlink readtokens readtokens0 readutmp realloc regex rename rename-dest-slash rmdir rmdir-errno root-dev-ino rpmatch safe-read same save-cwd savedir savewd selinux-at settime sig2str sigaction ssize_t stat-macros stat-time stdbool stdlib-safer stpcpy stpncpy strcspn strdup strftime strpbrk strtod strtoimax strtol strtoumax strverscmp sys_stat timespec tzset unicodeio unistd-safer unlink-busy unlinkdir unlocked-io update-copyright uptime useless-if-before-free userspec utimecmp utimens vasprintf-posix vc-list-files verify verror version-etc-fsf warnings wcwidth winsz-ioctl winsz-termios write-any-file xalloc xfreopen xgetcwd xgethostname xmemcoll xnanosleep xprintf xprintf-posix xstrtod xstrtoimax xstrtol xstrtold xstrtoumax yesno +# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl --lib=libcoreutils --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=gnulib-tests --aux-dir=build-aux --with-tests --avoid=canonicalize-lgpl --avoid=dummy --no-libtool --macro-prefix=gl acl alloca announce-gen areadlink-with-size argmatch argv-iter assert atexit autobuild backupfile base64 c-strcase c-strtod c-strtold calloc canon-host canonicalize chown cloexec closein closeout config-h configmake crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 cycle-check d-ino d-type diacrit dirfd dirname do-release-commit-and-tag dup2 environ error euidaccess exclude exitfail faccessat fchdir fcntl fcntl-safer fdl file-type fileblocks filemode filenamecat filevercmp fnmatch-gnu fopen-safer fprintftime freopen freopen-safer fseeko fsusage fsync ftello ftruncate fts getdate getgroups gethrxtime getline getloadavg getndelim2 getopt-gnu getpagesize getpass-gnu gettext gettime gettimeofday getugroups getusershell git-version-gen gitlog-to-changelog gnu-make gnu-web-doc-update gnumakefile gnupload group-member hard-locale hash hash-pjw host-os human idcache ignore-value inttostr inttypes isapipe isblank lchmod lchown lib-ignore linebuffer link link-follow linkat long-options lstat maintainer-makefile malloc manywarnings mbrtowc mbsalign mbswidth memcasecmp memchr memcmp memcmp2 memcpy memmove mempcpy memrchr memset mgetgroups mkancesdirs mkdir mkdir-p mkstemp mktime modechange mountlist mpsort nproc obstack pathmax perl physmem posix-shell posixtm posixver priv-set progname propername putenv quote quotearg raise randint randperm readlink readtokens readtokens0 readutmp realloc regex remove rename rmdir root-dev-ino rpmatch safe-read same save-cwd savedir savewd selinux-at settime sig2str sigaction ssize_t stat-macros stat-time stdbool stdlib-safer stpcpy stpncpy strcspn strdup-posix strftime strpbrk strsignal strtod strtoimax strtol strtoumax symlink sys_stat timespec tzset uname unicodeio unistd-safer unlink-busy unlocked-io unsetenv update-copyright uptime useless-if-before-free userspec utimecmp utimens vasprintf-posix vc-list-files verify verror version-etc-fsf wcwidth winsz-ioctl winsz-termios write-any-file xalloc xfreopen xgetcwd xgethostname xmemcoll xnanosleep xprintf xprintf-posix xreadlink xstrtod xstrtoimax xstrtol xstrtold xstrtoumax yesno AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects @@ -89,6 +89,14 @@ EXTRA_DIST += $(top_srcdir)/build-aux/announce-gen ## end gnulib module announce-gen +## begin gnulib module areadlink + +libcoreutils_a_SOURCES += areadlink.c + +EXTRA_DIST += areadlink.h + +## end gnulib module areadlink + ## begin gnulib module areadlink-with-size libcoreutils_a_SOURCES += areadlink-with-size.c @@ -97,6 +105,38 @@ EXTRA_DIST += areadlink.h ## end gnulib module areadlink-with-size +## begin gnulib module areadlinkat + +libcoreutils_a_SOURCES += areadlinkat.c + +EXTRA_DIST += areadlink.h + +## end gnulib module areadlinkat + +## begin gnulib module arg-nonnull + +# The BUILT_SOURCES created by this Makefile snippet are not used via #include +# statements but through direct file reference. Therefore this snippet must be +# present in all Makefile.am that need it. This is ensured by the applicability +# 'all' defined above. + +BUILT_SOURCES += arg-nonnull.h +# The arg-nonnull.h that gets inserted into generated .h files is the same as +# build-aux/arg-nonnull.h, except that it has the copyright header cut off. +arg-nonnull.h: $(top_srcdir)/build-aux/arg-nonnull.h + $(AM_V_GEN)rm -f $@-t $@ && \ + sed -n -e '/GL_ARG_NONNULL/,$$p' \ + < $(top_srcdir)/build-aux/arg-nonnull.h \ + > $@-t && \ + mv $@-t $@ +MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t + +ARG_NONNULL_H=arg-nonnull.h + +EXTRA_DIST += $(top_srcdir)/build-aux/arg-nonnull.h + +## end gnulib module arg-nonnull + ## begin gnulib module argmatch @@ -114,11 +154,11 @@ libcoreutils_a_SOURCES += argv-iter.c argv-iter.h ## begin gnulib module arpa_inet -BUILT_SOURCES += $(ARPA_INET_H) +BUILT_SOURCES += arpa/inet.h # We need the following in order to create when the system # doesn't have one. -arpa/inet.h: arpa_inet.in.h +arpa/inet.h: arpa_inet.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) $(AM_V_at)$(MKDIR_P) arpa $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ @@ -131,6 +171,7 @@ arpa/inet.h: arpa_inet.in.h -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \ -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/arpa_inet.in.h; \ } > $@-t && \ mv $@-t $@ @@ -240,7 +281,7 @@ EXTRA_libcoreutils_a_SOURCES += canon-host.c ## begin gnulib module canonicalize -EXTRA_DIST += canonicalize.c canonicalize.h pathmax.h +EXTRA_DIST += canonicalize.c canonicalize.h EXTRA_libcoreutils_a_SOURCES += canonicalize.c @@ -414,6 +455,30 @@ EXTRA_libcoreutils_a_SOURCES += sha512.c ## end gnulib module crypto/sha512 +## begin gnulib module ctype + +BUILT_SOURCES += ctype.h + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +ctype.h: ctype.in.h $(LINK_WARNING_H) + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''NEXT_CTYPE_H''@|$(NEXT_CTYPE_H)|g' \ + -e 's/@''GNULIB_ISBLANK''@/$(GNULIB_ISBLANK)/g' \ + -e 's/@''HAVE_ISBLANK''@/$(HAVE_ISBLANK)/g' \ + -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + < $(srcdir)/ctype.in.h; \ + } > $@-t && \ + mv $@-t $@ +MOSTLYCLEANFILES += ctype.h ctype.h-t + +EXTRA_DIST += ctype.in.h + +## end gnulib module ctype + ## begin gnulib module cycle-check @@ -438,11 +503,11 @@ libcoreutils_a_SOURCES += diacrit.h diacrit.c ## begin gnulib module dirent -BUILT_SOURCES += $(DIRENT_H) +BUILT_SOURCES += dirent.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. -dirent.h: dirent.in.h +dirent.h: dirent.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -456,8 +521,11 @@ dirent.h: dirent.in.h -e 's|@''HAVE_FDOPENDIR''@|$(HAVE_FDOPENDIR)|g' \ -e 's|@''HAVE_SCANDIR''@|$(HAVE_SCANDIR)|g' \ -e 's|@''HAVE_ALPHASORT''@|$(HAVE_ALPHASORT)|g' \ - -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ + -e 's|@''REPLACE_CLOSEDIR''@|$(REPLACE_CLOSEDIR)|g' \ + -e 's|@''REPLACE_FDOPENDIR''@|$(REPLACE_FDOPENDIR)|g' \ + -e 's|@''REPLACE_OPENDIR''@|$(REPLACE_OPENDIR)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/dirent.in.h; \ } > $@-t && \ mv $@-t $@ @@ -488,12 +556,28 @@ EXTRA_libcoreutils_a_SOURCES += dirfd.c ## begin gnulib module dirname -EXTRA_DIST += basename.c dirname.c dirname.h stripslash.c +EXTRA_DIST += basename.c dirname.c stripslash.c EXTRA_libcoreutils_a_SOURCES += basename.c dirname.c stripslash.c ## end gnulib module dirname +## begin gnulib module dirname-lgpl + + +EXTRA_DIST += basename-lgpl.c dirname-lgpl.c dirname.h stripslash.c + +EXTRA_libcoreutils_a_SOURCES += basename-lgpl.c dirname-lgpl.c stripslash.c + +## end gnulib module dirname-lgpl + +## begin gnulib module do-release-commit-and-tag + + +EXTRA_DIST += $(top_srcdir)/build-aux/do-release-commit-and-tag + +## end gnulib module do-release-commit-and-tag + ## begin gnulib module dup2 @@ -566,6 +650,15 @@ EXTRA_libcoreutils_a_SOURCES += exitfail.c ## end gnulib module exitfail +## begin gnulib module faccessat + + +EXTRA_DIST += faccessat.c + +EXTRA_libcoreutils_a_SOURCES += faccessat.c + +## end gnulib module faccessat + ## begin gnulib module fchdir @@ -584,23 +677,37 @@ EXTRA_libcoreutils_a_SOURCES += fclose.c ## end gnulib module fclose +## begin gnulib module fcntl + + +EXTRA_DIST += fcntl.c + +EXTRA_libcoreutils_a_SOURCES += fcntl.c + +## end gnulib module fcntl + ## begin gnulib module fcntl-h -BUILT_SOURCES += $(FCNTL_H) +BUILT_SOURCES += fcntl.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. -fcntl.h: fcntl.in.h +fcntl.h: fcntl.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \ + -e 's|@''GNULIB_FCNTL''@|$(GNULIB_FCNTL)|g' \ -e 's|@''GNULIB_OPEN''@|$(GNULIB_OPEN)|g' \ -e 's|@''GNULIB_OPENAT''@|$(GNULIB_OPENAT)|g' \ - -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \ + -e 's|@''HAVE_FCNTL''@|$(HAVE_FCNTL)|g' \ -e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \ + -e 's|@''REPLACE_FCNTL''@|$(REPLACE_FCNTL)|g' \ + -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \ + -e 's|@''REPLACE_OPENAT''@|$(REPLACE_OPENAT)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/fcntl.in.h; \ } > $@-t && \ mv $@-t $@ @@ -619,6 +726,12 @@ EXTRA_libcoreutils_a_SOURCES += creat-safer.c open-safer.c ## end gnulib module fcntl-safer +## begin gnulib module fd-safer-flag + +libcoreutils_a_SOURCES += fd-safer-flag.c dup-safer-flag.c + +## end gnulib module fd-safer-flag + ## begin gnulib module fdopendir @@ -675,12 +788,21 @@ EXTRA_libcoreutils_a_SOURCES += filemode.c ## begin gnulib module filenamecat -EXTRA_DIST += filenamecat.c filenamecat.h +EXTRA_DIST += filenamecat.c EXTRA_libcoreutils_a_SOURCES += filenamecat.c ## end gnulib module filenamecat +## begin gnulib module filenamecat-lgpl + + +EXTRA_DIST += filenamecat-lgpl.c filenamecat.h + +EXTRA_libcoreutils_a_SOURCES += filenamecat-lgpl.c + +## end gnulib module filenamecat-lgpl + ## begin gnulib module filevercmp libcoreutils_a_SOURCES += filevercmp.c @@ -716,10 +838,11 @@ BUILT_SOURCES += $(FNMATCH_H) # We need the following in order to create when the system # doesn't have one that supports the required API. -fnmatch.h: fnmatch.in.h +fnmatch.h: fnmatch.in.h $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - cat $(srcdir)/fnmatch.in.h; \ + sed -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + < $(srcdir)/fnmatch.in.h; \ } > $@-t && \ mv -f $@-t $@ MOSTLYCLEANFILES += fnmatch.h fnmatch.h-t @@ -814,6 +937,24 @@ EXTRA_DIST += freadseek.h stdio-impl.h ## end gnulib module freadseek +## begin gnulib module freopen + + +EXTRA_DIST += freopen.c + +EXTRA_libcoreutils_a_SOURCES += freopen.c + +## end gnulib module freopen + +## begin gnulib module freopen-safer + + +EXTRA_DIST += freopen-safer.c stdio--.h stdio-safer.h + +EXTRA_libcoreutils_a_SOURCES += freopen-safer.c + +## end gnulib module freopen-safer + ## begin gnulib module frexp-nolibm @@ -858,6 +999,15 @@ EXTRA_libcoreutils_a_SOURCES += fsusage.c ## end gnulib module fsusage +## begin gnulib module fsync + + +EXTRA_DIST += fsync.c + +EXTRA_libcoreutils_a_SOURCES += fsync.c + +## end gnulib module fsync + ## begin gnulib module ftello @@ -1002,10 +1152,15 @@ BUILT_SOURCES += $(GETOPT_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. -getopt.h: getopt.in.h +getopt.h: getopt.in.h $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - cat $(srcdir)/getopt.in.h; \ + sed -e 's|@''HAVE_GETOPT_H''@|$(HAVE_GETOPT_H)|g' \ + -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''NEXT_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + < $(srcdir)/getopt.in.h; \ } > $@-t && \ mv -f $@-t $@ MOSTLYCLEANFILES += getopt.h getopt.h-t @@ -1119,6 +1274,13 @@ EXTRA_DIST += $(top_srcdir)/build-aux/gitlog-to-changelog ## end gnulib module gnu-make +## begin gnulib module gnu-web-doc-update + + +EXTRA_DIST += $(top_srcdir)/build-aux/gnu-web-doc-update + +## end gnulib module gnu-web-doc-update + ## begin gnulib module gnumakefile distclean-local: clean-GNUmakefile @@ -1214,7 +1376,7 @@ BUILT_SOURCES += $(ICONV_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. -iconv.h: iconv.in.h +iconv.h: iconv.in.h $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -1224,6 +1386,7 @@ iconv.h: iconv.in.h -e 's|@''REPLACE_ICONV''@|$(REPLACE_ICONV)|g' \ -e 's|@''REPLACE_ICONV_OPEN''@|$(REPLACE_ICONV_OPEN)|g' \ -e 's|@''REPLACE_ICONV_UTF''@|$(REPLACE_ICONV_UTF)|g' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/iconv.in.h; \ } > $@-t && \ mv $@-t $@ @@ -1297,11 +1460,11 @@ EXTRA_libcoreutils_a_SOURCES += imaxtostr.c inttostr.c offtostr.c uinttostr.c um ## begin gnulib module inttypes -BUILT_SOURCES += $(INTTYPES_H) +BUILT_SOURCES += inttypes.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. -inttypes.h: inttypes.in.h +inttypes.h: inttypes.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \ @@ -1326,6 +1489,7 @@ inttypes.h: inttypes.in.h -e 's/@''UINT32_MAX_LT_UINTMAX_MAX''@/$(UINT32_MAX_LT_UINTMAX_MAX)/g' \ -e 's/@''UINT64_MAX_EQ_ULONG_MAX''@/$(UINT64_MAX_EQ_ULONG_MAX)/g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/inttypes.in.h; \ } > $@-t && \ mv $@-t $@ @@ -1344,6 +1508,15 @@ EXTRA_libcoreutils_a_SOURCES += isapipe.c ## end gnulib module isapipe +## begin gnulib module isblank + + +EXTRA_DIST += isblank.c + +EXTRA_libcoreutils_a_SOURCES += isblank.c + +## end gnulib module isblank + ## begin gnulib module isnand-nolibm @@ -1371,6 +1544,34 @@ EXTRA_libcoreutils_a_SOURCES += isnan.c isnanl.c ## end gnulib module isnanl-nolibm +## begin gnulib module langinfo + +BUILT_SOURCES += langinfo.h + +# We need the following in order to create an empty placeholder for +# when the system doesn't have one. +langinfo.h: langinfo.in.h $(LINK_WARNING_H) + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's|@''HAVE_LANGINFO_H''@|$(HAVE_LANGINFO_H)|g' \ + -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''NEXT_LANGINFO_H''@|$(NEXT_LANGINFO_H)|g' \ + -e 's|@''GNULIB_NL_LANGINFO''@|$(GNULIB_NL_LANGINFO)|g' \ + -e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \ + -e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \ + -e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \ + -e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \ + -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + < $(srcdir)/langinfo.in.h; \ + } > $@-t && \ + mv $@-t $@ +MOSTLYCLEANFILES += langinfo.h langinfo.h-t + +EXTRA_DIST += langinfo.in.h + +## end gnulib module langinfo + ## begin gnulib module lchown @@ -1397,12 +1598,37 @@ EXTRA_libcoreutils_a_SOURCES += link.c ## begin gnulib module link-warning -LINK_WARNING_H=$(top_srcdir)/build-aux/link-warning.h +# The BUILT_SOURCES created by this Makefile snippet are not used via #include +# statements but through direct file reference. Therefore this snippet must be +# present in all Makefile.am that need it. This is ensured by the applicability +# 'all' defined above. + +BUILT_SOURCES += link-warning.h +# The link-warning.h that gets inserted into generated .h files is the same as +# build-aux/link-warning.h, except that it has the copyright header cut off. +link-warning.h: $(top_srcdir)/build-aux/link-warning.h + $(AM_V_GEN)rm -f $@-t $@ && \ + sed -n -e '/GL_LINK_WARNING/,$$p' \ + < $(top_srcdir)/build-aux/link-warning.h \ + > $@-t && \ + mv $@-t $@ +MOSTLYCLEANFILES += link-warning.h link-warning.h-t + +LINK_WARNING_H=link-warning.h EXTRA_DIST += $(top_srcdir)/build-aux/link-warning.h ## end gnulib module link-warning +## begin gnulib module linkat + + +EXTRA_DIST += at-func2.c linkat.c + +EXTRA_libcoreutils_a_SOURCES += at-func2.c linkat.c + +## end gnulib module linkat + ## begin gnulib module localcharset libcoreutils_a_SOURCES += localcharset.h localcharset.c @@ -1477,6 +1703,38 @@ EXTRA_DIST += config.charset ref-add.sin ref-del.sin ## end gnulib module localcharset +## begin gnulib module locale + +BUILT_SOURCES += locale.h + +# We need the following in order to create when the system +# doesn't have one that provides all definitions. +locale.h: locale.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ + sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''NEXT_LOCALE_H''@|$(NEXT_LOCALE_H)|g' \ + -e 's|@''GNULIB_DUPLOCALE''@|$(GNULIB_DUPLOCALE)|g' \ + -e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \ + -e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \ + -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + < $(srcdir)/locale.in.h; \ + } > $@-t && \ + mv $@-t $@ +MOSTLYCLEANFILES += locale.h locale.h-t + +EXTRA_DIST += locale.in.h + +## end gnulib module locale + +## begin gnulib module lock + +libcoreutils_a_SOURCES += glthread/lock.h glthread/lock.c + +## end gnulib module lock + ## begin gnulib module long-options @@ -1542,7 +1800,7 @@ BUILT_SOURCES += math.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. -math.h: math.in.h +math.h: math.in.h $(LINK_WARNING_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \ @@ -1604,6 +1862,8 @@ math.h: math.in.h -e 's|@''REPLACE_SIGNBIT_USING_GCC''@|$(REPLACE_SIGNBIT_USING_GCC)|g' \ -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ < $(srcdir)/math.in.h; \ } > $@-t && \ mv $@-t $@ @@ -1846,7 +2106,7 @@ EXTRA_libcoreutils_a_SOURCES += mkstemp.c ## begin gnulib module mktime -EXTRA_DIST += mktime.c +EXTRA_DIST += mktime-internal.h mktime.c EXTRA_libcoreutils_a_SOURCES += mktime.c @@ -1894,7 +2154,7 @@ BUILT_SOURCES += $(NETDB_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. -netdb.h: netdb.in.h +netdb.h: netdb.in.h $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -1907,6 +2167,7 @@ netdb.h: netdb.in.h -e 's|@''HAVE_DECL_GAI_STRERROR''@|$(HAVE_DECL_GAI_STRERROR)|g' \ -e 's|@''HAVE_DECL_GETADDRINFO''@|$(HAVE_DECL_GETADDRINFO)|g' \ -e 's|@''HAVE_DECL_GETNAMEINFO''@|$(HAVE_DECL_GETNAMEINFO)|g' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/netdb.in.h; \ } > $@-t && \ mv $@-t $@ @@ -1940,6 +2201,23 @@ EXTRA_DIST += netinet_in.in.h ## end gnulib module netinet_in +## begin gnulib module nl_langinfo + + +EXTRA_DIST += nl_langinfo.c + +EXTRA_libcoreutils_a_SOURCES += nl_langinfo.c + +## end gnulib module nl_langinfo + +## begin gnulib module nproc + +libcoreutils_a_SOURCES += nproc.c + +EXTRA_DIST += nproc.h + +## end gnulib module nproc + ## begin gnulib module obstack @@ -1961,9 +2239,9 @@ EXTRA_libcoreutils_a_SOURCES += open.c ## begin gnulib module openat -EXTRA_DIST += at-func.c fchmodat.c fchownat.c fstatat.c mkdirat.c openat-priv.h openat-proc.c openat.c openat.h +EXTRA_DIST += at-func.c fchmodat.c fchownat.c fstatat.c mkdirat.c openat-priv.h openat-proc.c openat.c openat.h unlinkat.c -EXTRA_libcoreutils_a_SOURCES += at-func.c fchmodat.c fchownat.c fstatat.c mkdirat.c openat-proc.c openat.c +EXTRA_libcoreutils_a_SOURCES += at-func.c fchmodat.c fchownat.c fstatat.c mkdirat.c openat-proc.c openat.c unlinkat.c ## end gnulib module openat @@ -2183,6 +2461,15 @@ EXTRA_libcoreutils_a_SOURCES += regcomp.c regex.c regex_internal.c regexec.c ## end gnulib module regex +## begin gnulib module remove + + +EXTRA_DIST += remove.c + +EXTRA_libcoreutils_a_SOURCES += remove.c + +## end gnulib module remove + ## begin gnulib module rename @@ -2192,15 +2479,6 @@ EXTRA_libcoreutils_a_SOURCES += rename.c ## end gnulib module rename -## begin gnulib module rename-dest-slash - - -EXTRA_DIST += rename-dest-slash.c - -EXTRA_libcoreutils_a_SOURCES += rename-dest-slash.c - -## end gnulib module rename-dest-slash - ## begin gnulib module rmdir @@ -2308,25 +2586,38 @@ EXTRA_libcoreutils_a_SOURCES += selinux-at.c libcoreutils_a_SOURCES += se-context.in.h se-selinux.in.h -BUILT_SOURCES += $(SELINUX_SELINUX_H) -selinux/selinux.h: se-selinux.in.h +BUILT_SOURCES += selinux/selinux.h +selinux/selinux.h: se-selinux.in.h $(UNUSED_PARAMETER_H) $(AM_V_at)$(MKDIR_P) selinux $(AM_V_GEN)rm -f $@-t $@ && \ - cp $(srcdir)/se-selinux.in.h $@-t && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ + sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''NEXT_SELINUX_SELINUX_H''@|$(NEXT_SELINUX_SELINUX_H)|g' \ + -e '/definition of _GL_UNUSED_PARAMETER/r $(UNUSED_PARAMETER_H)' \ + < $(srcdir)/se-selinux.in.h; \ + } > $@-t && \ chmod a-x $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += selinux/selinux.h selinux/selinux.h-t BUILT_SOURCES += $(SELINUX_CONTEXT_H) -selinux/context.h: se-context.in.h +selinux/context.h: se-context.in.h $(UNUSED_PARAMETER_H) $(AM_V_at)$(MKDIR_P) selinux $(AM_V_GEN)rm -f $@-t $@ && \ - cp $(srcdir)/se-context.in.h $@-t && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ + sed -e '/definition of _GL_UNUSED_PARAMETER/r $(UNUSED_PARAMETER_H)' \ + < $(srcdir)/se-context.in.h; \ + } > $@-t && \ chmod a-x $@-t && \ mv $@-t $@ MOSTLYCLEANFILES += selinux/context.h selinux/context.h-t MOSTLYCLEANDIRS += selinux +EXTRA_DIST += getfilecon.c + +EXTRA_libcoreutils_a_SOURCES += getfilecon.c + ## end gnulib module selinux-h ## begin gnulib module setenv @@ -2371,7 +2662,7 @@ BUILT_SOURCES += signal.h # We need the following in order to create when the system # doesn't have a complete one. -signal.h: signal.in.h +signal.h: signal.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -2387,6 +2678,7 @@ signal.h: signal.in.h -e 's|@''HAVE_STRUCT_SIGACTION_SA_SIGACTION''@|$(HAVE_STRUCT_SIGACTION_SA_SIGACTION)|g' \ -e 's|@''HAVE_TYPE_VOLATILE_SIG_ATOMIC_T''@|$(HAVE_TYPE_VOLATILE_SIG_ATOMIC_T)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/signal.in.h; \ } > $@-t && \ mv $@-t $@ @@ -2437,6 +2729,15 @@ EXTRA_DIST += w32sock.h ## end gnulib module sockets +## begin gnulib module stat + + +EXTRA_DIST += stat.c + +EXTRA_libcoreutils_a_SOURCES += stat.c + +## end gnulib module stat + ## begin gnulib module stat-macros @@ -2561,7 +2862,7 @@ BUILT_SOURCES += stdio.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. -stdio.h: stdio.in.h +stdio.h: stdio.in.h $(LINK_WARNING_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -2593,7 +2894,9 @@ stdio.h: stdio.in.h -e 's|@''GNULIB_PUTC''@|$(GNULIB_PUTC)|g' \ -e 's|@''GNULIB_PUTCHAR''@|$(GNULIB_PUTCHAR)|g' \ -e 's|@''GNULIB_PUTS''@|$(GNULIB_PUTS)|g' \ + -e 's|@''GNULIB_REMOVE''@|$(GNULIB_REMOVE)|g' \ -e 's|@''GNULIB_RENAME''@|$(GNULIB_RENAME)|g' \ + -e 's|@''GNULIB_RENAMEAT''@|$(GNULIB_RENAMEAT)|g' \ -e 's|@''GNULIB_SNPRINTF''@|$(GNULIB_SNPRINTF)|g' \ -e 's|@''GNULIB_SPRINTF_POSIX''@|$(GNULIB_SPRINTF_POSIX)|g' \ -e 's|@''GNULIB_STDIO_H_SIGPIPE''@|$(GNULIB_STDIO_H_SIGPIPE)|g' \ @@ -2612,6 +2915,7 @@ stdio.h: stdio.in.h -e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \ -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \ -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \ + -e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \ -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \ -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \ -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \ @@ -2630,7 +2934,9 @@ stdio.h: stdio.in.h -e 's|@''REPLACE_PERROR''@|$(REPLACE_PERROR)|g' \ -e 's|@''REPLACE_POPEN''@|$(REPLACE_POPEN)|g' \ -e 's|@''REPLACE_PRINTF''@|$(REPLACE_PRINTF)|g' \ + -e 's|@''REPLACE_REMOVE''@|$(REPLACE_REMOVE)|g' \ -e 's|@''REPLACE_RENAME''@|$(REPLACE_RENAME)|g' \ + -e 's|@''REPLACE_RENAMEAT''@|$(REPLACE_RENAMEAT)|g' \ -e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \ -e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \ -e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \ @@ -2641,6 +2947,8 @@ stdio.h: stdio.in.h -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \ -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ < $(srcdir)/stdio.in.h; \ } > $@-t && \ mv $@-t $@ @@ -2658,24 +2966,27 @@ BUILT_SOURCES += stdlib.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. -stdlib.h: stdlib.in.h +stdlib.h: stdlib.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \ - -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \ - -e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \ - -e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \ - -e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \ -e 's|@''GNULIB_ATOLL''@|$(GNULIB_ATOLL)|g' \ + -e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \ + -e 's|@''GNULIB_CANONICALIZE_FILE_NAME''@|$(GNULIB_CANONICALIZE_FILE_NAME)|g' \ -e 's|@''GNULIB_GETLOADAVG''@|$(GNULIB_GETLOADAVG)|g' \ -e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \ + -e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \ -e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \ -e 's|@''GNULIB_MKOSTEMP''@|$(GNULIB_MKOSTEMP)|g' \ + -e 's|@''GNULIB_MKOSTEMPS''@|$(GNULIB_MKOSTEMPS)|g' \ -e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \ + -e 's|@''GNULIB_MKSTEMPS''@|$(GNULIB_MKSTEMPS)|g' \ -e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \ -e 's|@''GNULIB_RANDOM_R''@|$(GNULIB_RANDOM_R)|g' \ + -e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \ + -e 's|@''GNULIB_REALPATH''@|$(GNULIB_REALPATH)|g' \ -e 's|@''GNULIB_RPMATCH''@|$(GNULIB_RPMATCH)|g' \ -e 's|@''GNULIB_SETENV''@|$(GNULIB_SETENV)|g' \ -e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \ @@ -2684,12 +2995,18 @@ stdlib.h: stdlib.in.h -e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \ -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \ -e 's|@''HAVE_CALLOC_POSIX''@|$(HAVE_CALLOC_POSIX)|g' \ + -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \ + -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \ -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \ -e 's|@''HAVE_MALLOC_POSIX''@|$(HAVE_MALLOC_POSIX)|g' \ -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \ -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \ - -e 's|@''HAVE_REALLOC_POSIX''@|$(HAVE_REALLOC_POSIX)|g' \ + -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \ + -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \ + -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \ -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \ + -e 's|@''HAVE_REALLOC_POSIX''@|$(HAVE_REALLOC_POSIX)|g' \ + -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \ -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \ -e 's|@''HAVE_SETENV''@|$(HAVE_SETENV)|g' \ -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \ @@ -2698,12 +3015,15 @@ stdlib.h: stdlib.in.h -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \ -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \ -e 's|@''HAVE_UNSETENV''@|$(HAVE_UNSETENV)|g' \ - -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \ + -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \ -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \ -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \ + -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \ + -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \ -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \ - -e 's|@''VOID_UNSETENV''@|$(VOID_UNSETENV)|g' \ + -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/stdlib.in.h; \ } > $@-t && \ mv $@-t $@ @@ -2749,15 +3069,6 @@ EXTRA_libcoreutils_a_SOURCES += strcspn.c ## end gnulib module strcspn -## begin gnulib module strdup - - -EXTRA_DIST += strdup.c - -EXTRA_libcoreutils_a_SOURCES += strdup.c - -## end gnulib module strdup - ## begin gnulib module strdup-posix @@ -2806,7 +3117,7 @@ BUILT_SOURCES += string.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. -string.h: string.in.h +string.h: string.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -2845,6 +3156,7 @@ string.h: string.in.h -e 's|@''GNULIB_STRERROR''@|$(GNULIB_STRERROR)|g' \ -e 's|@''GNULIB_STRSIGNAL''@|$(GNULIB_STRSIGNAL)|g' \ -e 's|@''GNULIB_STRVERSCMP''@|$(GNULIB_STRVERSCMP)|g' \ + -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \ -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \ -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \ -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \ @@ -2873,6 +3185,7 @@ string.h: string.in.h -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \ -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/string.in.h; \ } > $@-t && \ mv $@-t $@ @@ -2915,6 +3228,15 @@ EXTRA_libcoreutils_a_SOURCES += strpbrk.c ## end gnulib module strpbrk +## begin gnulib module strsignal + + +EXTRA_DIST += siglist.h strsignal.c + +EXTRA_libcoreutils_a_SOURCES += strsignal.c + +## end gnulib module strsignal + ## begin gnulib module strstr-simple @@ -2988,22 +3310,31 @@ EXTRA_libcoreutils_a_SOURCES += strtoumax.c ## end gnulib module strtoumax -## begin gnulib module strverscmp +## begin gnulib module symlink -EXTRA_DIST += strverscmp.c +EXTRA_DIST += symlink.c -EXTRA_libcoreutils_a_SOURCES += strverscmp.c +EXTRA_libcoreutils_a_SOURCES += symlink.c -## end gnulib module strverscmp +## end gnulib module symlink + +## begin gnulib module symlinkat + + +EXTRA_DIST += symlinkat.c + +EXTRA_libcoreutils_a_SOURCES += symlinkat.c + +## end gnulib module symlinkat ## begin gnulib module sys_select -BUILT_SOURCES += $(SYS_SELECT_H) +BUILT_SOURCES += sys/select.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. -sys/select.h: sys_select.in.h +sys/select.h: sys_select.in.h $(LINK_WARNING_H) $(AM_V_at)$(MKDIR_P) sys $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ @@ -3027,11 +3358,11 @@ EXTRA_DIST += sys_select.in.h ## begin gnulib module sys_socket -BUILT_SOURCES += $(SYS_SOCKET_H) +BUILT_SOURCES += sys/socket.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. -sys/socket.h: sys_socket.in.h +sys/socket.h: sys_socket.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) $(AM_V_at)$(MKDIR_P) sys $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ @@ -3061,6 +3392,7 @@ sys/socket.h: sys_socket.in.h -e 's|@''HAVE_SA_FAMILY_T''@|$(HAVE_SA_FAMILY_T)|g' \ -e 's|@''HAVE_ACCEPT4''@|$(HAVE_ACCEPT4)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/sys_socket.in.h; \ } > $@-t && \ mv -f $@-t $@ @@ -3077,7 +3409,7 @@ BUILT_SOURCES += sys/stat.h # We need the following in order to create when the system # has one that is incomplete. -sys/stat.h: sys_stat.in.h +sys/stat.h: sys_stat.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) $(AM_V_at)$(MKDIR_P) sys $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ @@ -3086,23 +3418,38 @@ sys/stat.h: sys_stat.in.h -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \ -e 's|@''GNULIB_FCHMODAT''@|$(GNULIB_FCHMODAT)|g' \ -e 's|@''GNULIB_FSTATAT''@|$(GNULIB_FSTATAT)|g' \ + -e 's|@''GNULIB_FUTIMENS''@|$(GNULIB_FUTIMENS)|g' \ -e 's|@''GNULIB_LCHMOD''@|$(GNULIB_LCHMOD)|g' \ -e 's|@''GNULIB_LSTAT''@|$(GNULIB_LSTAT)|g' \ -e 's|@''GNULIB_MKDIRAT''@|$(GNULIB_MKDIRAT)|g' \ + -e 's|@''GNULIB_MKFIFO''@|$(GNULIB_MKFIFO)|g' \ -e 's|@''GNULIB_MKFIFOAT''@|$(GNULIB_MKFIFOAT)|g' \ + -e 's|@''GNULIB_MKNOD''@|$(GNULIB_MKNOD)|g' \ -e 's|@''GNULIB_MKNODAT''@|$(GNULIB_MKNODAT)|g' \ + -e 's|@''GNULIB_STAT''@|$(GNULIB_STAT)|g' \ + -e 's|@''GNULIB_UTIMENSAT''@|$(GNULIB_UTIMENSAT)|g' \ -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \ -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \ + -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \ -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \ -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \ -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \ + -e 's|@''HAVE_MKFIFO''@|$(HAVE_MKFIFO)|g' \ -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \ + -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \ -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \ - -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ + -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \ + -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \ -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \ + -e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \ -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \ -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \ + -e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \ + -e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \ + -e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \ + -e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/sys_stat.in.h; \ } > $@-t && \ mv $@-t $@ @@ -3119,7 +3466,7 @@ BUILT_SOURCES += $(SYS_TIME_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. -sys/time.h: sys_time.in.h +sys/time.h: sys_time.in.h $(ARG_NONNULL_H) $(AM_V_at)$(MKDIR_P) sys $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ @@ -3129,6 +3476,7 @@ sys/time.h: sys_time.in.h -e 's|@''NEXT_SYS_TIME_H''@|$(NEXT_SYS_TIME_H)|g' \ -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \ -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/sys_time.in.h; \ } > $@-t && \ mv $@-t $@ @@ -3138,6 +3486,35 @@ EXTRA_DIST += sys_time.in.h ## end gnulib module sys_time +## begin gnulib module sys_utsname + +BUILT_SOURCES += sys/utsname.h + +# We need the following in order to create when the system +# does not have one. +sys/utsname.h: sys_utsname.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) + $(AM_V_at)$(MKDIR_P) sys + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's/@''HAVE_SYS_UTSNAME_H''@/$(HAVE_SYS_UTSNAME_H)/g' \ + -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''NEXT_SYS_UTSNAME_H''@|$(NEXT_SYS_UTSNAME_H)|g' \ + -e 's|@''GNULIB_UNAME''@|$(GNULIB_UNAME)|g' \ + -e 's|@''HAVE_STRUCT_UTSNAME''@|$(HAVE_STRUCT_UTSNAME)|g' \ + -e 's|@''HAVE_UNAME''@|$(HAVE_UNAME)|g' \ + -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + < $(srcdir)/sys_utsname.in.h; \ + } > $@-t && \ + mv $@-t $@ +MOSTLYCLEANFILES += sys/utsname.h sys/utsname.h-t +MOSTLYCLEANDIRS += sys + +EXTRA_DIST += sys_utsname.in.h + +## end gnulib module sys_utsname + ## begin gnulib module tempname @@ -3147,13 +3524,21 @@ EXTRA_libcoreutils_a_SOURCES += tempname.c ## end gnulib module tempname +## begin gnulib module threadlib + +libcoreutils_a_SOURCES += glthread/threadlib.c + +EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath + +## end gnulib module threadlib + ## begin gnulib module time BUILT_SOURCES += time.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. -time.h: time.in.h +time.h: time.in.h $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -3166,6 +3551,7 @@ time.h: time.in.h -e 's|@REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \ -e 's|@SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ -e 's|@TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/time.in.h; \ } > $@-t && \ mv $@-t $@ @@ -3191,6 +3577,12 @@ EXTRA_DIST += timespec.h ## end gnulib module timespec +## begin gnulib module tls + +libcoreutils_a_SOURCES += glthread/tls.h glthread/tls.c + +## end gnulib module tls + ## begin gnulib module trim libcoreutils_a_SOURCES += trim.c @@ -3201,10 +3593,20 @@ EXTRA_DIST += trim.h ## begin gnulib module u64 + EXTRA_DIST += u64.h ## end gnulib module u64 +## begin gnulib module uname + + +EXTRA_DIST += uname.c + +EXTRA_libcoreutils_a_SOURCES += uname.c + +## end gnulib module uname + ## begin gnulib module unicodeio libcoreutils_a_SOURCES += unicodeio.h unicodeio.c @@ -3217,7 +3619,7 @@ BUILT_SOURCES += unistd.h # We need the following in order to create an empty placeholder for # when the system doesn't have one. -unistd.h: unistd.in.h +unistd.h: unistd.in.h $(LINK_WARNING_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \ @@ -3238,22 +3640,31 @@ unistd.h: unistd.in.h -e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \ -e 's|@''GNULIB_GETDOMAINNAME''@|$(GNULIB_GETDOMAINNAME)|g' \ -e 's|@''GNULIB_GETDTABLESIZE''@|$(GNULIB_GETDTABLESIZE)|g' \ + -e 's|@''GNULIB_GETGROUPS''@|$(GNULIB_GETGROUPS)|g' \ -e 's|@''GNULIB_GETHOSTNAME''@|$(GNULIB_GETHOSTNAME)|g' \ + -e 's|@''GNULIB_GETLOGIN''@|$(GNULIB_GETLOGIN)|g' \ -e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \ -e 's|@''GNULIB_GETPAGESIZE''@|$(GNULIB_GETPAGESIZE)|g' \ -e 's|@''GNULIB_GETUSERSHELL''@|$(GNULIB_GETUSERSHELL)|g' \ -e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \ -e 's|@''GNULIB_LINK''@|$(GNULIB_LINK)|g' \ + -e 's|@''GNULIB_LINKAT''@|$(GNULIB_LINKAT)|g' \ -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \ -e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \ + -e 's|@''GNULIB_PREAD''@|$(GNULIB_PREAD)|g' \ -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \ -e 's|@''GNULIB_READLINKAT''@|$(GNULIB_READLINKAT)|g' \ + -e 's|@''GNULIB_RMDIR''@|$(GNULIB_RMDIR)|g' \ -e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \ + -e 's|@''GNULIB_SYMLINK''@|$(GNULIB_SYMLINK)|g' \ -e 's|@''GNULIB_SYMLINKAT''@|$(GNULIB_SYMLINKAT)|g' \ -e 's|@''GNULIB_UNISTD_H_GETOPT''@|$(GNULIB_UNISTD_H_GETOPT)|g' \ -e 's|@''GNULIB_UNISTD_H_SIGPIPE''@|$(GNULIB_UNISTD_H_SIGPIPE)|g' \ + -e 's|@''GNULIB_UNLINK''@|$(GNULIB_UNLINK)|g' \ -e 's|@''GNULIB_UNLINKAT''@|$(GNULIB_UNLINKAT)|g' \ + -e 's|@''GNULIB_USLEEP''@|$(GNULIB_USLEEP)|g' \ -e 's|@''GNULIB_WRITE''@|$(GNULIB_WRITE)|g' \ + -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \ -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \ -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \ -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \ @@ -3263,34 +3674,54 @@ unistd.h: unistd.in.h -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \ -e 's|@''HAVE_GETDOMAINNAME''@|$(HAVE_GETDOMAINNAME)|g' \ -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \ + -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \ -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \ + -e 's|@''HAVE_GETLOGIN''@|$(HAVE_GETLOGIN)|g' \ -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \ -e 's|@''HAVE_GETUSERSHELL''@|$(HAVE_GETUSERSHELL)|g' \ + -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \ -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \ + -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \ -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \ + -e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \ -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \ -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \ -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \ + -e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \ -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \ -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \ + -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \ -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \ -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \ -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \ -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \ -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \ -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \ + -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \ -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \ -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \ -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ + -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \ -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \ -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \ + -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \ -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \ + -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \ + -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \ + -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \ + -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \ + -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \ + -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \ + -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \ + -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \ -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \ -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \ -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ < $(srcdir)/unistd.in.h; \ } > $@-t && \ mv $@-t $@ @@ -3344,14 +3775,14 @@ EXTRA_DIST += uniwidth/cjk.h ## end gnulib module uniwidth/width -## begin gnulib module unlinkdir +## begin gnulib module unlink -EXTRA_DIST += unlinkdir.c unlinkdir.h +EXTRA_DIST += unlink.c -EXTRA_libcoreutils_a_SOURCES += unlinkdir.c +EXTRA_libcoreutils_a_SOURCES += unlink.c -## end gnulib module unlinkdir +## end gnulib module unlink ## begin gnulib module unlocked-io @@ -3369,6 +3800,31 @@ EXTRA_libcoreutils_a_SOURCES += unsetenv.c ## end gnulib module unsetenv +## begin gnulib module unused-parameter + +# The BUILT_SOURCES created by this Makefile snippet are not used via #include +# statements but through direct file reference. Therefore this snippet must be +# present in all Makefile.am that need it. This is ensured by the applicability +# 'all' defined above. + +BUILT_SOURCES += unused-parameter.h +# The unused-parameter.h that gets inserted into generated .h files is the same +# as build-aux/unused-parameter.h, except that it has the copyright header cut +# off. +unused-parameter.h: $(top_srcdir)/build-aux/unused-parameter.h + $(AM_V_GEN)rm -f $@-t $@ && \ + sed -n -e '/GL_UNUSED_PARAMETER/,$$p' \ + < $(top_srcdir)/build-aux/unused-parameter.h \ + > $@-t && \ + mv $@-t $@ +MOSTLYCLEANFILES += unused-parameter.h unused-parameter.h-t + +UNUSED_PARAMETER_H=unused-parameter.h + +EXTRA_DIST += $(top_srcdir)/build-aux/unused-parameter.h + +## end gnulib module unused-parameter + ## begin gnulib module update-copyright @@ -3477,13 +3933,32 @@ EXTRA_libcoreutils_a_SOURCES += vprintf.c ## end gnulib module vprintf-posix +## begin gnulib module warn-on-use + +BUILT_SOURCES += warn-on-use.h +# The warn-on-use.h that gets inserted into generated .h files is the same as +# build-aux/warn-on-use.h, except that it has the copyright header cut off. +warn-on-use.h: $(top_srcdir)/build-aux/warn-on-use.h + $(AM_V_GEN)rm -f $@-t $@ && \ + sed -n -e '/^.ifndef/,$$p' \ + < $(top_srcdir)/build-aux/warn-on-use.h \ + > $@-t && \ + mv $@-t $@ +MOSTLYCLEANFILES += warn-on-use.h warn-on-use.h-t + +WARN_ON_USE_H=warn-on-use.h + +EXTRA_DIST += $(top_srcdir)/build-aux/warn-on-use.h + +## end gnulib module warn-on-use + ## begin gnulib module wchar -BUILT_SOURCES += $(WCHAR_H) +BUILT_SOURCES += wchar.h # We need the following in order to create when the system # version does not work standalone. -wchar.h: wchar.in.h +wchar.h: wchar.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -3526,6 +4001,7 @@ wchar.h: wchar.in.h -e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \ -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ < $(srcdir)/wchar.in.h; \ } > $@-t && \ mv $@-t $@ @@ -3653,6 +4129,14 @@ libcoreutils_a_SOURCES += xprintf.h xprintf.c ## end gnulib module xprintf +## begin gnulib module xreadlink + +libcoreutils_a_SOURCES += xreadlink.c + +EXTRA_DIST += xreadlink.h + +## end gnulib module xreadlink + ## begin gnulib module xsize libcoreutils_a_SOURCES += xsize.h diff --git a/src/bin/coreutils/lib/group-member.c b/src/bin/coreutils/lib/group-member.c index a34efc04af..8aa3d8c28c 100644 --- a/src/bin/coreutils/lib/group-member.c +++ b/src/bin/coreutils/lib/group-member.c @@ -1,6 +1,6 @@ /* group-member.c -- determine whether group id is in calling user's group list - Copyright (C) 1994, 1997, 1998, 2003, 2005, 2006 Free Software + Copyright (C) 1994, 1997-1998, 2003, 2005-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -32,11 +32,9 @@ struct group_info { int n_groups; - GETGROUPS_T *group; + gid_t *group; }; -#if HAVE_GETGROUPS - static void free_group_info (struct group_info const *g) { @@ -48,7 +46,7 @@ get_group_info (struct group_info *gi) { int n_groups; int n_group_slots = getgroups (0, NULL); - GETGROUPS_T *group; + gid_t *group; if (n_group_slots < 0) return false; @@ -72,18 +70,14 @@ get_group_info (struct group_info *gi) return true; } -#endif /* not HAVE_GETGROUPS */ - /* Return non-zero if GID is one that we have in our groups list. - If there is no getgroups function, return non-zero if GID matches - either of the current or effective group IDs. */ + Note that the groups list is not guaranteed to contain the current + or effective group ID, so they should generally be checked + separately. */ int group_member (gid_t gid) { -#ifndef HAVE_GETGROUPS - return ((gid == getgid ()) || (gid == getegid ())); -#else int i; int found; struct group_info gi; @@ -96,16 +90,15 @@ group_member (gid_t gid) for (i = 0; i < gi.n_groups; i++) { if (gid == gi.group[i]) - { - found = 1; - break; - } + { + found = 1; + break; + } } free_group_info (&gi); return found; -#endif /* HAVE_GETGROUPS */ } #ifdef TEST @@ -119,7 +112,7 @@ main (int argc, char **argv) program_name = argv[0]; - for (i=1; ibucket; bucket < table->bucket_limit; bucket++) { if (bucket->data) - { - struct hash_entry const *cursor = bucket; - size_t bucket_length = 1; + { + struct hash_entry const *cursor = bucket; + size_t bucket_length = 1; - while (cursor = cursor->next, cursor) - bucket_length++; + while (cursor = cursor->next, cursor) + bucket_length++; - if (bucket_length > max_bucket_length) - max_bucket_length = bucket_length; - } + if (bucket_length > max_bucket_length) + max_bucket_length = bucket_length; + } } return max_bucket_length; @@ -208,17 +207,17 @@ hash_table_ok (const Hash_table *table) for (bucket = table->bucket; bucket < table->bucket_limit; bucket++) { if (bucket->data) - { - struct hash_entry const *cursor = bucket; + { + struct hash_entry const *cursor = bucket; - /* Count bucket head. */ - n_buckets_used++; - n_entries++; + /* Count bucket head. */ + n_buckets_used++; + n_entries++; - /* Count bucket overflow. */ - while (cursor = cursor->next, cursor) - n_entries++; - } + /* Count bucket overflow. */ + while (cursor = cursor->next, cursor) + n_entries++; + } } if (n_buckets_used == table->n_buckets_used && n_entries == table->n_entries) @@ -238,10 +237,10 @@ hash_print_statistics (const Hash_table *table, FILE *stream) fprintf (stream, "# entries: %lu\n", (unsigned long int) n_entries); fprintf (stream, "# buckets: %lu\n", (unsigned long int) n_buckets); fprintf (stream, "# buckets used: %lu (%.2f%%)\n", - (unsigned long int) n_buckets_used, - (100.0 * n_buckets_used) / n_buckets); + (unsigned long int) n_buckets_used, + (100.0 * n_buckets_used) / n_buckets); fprintf (stream, "max bucket length: %lu\n", - (unsigned long int) max_bucket_length); + (unsigned long int) max_bucket_length); } /* If ENTRY matches an entry already in the hash table, return the @@ -327,7 +326,7 @@ hash_get_next (const Hash_table *table, const void *entry) size_t hash_get_entries (const Hash_table *table, void **buffer, - size_t buffer_size) + size_t buffer_size) { size_t counter = 0; struct hash_entry const *bucket; @@ -336,14 +335,14 @@ hash_get_entries (const Hash_table *table, void **buffer, for (bucket = table->bucket; bucket < table->bucket_limit; bucket++) { if (bucket->data) - { - for (cursor = bucket; cursor; cursor = cursor->next) - { - if (counter >= buffer_size) - return counter; - buffer[counter++] = cursor->data; - } - } + { + for (cursor = bucket; cursor; cursor = cursor->next) + { + if (counter >= buffer_size) + return counter; + buffer[counter++] = cursor->data; + } + } } return counter; @@ -359,7 +358,7 @@ hash_get_entries (const Hash_table *table, void **buffer, size_t hash_do_for_each (const Hash_table *table, Hash_processor processor, - void *processor_data) + void *processor_data) { size_t counter = 0; struct hash_entry const *bucket; @@ -368,14 +367,14 @@ hash_do_for_each (const Hash_table *table, Hash_processor processor, for (bucket = table->bucket; bucket < table->bucket_limit; bucket++) { if (bucket->data) - { - for (cursor = bucket; cursor; cursor = cursor->next) - { - if (! processor (cursor->data, processor_data)) - return counter; - counter++; - } - } + { + for (cursor = bucket; cursor; cursor = cursor->next) + { + if (! processor (cursor->data, processor_data)) + return counter; + counter++; + } + } } return counter; @@ -505,6 +504,7 @@ static bool check_tuning (Hash_table *table) { const Hash_tuning *tuning = table->tuning; + float epsilon; if (tuning == &default_tuning) return true; @@ -513,8 +513,7 @@ check_tuning (Hash_table *table) fail to grow or shrink as they should. The smallest allocation is 11 (due to next_prime's algorithm), so an epsilon of 0.1 should be good enough. */ - { - float epsilon = 0.1f; + epsilon = 0.1f; if (epsilon < tuning->growth_threshold && tuning->growth_threshold < 1 - epsilon @@ -524,7 +523,6 @@ check_tuning (Hash_table *table) && tuning->shrink_factor <= 1 && tuning->shrink_threshold + epsilon < tuning->growth_threshold) return true; - } table->tuning = &default_tuning; return false; @@ -541,7 +539,7 @@ compute_bucket_size (size_t candidate, const Hash_tuning *tuning) { float new_candidate = candidate / tuning->growth_threshold; if (SIZE_MAX <= new_candidate) - return 0; + return 0; candidate = new_candidate; } candidate = next_prime (candidate); @@ -586,8 +584,8 @@ compute_bucket_size (size_t candidate, const Hash_tuning *tuning) Hash_table * hash_initialize (size_t candidate, const Hash_tuning *tuning, - Hash_hasher hasher, Hash_comparator comparator, - Hash_data_freer data_freer) + Hash_hasher hasher, Hash_comparator comparator, + Hash_data_freer data_freer) { Hash_table *table; @@ -606,10 +604,10 @@ hash_initialize (size_t candidate, const Hash_tuning *tuning, if (!check_tuning (table)) { /* Fail if the tuning options are invalid. This is the only occasion - when the user gets some feedback about it. Once the table is created, - if the user provides invalid tuning options, we silently revert to - using the defaults, and ignore further request to change the tuning - options. */ + when the user gets some feedback about it. Once the table is created, + if the user provides invalid tuning options, we silently revert to + using the defaults, and ignore further request to change the tuning + options. */ goto fail; } @@ -651,30 +649,30 @@ hash_clear (Hash_table *table) for (bucket = table->bucket; bucket < table->bucket_limit; bucket++) { if (bucket->data) - { - struct hash_entry *cursor; - struct hash_entry *next; + { + struct hash_entry *cursor; + struct hash_entry *next; - /* Free the bucket overflow. */ - for (cursor = bucket->next; cursor; cursor = next) - { - if (table->data_freer) - table->data_freer (cursor->data); - cursor->data = NULL; + /* Free the bucket overflow. */ + for (cursor = bucket->next; cursor; cursor = next) + { + if (table->data_freer) + table->data_freer (cursor->data); + cursor->data = NULL; - next = cursor->next; - /* Relinking is done one entry at a time, as it is to be expected - that overflows are either rare or short. */ - cursor->next = table->free_entry_list; - table->free_entry_list = cursor; - } + next = cursor->next; + /* Relinking is done one entry at a time, as it is to be expected + that overflows are either rare or short. */ + cursor->next = table->free_entry_list; + table->free_entry_list = cursor; + } - /* Free the bucket head. */ - if (table->data_freer) - table->data_freer (bucket->data); - bucket->data = NULL; - bucket->next = NULL; - } + /* Free the bucket head. */ + if (table->data_freer) + table->data_freer (bucket->data); + bucket->data = NULL; + bucket->next = NULL; + } } table->n_buckets_used = 0; @@ -697,13 +695,13 @@ hash_free (Hash_table *table) if (table->data_freer && table->n_entries) { for (bucket = table->bucket; bucket < table->bucket_limit; bucket++) - { - if (bucket->data) - { - for (cursor = bucket; cursor; cursor = cursor->next) - table->data_freer (cursor->data); - } - } + { + if (bucket->data) + { + for (cursor = bucket; cursor; cursor = cursor->next) + table->data_freer (cursor->data); + } + } } #if USE_OBSTACK @@ -716,10 +714,10 @@ hash_free (Hash_table *table) for (bucket = table->bucket; bucket < table->bucket_limit; bucket++) { for (cursor = bucket->next; cursor; cursor = next) - { - next = cursor->next; - free (cursor); - } + { + next = cursor->next; + free (cursor); + } } /* Also reclaim the internal list of previously freed entries. */ @@ -782,7 +780,7 @@ free_entry (Hash_table *table, struct hash_entry *entry) static void * hash_find_entry (Hash_table *table, const void *entry, - struct hash_entry **bucket_head, bool delete) + struct hash_entry **bucket_head, bool delete) { struct hash_entry *bucket = table->bucket + table->hasher (entry, table->n_buckets); @@ -803,21 +801,21 @@ hash_find_entry (Hash_table *table, const void *entry, void *data = bucket->data; if (delete) - { - if (bucket->next) - { - struct hash_entry *next = bucket->next; + { + if (bucket->next) + { + struct hash_entry *next = bucket->next; - /* Bump the first overflow entry into the bucket head, then save - the previous first overflow entry for later recycling. */ - *bucket = *next; - free_entry (table, next); - } - else - { - bucket->data = NULL; - } - } + /* Bump the first overflow entry into the bucket head, then save + the previous first overflow entry for later recycling. */ + *bucket = *next; + free_entry (table, next); + } + else + { + bucket->data = NULL; + } + } return data; } @@ -826,22 +824,22 @@ hash_find_entry (Hash_table *table, const void *entry, for (cursor = bucket; cursor->next; cursor = cursor->next) { if (entry == cursor->next->data - || table->comparator (entry, cursor->next->data)) - { - void *data = cursor->next->data; + || table->comparator (entry, cursor->next->data)) + { + void *data = cursor->next->data; - if (delete) - { - struct hash_entry *next = cursor->next; + if (delete) + { + struct hash_entry *next = cursor->next; - /* Unlink the entry to delete, then save the freed entry for later - recycling. */ - cursor->next = next->next; - free_entry (table, next); - } + /* Unlink the entry to delete, then save the freed entry for later + recycling. */ + cursor->next = next->next; + free_entry (table, next); + } - return data; - } + return data; + } } /* No entry found. */ @@ -863,74 +861,74 @@ transfer_entries (Hash_table *dst, Hash_table *src, bool safe) for (bucket = src->bucket; bucket < src->bucket_limit; bucket++) if (bucket->data) { - void *data; - struct hash_entry *new_bucket; + void *data; + struct hash_entry *new_bucket; - /* Within each bucket, transfer overflow entries first and - then the bucket head, to minimize memory pressure. After - all, the only time we might allocate is when moving the - bucket head, but moving overflow entries first may create - free entries that can be recycled by the time we finally - get to the bucket head. */ - for (cursor = bucket->next; cursor; cursor = next) - { - data = cursor->data; - new_bucket = (dst->bucket + dst->hasher (data, dst->n_buckets)); + /* Within each bucket, transfer overflow entries first and + then the bucket head, to minimize memory pressure. After + all, the only time we might allocate is when moving the + bucket head, but moving overflow entries first may create + free entries that can be recycled by the time we finally + get to the bucket head. */ + for (cursor = bucket->next; cursor; cursor = next) + { + data = cursor->data; + new_bucket = (dst->bucket + dst->hasher (data, dst->n_buckets)); - if (! (new_bucket < dst->bucket_limit)) - abort (); + if (! (new_bucket < dst->bucket_limit)) + abort (); - next = cursor->next; + next = cursor->next; - if (new_bucket->data) - { - /* Merely relink an existing entry, when moving from a - bucket overflow into a bucket overflow. */ - cursor->next = new_bucket->next; - new_bucket->next = cursor; - } - else - { - /* Free an existing entry, when moving from a bucket - overflow into a bucket header. */ - new_bucket->data = data; - dst->n_buckets_used++; - free_entry (dst, cursor); - } - } - /* Now move the bucket head. Be sure that if we fail due to - allocation failure that the src table is in a consistent - state. */ - data = bucket->data; - bucket->next = NULL; - if (safe) - continue; - new_bucket = (dst->bucket + dst->hasher (data, dst->n_buckets)); + if (new_bucket->data) + { + /* Merely relink an existing entry, when moving from a + bucket overflow into a bucket overflow. */ + cursor->next = new_bucket->next; + new_bucket->next = cursor; + } + else + { + /* Free an existing entry, when moving from a bucket + overflow into a bucket header. */ + new_bucket->data = data; + dst->n_buckets_used++; + free_entry (dst, cursor); + } + } + /* Now move the bucket head. Be sure that if we fail due to + allocation failure that the src table is in a consistent + state. */ + data = bucket->data; + bucket->next = NULL; + if (safe) + continue; + new_bucket = (dst->bucket + dst->hasher (data, dst->n_buckets)); - if (! (new_bucket < dst->bucket_limit)) - abort (); + if (! (new_bucket < dst->bucket_limit)) + abort (); - if (new_bucket->data) - { - /* Allocate or recycle an entry, when moving from a bucket - header into a bucket overflow. */ - struct hash_entry *new_entry = allocate_entry (dst); + if (new_bucket->data) + { + /* Allocate or recycle an entry, when moving from a bucket + header into a bucket overflow. */ + struct hash_entry *new_entry = allocate_entry (dst); - if (new_entry == NULL) - return false; + if (new_entry == NULL) + return false; - new_entry->data = data; - new_entry->next = new_bucket->next; - new_bucket->next = new_entry; - } - else - { - /* Move from one bucket header to another. */ - new_bucket->data = data; - dst->n_buckets_used++; - } - bucket->data = NULL; - src->n_buckets_used--; + new_entry->data = data; + new_entry->next = new_bucket->next; + new_bucket->next = new_entry; + } + else + { + /* Move from one bucket header to another. */ + new_bucket->data = data; + dst->n_buckets_used++; + } + bucket->data = NULL; + src->n_buckets_used--; } return true; } @@ -1015,7 +1013,7 @@ hash_rehash (Hash_table *table, size_t candidate) and safe is better than failure. */ table->free_entry_list = new_table->free_entry_list; if (! (transfer_entries (table, new_table, true) - && transfer_entries (table, new_table, false))) + && transfer_entries (table, new_table, false))) abort (); /* table->n_entries already holds its value. */ free (new_table->bucket); @@ -1051,29 +1049,29 @@ hash_insert (Hash_table *table, const void *entry) > table->tuning->growth_threshold * table->n_buckets) { /* Check more fully, before starting real work. If tuning arguments - became invalid, the second check will rely on proper defaults. */ + became invalid, the second check will rely on proper defaults. */ check_tuning (table); if (table->n_buckets_used - > table->tuning->growth_threshold * table->n_buckets) - { - const Hash_tuning *tuning = table->tuning; - float candidate = - (tuning->is_n_buckets - ? (table->n_buckets * tuning->growth_factor) - : (table->n_buckets * tuning->growth_factor - * tuning->growth_threshold)); + > table->tuning->growth_threshold * table->n_buckets) + { + const Hash_tuning *tuning = table->tuning; + float candidate = + (tuning->is_n_buckets + ? (table->n_buckets * tuning->growth_factor) + : (table->n_buckets * tuning->growth_factor + * tuning->growth_threshold)); - if (SIZE_MAX <= candidate) - return NULL; + if (SIZE_MAX <= candidate) + return NULL; - /* If the rehash fails, arrange to return NULL. */ - if (!hash_rehash (table, candidate)) - return NULL; + /* If the rehash fails, arrange to return NULL. */ + if (!hash_rehash (table, candidate)) + return NULL; - /* Update the bucket we are interested in. */ - if (hash_find_entry (table, entry, &bucket, false) != NULL) - abort (); - } + /* Update the bucket we are interested in. */ + if (hash_find_entry (table, entry, &bucket, false) != NULL) + abort (); + } } /* ENTRY is not matched, it should be inserted. */ @@ -1083,7 +1081,7 @@ hash_insert (Hash_table *table, const void *entry) struct hash_entry *new_entry = allocate_entry (table); if (new_entry == NULL) - return NULL; + return NULL; /* Add ENTRY in the overflow of the bucket. */ @@ -1123,45 +1121,45 @@ hash_delete (Hash_table *table, const void *entry) table->n_buckets_used--; /* If the shrink threshold of the buckets in use has been reached, - rehash into a smaller table. */ + rehash into a smaller table. */ if (table->n_buckets_used - < table->tuning->shrink_threshold * table->n_buckets) - { - /* Check more fully, before starting real work. If tuning arguments - became invalid, the second check will rely on proper defaults. */ - check_tuning (table); - if (table->n_buckets_used - < table->tuning->shrink_threshold * table->n_buckets) - { - const Hash_tuning *tuning = table->tuning; - size_t candidate = - (tuning->is_n_buckets - ? table->n_buckets * tuning->shrink_factor - : (table->n_buckets * tuning->shrink_factor - * tuning->growth_threshold)); + < table->tuning->shrink_threshold * table->n_buckets) + { + /* Check more fully, before starting real work. If tuning arguments + became invalid, the second check will rely on proper defaults. */ + check_tuning (table); + if (table->n_buckets_used + < table->tuning->shrink_threshold * table->n_buckets) + { + const Hash_tuning *tuning = table->tuning; + size_t candidate = + (tuning->is_n_buckets + ? table->n_buckets * tuning->shrink_factor + : (table->n_buckets * tuning->shrink_factor + * tuning->growth_threshold)); - if (!hash_rehash (table, candidate)) - { - /* Failure to allocate memory in an attempt to - shrink the table is not fatal. But since memory - is low, we can at least be kind and free any - spare entries, rather than keeping them tied up - in the free entry list. */ + if (!hash_rehash (table, candidate)) + { + /* Failure to allocate memory in an attempt to + shrink the table is not fatal. But since memory + is low, we can at least be kind and free any + spare entries, rather than keeping them tied up + in the free entry list. */ #if ! USE_OBSTACK - struct hash_entry *cursor = table->free_entry_list; - struct hash_entry *next; - while (cursor) - { - next = cursor->next; - free (cursor); - cursor = next; - } - table->free_entry_list = NULL; + struct hash_entry *cursor = table->free_entry_list; + struct hash_entry *next; + while (cursor) + { + next = cursor->next; + free (cursor); + cursor = next; + } + table->free_entry_list = NULL; #endif - } - } - } + } + } + } } return data; @@ -1181,15 +1179,15 @@ hash_print (const Hash_table *table) struct hash_entry *cursor; if (bucket) - printf ("%lu:\n", (unsigned long int) (bucket - table->bucket)); + printf ("%lu:\n", (unsigned long int) (bucket - table->bucket)); for (cursor = bucket; cursor; cursor = cursor->next) - { - char const *s = cursor->data; - /* FIXME */ - if (s) - printf (" %s\n", s); - } + { + char const *s = cursor->data; + /* FIXME */ + if (s) + printf (" %s\n", s); + } } } diff --git a/src/bin/coreutils/lib/hash.h b/src/bin/coreutils/lib/hash.h index c1e60ca10f..e795cdc836 100644 --- a/src/bin/coreutils/lib/hash.h +++ b/src/bin/coreutils/lib/hash.h @@ -1,5 +1,6 @@ /* hash - hashing table processing. - Copyright (C) 1998, 1999, 2001, 2003, 2009 Free Software Foundation, Inc. + Copyright (C) 1998-1999, 2001, 2003, 2009-2010 Free Software Foundation, + Inc. Written by Jim Meyering , 1998. This program is free software: you can redistribute it and/or modify @@ -47,11 +48,11 @@ struct hash_tuning /* This structure is mainly used for `hash_initialize', see the block documentation of `hash_reset_tuning' for more complete comments. */ - float shrink_threshold; /* ratio of used buckets to trigger a shrink */ - float shrink_factor; /* ratio of new smaller size to original size */ - float growth_threshold; /* ratio of used buckets to trigger a growth */ - float growth_factor; /* ratio of new bigger size to original size */ - bool is_n_buckets; /* if CANDIDATE really means table size */ + float shrink_threshold; /* ratio of used buckets to trigger a shrink */ + float shrink_factor; /* ratio of new smaller size to original size */ + float growth_threshold; /* ratio of used buckets to trigger a growth */ + float growth_factor; /* ratio of new bigger size to original size */ + bool is_n_buckets; /* if CANDIDATE really means table size */ }; typedef struct hash_tuning Hash_tuning; @@ -79,8 +80,8 @@ size_t hash_do_for_each (const Hash_table *, Hash_processor, void *); size_t hash_string (const char *, size_t); void hash_reset_tuning (Hash_tuning *); Hash_table *hash_initialize (size_t, const Hash_tuning *, - Hash_hasher, Hash_comparator, - Hash_data_freer) ATTRIBUTE_WUR; + Hash_hasher, Hash_comparator, + Hash_data_freer) ATTRIBUTE_WUR; void hash_clear (Hash_table *); void hash_free (Hash_table *); diff --git a/src/bin/coreutils/lib/human.c b/src/bin/coreutils/lib/human.c index c7291b7324..f5b9511ca1 100644 --- a/src/bin/coreutils/lib/human.c +++ b/src/bin/coreutils/lib/human.c @@ -1,7 +1,7 @@ /* human.c -- print human readable file size - Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + 2006, 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -36,15 +36,15 @@ static const char power_letter[] = { - 0, /* not used */ - 'K', /* kibi ('k' for kilo is a special case) */ - 'M', /* mega or mebi */ - 'G', /* giga or gibi */ - 'T', /* tera or tebi */ - 'P', /* peta or pebi */ - 'E', /* exa or exbi */ - 'Z', /* zetta or 2**70 */ - 'Y' /* yotta or 2**80 */ + 0, /* not used */ + 'K', /* kibi ('k' for kilo is a special case) */ + 'M', /* mega or mebi */ + 'G', /* giga or gibi */ + 'T', /* tera or tebi */ + 'P', /* peta or pebi */ + 'E', /* exa or exbi */ + 'Z', /* zetta or 2**70 */ + 'Y' /* yotta or 2**80 */ }; @@ -78,7 +78,7 @@ adjust_value (int inexact_style, long double value) static char * group_number (char *number, size_t numberlen, - char const *grouping, char const *thousands_sep) + char const *grouping, char const *thousands_sep) { register char *d; size_t grouplen = SIZE_MAX; @@ -97,19 +97,19 @@ group_number (char *number, size_t numberlen, unsigned char g = *grouping; if (g) - { - grouplen = g < CHAR_MAX ? g : i; - grouping++; - } + { + grouplen = g < CHAR_MAX ? g : i; + grouping++; + } if (i < grouplen) - grouplen = i; + grouplen = i; d -= grouplen; i -= grouplen; memcpy (d, buf + i, grouplen); if (i == 0) - return d; + return d; d -= thousands_seplen; memcpy (d, thousands_sep, thousands_seplen); @@ -152,7 +152,7 @@ group_number (char *number, size_t numberlen, char * human_readable (uintmax_t n, char *buf, int opts, - uintmax_t from_block_size, uintmax_t to_block_size) + uintmax_t from_block_size, uintmax_t to_block_size) { int inexact_style = opts & (human_round_to_nearest | human_floor | human_ceiling); @@ -195,16 +195,16 @@ human_readable (uintmax_t n, char *buf, int opts, if (to_block_size <= from_block_size) { if (from_block_size % to_block_size == 0) - { - uintmax_t multiplier = from_block_size / to_block_size; - amt = n * multiplier; - if (amt / multiplier == n) - { - tenths = 0; - rounding = 0; - goto use_integer_arithmetic; - } - } + { + uintmax_t multiplier = from_block_size / to_block_size; + amt = n * multiplier; + if (amt / multiplier == n) + { + tenths = 0; + rounding = 0; + goto use_integer_arithmetic; + } + } } else if (from_block_size != 0 && to_block_size % from_block_size == 0) { @@ -229,37 +229,37 @@ human_readable (uintmax_t n, char *buf, int opts, if (! (opts & human_autoscale)) { - sprintf (buf, "%.0Lf", adjust_value (inexact_style, damt)); - buflen = strlen (buf); - nonintegerlen = 0; + sprintf (buf, "%.0Lf", adjust_value (inexact_style, damt)); + buflen = strlen (buf); + nonintegerlen = 0; } else { - long double e = 1; - exponent = 0; + long double e = 1; + exponent = 0; - do - { - e *= base; - exponent++; - } - while (e * base <= damt && exponent < exponent_max); + do + { + e *= base; + exponent++; + } + while (e * base <= damt && exponent < exponent_max); - damt /= e; + damt /= e; - sprintf (buf, "%.1Lf", adjust_value (inexact_style, damt)); - buflen = strlen (buf); - nonintegerlen = decimal_pointlen + 1; + sprintf (buf, "%.1Lf", adjust_value (inexact_style, damt)); + buflen = strlen (buf); + nonintegerlen = decimal_pointlen + 1; - if (1 + nonintegerlen + ! (opts & human_base_1024) < buflen - || ((opts & human_suppress_point_zero) - && buf[buflen - 1] == '0')) - { - sprintf (buf, "%.0Lf", - adjust_value (inexact_style, damt * 10) / 10); - buflen = strlen (buf); - nonintegerlen = 0; - } + if (1 + nonintegerlen + ! (opts & human_base_1024) < buflen + || ((opts & human_suppress_point_zero) + && buf[buflen - 1] == '0')) + { + sprintf (buf, "%.0Lf", + adjust_value (inexact_style, damt * 10) / 10); + buflen = strlen (buf); + nonintegerlen = 0; + } } p = psuffix - buflen; @@ -277,77 +277,77 @@ human_readable (uintmax_t n, char *buf, int opts, if (opts & human_autoscale) { - exponent = 0; + exponent = 0; - if (base <= amt) - { - do - { - unsigned int r10 = (amt % base) * 10 + tenths; - unsigned int r2 = (r10 % base) * 2 + (rounding >> 1); - amt /= base; - tenths = r10 / base; - rounding = (r2 < base - ? (r2 + rounding) != 0 - : 2 + (base < r2 + rounding)); - exponent++; - } - while (base <= amt && exponent < exponent_max); + if (base <= amt) + { + do + { + unsigned int r10 = (amt % base) * 10 + tenths; + unsigned int r2 = (r10 % base) * 2 + (rounding >> 1); + amt /= base; + tenths = r10 / base; + rounding = (r2 < base + ? (r2 + rounding) != 0 + : 2 + (base < r2 + rounding)); + exponent++; + } + while (base <= amt && exponent < exponent_max); - if (amt < 10) - { - if (inexact_style == human_round_to_nearest - ? 2 < rounding + (tenths & 1) - : inexact_style == human_ceiling && 0 < rounding) - { - tenths++; - rounding = 0; + if (amt < 10) + { + if (inexact_style == human_round_to_nearest + ? 2 < rounding + (tenths & 1) + : inexact_style == human_ceiling && 0 < rounding) + { + tenths++; + rounding = 0; - if (tenths == 10) - { - amt++; - tenths = 0; - } - } + if (tenths == 10) + { + amt++; + tenths = 0; + } + } - if (amt < 10 - && (tenths || ! (opts & human_suppress_point_zero))) - { - *--p = '0' + tenths; - p -= decimal_pointlen; - memcpy (p, decimal_point, decimal_pointlen); - tenths = rounding = 0; - } - } - } + if (amt < 10 + && (tenths || ! (opts & human_suppress_point_zero))) + { + *--p = '0' + tenths; + p -= decimal_pointlen; + memcpy (p, decimal_point, decimal_pointlen); + tenths = rounding = 0; + } + } + } } if (inexact_style == human_round_to_nearest - ? 5 < tenths + (0 < rounding + (amt & 1)) - : inexact_style == human_ceiling && 0 < tenths + rounding) + ? 5 < tenths + (0 < rounding + (amt & 1)) + : inexact_style == human_ceiling && 0 < tenths + rounding) { - amt++; + amt++; - if ((opts & human_autoscale) - && amt == base && exponent < exponent_max) - { - exponent++; - if (! (opts & human_suppress_point_zero)) - { - *--p = '0'; - p -= decimal_pointlen; - memcpy (p, decimal_point, decimal_pointlen); - } - amt = 1; - } + if ((opts & human_autoscale) + && amt == base && exponent < exponent_max) + { + exponent++; + if (! (opts & human_suppress_point_zero)) + { + *--p = '0'; + p -= decimal_pointlen; + memcpy (p, decimal_point, decimal_pointlen); + } + amt = 1; + } } integerlim = p; do { - int digit = amt % 10; - *--p = digit + '0'; + int digit = amt % 10; + *--p = digit + '0'; } while ((amt /= 10) != 0); } @@ -359,28 +359,28 @@ human_readable (uintmax_t n, char *buf, int opts, if (opts & human_SI) { if (exponent < 0) - { - uintmax_t power; - exponent = 0; - for (power = 1; power < to_block_size; power *= base) - if (++exponent == exponent_max) - break; - } + { + uintmax_t power; + exponent = 0; + for (power = 1; power < to_block_size; power *= base) + if (++exponent == exponent_max) + break; + } if ((exponent | (opts & human_B)) && (opts & human_space_before_unit)) - *psuffix++ = ' '; + *psuffix++ = ' '; if (exponent) - *psuffix++ = (! (opts & human_base_1024) && exponent == 1 - ? 'k' - : power_letter[exponent]); + *psuffix++ = (! (opts & human_base_1024) && exponent == 1 + ? 'k' + : power_letter[exponent]); if (opts & human_B) - { - if ((opts & human_base_1024) && exponent) - *psuffix++ = 'i'; - *psuffix++ = 'B'; - } + { + if ((opts & human_base_1024) && exponent) + *psuffix++ = 'i'; + *psuffix++ = 'B'; + } } *psuffix = '\0'; @@ -421,37 +421,37 @@ humblock (char const *spec, uintmax_t *block_size, int *options) else { if (*spec == '\'') - { - opts |= human_group_digits; - spec++; - } + { + opts |= human_group_digits; + spec++; + } if (0 <= (i = ARGMATCH (spec, block_size_args, block_size_opts))) - { - opts |= block_size_opts[i]; - *block_size = 1; - } + { + opts |= block_size_opts[i]; + *block_size = 1; + } else - { - char *ptr; - strtol_error e = xstrtoumax (spec, &ptr, 0, block_size, - "eEgGkKmMpPtTyYzZ0"); - if (e != LONGINT_OK) - { - *options = 0; - return e; - } - for (; ! ('0' <= *spec && *spec <= '9'); spec++) - if (spec == ptr) - { - opts |= human_SI; - if (ptr[-1] == 'B') - opts |= human_B; - if (ptr[-1] != 'B' || ptr[-2] == 'i') - opts |= human_base_1024; - break; - } - } + { + char *ptr; + strtol_error e = xstrtoumax (spec, &ptr, 0, block_size, + "eEgGkKmMpPtTyYzZ0"); + if (e != LONGINT_OK) + { + *options = 0; + return e; + } + for (; ! ('0' <= *spec && *spec <= '9'); spec++) + if (spec == ptr) + { + opts |= human_SI; + if (ptr[-1] == 'B') + opts |= human_B; + if (ptr[-1] != 'B' || ptr[-2] == 'i') + opts |= human_base_1024; + break; + } + } } *options = opts; diff --git a/src/bin/coreutils/lib/human.h b/src/bin/coreutils/lib/human.h index 11b1e0cee4..d6b6ed5b4b 100644 --- a/src/bin/coreutils/lib/human.h +++ b/src/bin/coreutils/lib/human.h @@ -1,7 +1,7 @@ /* human.h -- print human readable file size - Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + 2006, 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/i-ring.c b/src/bin/coreutils/lib/i-ring.c index aee1fb3d28..2825ab97d3 100644 --- a/src/bin/coreutils/lib/i-ring.c +++ b/src/bin/coreutils/lib/i-ring.c @@ -1,5 +1,5 @@ /* a simple ring buffer - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/i-ring.h b/src/bin/coreutils/lib/i-ring.h index 21bd249445..2009266f32 100644 --- a/src/bin/coreutils/lib/i-ring.h +++ b/src/bin/coreutils/lib/i-ring.h @@ -1,5 +1,5 @@ /* definitions for a simple ring buffer - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/iconv.in.h b/src/bin/coreutils/lib/iconv.in.h index f2477858c5..c79f25579c 100644 --- a/src/bin/coreutils/lib/iconv.in.h +++ b/src/bin/coreutils/lib/iconv.in.h @@ -3,7 +3,7 @@ #line 1 /* A GNU-like . - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,6 +31,8 @@ #ifndef _GL_ICONV_H #define _GL_ICONV_H +/* The definition of _GL_ARG_NONNULL is copied here. */ + #ifdef __cplusplus extern "C" { #endif @@ -40,7 +42,8 @@ extern "C" { /* An iconv_open wrapper that supports the IANA standardized encoding names ("ISO-8859-1" etc.) as far as possible. */ # define iconv_open rpl_iconv_open -extern iconv_t iconv_open (const char *tocode, const char *fromcode); +extern iconv_t iconv_open (const char *tocode, const char *fromcode) + _GL_ARG_NONNULL ((1, 2)); #endif #if @REPLACE_ICONV_UTF@ @@ -59,8 +62,8 @@ extern iconv_t iconv_open (const char *tocode, const char *fromcode); #if @REPLACE_ICONV@ # define iconv rpl_iconv extern size_t iconv (iconv_t cd, - @ICONV_CONST@ char **inbuf, size_t *inbytesleft, - char **outbuf, size_t *outbytesleft); + @ICONV_CONST@ char **inbuf, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft); # define iconv_close rpl_iconv_close extern int iconv_close (iconv_t cd); #endif diff --git a/src/bin/coreutils/lib/iconv_open.c b/src/bin/coreutils/lib/iconv_open.c index b2e7f54a08..347127204c 100644 --- a/src/bin/coreutils/lib/iconv_open.c +++ b/src/bin/coreutils/lib/iconv_open.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Character set conversion. - Copyright (C) 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -70,33 +70,33 @@ rpl_iconv_open (const char *tocode, const char *fromcode) && fromcode[3] == '-') { if (c_toupper (tocode[0]) == 'U' - && c_toupper (tocode[1]) == 'T' - && c_toupper (tocode[2]) == 'F' - && tocode[3] == '-') - { - if (strcmp (fromcode + 4, "8") == 0) - { - if (c_strcasecmp (tocode + 4, "16BE") == 0) - return _ICONV_UTF8_UTF16BE; - if (c_strcasecmp (tocode + 4, "16LE") == 0) - return _ICONV_UTF8_UTF16LE; - if (c_strcasecmp (tocode + 4, "32BE") == 0) - return _ICONV_UTF8_UTF32BE; - if (c_strcasecmp (tocode + 4, "32LE") == 0) - return _ICONV_UTF8_UTF32LE; - } - else if (strcmp (tocode + 4, "8") == 0) - { - if (c_strcasecmp (fromcode + 4, "16BE") == 0) - return _ICONV_UTF16BE_UTF8; - if (c_strcasecmp (fromcode + 4, "16LE") == 0) - return _ICONV_UTF16LE_UTF8; - if (c_strcasecmp (fromcode + 4, "32BE") == 0) - return _ICONV_UTF32BE_UTF8; - if (c_strcasecmp (fromcode + 4, "32LE") == 0) - return _ICONV_UTF32LE_UTF8; - } - } + && c_toupper (tocode[1]) == 'T' + && c_toupper (tocode[2]) == 'F' + && tocode[3] == '-') + { + if (strcmp (fromcode + 4, "8") == 0) + { + if (c_strcasecmp (tocode + 4, "16BE") == 0) + return _ICONV_UTF8_UTF16BE; + if (c_strcasecmp (tocode + 4, "16LE") == 0) + return _ICONV_UTF8_UTF16LE; + if (c_strcasecmp (tocode + 4, "32BE") == 0) + return _ICONV_UTF8_UTF32BE; + if (c_strcasecmp (tocode + 4, "32LE") == 0) + return _ICONV_UTF8_UTF32LE; + } + else if (strcmp (tocode + 4, "8") == 0) + { + if (c_strcasecmp (fromcode + 4, "16BE") == 0) + return _ICONV_UTF16BE_UTF8; + if (c_strcasecmp (fromcode + 4, "16LE") == 0) + return _ICONV_UTF16LE_UTF8; + if (c_strcasecmp (fromcode + 4, "32BE") == 0) + return _ICONV_UTF32BE_UTF8; + if (c_strcasecmp (fromcode + 4, "32LE") == 0) + return _ICONV_UTF32LE_UTF8; + } + } } #endif @@ -119,20 +119,20 @@ rpl_iconv_open (const char *tocode, const char *fromcode) /* Convert the encodings to upper case, because 1. in the arguments of iconv_open() on AIX, HP-UX, and OSF/1 the case - matters, + matters, 2. it makes searching in the table faster. */ { const char *p = fromcode; char *q = fromcode_upper; while ((*q = c_toupper (*p)) != '\0') { - p++; - q++; - if (q == &fromcode_upper[SIZEOF (fromcode_upper)]) - { - errno = EINVAL; - return (iconv_t)(-1); - } + p++; + q++; + if (q == &fromcode_upper[SIZEOF (fromcode_upper)]) + { + errno = EINVAL; + return (iconv_t)(-1); + } } fromcode_upper_end = q; } @@ -142,13 +142,13 @@ rpl_iconv_open (const char *tocode, const char *fromcode) char *q = tocode_upper; while ((*q = c_toupper (*p)) != '\0') { - p++; - q++; - if (q == &tocode_upper[SIZEOF (tocode_upper)]) - { - errno = EINVAL; - return (iconv_t)(-1); - } + p++; + q++; + if (q == &tocode_upper[SIZEOF (tocode_upper)]) + { + errno = EINVAL; + return (iconv_t)(-1); + } } tocode_upper_end = q; } diff --git a/src/bin/coreutils/lib/idcache.c b/src/bin/coreutils/lib/idcache.c index 4951873d1d..11c82f0143 100644 --- a/src/bin/coreutils/lib/idcache.c +++ b/src/bin/coreutils/lib/idcache.c @@ -1,7 +1,7 @@ /* idcache.c -- map user and group IDs, cached for speed - Copyright (C) 1985, 1988, 1989, 1990, 1997, 1998, 2003, 2005-2007 - Free Software Foundation, Inc. + Copyright (C) 1985, 1988-1990, 1997-1998, 2003, 2005-2007, 2009-2010 Free + Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -73,10 +73,10 @@ getuser (uid_t uid) for (tail = user_alist; tail; tail = tail->next) { if (tail->id.u == uid) - { - match = tail; - break; - } + { + match = tail; + break; + } } if (match == NULL) @@ -123,7 +123,7 @@ getuidbyname (const char *user) if (!pwent && strspn (user, digits) < strlen (user)) { setenv ("USER", user, 1); - pwent = getpwnam (user); /* now it will succeed */ + pwent = getpwnam (user); /* now it will succeed */ } #endif @@ -155,10 +155,10 @@ getgroup (gid_t gid) for (tail = group_alist; tail; tail = tail->next) { if (tail->id.g == gid) - { - match = tail; - break; - } + { + match = tail; + break; + } } if (match == NULL) @@ -205,7 +205,7 @@ getgidbyname (const char *group) if (!grent && strspn (group, digits) < strlen (group)) { setenv ("GROUP", group, 1); - grent = getgrnam (group); /* now it will succeed */ + grent = getgrnam (group); /* now it will succeed */ } #endif diff --git a/src/bin/coreutils/lib/ignore-value.h b/src/bin/coreutils/lib/ignore-value.h index 86cfad77b2..2eb6918db5 100644 --- a/src/bin/coreutils/lib/ignore-value.h +++ b/src/bin/coreutils/lib/ignore-value.h @@ -1,6 +1,6 @@ /* ignore a function return without a compiler warning - Copyright (C) 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/imaxtostr.c b/src/bin/coreutils/lib/imaxtostr.c index 5e87ad526f..34ef96c450 100644 --- a/src/bin/coreutils/lib/imaxtostr.c +++ b/src/bin/coreutils/lib/imaxtostr.c @@ -1,3 +1,4 @@ #define inttostr imaxtostr #define inttype intmax_t +#define inttype_is_signed 1 #include "inttostr.c" diff --git a/src/bin/coreutils/lib/inet_ntop.c b/src/bin/coreutils/lib/inet_ntop.c index b1443f4371..3e6e2f5e86 100644 --- a/src/bin/coreutils/lib/inet_ntop.c +++ b/src/bin/coreutils/lib/inet_ntop.c @@ -3,7 +3,7 @@ #line 1 /* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form - Copyright (C) 2005, 2006, 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2008-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -62,15 +62,15 @@ static const char *inet_ntop6 (const unsigned char *src, char *dst, socklen_t si /* char * * inet_ntop(af, src, dst, size) - * convert a network format address to presentation format. + * convert a network format address to presentation format. * return: - * pointer to presentation format address (`dst'), or NULL (see errno). + * pointer to presentation format address (`dst'), or NULL (see errno). * author: - * Paul Vixie, 1996. + * Paul Vixie, 1996. */ const char * inet_ntop (int af, const void *restrict src, - char *restrict dst, socklen_t cnt) + char *restrict dst, socklen_t cnt) { switch (af) { @@ -93,14 +93,14 @@ inet_ntop (int af, const void *restrict src, /* const char * * inet_ntop4(src, dst, size) - * format an IPv4 address + * format an IPv4 address * return: - * `dst' (as a const) + * `dst' (as a const) * notes: - * (1) uses no statics - * (2) takes a u_char* not an in_addr as input + * (1) uses no statics + * (2) takes a u_char* not an in_addr as input * author: - * Paul Vixie, 1996. + * Paul Vixie, 1996. */ static const char * inet_ntop4 (const unsigned char *src, char *dst, socklen_t size) @@ -125,9 +125,9 @@ inet_ntop4 (const unsigned char *src, char *dst, socklen_t size) /* const char * * inet_ntop6(src, dst, size) - * convert IPv6 binary address into presentation (printable) format + * convert IPv6 binary address into presentation (printable) format * author: - * Paul Vixie, 1996. + * Paul Vixie, 1996. */ static const char * inet_ntop6 (const unsigned char *src, char *dst, socklen_t size) @@ -160,26 +160,26 @@ inet_ntop6 (const unsigned char *src, char *dst, socklen_t size) for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { if (words[i] == 0) - { - if (cur.base == -1) - cur.base = i, cur.len = 1; - else - cur.len++; - } + { + if (cur.base == -1) + cur.base = i, cur.len = 1; + else + cur.len++; + } else - { - if (cur.base != -1) - { - if (best.base == -1 || cur.len > best.len) - best = cur; - cur.base = -1; - } - } + { + if (cur.base != -1) + { + if (best.base == -1 || cur.len > best.len) + best = cur; + cur.base = -1; + } + } } if (cur.base != -1) { if (best.base == -1 || cur.len > best.len) - best = cur; + best = cur; } if (best.base != -1 && best.len < 2) best.base = -1; @@ -192,28 +192,28 @@ inet_ntop6 (const unsigned char *src, char *dst, socklen_t size) { /* Are we inside the best run of 0x00's? */ if (best.base != -1 && i >= best.base && i < (best.base + best.len)) - { - if (i == best.base) - *tp++ = ':'; - continue; - } + { + if (i == best.base) + *tp++ = ':'; + continue; + } /* Are we following an initial run of 0x00s or any real hex? */ if (i != 0) - *tp++ = ':'; + *tp++ = ':'; /* Is this address an encapsulated IPv4? */ if (i == 6 && best.base == 0 && - (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) - { - if (!inet_ntop4 (src + 12, tp, sizeof tmp - (tp - tmp))) - return (NULL); - tp += strlen (tp); - break; - } + (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) + { + if (!inet_ntop4 (src + 12, tp, sizeof tmp - (tp - tmp))) + return (NULL); + tp += strlen (tp); + break; + } { - int len = sprintf (tp, "%x", words[i]); - if (len < 0) - return NULL; - tp += len; + int len = sprintf (tp, "%x", words[i]); + if (len < 0) + return NULL; + tp += len; } } /* Was it a trailing run of 0x00's? */ diff --git a/src/bin/coreutils/lib/intprops.h b/src/bin/coreutils/lib/intprops.h index 002161ee57..46f4d47d70 100644 --- a/src/bin/coreutils/lib/intprops.h +++ b/src/bin/coreutils/lib/intprops.h @@ -1,6 +1,7 @@ /* intprops.h -- properties of integer types - Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009, 2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,40 +18,43 @@ /* Written by Paul Eggert. */ -#include +#ifndef GL_INTPROPS_H +# define GL_INTPROPS_H + +# include /* The extra casts in the following macros work around compiler bugs, e.g., in Cray C 5.0.3.0. */ /* True if the arithmetic type T is an integer type. bool counts as an integer. */ -#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1) +# define TYPE_IS_INTEGER(t) ((t) 1.5 == 1) /* True if negative values of the signed integer type T use two's complement, ones' complement, or signed magnitude representation, respectively. Much GNU code assumes two's complement, but some people like to be portable to all possible C hosts. */ -#define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1) -#define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0) -#define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1) +# define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1) +# define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0) +# define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1) /* True if the arithmetic type T is signed. */ -#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) +# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) /* The maximum and minimum values for the integer type T. These macros have undefined behavior if T is signed and has padding bits. If this is a problem for you, please let us know how to fix it for your host. */ -#define TYPE_MINIMUM(t) \ +# define TYPE_MINIMUM(t) \ ((t) (! TYPE_SIGNED (t) \ - ? (t) 0 \ - : TYPE_SIGNED_MAGNITUDE (t) \ - ? ~ (t) 0 \ - : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))) -#define TYPE_MAXIMUM(t) \ + ? (t) 0 \ + : TYPE_SIGNED_MAGNITUDE (t) \ + ? ~ (t) 0 \ + : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))) +# define TYPE_MAXIMUM(t) \ ((t) (! TYPE_SIGNED (t) \ - ? (t) -1 \ - : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))) + ? (t) -1 \ + : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))) /* Return zero if T can be determined to be an unsigned type. Otherwise, return 1. @@ -58,20 +62,22 @@ tighter bound. Otherwise, it overestimates the true bound by one byte when applied to unsigned types of size 2, 4, 16, ... bytes. The symbol signed_type_or_expr__ is private to this header file. */ -#if __GNUC__ >= 2 -# define signed_type_or_expr__(t) TYPE_SIGNED (__typeof__ (t)) -#else -# define signed_type_or_expr__(t) 1 -#endif +# if __GNUC__ >= 2 +# define signed_type_or_expr__(t) TYPE_SIGNED (__typeof__ (t)) +# else +# define signed_type_or_expr__(t) 1 +# endif /* Bound on length of the string representing an integer type or expression T. Subtract 1 for the sign bit if T is signed; log10 (2.0) < 146/485; add 1 for integer division truncation; add 1 more for a minus sign if needed. */ -#define INT_STRLEN_BOUND(t) \ +# define INT_STRLEN_BOUND(t) \ ((sizeof (t) * CHAR_BIT - signed_type_or_expr__ (t)) * 146 / 485 \ + signed_type_or_expr__ (t) + 1) /* Bound on buffer size needed to represent an integer type or expression T, including the terminating null. */ -#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1) +# define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1) + +#endif /* GL_INTPROPS_H */ diff --git a/src/bin/coreutils/lib/inttostr.c b/src/bin/coreutils/lib/inttostr.c index ed6a6933de..7ea8aea9ed 100644 --- a/src/bin/coreutils/lib/inttostr.c +++ b/src/bin/coreutils/lib/inttostr.c @@ -1,6 +1,6 @@ /* inttostr.c -- convert integers to printable strings - Copyright (C) 2001, 2006, 2008 Free Software Foundation, Inc. + Copyright (C) 2001, 2006, 2008, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,14 +17,10 @@ /* Written by Paul Eggert */ -/* Tell gcc not to warn about the (i < 0) test, below. */ -#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__ -# pragma GCC diagnostic ignored "-Wtype-limits" -#endif - #include #include "inttostr.h" +#include "verify.h" /* Convert I to a printable string in BUF, which must be at least INT_BUFSIZE_BOUND (INTTYPE) bytes long. Return the address of the @@ -36,18 +32,21 @@ inttostr (inttype i, char *buf) char *p = buf + INT_STRLEN_BOUND (inttype); *p = 0; + { verify (TYPE_SIGNED (inttype) == inttype_is_signed); } +#if inttype_is_signed if (i < 0) { do - *--p = '0' - i % 10; + *--p = '0' - i % 10; while ((i /= 10) != 0); *--p = '-'; } else +#endif { do - *--p = '0' + i % 10; + *--p = '0' + i % 10; while ((i /= 10) != 0); } diff --git a/src/bin/coreutils/lib/inttostr.h b/src/bin/coreutils/lib/inttostr.h index a103caf587..f11a5ff672 100644 --- a/src/bin/coreutils/lib/inttostr.h +++ b/src/bin/coreutils/lib/inttostr.h @@ -1,7 +1,6 @@ /* inttostr.h -- convert integers to printable strings - Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software - Foundation, Inc. + Copyright (C) 2001-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/inttypes.h b/src/bin/coreutils/lib/inttypes.h index 30f1aecc70..a7c07ec581 100644 --- a/src/bin/coreutils/lib/inttypes.h +++ b/src/bin/coreutils/lib/inttypes.h @@ -1,41 +1,47 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ -/* Copyright (C) 2006 Free Software Foundation, Inc. +/* Copyright (C) 2006-2010 Free Software Foundation, Inc. Written by Paul Eggert, Bruno Haible, Derek Price. This file is part of gnulib. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1, or (at your option) - any later version. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU Lesser General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -/* Include the original if it exists, and if this file - has not been included yet or if this file includes gnulib stdint.h - which in turn includes this file. */ -#if ! defined INTTYPES_H || defined _GL_JUST_INCLUDE_ABSOLUTE_INTTYPES_H -# if 1 -# include_next "inttypes.h" -# endif -#endif - -#if ! defined INTTYPES_H && ! defined _GL_JUST_INCLUDE_ABSOLUTE_INTTYPES_H -#define INTTYPES_H + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ /* * ISO C 99 for platforms that lack it. * */ -/* Include or the gnulib replacement. */ -#include +/* Include the original if it exists, and if this file + has not been included yet or if this file includes gnulib stdint.h + which in turn includes this file. + The include_next requires a split double-inclusion guard. */ +#if ! defined INTTYPES_H || defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H +# if 1 +# if __GNUC__ >= 3 +#pragma GCC system_header +# endif +# include_next +# endif +#endif + +#if ! defined INTTYPES_H && ! defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H +#define INTTYPES_H + +/* Include or the gnulib replacement. + But avoid namespace pollution on glibc systems. */ +#ifndef __GLIBC__ +# include +#endif /* Get CHAR_BIT. */ #include @@ -43,6 +49,48 @@ # error "This file assumes that 'int' has exactly 32 bits. Please report your platform and compiler to ." #endif +/* The definition of GL_LINK_WARNING is copied here. */ +/* GL_LINK_WARNING("literal string") arranges to emit the literal string as + a linker warning on most glibc systems. + We use a linker warning rather than a preprocessor warning, because + #warning cannot be used inside macros. */ +#ifndef GL_LINK_WARNING + /* This works on platforms with GNU ld and ELF object format. + Testing __GLIBC__ is sufficient for asserting that GNU ld is in use. + Testing __ELF__ guarantees the ELF object format. + Testing __GNUC__ is necessary for the compound expression syntax. */ +# if defined __GLIBC__ && defined __ELF__ && defined __GNUC__ +# define GL_LINK_WARNING(message) \ + GL_LINK_WARNING1 (__FILE__, __LINE__, message) +# define GL_LINK_WARNING1(file, line, message) \ + GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */ +# define GL_LINK_WARNING2(file, line, message) \ + GL_LINK_WARNING3 (file ":" #line ": warning: " message) +# define GL_LINK_WARNING3(message) \ + ({ static const char warning[sizeof (message)] \ + __attribute__ ((__unused__, \ + __section__ (".gnu.warning"), \ + __aligned__ (1))) \ + = message "\n"; \ + (void)0; \ + }) +# else +# define GL_LINK_WARNING(message) ((void) 0) +# endif +#endif + +/* The definition of _GL_ARG_NONNULL is copied here. */ +/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools + that the values passed as arguments n, ..., m must be non-NULL pointers. + n = 1 stands for the first argument, n = 2 for the second argument etc. */ +#ifndef _GL_ARG_NONNULL +# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 +# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) +# else +# define _GL_ARG_NONNULL(params) +# endif +#endif + /* 7.8.1 Macros for format specifiers */ #if ! defined __cplusplus || defined __STDC_FORMAT_MACROS @@ -164,7 +212,7 @@ # endif # endif # ifdef INT64_MAX -# if INT64_MAX == LONG_MAX +# if (0 ? defined _LP64 : 0) # define _PRI64_PREFIX "l" # elif defined _MSC_VER || defined __MINGW32__ # define _PRI64_PREFIX "I64" @@ -181,7 +229,7 @@ # endif # endif # ifdef UINT64_MAX -# if UINT64_MAX == ULONG_MAX +# if (0 ? defined _LP64 : 0) # define _PRIu64_PREFIX "l" # elif defined _MSC_VER || defined __MINGW32__ # define _PRIu64_PREFIX "I64" @@ -482,7 +530,7 @@ # if !defined PRIdMAX || 0 # undef PRIdMAX -# if INTMAX_MAX > INT32_MAX +# if 1 # define PRIdMAX PRId64 # else # define PRIdMAX "ld" @@ -490,7 +538,7 @@ # endif # if !defined PRIiMAX || 0 # undef PRIiMAX -# if INTMAX_MAX > INT32_MAX +# if 1 # define PRIiMAX PRIi64 # else # define PRIiMAX "li" @@ -498,7 +546,7 @@ # endif # if !defined PRIoMAX || 0 # undef PRIoMAX -# if UINTMAX_MAX > UINT32_MAX +# if 1 # define PRIoMAX PRIo64 # else # define PRIoMAX "lo" @@ -506,7 +554,7 @@ # endif # if !defined PRIuMAX || 0 # undef PRIuMAX -# if UINTMAX_MAX > UINT32_MAX +# if 1 # define PRIuMAX PRIu64 # else # define PRIuMAX "lu" @@ -514,7 +562,7 @@ # endif # if !defined PRIxMAX || 0 # undef PRIxMAX -# if UINTMAX_MAX > UINT32_MAX +# if 1 # define PRIxMAX PRIx64 # else # define PRIxMAX "lx" @@ -522,7 +570,7 @@ # endif # if !defined PRIXMAX || 0 # undef PRIXMAX -# if UINTMAX_MAX > UINT32_MAX +# if 1 # define PRIXMAX PRIX64 # else # define PRIXMAX "lX" @@ -657,7 +705,7 @@ # endif # endif # ifdef INT64_MAX -# if INT64_MAX == LONG_MAX +# if (0 ? defined _LP64 : 0) # define _SCN64_PREFIX "l" # elif defined _MSC_VER || defined __MINGW32__ # define _SCN64_PREFIX "I64" @@ -674,7 +722,7 @@ # endif # endif # ifdef UINT64_MAX -# if UINT64_MAX == ULONG_MAX +# if (0 ? defined _LP64 : 0) # define _SCNu64_PREFIX "l" # elif defined _MSC_VER || defined __MINGW32__ # define _SCNu64_PREFIX "I64" @@ -957,7 +1005,7 @@ # if !defined SCNdMAX || 0 # undef SCNdMAX -# if INTMAX_MAX > INT32_MAX +# if 1 # define SCNdMAX SCNd64 # else # define SCNdMAX "ld" @@ -965,7 +1013,7 @@ # endif # if !defined SCNiMAX || 0 # undef SCNiMAX -# if INTMAX_MAX > INT32_MAX +# if 1 # define SCNiMAX SCNi64 # else # define SCNiMAX "li" @@ -973,7 +1021,7 @@ # endif # if !defined SCNoMAX || 0 # undef SCNoMAX -# if UINTMAX_MAX > UINT32_MAX +# if 1 # define SCNoMAX SCNo64 # else # define SCNoMAX "lo" @@ -981,7 +1029,7 @@ # endif # if !defined SCNuMAX || 0 # undef SCNuMAX -# if UINTMAX_MAX > UINT32_MAX +# if 1 # define SCNuMAX SCNu64 # else # define SCNuMAX "lu" @@ -989,7 +1037,7 @@ # endif # if !defined SCNxMAX || 0 # undef SCNxMAX -# if UINTMAX_MAX > UINT32_MAX +# if 1 # define SCNxMAX SCNx64 # else # define SCNxMAX "lx" @@ -1035,20 +1083,53 @@ extern "C" { #endif -#if !1 +#if 0 +# if !1 extern intmax_t imaxabs (intmax_t); +# endif +#elif defined GNULIB_POSIXCHECK +# undef imaxabs +# define imaxabs(a) \ + (GL_LINK_WARNING ("imaxabs is unportable - " \ + "use gnulib module imaxabs for portability"), \ + imaxabs (a)) #endif -#if !1 +#if 0 +# if !1 typedef struct { intmax_t quot; intmax_t rem; } imaxdiv_t; extern imaxdiv_t imaxdiv (intmax_t, intmax_t); +# endif +#elif defined GNULIB_POSIXCHECK +# undef imaxdiv +# define imaxdiv(a,b) \ + (GL_LINK_WARNING ("imaxdiv is unportable - " \ + "use gnulib module imaxdiv for portability"), \ + imaxdiv (a, b)) #endif -#if !1 -extern intmax_t strtoimax (const char *, char **, int); +#if 1 +# if !1 +extern intmax_t strtoimax (const char *, char **, int) _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strtoimax +# define strtoimax(p,e,b) \ + (GL_LINK_WARNING ("strtoimax is unportable - " \ + "use gnulib module strtoimax for portability"), \ + strtoimax (p, e, b)) #endif -#if !1 -extern uintmax_t strtoumax (const char *, char **, int); + +#if 1 +# if !1 +extern uintmax_t strtoumax (const char *, char **, int) _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strtoumax +# define strtoumax(p,e,b) \ + (GL_LINK_WARNING ("strtoumax is unportable - " \ + "use gnulib module strtoumax for portability"), \ + strtoumax (p, e, b)) #endif /* Don't bother defining or declaring wcstoimax and wcstoumax, since @@ -1058,4 +1139,4 @@ extern uintmax_t strtoumax (const char *, char **, int); } #endif -#endif /* INTTYPES_H */ +#endif /* !defined INTTYPES_H && !defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H */ diff --git a/src/bin/coreutils/lib/inttypes.in.h b/src/bin/coreutils/lib/inttypes.in.h index 7022ebc354..14c2b20523 100644 --- a/src/bin/coreutils/lib/inttypes.in.h +++ b/src/bin/coreutils/lib/inttypes.in.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2006-2009 Free Software Foundation, Inc. +/* Copyright (C) 2006-2010 Free Software Foundation, Inc. Written by Paul Eggert, Bruno Haible, Derek Price. This file is part of gnulib. @@ -36,8 +36,11 @@ #if ! defined INTTYPES_H && ! defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H #define INTTYPES_H -/* Include or the gnulib replacement. */ -#include +/* Include or the gnulib replacement. + But avoid namespace pollution on glibc systems. */ +#ifndef __GLIBC__ +# include +#endif /* Get CHAR_BIT. */ #include @@ -47,6 +50,8 @@ /* The definition of GL_LINK_WARNING is copied here. */ +/* The definition of _GL_ARG_NONNULL is copied here. */ + /* 7.8.1 Macros for format specifiers */ #if ! defined __cplusplus || defined __STDC_FORMAT_MACROS @@ -1066,7 +1071,7 @@ extern imaxdiv_t imaxdiv (intmax_t, intmax_t); #if @GNULIB_STRTOIMAX@ # if !@HAVE_DECL_STRTOIMAX@ -extern intmax_t strtoimax (const char *, char **, int); +extern intmax_t strtoimax (const char *, char **, int) _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef strtoimax @@ -1078,7 +1083,7 @@ extern intmax_t strtoimax (const char *, char **, int); #if @GNULIB_STRTOUMAX@ # if !@HAVE_DECL_STRTOUMAX@ -extern uintmax_t strtoumax (const char *, char **, int); +extern uintmax_t strtoumax (const char *, char **, int) _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef strtoumax diff --git a/src/bin/coreutils/lib/isapipe.c b/src/bin/coreutils/lib/isapipe.c index 495cba6a6a..b8db860074 100644 --- a/src/bin/coreutils/lib/isapipe.c +++ b/src/bin/coreutils/lib/isapipe.c @@ -1,6 +1,6 @@ /* Test whether a file descriptor is a pipe. - Copyright (C) 2006, 2008 Free Software Foundation, Inc. + Copyright (C) 2006, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -87,28 +87,28 @@ isapipe (int fd) On Darwin 7.7, pipes are sockets, so check for those instead. */ if (! ((HAVE_FIFO_PIPES == 0 || HAVE_FIFO_PIPES == 1) - && PIPE_LINK_COUNT_MAX != (nlink_t) -1) + && PIPE_LINK_COUNT_MAX != (nlink_t) -1) && (S_ISFIFO (st.st_mode) | S_ISSOCK (st.st_mode))) { int fd_pair[2]; int pipe_result = pipe (fd_pair); if (pipe_result != 0) - return pipe_result; + return pipe_result; else - { - struct stat pipe_st; - int fstat_pipe_result = fstat (fd_pair[0], &pipe_st); - int fstat_pipe_errno = errno; - close (fd_pair[0]); - close (fd_pair[1]); - if (fstat_pipe_result != 0) - { - errno = fstat_pipe_errno; - return fstat_pipe_result; - } - check_for_fifo = (S_ISFIFO (pipe_st.st_mode) != 0); - pipe_link_count_max = pipe_st.st_nlink; - } + { + struct stat pipe_st; + int fstat_pipe_result = fstat (fd_pair[0], &pipe_st); + int fstat_pipe_errno = errno; + close (fd_pair[0]); + close (fd_pair[1]); + if (fstat_pipe_result != 0) + { + errno = fstat_pipe_errno; + return fstat_pipe_result; + } + check_for_fifo = (S_ISFIFO (pipe_st.st_mode) != 0); + pipe_link_count_max = pipe_st.st_nlink; + } } return diff --git a/src/bin/coreutils/lib/isblank.c b/src/bin/coreutils/lib/isblank.c new file mode 100644 index 0000000000..e4cddac2a5 --- /dev/null +++ b/src/bin/coreutils/lib/isblank.c @@ -0,0 +1,33 @@ +/* Test whether a character is a blank. + + Copyright (C) 2009, 2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +int +isblank (int c) +{ + /* On all known platforms, in all predefined locales, isblank(c) is likely + equivalent with (c == ' ' || c == '\t'). Look at the glibc definition + (in glibc/localedata/locales/i18n): The "blank" characters are '\t', ' ', + U+1680, U+180E, U+2000..U+2006, U+2008..U+200A, U+205F, U+3000, and none + except the first two is present in a common 8-bit encoding. Therefore + the substitute for other platforms is not more complicated than this. */ + return (c == ' ' || c == '\t'); +} diff --git a/src/bin/coreutils/lib/isnan.c b/src/bin/coreutils/lib/isnan.c index a5ca38df41..ee9fa8b644 100644 --- a/src/bin/coreutils/lib/isnan.c +++ b/src/bin/coreutils/lib/isnan.c @@ -1,5 +1,5 @@ /* Test for NaN that does not need libm. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,6 +18,18 @@ #include +/* Specification. */ +#ifdef USE_LONG_DOUBLE +/* Specification found in math.h or isnanl-nolibm.h. */ +extern int rpl_isnanl (long double x); +#elif ! defined USE_FLOAT +/* Specification found in math.h or isnand-nolibm.h. */ +extern int rpl_isnand (double x); +#else /* defined USE_FLOAT */ +/* Specification found in math.h or isnanf-nolibm.h. */ +extern int rpl_isnanf (float x); +#endif + #include #include @@ -128,10 +140,10 @@ FUNC (DOUBLE x) -Infinity, which have the same exponent. */ m.value = x; if (((m.word[EXPBIT0_WORD] ^ nan.word[EXPBIT0_WORD]) - & (EXP_MASK << EXPBIT0_BIT)) - == 0) + & (EXP_MASK << EXPBIT0_BIT)) + == 0) return (memcmp (&m.value, &plus_inf, SIZE) != 0 - && memcmp (&m.value, &minus_inf, SIZE) != 0); + && memcmp (&m.value, &minus_inf, SIZE) != 0); else return 0; } diff --git a/src/bin/coreutils/lib/isnand-nolibm.h b/src/bin/coreutils/lib/isnand-nolibm.h index d248b2f5ea..bcf6b85a1f 100644 --- a/src/bin/coreutils/lib/isnand-nolibm.h +++ b/src/bin/coreutils/lib/isnand-nolibm.h @@ -1,5 +1,5 @@ /* Test for NaN that does not need libm. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/isnand.c b/src/bin/coreutils/lib/isnand.c index 8e5bbb3999..de026deffd 100644 --- a/src/bin/coreutils/lib/isnand.c +++ b/src/bin/coreutils/lib/isnand.c @@ -1,5 +1,5 @@ /* Test for NaN that does not need libm. - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/isnanf-nolibm.h b/src/bin/coreutils/lib/isnanf-nolibm.h index 774942c728..4f90031fbe 100644 --- a/src/bin/coreutils/lib/isnanf-nolibm.h +++ b/src/bin/coreutils/lib/isnanf-nolibm.h @@ -1,5 +1,5 @@ /* Test for NaN that does not need libm. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/isnanf.c b/src/bin/coreutils/lib/isnanf.c index 8f70eb60d8..4f2e5abc4a 100644 --- a/src/bin/coreutils/lib/isnanf.c +++ b/src/bin/coreutils/lib/isnanf.c @@ -1,5 +1,5 @@ /* Test for NaN that does not need libm. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/isnanl-nolibm.h b/src/bin/coreutils/lib/isnanl-nolibm.h index fa29f54af7..3dbba8bc67 100644 --- a/src/bin/coreutils/lib/isnanl-nolibm.h +++ b/src/bin/coreutils/lib/isnanl-nolibm.h @@ -1,5 +1,5 @@ /* Test for NaN that does not need libm. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/isnanl.c b/src/bin/coreutils/lib/isnanl.c index 6af5a70bd6..9594801fd2 100644 --- a/src/bin/coreutils/lib/isnanl.c +++ b/src/bin/coreutils/lib/isnanl.c @@ -1,5 +1,5 @@ /* Test for NaN that does not need libm. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/langinfo.h b/src/bin/coreutils/lib/langinfo.h new file mode 100644 index 0000000000..72a95379ff --- /dev/null +++ b/src/bin/coreutils/lib/langinfo.h @@ -0,0 +1,194 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +#line 1 +/* Substitute for and wrapper around . + Copyright (C) 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* + * POSIX for platforms that lack it or have an incomplete one. + * + */ + +#ifndef _GL_LANGINFO_H + +#if __GNUC__ >= 3 +#pragma GCC system_header +#endif + +/* The include_next requires a split double-inclusion guard. */ +#if 0 +# include_next +#endif + +#ifndef _GL_LANGINFO_H +#define _GL_LANGINFO_H + + +#if !0 + +/* A platform that lacks . */ + +/* Assume that it also lacks and the nl_item type. */ +typedef int nl_item; + +/* nl_langinfo items of the LC_CTYPE category */ +# define CODESET 10000 +/* nl_langinfo items of the LC_NUMERIC category */ +# define RADIXCHAR 10001 +# define THOUSEP 10002 +/* nl_langinfo items of the LC_TIME category */ +# define D_T_FMT 10003 +# define D_FMT 10004 +# define T_FMT 10005 +# define T_FMT_AMPM 10006 +# define AM_STR 10007 +# define PM_STR 10008 +# define DAY_1 10009 +# define DAY_2 (DAY_1 + 1) +# define DAY_3 (DAY_1 + 2) +# define DAY_4 (DAY_1 + 3) +# define DAY_5 (DAY_1 + 4) +# define DAY_6 (DAY_1 + 5) +# define DAY_7 (DAY_1 + 6) +# define ABDAY_1 10016 +# define ABDAY_2 (ABDAY_1 + 1) +# define ABDAY_3 (ABDAY_1 + 2) +# define ABDAY_4 (ABDAY_1 + 3) +# define ABDAY_5 (ABDAY_1 + 4) +# define ABDAY_6 (ABDAY_1 + 5) +# define ABDAY_7 (ABDAY_1 + 6) +# define MON_1 10023 +# define MON_2 (MON_1 + 1) +# define MON_3 (MON_1 + 2) +# define MON_4 (MON_1 + 3) +# define MON_5 (MON_1 + 4) +# define MON_6 (MON_1 + 5) +# define MON_7 (MON_1 + 6) +# define MON_8 (MON_1 + 7) +# define MON_9 (MON_1 + 8) +# define MON_10 (MON_1 + 9) +# define MON_11 (MON_1 + 10) +# define MON_12 (MON_1 + 11) +# define ABMON_1 10035 +# define ABMON_2 (ABMON_1 + 1) +# define ABMON_3 (ABMON_1 + 2) +# define ABMON_4 (ABMON_1 + 3) +# define ABMON_5 (ABMON_1 + 4) +# define ABMON_6 (ABMON_1 + 5) +# define ABMON_7 (ABMON_1 + 6) +# define ABMON_8 (ABMON_1 + 7) +# define ABMON_9 (ABMON_1 + 8) +# define ABMON_10 (ABMON_1 + 9) +# define ABMON_11 (ABMON_1 + 10) +# define ABMON_12 (ABMON_1 + 11) +# define ERA 10047 +# define ERA_D_FMT 10048 +# define ERA_D_T_FMT 10049 +# define ERA_T_FMT 10050 +# define ALT_DIGITS 10051 +/* nl_langinfo items of the LC_MONETARY category */ +# define CRNCYSTR 10052 +/* nl_langinfo items of the LC_MESSAGES category */ +# define YESEXPR 10053 +# define NOEXPR 10054 + +#else + +/* A platform that has . */ + +# if !0 +# define CODESET 10000 +# define GNULIB_defined_CODESET 1 +# endif + +# if !0 +# define ERA 10047 +# define ERA_D_FMT 10048 +# define ERA_D_T_FMT 10049 +# define ERA_T_FMT 10050 +# define ALT_DIGITS 10051 +# define GNULIB_defined_ERA 1 +# endif + +#endif + +/* The definition of GL_LINK_WARNING is copied here. */ +/* GL_LINK_WARNING("literal string") arranges to emit the literal string as + a linker warning on most glibc systems. + We use a linker warning rather than a preprocessor warning, because + #warning cannot be used inside macros. */ +#ifndef GL_LINK_WARNING + /* This works on platforms with GNU ld and ELF object format. + Testing __GLIBC__ is sufficient for asserting that GNU ld is in use. + Testing __ELF__ guarantees the ELF object format. + Testing __GNUC__ is necessary for the compound expression syntax. */ +# if defined __GLIBC__ && defined __ELF__ && defined __GNUC__ +# define GL_LINK_WARNING(message) \ + GL_LINK_WARNING1 (__FILE__, __LINE__, message) +# define GL_LINK_WARNING1(file, line, message) \ + GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */ +# define GL_LINK_WARNING2(file, line, message) \ + GL_LINK_WARNING3 (file ":" #line ": warning: " message) +# define GL_LINK_WARNING3(message) \ + ({ static const char warning[sizeof (message)] \ + __attribute__ ((__unused__, \ + __section__ (".gnu.warning"), \ + __aligned__ (1))) \ + = message "\n"; \ + (void)0; \ + }) +# else +# define GL_LINK_WARNING(message) ((void) 0) +# endif +#endif + +/* Declare overridden functions. */ + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Return a piece of locale dependent information. + Note: The difference between nl_langinfo (CODESET) and locale_charset () + is that the latter normalizes the encoding names to GNU conventions. */ + +#if 1 +# if 0 +# undef nl_langinfo +# define nl_langinfo rpl_nl_langinfo +# endif +# if !0 || 0 +extern char *nl_langinfo (nl_item item); +# endif +#elif defined GNULIB_POSIXCHECK +# undef nl_langinfo +# define nl_langinfo(i) \ + (GL_LINK_WARNING ("nl_langinfo is not portable - " \ + "use gnulib module nl_langinfo for portability"), \ + nl_langinfo (i)) +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif /* _GL_LANGINFO_H */ +#endif /* _GL_LANGINFO_H */ diff --git a/src/bin/coreutils/lib/langinfo.in.h b/src/bin/coreutils/lib/langinfo.in.h new file mode 100644 index 0000000000..cc0faf2c25 --- /dev/null +++ b/src/bin/coreutils/lib/langinfo.in.h @@ -0,0 +1,165 @@ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +#line 1 +/* Substitute for and wrapper around . + Copyright (C) 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* + * POSIX for platforms that lack it or have an incomplete one. + * + */ + +#ifndef _GL_LANGINFO_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif + +/* The include_next requires a split double-inclusion guard. */ +#if @HAVE_LANGINFO_H@ +# @INCLUDE_NEXT@ @NEXT_LANGINFO_H@ +#endif + +#ifndef _GL_LANGINFO_H +#define _GL_LANGINFO_H + + +#if !@HAVE_LANGINFO_H@ + +/* A platform that lacks . */ + +/* Assume that it also lacks and the nl_item type. */ +typedef int nl_item; + +/* nl_langinfo items of the LC_CTYPE category */ +# define CODESET 10000 +/* nl_langinfo items of the LC_NUMERIC category */ +# define RADIXCHAR 10001 +# define THOUSEP 10002 +/* nl_langinfo items of the LC_TIME category */ +# define D_T_FMT 10003 +# define D_FMT 10004 +# define T_FMT 10005 +# define T_FMT_AMPM 10006 +# define AM_STR 10007 +# define PM_STR 10008 +# define DAY_1 10009 +# define DAY_2 (DAY_1 + 1) +# define DAY_3 (DAY_1 + 2) +# define DAY_4 (DAY_1 + 3) +# define DAY_5 (DAY_1 + 4) +# define DAY_6 (DAY_1 + 5) +# define DAY_7 (DAY_1 + 6) +# define ABDAY_1 10016 +# define ABDAY_2 (ABDAY_1 + 1) +# define ABDAY_3 (ABDAY_1 + 2) +# define ABDAY_4 (ABDAY_1 + 3) +# define ABDAY_5 (ABDAY_1 + 4) +# define ABDAY_6 (ABDAY_1 + 5) +# define ABDAY_7 (ABDAY_1 + 6) +# define MON_1 10023 +# define MON_2 (MON_1 + 1) +# define MON_3 (MON_1 + 2) +# define MON_4 (MON_1 + 3) +# define MON_5 (MON_1 + 4) +# define MON_6 (MON_1 + 5) +# define MON_7 (MON_1 + 6) +# define MON_8 (MON_1 + 7) +# define MON_9 (MON_1 + 8) +# define MON_10 (MON_1 + 9) +# define MON_11 (MON_1 + 10) +# define MON_12 (MON_1 + 11) +# define ABMON_1 10035 +# define ABMON_2 (ABMON_1 + 1) +# define ABMON_3 (ABMON_1 + 2) +# define ABMON_4 (ABMON_1 + 3) +# define ABMON_5 (ABMON_1 + 4) +# define ABMON_6 (ABMON_1 + 5) +# define ABMON_7 (ABMON_1 + 6) +# define ABMON_8 (ABMON_1 + 7) +# define ABMON_9 (ABMON_1 + 8) +# define ABMON_10 (ABMON_1 + 9) +# define ABMON_11 (ABMON_1 + 10) +# define ABMON_12 (ABMON_1 + 11) +# define ERA 10047 +# define ERA_D_FMT 10048 +# define ERA_D_T_FMT 10049 +# define ERA_T_FMT 10050 +# define ALT_DIGITS 10051 +/* nl_langinfo items of the LC_MONETARY category */ +# define CRNCYSTR 10052 +/* nl_langinfo items of the LC_MESSAGES category */ +# define YESEXPR 10053 +# define NOEXPR 10054 + +#else + +/* A platform that has . */ + +# if !@HAVE_LANGINFO_CODESET@ +# define CODESET 10000 +# define GNULIB_defined_CODESET 1 +# endif + +# if !@HAVE_LANGINFO_ERA@ +# define ERA 10047 +# define ERA_D_FMT 10048 +# define ERA_D_T_FMT 10049 +# define ERA_T_FMT 10050 +# define ALT_DIGITS 10051 +# define GNULIB_defined_ERA 1 +# endif + +#endif + +/* The definition of GL_LINK_WARNING is copied here. */ + +/* Declare overridden functions. */ + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Return a piece of locale dependent information. + Note: The difference between nl_langinfo (CODESET) and locale_charset () + is that the latter normalizes the encoding names to GNU conventions. */ + +#if @GNULIB_NL_LANGINFO@ +# if @REPLACE_NL_LANGINFO@ +# undef nl_langinfo +# define nl_langinfo rpl_nl_langinfo +# endif +# if !@HAVE_NL_LANGINFO@ || @REPLACE_NL_LANGINFO@ +extern char *nl_langinfo (nl_item item); +# endif +#elif defined GNULIB_POSIXCHECK +# undef nl_langinfo +# define nl_langinfo(i) \ + (GL_LINK_WARNING ("nl_langinfo is not portable - " \ + "use gnulib module nl_langinfo for portability"), \ + nl_langinfo (i)) +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif /* _GL_LANGINFO_H */ +#endif /* _GL_LANGINFO_H */ diff --git a/src/bin/coreutils/lib/lchown.c b/src/bin/coreutils/lib/lchown.c index 8cf10dd0c2..0d2ecb05e3 100644 --- a/src/bin/coreutils/lib/lchown.c +++ b/src/bin/coreutils/lib/lchown.c @@ -1,7 +1,7 @@ /* Provide a stub lchown function for systems that lack it. - Copyright (C) 1998, 1999, 2002, 2004, 2006, 2007, 2009 Free - Software Foundation, Inc. + Copyright (C) 1998-1999, 2002, 2004, 2006-2007, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,16 +20,21 @@ #include -/* If the system chown does not follow symlinks, we don't want it - replaced by gnulib's chown, which does follow symlinks. */ -#if CHOWN_MODIFIES_SYMLINK -# define REPLACE_CHOWN 0 -#endif #include #include +#include +#include #include +#if !HAVE_LCHOWN + +/* If the system chown does not follow symlinks, we don't want it + replaced by gnulib's chown, which does follow symlinks. */ +# if CHOWN_MODIFIES_SYMLINK +# undef chown +# endif + /* Work just like chown, except when FILE is a symbolic link. In that case, set errno to EOPNOTSUPP and return -1. But if autoconf tests determined that chown modifies @@ -38,8 +43,8 @@ int lchown (const char *file, uid_t uid, gid_t gid) { -#if HAVE_CHOWN -# if ! CHOWN_MODIFIES_SYMLINK +# if HAVE_CHOWN +# if ! CHOWN_MODIFIES_SYMLINK struct stat stats; if (lstat (file, &stats) == 0 && S_ISLNK (stats.st_mode)) @@ -47,12 +52,65 @@ lchown (const char *file, uid_t uid, gid_t gid) errno = EOPNOTSUPP; return -1; } -# endif +# endif return chown (file, uid, gid); -#else /* !HAVE_CHOWN */ +# else /* !HAVE_CHOWN */ errno = ENOSYS; return -1; -#endif +# endif } + +#else /* HAVE_LCHOWN */ + +# undef lchown + +/* Work around trailing slash bugs in lchown. */ +int +rpl_lchown (const char *file, uid_t uid, gid_t gid) +{ + struct stat st; + bool stat_valid = false; + int result; + +# if CHOWN_CHANGE_TIME_BUG + if (gid != (gid_t) -1 || uid != (uid_t) -1) + { + if (lstat (file, &st)) + return -1; + stat_valid = true; + if (!S_ISLNK (st.st_mode)) + return chown (file, uid, gid); + } +# endif + +# if CHOWN_TRAILING_SLASH_BUG + if (!stat_valid) + { + size_t len = strlen (file); + if (len && file[len - 1] == '/') + return chown (file, uid, gid); + } +# endif + + result = lchown (file, uid, gid); + +# if CHOWN_CHANGE_TIME_BUG && HAVE_LCHMOD + if (result == 0 && stat_valid + && (uid == st.st_uid || uid == (uid_t) -1) + && (gid == st.st_gid || gid == (gid_t) -1)) + { + /* No change in ownership, but at least one argument was not -1, + so we are required to update ctime. Since lchown succeeded, + we assume that lchmod will do likewise. But if the system + lacks lchmod and lutimes, we are out of luck. Oh well. */ + result = lchmod (file, st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO + | S_ISUID | S_ISGID | S_ISVTX)); + } +# endif + + return result; +} + +#endif /* HAVE_LCHOWN */ diff --git a/src/bin/coreutils/lib/linebuffer.c b/src/bin/coreutils/lib/linebuffer.c index 90e4cca869..74b7c89435 100644 --- a/src/bin/coreutils/lib/linebuffer.c +++ b/src/bin/coreutils/lib/linebuffer.c @@ -1,6 +1,6 @@ /* linebuffer.c -- read arbitrarily long lines - Copyright (C) 1986, 1991, 1998, 1999, 2001, 2003, 2004, 2006, 2007 + Copyright (C) 1986, 1991, 1998-1999, 2001, 2003-2004, 2006-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -57,7 +57,7 @@ readlinebuffer (struct linebuffer *linebuffer, FILE *stream) Otherwise, return LINEBUFFER. */ struct linebuffer * readlinebuffer_delim (struct linebuffer *linebuffer, FILE *stream, - char delimiter) + char delimiter) { int c; char *buffer = linebuffer->buffer; @@ -71,21 +71,21 @@ readlinebuffer_delim (struct linebuffer *linebuffer, FILE *stream, { c = getc (stream); if (c == EOF) - { - if (p == buffer || ferror (stream)) - return NULL; - if (p[-1] == delimiter) - break; - c = delimiter; - } + { + if (p == buffer || ferror (stream)) + return NULL; + if (p[-1] == delimiter) + break; + c = delimiter; + } if (p == end) - { - size_t oldsize = linebuffer->size; - buffer = x2realloc (buffer, &linebuffer->size); - p = buffer + oldsize; - linebuffer->buffer = buffer; - end = buffer + linebuffer->size; - } + { + size_t oldsize = linebuffer->size; + buffer = x2realloc (buffer, &linebuffer->size); + p = buffer + oldsize; + linebuffer->buffer = buffer; + end = buffer + linebuffer->size; + } *p++ = c; } while (c != delimiter); diff --git a/src/bin/coreutils/lib/linebuffer.h b/src/bin/coreutils/lib/linebuffer.h index db41103045..4e12147345 100644 --- a/src/bin/coreutils/lib/linebuffer.h +++ b/src/bin/coreutils/lib/linebuffer.h @@ -1,7 +1,7 @@ /* linebuffer.h -- declarations for reading arbitrarily long lines - Copyright (C) 1986, 1991, 1998, 1999, 2002, 2003, 2007 Free Software - Foundation, Inc. + Copyright (C) 1986, 1991, 1998-1999, 2002-2003, 2007, 2009-2010 Free + Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,8 +25,8 @@ struct linebuffer { - size_t size; /* Allocated. */ - size_t length; /* Used. */ + size_t size; /* Allocated. */ + size_t length; /* Used. */ char *buffer; }; @@ -39,7 +39,7 @@ void initbuffer (struct linebuffer *linebuffer); the last character in the file. Do not NUL-terminate. Return LINEBUFFER, except at end of file return NULL. */ struct linebuffer *readlinebuffer_delim (struct linebuffer *linebuffer, - FILE *stream, char delimiter); + FILE *stream, char delimiter); /* Read an arbitrarily long line of text from STREAM into LINEBUFFER. Keep the newline; append a newline if it's the last line of a file diff --git a/src/bin/coreutils/lib/link-warning.h b/src/bin/coreutils/lib/link-warning.h new file mode 100644 index 0000000000..26027ef654 --- /dev/null +++ b/src/bin/coreutils/lib/link-warning.h @@ -0,0 +1,28 @@ +/* GL_LINK_WARNING("literal string") arranges to emit the literal string as + a linker warning on most glibc systems. + We use a linker warning rather than a preprocessor warning, because + #warning cannot be used inside macros. */ +#ifndef GL_LINK_WARNING + /* This works on platforms with GNU ld and ELF object format. + Testing __GLIBC__ is sufficient for asserting that GNU ld is in use. + Testing __ELF__ guarantees the ELF object format. + Testing __GNUC__ is necessary for the compound expression syntax. */ +# if defined __GLIBC__ && defined __ELF__ && defined __GNUC__ +# define GL_LINK_WARNING(message) \ + GL_LINK_WARNING1 (__FILE__, __LINE__, message) +# define GL_LINK_WARNING1(file, line, message) \ + GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */ +# define GL_LINK_WARNING2(file, line, message) \ + GL_LINK_WARNING3 (file ":" #line ": warning: " message) +# define GL_LINK_WARNING3(message) \ + ({ static const char warning[sizeof (message)] \ + __attribute__ ((__unused__, \ + __section__ (".gnu.warning"), \ + __aligned__ (1))) \ + = message "\n"; \ + (void)0; \ + }) +# else +# define GL_LINK_WARNING(message) ((void) 0) +# endif +#endif diff --git a/src/bin/coreutils/lib/link.c b/src/bin/coreutils/lib/link.c index 0b4fb0cd93..3d17709dd4 100644 --- a/src/bin/coreutils/lib/link.c +++ b/src/bin/coreutils/lib/link.c @@ -3,7 +3,7 @@ #line 1 /* Emulate link on platforms that lack it, namely native Windows platforms. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009, 2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -36,19 +36,19 @@ /* CreateHardLink was introduced only in Windows 2000. */ typedef BOOL (WINAPI * CreateHardLinkFuncType) (LPCTSTR lpFileName, - LPCTSTR lpExistingFileName, - LPSECURITY_ATTRIBUTES lpSecurityAttributes); + LPCTSTR lpExistingFileName, + LPSECURITY_ATTRIBUTES lpSecurityAttributes); static CreateHardLinkFuncType CreateHardLinkFunc = NULL; static BOOL initialized = FALSE; static void initialize (void) { - HMODULE kernel32 = LoadLibrary ("kernel32.dll"); + HMODULE kernel32 = GetModuleHandle ("kernel32.dll"); if (kernel32 != NULL) { CreateHardLinkFunc = - (CreateHardLinkFuncType) GetProcAddress (kernel32, "CreateHardLinkA"); + (CreateHardLinkFuncType) GetProcAddress (kernel32, "CreateHardLinkA"); } initialized = TRUE; } @@ -106,39 +106,39 @@ link (const char *file1, const char *file2) * system. */ DWORD err = GetLastError (); switch (err) - { - case ERROR_ACCESS_DENIED: - errno = EACCES; - break; + { + case ERROR_ACCESS_DENIED: + errno = EACCES; + break; - case ERROR_INVALID_FUNCTION: /* fs does not support hard links */ - errno = EPERM; - break; + case ERROR_INVALID_FUNCTION: /* fs does not support hard links */ + errno = EPERM; + break; - case ERROR_NOT_SAME_DEVICE: - errno = EXDEV; - break; + case ERROR_NOT_SAME_DEVICE: + errno = EXDEV; + break; - case ERROR_PATH_NOT_FOUND: - case ERROR_FILE_NOT_FOUND: - errno = ENOENT; - break; + case ERROR_PATH_NOT_FOUND: + case ERROR_FILE_NOT_FOUND: + errno = ENOENT; + break; - case ERROR_INVALID_PARAMETER: - errno = ENAMETOOLONG; - break; + case ERROR_INVALID_PARAMETER: + errno = ENAMETOOLONG; + break; - case ERROR_TOO_MANY_LINKS: - errno = EMLINK; - break; + case ERROR_TOO_MANY_LINKS: + errno = EMLINK; + break; - case ERROR_ALREADY_EXISTS: - errno = EEXIST; - break; + case ERROR_ALREADY_EXISTS: + errno = EEXIST; + break; - default: - errno = EIO; - } + default: + errno = EIO; + } return -1; } @@ -165,11 +165,13 @@ rpl_link (char const *file1, char const *file2) || (len2 && file2[len2 - 1] == '/')) { /* Let link() decide whether hard-linking directories is legal. - If stat() fails, link() will probably fail for the same - reason; so we only have to worry about successful stat() and - non-directory. */ + If stat() fails, then link() should fail for the same reason + (although on Solaris 9, link("file/","oops") mistakenly + succeeds); if stat() succeeds, require a directory. */ struct stat st; - if (stat (file1, &st) == 0 && !S_ISDIR (st.st_mode)) + if (stat (file1, &st)) + return -1; + if (!S_ISDIR (st.st_mode)) { errno = ENOTDIR; return -1; diff --git a/src/bin/coreutils/lib/linkat.c b/src/bin/coreutils/lib/linkat.c new file mode 100644 index 0000000000..30a61e938b --- /dev/null +++ b/src/bin/coreutils/lib/linkat.c @@ -0,0 +1,290 @@ +/* Create a hard link relative to open directories. + Copyright (C) 2009-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* written by Eric Blake */ + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "areadlink.h" +#include "dirname.h" +#include "filenamecat.h" +#include "openat-priv.h" + +#if HAVE_SYS_PARAM_H +# include +#endif +#ifndef MAXSYMLINKS +# ifdef SYMLOOP_MAX +# define MAXSYMLINKS SYMLOOP_MAX +# else +# define MAXSYMLINKS 20 +# endif +#endif + +#if !HAVE_LINKAT + +/* Create a link. If FILE1 is a symlink, either create a hardlink to + that symlink, or fake it by creating an identical symlink. */ +# if LINK_FOLLOWS_SYMLINKS == 0 +# define link_immediate link +# else +static int +link_immediate (char const *file1, char const *file2) +{ + char *target = areadlink (file1); + if (target) + { + /* A symlink cannot be modified in-place. Therefore, creating + an identical symlink behaves like a hard link to a symlink, + except for incorrect st_ino and st_nlink. However, we must + be careful of EXDEV. */ + struct stat st1; + struct stat st2; + char *dir = mdir_name (file2); + if (!dir) + { + free (target); + errno = ENOMEM; + return -1; + } + if (lstat (file1, &st1) == 0 && stat (dir, &st2) == 0) + { + if (st1.st_dev == st2.st_dev) + { + int result = symlink (target, file2); + int saved_errno = errno; + free (target); + free (dir); + errno = saved_errno; + return result; + } + free (target); + free (dir); + errno = EXDEV; + return -1; + } + free (target); + free (dir); + } + if (errno == ENOMEM) + return -1; + return link (file1, file2); +} +# endif /* LINK_FOLLOWS_SYMLINKS == 0 */ + +/* Create a link. If FILE1 is a symlink, create a hardlink to the + canonicalized file. */ +# if 0 < LINK_FOLLOWS_SYMLINKS +# define link_follow link +# else +static int +link_follow (char const *file1, char const *file2) +{ + char *name = (char *) file1; + char *target; + int result; + int i = MAXSYMLINKS; + + /* Using realpath or canonicalize_file_name is too heavy-handed: we + don't need an absolute name, and we don't need to resolve + intermediate symlinks, just the basename of each iteration. */ + while (i-- && (target = areadlink (name))) + { + if (IS_ABSOLUTE_FILE_NAME (target)) + { + if (name != file1) + free (name); + name = target; + } + else + { + char *dir = mdir_name (name); + if (name != file1) + free (name); + if (!dir) + { + free (target); + errno = ENOMEM; + return -1; + } + name = mfile_name_concat (dir, target, NULL); + free (dir); + free (target); + if (!name) + { + errno = ENOMEM; + return -1; + } + } + } + if (i < 0) + { + target = NULL; + errno = ELOOP; + } + if (!target && errno != EINVAL) + { + if (name != file1) + { + int saved_errno = errno; + free (name); + errno = saved_errno; + } + return -1; + } + result = link (name, file2); + if (name != file1) + { + int saved_errno = errno; + free (name); + errno = saved_errno; + } + return result; +} +# endif /* 0 < LINK_FOLLOWS_SYMLINKS */ + +/* Create a link to FILE1, in the directory open on descriptor FD1, to FILE2, + in the directory open on descriptor FD2. If FILE1 is a symlink, FLAG + controls whether to dereference FILE1 first. If possible, do it without + changing the working directory. Otherwise, resort to using + save_cwd/fchdir, then rename/restore_cwd. If either the save_cwd or + the restore_cwd fails, then give a diagnostic and exit nonzero. */ + +int +linkat (int fd1, char const *file1, int fd2, char const *file2, int flag) +{ + if (flag & ~AT_SYMLINK_FOLLOW) + { + errno = EINVAL; + return -1; + } + return at_func2 (fd1, file1, fd2, file2, + flag ? link_follow : link_immediate); +} + +#else /* HAVE_LINKAT */ + +# undef linkat + +/* Create a link. If FILE1 is a symlink, create a hardlink to the + canonicalized file. */ + +static int +linkat_follow (int fd1, char const *file1, int fd2, char const *file2) +{ + char *name = (char *) file1; + char *target; + int result; + int i = MAXSYMLINKS; + + /* There is no realpathat. */ + while (i-- && (target = areadlinkat (fd1, name))) + { + if (IS_ABSOLUTE_FILE_NAME (target)) + { + if (name != file1) + free (name); + name = target; + } + else + { + char *dir = mdir_name (name); + if (name != file1) + free (name); + if (!dir) + { + free (target); + errno = ENOMEM; + return -1; + } + name = mfile_name_concat (dir, target, NULL); + free (dir); + free (target); + if (!name) + { + errno = ENOMEM; + return -1; + } + } + } + if (i < 0) + { + target = NULL; + errno = ELOOP; + } + if (!target && errno != EINVAL) + { + if (name != file1) + { + int saved_errno = errno; + free (name); + errno = saved_errno; + } + return -1; + } + result = linkat (fd1, name, fd2, file2, 0); + if (name != file1) + { + int saved_errno = errno; + free (name); + errno = saved_errno; + } + return result; +} + + +/* Like linkat, but guarantee that AT_SYMLINK_FOLLOW works even on + older Linux kernels. */ + +int +rpl_linkat (int fd1, char const *file1, int fd2, char const *file2, int flag) +{ + if (!flag) + return linkat (fd1, file1, fd2, file2, flag); + if (flag & ~AT_SYMLINK_FOLLOW) + { + errno = EINVAL; + return -1; + } + + /* Cache the information on whether the system call really works. */ + { + static int have_follow_really; /* 0 = unknown, 1 = yes, -1 = no */ + if (0 <= have_follow_really) + { + int result = linkat (fd1, file1, fd2, file2, flag); + if (!(result == -1 && errno == EINVAL)) + { + have_follow_really = 1; + return result; + } + have_follow_really = -1; + } + } + return linkat_follow (fd1, file1, fd2, file2); +} + +#endif /* HAVE_LINKAT */ diff --git a/src/bin/coreutils/lib/localcharset.c b/src/bin/coreutils/lib/localcharset.c index 2044243cc4..8e1a2c62e6 100644 --- a/src/bin/coreutils/lib/localcharset.c +++ b/src/bin/coreutils/lib/localcharset.c @@ -3,7 +3,7 @@ #line 1 /* Determine a canonical name for the current locale's character encoding. - Copyright (C) 2000-2006, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2000-2006, 2008-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,6 +26,7 @@ /* Specification. */ #include "localcharset.h" +#include #include #include #include @@ -47,6 +48,7 @@ #endif #if !defined WIN32_NATIVE +# include # if HAVE_LANGINFO_CODESET # include # else @@ -78,6 +80,11 @@ # include "configmake.h" #endif +/* Define O_NOFOLLOW to 0 on platforms where it does not exist. */ +#ifndef O_NOFOLLOW +# define O_NOFOLLOW 0 +#endif + #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ /* Win32, Cygwin, OS/2, DOS */ # define ISSLASH(C) ((C) == '/' || (C) == '\\') @@ -120,192 +127,219 @@ get_charset_aliases (void) if (cp == NULL) { #if !(defined DARWIN7 || defined VMS || defined WIN32_NATIVE || defined __CYGWIN__ || defined __BEOS__ || defined __HAIKU__) - FILE *fp; const char *dir; const char *base = "charset.alias"; char *file_name; /* Make it possible to override the charset.alias location. This is - necessary for running the testsuite before "make install". */ + necessary for running the testsuite before "make install". */ dir = getenv ("CHARSETALIASDIR"); if (dir == NULL || dir[0] == '\0') - dir = relocate (LIBDIR); + dir = relocate (LIBDIR); /* Concatenate dir and base into freshly allocated file_name. */ { - size_t dir_len = strlen (dir); - size_t base_len = strlen (base); - int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1])); - file_name = (char *) malloc (dir_len + add_slash + base_len + 1); - if (file_name != NULL) - { - memcpy (file_name, dir, dir_len); - if (add_slash) - file_name[dir_len] = DIRECTORY_SEPARATOR; - memcpy (file_name + dir_len + add_slash, base, base_len + 1); - } + size_t dir_len = strlen (dir); + size_t base_len = strlen (base); + int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1])); + file_name = (char *) malloc (dir_len + add_slash + base_len + 1); + if (file_name != NULL) + { + memcpy (file_name, dir, dir_len); + if (add_slash) + file_name[dir_len] = DIRECTORY_SEPARATOR; + memcpy (file_name + dir_len + add_slash, base, base_len + 1); + } } - if (file_name == NULL || (fp = fopen (file_name, "r")) == NULL) - /* Out of memory or file not found, treat it as empty. */ - cp = ""; + if (file_name == NULL) + /* Out of memory. Treat the file as empty. */ + cp = ""; else - { - /* Parse the file's contents. */ - char *res_ptr = NULL; - size_t res_size = 0; + { + int fd; - for (;;) - { - int c; - char buf1[50+1]; - char buf2[50+1]; - size_t l1, l2; - char *old_res_ptr; + /* Open the file. Reject symbolic links on platforms that support + O_NOFOLLOW. This is a security feature. Without it, an attacker + could retrieve parts of the contents (namely, the tail of the + first line that starts with "* ") of an arbitrary file by placing + a symbolic link to that file under the name "charset.alias" in + some writable directory and defining the environment variable + CHARSETALIASDIR to point to that directory. */ + fd = open (file_name, + O_RDONLY | (HAVE_WORKING_O_NOFOLLOW ? O_NOFOLLOW : 0)); + if (fd < 0) + /* File not found. Treat it as empty. */ + cp = ""; + else + { + FILE *fp; - c = getc (fp); - if (c == EOF) - break; - if (c == '\n' || c == ' ' || c == '\t') - continue; - if (c == '#') - { - /* Skip comment, to end of line. */ - do - c = getc (fp); - while (!(c == EOF || c == '\n')); - if (c == EOF) - break; - continue; - } - ungetc (c, fp); - if (fscanf (fp, "%50s %50s", buf1, buf2) < 2) - break; - l1 = strlen (buf1); - l2 = strlen (buf2); - old_res_ptr = res_ptr; - if (res_size == 0) - { - res_size = l1 + 1 + l2 + 1; - res_ptr = (char *) malloc (res_size + 1); - } - else - { - res_size += l1 + 1 + l2 + 1; - res_ptr = (char *) realloc (res_ptr, res_size + 1); - } - if (res_ptr == NULL) - { - /* Out of memory. */ - res_size = 0; - if (old_res_ptr != NULL) - free (old_res_ptr); - break; - } - strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1); - strcpy (res_ptr + res_size - (l2 + 1), buf2); - } - fclose (fp); - if (res_size == 0) - cp = ""; - else - { - *(res_ptr + res_size) = '\0'; - cp = res_ptr; - } - } + fp = fdopen (fd, "r"); + if (fp == NULL) + { + /* Out of memory. Treat the file as empty. */ + close (fd); + cp = ""; + } + else + { + /* Parse the file's contents. */ + char *res_ptr = NULL; + size_t res_size = 0; - if (file_name != NULL) - free (file_name); + for (;;) + { + int c; + char buf1[50+1]; + char buf2[50+1]; + size_t l1, l2; + char *old_res_ptr; + + c = getc (fp); + if (c == EOF) + break; + if (c == '\n' || c == ' ' || c == '\t') + continue; + if (c == '#') + { + /* Skip comment, to end of line. */ + do + c = getc (fp); + while (!(c == EOF || c == '\n')); + if (c == EOF) + break; + continue; + } + ungetc (c, fp); + if (fscanf (fp, "%50s %50s", buf1, buf2) < 2) + break; + l1 = strlen (buf1); + l2 = strlen (buf2); + old_res_ptr = res_ptr; + if (res_size == 0) + { + res_size = l1 + 1 + l2 + 1; + res_ptr = (char *) malloc (res_size + 1); + } + else + { + res_size += l1 + 1 + l2 + 1; + res_ptr = (char *) realloc (res_ptr, res_size + 1); + } + if (res_ptr == NULL) + { + /* Out of memory. */ + res_size = 0; + if (old_res_ptr != NULL) + free (old_res_ptr); + break; + } + strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1); + strcpy (res_ptr + res_size - (l2 + 1), buf2); + } + fclose (fp); + if (res_size == 0) + cp = ""; + else + { + *(res_ptr + res_size) = '\0'; + cp = res_ptr; + } + } + } + + free (file_name); + } #else # if defined DARWIN7 /* To avoid the trouble of installing a file that is shared by many - GNU packages -- many packaging systems have problems with this --, - simply inline the aliases here. */ + GNU packages -- many packaging systems have problems with this --, + simply inline the aliases here. */ cp = "ISO8859-1" "\0" "ISO-8859-1" "\0" - "ISO8859-2" "\0" "ISO-8859-2" "\0" - "ISO8859-4" "\0" "ISO-8859-4" "\0" - "ISO8859-5" "\0" "ISO-8859-5" "\0" - "ISO8859-7" "\0" "ISO-8859-7" "\0" - "ISO8859-9" "\0" "ISO-8859-9" "\0" - "ISO8859-13" "\0" "ISO-8859-13" "\0" - "ISO8859-15" "\0" "ISO-8859-15" "\0" - "KOI8-R" "\0" "KOI8-R" "\0" - "KOI8-U" "\0" "KOI8-U" "\0" - "CP866" "\0" "CP866" "\0" - "CP949" "\0" "CP949" "\0" - "CP1131" "\0" "CP1131" "\0" - "CP1251" "\0" "CP1251" "\0" - "eucCN" "\0" "GB2312" "\0" - "GB2312" "\0" "GB2312" "\0" - "eucJP" "\0" "EUC-JP" "\0" - "eucKR" "\0" "EUC-KR" "\0" - "Big5" "\0" "BIG5" "\0" - "Big5HKSCS" "\0" "BIG5-HKSCS" "\0" - "GBK" "\0" "GBK" "\0" - "GB18030" "\0" "GB18030" "\0" - "SJIS" "\0" "SHIFT_JIS" "\0" - "ARMSCII-8" "\0" "ARMSCII-8" "\0" - "PT154" "\0" "PT154" "\0" - /*"ISCII-DEV" "\0" "?" "\0"*/ - "*" "\0" "UTF-8" "\0"; + "ISO8859-2" "\0" "ISO-8859-2" "\0" + "ISO8859-4" "\0" "ISO-8859-4" "\0" + "ISO8859-5" "\0" "ISO-8859-5" "\0" + "ISO8859-7" "\0" "ISO-8859-7" "\0" + "ISO8859-9" "\0" "ISO-8859-9" "\0" + "ISO8859-13" "\0" "ISO-8859-13" "\0" + "ISO8859-15" "\0" "ISO-8859-15" "\0" + "KOI8-R" "\0" "KOI8-R" "\0" + "KOI8-U" "\0" "KOI8-U" "\0" + "CP866" "\0" "CP866" "\0" + "CP949" "\0" "CP949" "\0" + "CP1131" "\0" "CP1131" "\0" + "CP1251" "\0" "CP1251" "\0" + "eucCN" "\0" "GB2312" "\0" + "GB2312" "\0" "GB2312" "\0" + "eucJP" "\0" "EUC-JP" "\0" + "eucKR" "\0" "EUC-KR" "\0" + "Big5" "\0" "BIG5" "\0" + "Big5HKSCS" "\0" "BIG5-HKSCS" "\0" + "GBK" "\0" "GBK" "\0" + "GB18030" "\0" "GB18030" "\0" + "SJIS" "\0" "SHIFT_JIS" "\0" + "ARMSCII-8" "\0" "ARMSCII-8" "\0" + "PT154" "\0" "PT154" "\0" + /*"ISCII-DEV" "\0" "?" "\0"*/ + "*" "\0" "UTF-8" "\0"; # endif # if defined VMS /* To avoid the troubles of an extra file charset.alias_vms in the - sources of many GNU packages, simply inline the aliases here. */ + sources of many GNU packages, simply inline the aliases here. */ /* The list of encodings is taken from the OpenVMS 7.3-1 documentation - "Compaq C Run-Time Library Reference Manual for OpenVMS systems" - section 10.7 "Handling Different Character Sets". */ + "Compaq C Run-Time Library Reference Manual for OpenVMS systems" + section 10.7 "Handling Different Character Sets". */ cp = "ISO8859-1" "\0" "ISO-8859-1" "\0" - "ISO8859-2" "\0" "ISO-8859-2" "\0" - "ISO8859-5" "\0" "ISO-8859-5" "\0" - "ISO8859-7" "\0" "ISO-8859-7" "\0" - "ISO8859-8" "\0" "ISO-8859-8" "\0" - "ISO8859-9" "\0" "ISO-8859-9" "\0" - /* Japanese */ - "eucJP" "\0" "EUC-JP" "\0" - "SJIS" "\0" "SHIFT_JIS" "\0" - "DECKANJI" "\0" "DEC-KANJI" "\0" - "SDECKANJI" "\0" "EUC-JP" "\0" - /* Chinese */ - "eucTW" "\0" "EUC-TW" "\0" - "DECHANYU" "\0" "DEC-HANYU" "\0" - "DECHANZI" "\0" "GB2312" "\0" - /* Korean */ - "DECKOREAN" "\0" "EUC-KR" "\0"; + "ISO8859-2" "\0" "ISO-8859-2" "\0" + "ISO8859-5" "\0" "ISO-8859-5" "\0" + "ISO8859-7" "\0" "ISO-8859-7" "\0" + "ISO8859-8" "\0" "ISO-8859-8" "\0" + "ISO8859-9" "\0" "ISO-8859-9" "\0" + /* Japanese */ + "eucJP" "\0" "EUC-JP" "\0" + "SJIS" "\0" "SHIFT_JIS" "\0" + "DECKANJI" "\0" "DEC-KANJI" "\0" + "SDECKANJI" "\0" "EUC-JP" "\0" + /* Chinese */ + "eucTW" "\0" "EUC-TW" "\0" + "DECHANYU" "\0" "DEC-HANYU" "\0" + "DECHANZI" "\0" "GB2312" "\0" + /* Korean */ + "DECKOREAN" "\0" "EUC-KR" "\0"; # endif # if defined WIN32_NATIVE || defined __CYGWIN__ /* To avoid the troubles of installing a separate file in the same - directory as the DLL and of retrieving the DLL's directory at - runtime, simply inline the aliases here. */ + directory as the DLL and of retrieving the DLL's directory at + runtime, simply inline the aliases here. */ cp = "CP936" "\0" "GBK" "\0" - "CP1361" "\0" "JOHAB" "\0" - "CP20127" "\0" "ASCII" "\0" - "CP20866" "\0" "KOI8-R" "\0" - "CP20936" "\0" "GB2312" "\0" - "CP21866" "\0" "KOI8-RU" "\0" - "CP28591" "\0" "ISO-8859-1" "\0" - "CP28592" "\0" "ISO-8859-2" "\0" - "CP28593" "\0" "ISO-8859-3" "\0" - "CP28594" "\0" "ISO-8859-4" "\0" - "CP28595" "\0" "ISO-8859-5" "\0" - "CP28596" "\0" "ISO-8859-6" "\0" - "CP28597" "\0" "ISO-8859-7" "\0" - "CP28598" "\0" "ISO-8859-8" "\0" - "CP28599" "\0" "ISO-8859-9" "\0" - "CP28605" "\0" "ISO-8859-15" "\0" - "CP38598" "\0" "ISO-8859-8" "\0" - "CP51932" "\0" "EUC-JP" "\0" - "CP51936" "\0" "GB2312" "\0" - "CP51949" "\0" "EUC-KR" "\0" - "CP51950" "\0" "EUC-TW" "\0" - "CP54936" "\0" "GB18030" "\0" - "CP65001" "\0" "UTF-8" "\0"; + "CP1361" "\0" "JOHAB" "\0" + "CP20127" "\0" "ASCII" "\0" + "CP20866" "\0" "KOI8-R" "\0" + "CP20936" "\0" "GB2312" "\0" + "CP21866" "\0" "KOI8-RU" "\0" + "CP28591" "\0" "ISO-8859-1" "\0" + "CP28592" "\0" "ISO-8859-2" "\0" + "CP28593" "\0" "ISO-8859-3" "\0" + "CP28594" "\0" "ISO-8859-4" "\0" + "CP28595" "\0" "ISO-8859-5" "\0" + "CP28596" "\0" "ISO-8859-6" "\0" + "CP28597" "\0" "ISO-8859-7" "\0" + "CP28598" "\0" "ISO-8859-8" "\0" + "CP28599" "\0" "ISO-8859-9" "\0" + "CP28605" "\0" "ISO-8859-15" "\0" + "CP38598" "\0" "ISO-8859-8" "\0" + "CP51932" "\0" "EUC-JP" "\0" + "CP51936" "\0" "GB2312" "\0" + "CP51949" "\0" "EUC-KR" "\0" + "CP51950" "\0" "EUC-TW" "\0" + "CP54936" "\0" "GB18030" "\0" + "CP65001" "\0" "UTF-8" "\0"; # endif # if defined __BEOS__ || defined __HAIKU__ @@ -346,7 +380,7 @@ locale_charset (void) codeset = nl_langinfo (CODESET); # ifdef __CYGWIN__ - /* Cygwin 2006 does not have locales. nl_langinfo (CODESET) always + /* Cygwin 1.5.x does not have locales. nl_langinfo (CODESET) always returns "US-ASCII". As long as this is not fixed, return the suffix of the locale name from the environment variables (if present) or the codepage as a number. */ @@ -357,36 +391,46 @@ locale_charset (void) locale = getenv ("LC_ALL"); if (locale == NULL || locale[0] == '\0') - { - locale = getenv ("LC_CTYPE"); - if (locale == NULL || locale[0] == '\0') - locale = getenv ("LANG"); - } + { + locale = getenv ("LC_CTYPE"); + if (locale == NULL || locale[0] == '\0') + locale = getenv ("LANG"); + } if (locale != NULL && locale[0] != '\0') - { - /* If the locale name contains an encoding after the dot, return - it. */ - const char *dot = strchr (locale, '.'); + { + /* If the locale name contains an encoding after the dot, return + it. */ + const char *dot = strchr (locale, '.'); - if (dot != NULL) - { - const char *modifier; + if (dot != NULL) + { + const char *modifier; - dot++; - /* Look for the possible @... trailer and remove it, if any. */ - modifier = strchr (dot, '@'); - if (modifier == NULL) - return dot; - if (modifier - dot < sizeof (buf)) - { - memcpy (buf, dot, modifier - dot); - buf [modifier - dot] = '\0'; - return buf; - } - } - } + dot++; + /* Look for the possible @... trailer and remove it, if any. */ + modifier = strchr (dot, '@'); + if (modifier == NULL) + return dot; + if (modifier - dot < sizeof (buf)) + { + memcpy (buf, dot, modifier - dot); + buf [modifier - dot] = '\0'; + return buf; + } + } + } - /* Woe32 has a function returning the locale's codepage as a number. */ + /* Woe32 has a function returning the locale's codepage as a number: + GetACP(). This encoding is used by Cygwin, unless the user has set + the environment variable CYGWIN=codepage:oem (which very few people + do). + Output directed to console windows needs to be converted (to + GetOEMCP() if the console is using a raster font, or to + GetConsoleOutputCP() if it is using a TrueType font). Cygwin does + this conversion transparently (see winsup/cygwin/fhandler_console.cc), + converting to GetConsoleOutputCP(). This leads to correct results, + except when SetConsoleOutputCP has been called and a raster font is + in use. */ sprintf (buf, "CP%u", GetACP ()); codeset = buf; } @@ -408,11 +452,11 @@ locale_charset (void) { locale = getenv ("LC_ALL"); if (locale == NULL || locale[0] == '\0') - { - locale = getenv ("LC_CTYPE"); - if (locale == NULL || locale[0] == '\0') - locale = getenv ("LANG"); - } + { + locale = getenv ("LC_CTYPE"); + if (locale == NULL || locale[0] == '\0') + locale = getenv ("LANG"); + } } /* On some old systems, one used to set locale = "iso8859_1". On others, @@ -426,7 +470,13 @@ locale_charset (void) static char buf[2 + 10 + 1]; - /* Woe32 has a function returning the locale's codepage as a number. */ + /* Woe32 has a function returning the locale's codepage as a number: + GetACP(). + When the output goes to a console window, it needs to be provided in + GetOEMCP() encoding if the console is using a raster font, or in + GetConsoleOutputCP() encoding if it is using a TrueType font. + But in GUI programs and for output sent to files and pipes, GetACP() + encoding is the best bet. */ sprintf (buf, "CP%u", GetACP ()); codeset = buf; @@ -444,7 +494,7 @@ locale_charset (void) { locale = getenv ("LC_CTYPE"); if (locale == NULL || locale[0] == '\0') - locale = getenv ("LANG"); + locale = getenv ("LANG"); } if (locale != NULL && locale[0] != '\0') { @@ -452,21 +502,21 @@ locale_charset (void) const char *dot = strchr (locale, '.'); if (dot != NULL) - { - const char *modifier; + { + const char *modifier; - dot++; - /* Look for the possible @... trailer and remove it, if any. */ - modifier = strchr (dot, '@'); - if (modifier == NULL) - return dot; - if (modifier - dot < sizeof (buf)) - { - memcpy (buf, dot, modifier - dot); - buf [modifier - dot] = '\0'; - return buf; - } - } + dot++; + /* Look for the possible @... trailer and remove it, if any. */ + modifier = strchr (dot, '@'); + if (modifier == NULL) + return dot; + if (modifier - dot < sizeof (buf)) + { + memcpy (buf, dot, modifier - dot); + buf [modifier - dot] = '\0'; + return buf; + } + } /* Resolve through the charset.alias file. */ codeset = locale; @@ -475,12 +525,12 @@ locale_charset (void) { /* OS/2 has a function returning the locale's codepage as a number. */ if (DosQueryCp (sizeof (cp), cp, &cplen)) - codeset = ""; + codeset = ""; else - { - sprintf (buf, "CP%u", cp[0]); - codeset = buf; - } + { + sprintf (buf, "CP%u", cp[0]); + codeset = buf; + } } #endif @@ -494,10 +544,10 @@ locale_charset (void) *aliases != '\0'; aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1) if (strcmp (codeset, aliases) == 0 - || (aliases[0] == '*' && aliases[1] == '\0')) + || (aliases[0] == '*' && aliases[1] == '\0')) { - codeset = aliases + strlen (aliases) + 1; - break; + codeset = aliases + strlen (aliases) + 1; + break; } /* Don't return an empty string. GNU libc and GNU libiconv interpret diff --git a/src/bin/coreutils/lib/localcharset.h b/src/bin/coreutils/lib/localcharset.h index 19567efacf..0ff6c176d5 100644 --- a/src/bin/coreutils/lib/localcharset.h +++ b/src/bin/coreutils/lib/localcharset.h @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Determine a canonical name for the current locale's character encoding. - Copyright (C) 2000-2003 Free Software Foundation, Inc. + Copyright (C) 2000-2003, 2009-2010 Free Software Foundation, Inc. This file is part of the GNU CHARSET Library. This program is free software; you can redistribute it and/or modify diff --git a/src/bin/coreutils/lib/locale.h b/src/bin/coreutils/lib/locale.h new file mode 100644 index 0000000000..63fecc11ee --- /dev/null +++ b/src/bin/coreutils/lib/locale.h @@ -0,0 +1,101 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* A POSIX . + Copyright (C) 2007-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef _GL_LOCALE_H + +#if __GNUC__ >= 3 +#pragma GCC system_header +#endif + +/* The include_next requires a split double-inclusion guard. */ +#include_next + +#ifndef _GL_LOCALE_H +#define _GL_LOCALE_H + +/* NetBSD 5.0 mis-defines NULL. */ +#include + +/* MacOS X 10.5 defines the locale_t type in . */ +#if 0 +# include +#endif + +/* The definition of GL_LINK_WARNING is copied here. */ +/* GL_LINK_WARNING("literal string") arranges to emit the literal string as + a linker warning on most glibc systems. + We use a linker warning rather than a preprocessor warning, because + #warning cannot be used inside macros. */ +#ifndef GL_LINK_WARNING + /* This works on platforms with GNU ld and ELF object format. + Testing __GLIBC__ is sufficient for asserting that GNU ld is in use. + Testing __ELF__ guarantees the ELF object format. + Testing __GNUC__ is necessary for the compound expression syntax. */ +# if defined __GLIBC__ && defined __ELF__ && defined __GNUC__ +# define GL_LINK_WARNING(message) \ + GL_LINK_WARNING1 (__FILE__, __LINE__, message) +# define GL_LINK_WARNING1(file, line, message) \ + GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */ +# define GL_LINK_WARNING2(file, line, message) \ + GL_LINK_WARNING3 (file ":" #line ": warning: " message) +# define GL_LINK_WARNING3(message) \ + ({ static const char warning[sizeof (message)] \ + __attribute__ ((__unused__, \ + __section__ (".gnu.warning"), \ + __aligned__ (1))) \ + = message "\n"; \ + (void)0; \ + }) +# else +# define GL_LINK_WARNING(message) ((void) 0) +# endif +#endif + +/* The definition of _GL_ARG_NONNULL is copied here. */ +/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools + that the values passed as arguments n, ..., m must be non-NULL pointers. + n = 1 stands for the first argument, n = 2 for the second argument etc. */ +#ifndef _GL_ARG_NONNULL +# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 +# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) +# else +# define _GL_ARG_NONNULL(params) +# endif +#endif + +/* The LC_MESSAGES locale category is specified in POSIX, but not in ISO C. + On systems that don't define it, use the same value as GNU libintl. */ +#if !defined LC_MESSAGES +# define LC_MESSAGES 1729 +#endif + +#if 0 +# if 0 +# undef duplocale +# define duplocale rpl_duplocale +extern locale_t duplocale (locale_t locale) _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef duplocale +# define duplocale(l) \ + (GL_LINK_WARNING ("duplocale is buggy on some glibc systems - " \ + "use gnulib module duplocale for portability"), \ + duplocale (l)) +#endif + +#endif /* _GL_LOCALE_H */ +#endif /* _GL_LOCALE_H */ diff --git a/src/bin/coreutils/lib/locale.in.h b/src/bin/coreutils/lib/locale.in.h new file mode 100644 index 0000000000..b8031e184c --- /dev/null +++ b/src/bin/coreutils/lib/locale.in.h @@ -0,0 +1,62 @@ +/* A POSIX . + Copyright (C) 2007-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef _GL_LOCALE_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif + +/* The include_next requires a split double-inclusion guard. */ +#@INCLUDE_NEXT@ @NEXT_LOCALE_H@ + +#ifndef _GL_LOCALE_H +#define _GL_LOCALE_H + +/* NetBSD 5.0 mis-defines NULL. */ +#include + +/* MacOS X 10.5 defines the locale_t type in . */ +#if @HAVE_XLOCALE_H@ +# include +#endif + +/* The definition of GL_LINK_WARNING is copied here. */ + +/* The definition of _GL_ARG_NONNULL is copied here. */ + +/* The LC_MESSAGES locale category is specified in POSIX, but not in ISO C. + On systems that don't define it, use the same value as GNU libintl. */ +#if !defined LC_MESSAGES +# define LC_MESSAGES 1729 +#endif + +#if @GNULIB_DUPLOCALE@ +# if @REPLACE_DUPLOCALE@ +# undef duplocale +# define duplocale rpl_duplocale +extern locale_t duplocale (locale_t locale) _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef duplocale +# define duplocale(l) \ + (GL_LINK_WARNING ("duplocale is buggy on some glibc systems - " \ + "use gnulib module duplocale for portability"), \ + duplocale (l)) +#endif + +#endif /* _GL_LOCALE_H */ +#endif /* _GL_LOCALE_H */ diff --git a/src/bin/coreutils/lib/long-options.c b/src/bin/coreutils/lib/long-options.c index 0286bdf98c..d28d69fa63 100644 --- a/src/bin/coreutils/lib/long-options.c +++ b/src/bin/coreutils/lib/long-options.c @@ -1,7 +1,7 @@ /* Utility to accept --help and --version options as unobtrusively as possible. - Copyright (C) 1993, 1994, 1998, 1999, 2000, 2002, 2003, 2004, 2005, - 2006 Free Software Foundation, Inc. + Copyright (C) 1993-1994, 1998-2000, 2002-2006, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -42,12 +42,12 @@ static struct option const long_options[] = void parse_long_options (int argc, - char **argv, - const char *command_name, - const char *package, - const char *version, - void (*usage_func) (int), - /* const char *author1, ...*/ ...) + char **argv, + const char *command_name, + const char *package, + const char *version, + void (*usage_func) (int), + /* const char *author1, ...*/ ...) { int c; int saved_opterr; @@ -61,22 +61,22 @@ parse_long_options (int argc, && (c = getopt_long (argc, argv, "+", long_options, NULL)) != -1) { switch (c) - { - case 'h': - (*usage_func) (EXIT_SUCCESS); + { + case 'h': + (*usage_func) (EXIT_SUCCESS); - case 'v': - { - va_list authors; - va_start (authors, usage_func); - version_etc_va (stdout, command_name, package, version, authors); - exit (0); - } + case 'v': + { + va_list authors; + va_start (authors, usage_func); + version_etc_va (stdout, command_name, package, version, authors); + exit (0); + } - default: - /* Don't process any other long-named options. */ - break; - } + default: + /* Don't process any other long-named options. */ + break; + } } /* Restore previous value. */ diff --git a/src/bin/coreutils/lib/long-options.h b/src/bin/coreutils/lib/long-options.h index 36ecb333c1..3fe24d7b5b 100644 --- a/src/bin/coreutils/lib/long-options.h +++ b/src/bin/coreutils/lib/long-options.h @@ -1,5 +1,6 @@ /* long-options.h -- declaration for --help- and --version-handling function. - Copyright (C) 1993, 1994, 1998, 1999, 2003 Free Software Foundation, Inc. + Copyright (C) 1993-1994, 1998-1999, 2003, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,9 +18,9 @@ /* Written by Jim Meyering. */ void parse_long_options (int _argc, - char **_argv, - const char *_command_name, - const char *_package, - const char *_version, - void (*_usage) (int), - /* const char *author1, ...*/ ...); + char **_argv, + const char *_command_name, + const char *_package, + const char *_version, + void (*_usage) (int), + /* const char *author1, ...*/ ...); diff --git a/src/bin/coreutils/lib/lseek.c b/src/bin/coreutils/lib/lseek.c index a9178400dd..a062bf08ae 100644 --- a/src/bin/coreutils/lib/lseek.c +++ b/src/bin/coreutils/lib/lseek.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* An lseek() function that detects pipes. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/lstat.c b/src/bin/coreutils/lib/lstat.c index 3e07270801..586ab16b2a 100644 --- a/src/bin/coreutils/lib/lstat.c +++ b/src/bin/coreutils/lib/lstat.c @@ -1,6 +1,6 @@ /* Work around a bug of lstat on some systems - Copyright (C) 1997-1999, 2000-2006, 2008 Free Software Foundation, Inc. + Copyright (C) 1997-2006, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,11 +19,18 @@ #include -/* Get the original definition of open. It might be defined as a macro. */ -#define __need_system_sys_stat_h -#include -#include -#undef __need_system_sys_stat_h +#if !HAVE_LSTAT +/* On systems that lack symlinks, our replacement already + defined lstat as stat, so there is nothing further to do other than + avoid an empty file. */ +typedef int dummy; +#else /* HAVE_LSTAT */ + +/* Get the original definition of lstat. It might be defined as a macro. */ +# define __need_system_sys_stat_h +# include +# include +# undef __need_system_sys_stat_h static inline int orig_lstat (const char *filename, struct stat *buf) @@ -32,10 +39,10 @@ orig_lstat (const char *filename, struct stat *buf) } /* Specification. */ -#include +# include -#include -#include +# include +# include /* lstat works differently on Linux and Solaris systems. POSIX (see `pathname resolution' in the glossary) requires that programs like @@ -56,27 +63,29 @@ rpl_lstat (const char *file, struct stat *sbuf) size_t len; int lstat_result = orig_lstat (file, sbuf); - if (lstat_result != 0 || !S_ISLNK (sbuf->st_mode)) + if (lstat_result != 0) return lstat_result; + /* This replacement file can blindly check against '/' rather than + using the ISSLASH macro, because all platforms with '\\' either + lack symlinks (mingw) or have working lstat (cygwin) and thus do + not compile this file. 0 len should have already been filtered + out above, with a failure return of ENOENT. */ len = strlen (file); - if (len == 0 || file[len - 1] != '/') + if (file[len - 1] != '/' || S_ISDIR (sbuf->st_mode)) return 0; - /* FILE refers to a symbolic link and the name ends with a slash. - Call stat() to get info about the link's referent. */ - - /* If stat fails, then we do the same. */ - if (stat (file, sbuf) != 0) - return -1; - - /* If FILE references a directory, return 0. */ - if (S_ISDIR (sbuf->st_mode)) - return 0; - - /* Here, we know stat succeeded and FILE references a non-directory. - But it was specified via a name including a trailing slash. - Fail with errno set to ENOTDIR to indicate the contradiction. */ - errno = ENOTDIR; - return -1; + /* At this point, a trailing slash is only permitted on + symlink-to-dir; but it should have found information on the + directory, not the symlink. Call stat() to get info about the + link's referent. Our replacement stat guarantees valid results, + even if the symlink is not pointing to a directory. */ + if (!S_ISLNK (sbuf->st_mode)) + { + errno = ENOTDIR; + return -1; + } + return stat (file, sbuf); } + +#endif /* HAVE_LSTAT */ diff --git a/src/bin/coreutils/lib/malloc.c b/src/bin/coreutils/lib/malloc.c index 2c10d78fbe..4ea95b9156 100644 --- a/src/bin/coreutils/lib/malloc.c +++ b/src/bin/coreutils/lib/malloc.c @@ -3,7 +3,7 @@ #line 1 /* malloc() function that is glibc compatible. - Copyright (C) 1997, 1998, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 1997-1998, 2006-2007, 2009-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/malloca.c b/src/bin/coreutils/lib/malloca.c index 9a51538e08..e1d2f216ee 100644 --- a/src/bin/coreutils/lib/malloca.c +++ b/src/bin/coreutils/lib/malloca.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Safe automatic memory allocation. - Copyright (C) 2003, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 2003, 2006-2007, 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible , 2003. This program is free software; you can redistribute it and/or modify @@ -77,21 +77,21 @@ mmalloca (size_t n) char *p = (char *) malloc (nplus); if (p != NULL) - { - size_t slot; + { + size_t slot; - p += HEADER_SIZE; + p += HEADER_SIZE; - /* Put a magic number into the indicator word. */ - ((int *) p)[-1] = MAGIC_NUMBER; + /* Put a magic number into the indicator word. */ + ((int *) p)[-1] = MAGIC_NUMBER; - /* Enter p into the hash table. */ - slot = (unsigned long) p % HASH_TABLE_SIZE; - ((struct header *) (p - HEADER_SIZE))->next = mmalloca_results[slot]; - mmalloca_results[slot] = p; + /* Enter p into the hash table. */ + slot = (unsigned long) p % HASH_TABLE_SIZE; + ((struct header *) (p - HEADER_SIZE))->next = mmalloca_results[slot]; + mmalloca_results[slot] = p; - return p; - } + return p; + } } /* Out of memory. */ return NULL; @@ -112,28 +112,28 @@ freea (void *p) if (p != NULL) { /* Attempt to quickly distinguish the mmalloca() result - which has - a magic indicator word - and the alloca() result - which has an - uninitialized indicator word. It is for this test that sa_increment - additional bytes are allocated in the alloca() case. */ + a magic indicator word - and the alloca() result - which has an + uninitialized indicator word. It is for this test that sa_increment + additional bytes are allocated in the alloca() case. */ if (((int *) p)[-1] == MAGIC_NUMBER) - { - /* Looks like a mmalloca() result. To see whether it really is one, - perform a lookup in the hash table. */ - size_t slot = (unsigned long) p % HASH_TABLE_SIZE; - void **chain = &mmalloca_results[slot]; - for (; *chain != NULL;) - { - if (*chain == p) - { - /* Found it. Remove it from the hash table and free it. */ - char *p_begin = (char *) p - HEADER_SIZE; - *chain = ((struct header *) p_begin)->next; - free (p_begin); - return; - } - chain = &((struct header *) ((char *) *chain - HEADER_SIZE))->next; - } - } + { + /* Looks like a mmalloca() result. To see whether it really is one, + perform a lookup in the hash table. */ + size_t slot = (unsigned long) p % HASH_TABLE_SIZE; + void **chain = &mmalloca_results[slot]; + for (; *chain != NULL;) + { + if (*chain == p) + { + /* Found it. Remove it from the hash table and free it. */ + char *p_begin = (char *) p - HEADER_SIZE; + *chain = ((struct header *) p_begin)->next; + free (p_begin); + return; + } + chain = &((struct header *) ((char *) *chain - HEADER_SIZE))->next; + } + } /* At this point, we know it was not a mmalloca() result. */ } } diff --git a/src/bin/coreutils/lib/malloca.h b/src/bin/coreutils/lib/malloca.h index 6259405cf8..88e8c37286 100644 --- a/src/bin/coreutils/lib/malloca.h +++ b/src/bin/coreutils/lib/malloca.h @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Safe automatic memory allocation. - Copyright (C) 2003-2007 Free Software Foundation, Inc. + Copyright (C) 2003-2007, 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible , 2003. This program is free software; you can redistribute it and/or modify @@ -57,7 +57,7 @@ extern "C" { the function returns. Upon failure, it returns NULL. */ #if HAVE_ALLOCA # define malloca(N) \ - ((N) < 4032 - sa_increment \ + ((N) < 4032 - sa_increment \ ? (void *) ((char *) alloca ((N) + sa_increment) + sa_increment) \ : mmalloca (N)) #else @@ -125,10 +125,10 @@ enum sa_alignment_longdouble = sa_alignof (long double), sa_alignment_max = ((sa_alignment_long - 1) | (sa_alignment_double - 1) #if HAVE_LONG_LONG_INT - | (sa_alignment_longlong - 1) + | (sa_alignment_longlong - 1) #endif - | (sa_alignment_longdouble - 1) - ) + 1, + | (sa_alignment_longdouble - 1) + ) + 1, /* The increment that guarantees room for a magic word must be >= sizeof (int) and a multiple of sa_alignment_max. */ sa_increment = ((sizeof (int) + sa_alignment_max - 1) / sa_alignment_max) * sa_alignment_max diff --git a/src/bin/coreutils/lib/math.h b/src/bin/coreutils/lib/math.h new file mode 100644 index 0000000000..64c1d1802c --- /dev/null +++ b/src/bin/coreutils/lib/math.h @@ -0,0 +1,655 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* A GNU-like . + + Copyright (C) 2002-2003, 2007-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef _GL_MATH_H + +#if __GNUC__ >= 3 +#pragma GCC system_header +#endif + +/* The include_next requires a split double-inclusion guard. */ +#include_next + +#ifndef _GL_MATH_H +#define _GL_MATH_H + + +/* The definition of GL_LINK_WARNING is copied here. */ +/* GL_LINK_WARNING("literal string") arranges to emit the literal string as + a linker warning on most glibc systems. + We use a linker warning rather than a preprocessor warning, because + #warning cannot be used inside macros. */ +#ifndef GL_LINK_WARNING + /* This works on platforms with GNU ld and ELF object format. + Testing __GLIBC__ is sufficient for asserting that GNU ld is in use. + Testing __ELF__ guarantees the ELF object format. + Testing __GNUC__ is necessary for the compound expression syntax. */ +# if defined __GLIBC__ && defined __ELF__ && defined __GNUC__ +# define GL_LINK_WARNING(message) \ + GL_LINK_WARNING1 (__FILE__, __LINE__, message) +# define GL_LINK_WARNING1(file, line, message) \ + GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */ +# define GL_LINK_WARNING2(file, line, message) \ + GL_LINK_WARNING3 (file ":" #line ": warning: " message) +# define GL_LINK_WARNING3(message) \ + ({ static const char warning[sizeof (message)] \ + __attribute__ ((__unused__, \ + __section__ (".gnu.warning"), \ + __aligned__ (1))) \ + = message "\n"; \ + (void)0; \ + }) +# else +# define GL_LINK_WARNING(message) ((void) 0) +# endif +#endif + +/* The definition of _GL_ARG_NONNULL is copied here. */ +/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools + that the values passed as arguments n, ..., m must be non-NULL pointers. + n = 1 stands for the first argument, n = 2 for the second argument etc. */ +#ifndef _GL_ARG_NONNULL +# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 +# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) +# else +# define _GL_ARG_NONNULL(params) +# endif +#endif + +/* Helper macros to define a portability warning for the + classification macro FUNC called with VALUE. POSIX declares the + classification macros with an argument of real-floating (that is, + one of float, double, or long double). */ +#define _GL_WARN_REAL_FLOATING_DECL(func) \ +static inline int \ +rpl_ ## func ## f (float f) \ +{ \ + return func (f); \ +} \ +static inline int \ +rpl_ ## func ## d (double d) \ +{ \ + return func (d); \ +} \ +static inline int \ +rpl_ ## func ## l (long double l) \ +{ \ + return func (l); \ +} \ +_GL_WARN_ON_USE (rpl_ ## func ## f, #func " is unportable - " \ + "use gnulib module " #func " for portability"); \ +_GL_WARN_ON_USE (rpl_ ## func ## d, #func " is unportable - " \ + "use gnulib module " #func " for portability"); \ +_GL_WARN_ON_USE (rpl_ ## func ## l, #func " is unportable - " \ + "use gnulib module " #func " for portability") +#define _GL_WARN_REAL_FLOATING_IMPL(func, value) \ + (sizeof (value) == sizeof (float) ? rpl_ ## func ## f (value) \ + : sizeof (value) == sizeof (double) ? rpl_ ## func ## d (value) \ + : rpl_ ## func ## l (value)) + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* POSIX allows platforms that don't support NAN. But all major + machines in the past 15 years have supported something close to + IEEE NaN, so we define this unconditionally. We also must define + it on platforms like Solaris 10, where NAN is present but defined + as a function pointer rather than a floating point constant. */ +#if !defined NAN || 0 +# undef NAN + /* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */ +# ifdef __DECC +static float +_NaN () +{ + static float zero = 0.0f; + return zero / zero; +} +# define NAN (_NaN()) +# else +# define NAN (0.0f / 0.0f) +# endif +#endif + +/* Solaris 10 defines HUGE_VAL, but as a function pointer rather + than a floating point constant. */ +#if 0 +# undef HUGE_VAL +# define HUGE_VAL (1.0 / 0.0) +#endif + +/* Write x as + x = mantissa * 2^exp + where + If x finite and nonzero: 0.5 <= |mantissa| < 1.0. + If x is zero: mantissa = x, exp = 0. + If x is infinite or NaN: mantissa = x, exp unspecified. + Store exp in *EXPPTR and return mantissa. */ +#if 1 +# if 0 +# define frexp rpl_frexp +extern double frexp (double x, int *expptr) _GL_ARG_NONNULL ((2)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef frexp +# define frexp(x,e) \ + (GL_LINK_WARNING ("frexp is unportable - " \ + "use gnulib module frexp for portability"), \ + frexp (x, e)) +#endif + + +#if 0 || !1 +extern long double acosl (long double x); +#endif +#if !0 && defined GNULIB_POSIXCHECK +# undef acosl +# define acosl(x) \ + (GL_LINK_WARNING ("acosl is unportable - " \ + "use gnulib module mathl for portability"), \ + acosl (x)) +#endif + + +#if 0 || !1 +extern long double asinl (long double x); +#endif +#if !0 && defined GNULIB_POSIXCHECK +# undef asinl +# define asinl(x) \ + (GL_LINK_WARNING ("asinl is unportable - " \ + "use gnulib module mathl for portability"), \ + asinl (x)) +#endif + + +#if 0 || !1 +extern long double atanl (long double x); +#endif +#if !0 && defined GNULIB_POSIXCHECK +# undef atanl +# define atanl(x) \ + (GL_LINK_WARNING ("atanl is unportable - " \ + "use gnulib module mathl for portability"), \ + atanl (x)) +#endif + + +#if 0 +# if 0 +# define ceilf rpl_ceilf +extern float ceilf (float x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef ceilf +# define ceilf(x) \ + (GL_LINK_WARNING ("ceilf is unportable - " \ + "use gnulib module ceilf for portability"), \ + ceilf (x)) +#endif + +#if 0 +# if 0 +# define ceill rpl_ceill +extern long double ceill (long double x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef ceill +# define ceill(x) \ + (GL_LINK_WARNING ("ceill is unportable - " \ + "use gnulib module ceill for portability"), \ + ceill (x)) +#endif + + +#if 0 || (!1 && !defined cosl) +# undef cosl +extern long double cosl (long double x); +#endif +#if !0 && defined GNULIB_POSIXCHECK +# undef cosl +# define cosl(x) \ + (GL_LINK_WARNING ("cosl is unportable - " \ + "use gnulib module mathl for portability"), \ + cosl (x)) +#endif + + +#if 0 || !1 +extern long double expl (long double x); +#endif +#if !0 && defined GNULIB_POSIXCHECK +# undef expl +# define expl(x) \ + (GL_LINK_WARNING ("expl is unportable - " \ + "use gnulib module mathl for portability"), \ + expl (x)) +#endif + + +#if 0 +# if 0 +# define floorf rpl_floorf +extern float floorf (float x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef floorf +# define floorf(x) \ + (GL_LINK_WARNING ("floorf is unportable - " \ + "use gnulib module floorf for portability"), \ + floorf (x)) +#endif + +#if 0 +# if 0 +# define floorl rpl_floorl +extern long double floorl (long double x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef floorl +# define floorl(x) \ + (GL_LINK_WARNING ("floorl is unportable - " \ + "use gnulib module floorl for portability"), \ + floorl (x)) +#endif + + +/* Write x as + x = mantissa * 2^exp + where + If x finite and nonzero: 0.5 <= |mantissa| < 1.0. + If x is zero: mantissa = x, exp = 0. + If x is infinite or NaN: mantissa = x, exp unspecified. + Store exp in *EXPPTR and return mantissa. */ +#if 1 && 0 +# define frexpl rpl_frexpl +#endif +#if (1 && 0) || !0 +extern long double frexpl (long double x, int *expptr) _GL_ARG_NONNULL ((2)); +#endif +#if !1 && defined GNULIB_POSIXCHECK +# undef frexpl +# define frexpl(x,e) \ + (GL_LINK_WARNING ("frexpl is unportable - " \ + "use gnulib module frexpl for portability"), \ + frexpl (x, e)) +#endif + + +/* Return x * 2^exp. */ +#if 0 && 0 +# define ldexpl rpl_ldexpl +#endif +#if (0 && 0) || !1 +extern long double ldexpl (long double x, int exp); +#endif +#if !0 && defined GNULIB_POSIXCHECK +# undef ldexpl +# define ldexpl(x,e) \ + (GL_LINK_WARNING ("ldexpl is unportable - " \ + "use gnulib module ldexpl for portability"), \ + ldexpl (x, e)) +#endif + + +#if 0 || (!1 && !defined logl) +# undef logl +extern long double logl (long double x); +#endif +#if !0 && defined GNULIB_POSIXCHECK +# undef logl +# define logl(x) \ + (GL_LINK_WARNING ("logl is unportable - " \ + "use gnulib module mathl for portability"), \ + logl (x)) +#endif + + +#if 0 +# if 0 +# undef roundf +# define roundf rpl_roundf +extern float roundf (float x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef roundf +# define roundf(x) \ + (GL_LINK_WARNING ("roundf is unportable - " \ + "use gnulib module roundf for portability"), \ + roundf (x)) +#endif + +#if 0 +# if 0 +# undef round +# define round rpl_round +extern double round (double x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef round +# define round(x) \ + (GL_LINK_WARNING ("round is unportable - " \ + "use gnulib module round for portability"), \ + round (x)) +#endif + +#if 0 +# if 0 +# undef roundl +# define roundl rpl_roundl +extern long double roundl (long double x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef roundl +# define roundl(x) \ + (GL_LINK_WARNING ("roundl is unportable - " \ + "use gnulib module roundl for portability"), \ + roundl (x)) +#endif + + +#if 0 || (!1 && !defined sinl) +# undef sinl +extern long double sinl (long double x); +#endif +#if !0 && defined GNULIB_POSIXCHECK +# undef sinl +# define sinl(x) \ + (GL_LINK_WARNING ("sinl is unportable - " \ + "use gnulib module mathl for portability"), \ + sinl (x)) +#endif + + +#if 0 || !1 +extern long double sqrtl (long double x); +#endif +#if !0 && defined GNULIB_POSIXCHECK +# undef sqrtl +# define sqrtl(x) \ + (GL_LINK_WARNING ("sqrtl is unportable - " \ + "use gnulib module mathl for portability"), \ + sqrtl (x)) +#endif + + +#if 0 || !1 +extern long double tanl (long double x); +#endif +#if !0 && defined GNULIB_POSIXCHECK +# undef tanl +# define tanl(x) \ + (GL_LINK_WARNING ("tanl is unportable - " \ + "use gnulib module mathl for portability"), \ + tanl (x)) +#endif + + +#if 0 +# if !1 +# define truncf rpl_truncf +extern float truncf (float x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef truncf +# define truncf(x) \ + (GL_LINK_WARNING ("truncf is unportable - " \ + "use gnulib module truncf for portability"), \ + truncf (x)) +#endif + +#if 0 +# if !1 +# define trunc rpl_trunc +extern double trunc (double x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef trunc +# define trunc(x) \ + (GL_LINK_WARNING ("trunc is unportable - " \ + "use gnulib module trunc for portability"), \ + trunc (x)) +#endif + +#if 0 +# if 0 +# undef truncl +# define truncl rpl_truncl +extern long double truncl (long double x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef truncl +# define truncl(x) \ + (GL_LINK_WARNING ("truncl is unportable - " \ + "use gnulib module truncl for portability"), \ + truncl (x)) +#endif + + +#if 0 +# if 0 +extern int gl_isfinitef (float x); +extern int gl_isfinited (double x); +extern int gl_isfinitel (long double x); +# undef isfinite +# define isfinite(x) \ + (sizeof (x) == sizeof (long double) ? gl_isfinitel (x) : \ + sizeof (x) == sizeof (double) ? gl_isfinited (x) : \ + gl_isfinitef (x)) +# endif +#elif defined GNULIB_POSIXCHECK +# if defined isfinite +_GL_WARN_REAL_FLOATING_DECL (isfinite); +# undef isfinite +# define isfinite(x) _GL_WARN_REAL_FLOATING_IMPL (isfinite, x) +# endif +#endif + + +#if 0 +# if 0 +extern int gl_isinff (float x); +extern int gl_isinfd (double x); +extern int gl_isinfl (long double x); +# undef isinf +# define isinf(x) \ + (sizeof (x) == sizeof (long double) ? gl_isinfl (x) : \ + sizeof (x) == sizeof (double) ? gl_isinfd (x) : \ + gl_isinff (x)) +# endif +#elif defined GNULIB_POSIXCHECK +# if defined isinf +_GL_WARN_REAL_FLOATING_DECL (isinf); +# undef isinf +# define isinf(x) _GL_WARN_REAL_FLOATING_IMPL (isinf, x) +# endif +#endif + + +#if 0 +/* Test for NaN for 'float' numbers. */ +# if 1 +/* The original included above provides a declaration of isnan macro + or (older) isnanf function. */ +# if __GNUC__ >= 4 + /* GCC 4.0 and newer provides three built-ins for isnan. */ +# undef isnanf +# define isnanf(x) __builtin_isnanf ((float)(x)) +# elif defined isnan +# undef isnanf +# define isnanf(x) isnan ((float)(x)) +# endif +# else +/* Test whether X is a NaN. */ +# undef isnanf +# define isnanf rpl_isnanf +extern int isnanf (float x); +# endif +#endif + +#if 0 +/* Test for NaN for 'double' numbers. + This function is a gnulib extension, unlike isnan() which applied only + to 'double' numbers earlier but now is a type-generic macro. */ +# if 1 +/* The original included above provides a declaration of isnan macro. */ +# if __GNUC__ >= 4 + /* GCC 4.0 and newer provides three built-ins for isnan. */ +# undef isnand +# define isnand(x) __builtin_isnan ((double)(x)) +# else +# undef isnand +# define isnand(x) isnan ((double)(x)) +# endif +# else +/* Test whether X is a NaN. */ +# undef isnand +# define isnand rpl_isnand +extern int isnand (double x); +# endif +#endif + +#if 0 +/* Test for NaN for 'long double' numbers. */ +# if 1 +/* The original included above provides a declaration of isnan macro or (older) isnanl function. */ +# if __GNUC__ >= 4 + /* GCC 4.0 and newer provides three built-ins for isnan. */ +# undef isnanl +# define isnanl(x) __builtin_isnanl ((long double)(x)) +# elif defined isnan +# undef isnanl +# define isnanl(x) isnan ((long double)(x)) +# endif +# else +/* Test whether X is a NaN. */ +# undef isnanl +# define isnanl rpl_isnanl +extern int isnanl (long double x); +# endif +#endif + +/* This must come *after* the snippets for GNULIB_ISNANF and GNULIB_ISNANL! */ +#if 0 +# if 0 +/* We can't just use the isnanf macro (e.g.) as exposed by + isnanf.h (e.g.) here, because those may end up being macros + that recursively expand back to isnan. So use the gnulib + replacements for them directly. */ +# if 1 && __GNUC__ >= 4 +# define gl_isnan_f(x) __builtin_isnan ((float)(x)) +# else +extern int rpl_isnanf (float x); +# define gl_isnan_f(x) rpl_isnanf (x) +# endif +# if 1 && __GNUC__ >= 4 +# define gl_isnan_d(x) __builtin_isnan ((double)(x)) +# else +extern int rpl_isnand (double x); +# define gl_isnan_d(x) rpl_isnand (x) +# endif +# if 1 && __GNUC__ >= 4 +# define gl_isnan_l(x) __builtin_isnan ((long double)(x)) +# else +extern int rpl_isnanl (long double x); +# define gl_isnan_l(x) rpl_isnanl (x) +# endif +# undef isnan +# define isnan(x) \ + (sizeof (x) == sizeof (long double) ? gl_isnan_l (x) : \ + sizeof (x) == sizeof (double) ? gl_isnan_d (x) : \ + gl_isnan_f (x)) +# endif +#elif defined GNULIB_POSIXCHECK +# if defined isnan +_GL_WARN_REAL_FLOATING_DECL (isnan); +# undef isnan +# define isnan(x) _GL_WARN_REAL_FLOATING_IMPL (isnan, x) +# endif +#endif + + +#if 1 +# if 0 +# undef signbit + /* GCC 4.0 and newer provides three built-ins for signbit. */ +# define signbit(x) \ + (sizeof (x) == sizeof (long double) ? __builtin_signbitl (x) : \ + sizeof (x) == sizeof (double) ? __builtin_signbit (x) : \ + __builtin_signbitf (x)) +# endif +# if 0 +# undef signbit +extern int gl_signbitf (float arg); +extern int gl_signbitd (double arg); +extern int gl_signbitl (long double arg); +# if __GNUC__ >= 2 && !__STRICT_ANSI__ +# if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT && !defined gl_signbitf +# define gl_signbitf_OPTIMIZED_MACRO +# define gl_signbitf(arg) \ + ({ union { float _value; \ + unsigned int _word[(sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ + } _m; \ + _m._value = (arg); \ + (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \ + }) +# endif +# if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT && !defined gl_signbitd +# define gl_signbitd_OPTIMIZED_MACRO +# define gl_signbitd(arg) \ + ({ union { double _value; \ + unsigned int _word[(sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ + } _m; \ + _m._value = (arg); \ + (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \ + }) +# endif +# if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT && !defined gl_signbitl +# define gl_signbitl_OPTIMIZED_MACRO +# define gl_signbitl(arg) \ + ({ union { long double _value; \ + unsigned int _word[(sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ + } _m; \ + _m._value = (arg); \ + (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \ + }) +# endif +# endif +# define signbit(x) \ + (sizeof (x) == sizeof (long double) ? gl_signbitl (x) : \ + sizeof (x) == sizeof (double) ? gl_signbitd (x) : \ + gl_signbitf (x)) +# endif +#elif defined GNULIB_POSIXCHECK +# if defined signbit +_GL_WARN_REAL_FLOATING_DECL (signbit); +# undef signbit +# define signbit(x) _GL_WARN_REAL_FLOATING_IMPL (signbit, x) +# endif +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* _GL_MATH_H */ +#endif /* _GL_MATH_H */ diff --git a/src/bin/coreutils/lib/math.in.h b/src/bin/coreutils/lib/math.in.h index 1778e6e918..7f0942431b 100644 --- a/src/bin/coreutils/lib/math.in.h +++ b/src/bin/coreutils/lib/math.in.h @@ -1,6 +1,6 @@ /* A GNU-like . - Copyright (C) 2002-2003, 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2002-2003, 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,6 +30,39 @@ /* The definition of GL_LINK_WARNING is copied here. */ +/* The definition of _GL_ARG_NONNULL is copied here. */ + +/* Helper macros to define a portability warning for the + classification macro FUNC called with VALUE. POSIX declares the + classification macros with an argument of real-floating (that is, + one of float, double, or long double). */ +#define _GL_WARN_REAL_FLOATING_DECL(func) \ +static inline int \ +rpl_ ## func ## f (float f) \ +{ \ + return func (f); \ +} \ +static inline int \ +rpl_ ## func ## d (double d) \ +{ \ + return func (d); \ +} \ +static inline int \ +rpl_ ## func ## l (long double l) \ +{ \ + return func (l); \ +} \ +_GL_WARN_ON_USE (rpl_ ## func ## f, #func " is unportable - " \ + "use gnulib module " #func " for portability"); \ +_GL_WARN_ON_USE (rpl_ ## func ## d, #func " is unportable - " \ + "use gnulib module " #func " for portability"); \ +_GL_WARN_ON_USE (rpl_ ## func ## l, #func " is unportable - " \ + "use gnulib module " #func " for portability") +#define _GL_WARN_REAL_FLOATING_IMPL(func, value) \ + (sizeof (value) == sizeof (float) ? rpl_ ## func ## f (value) \ + : sizeof (value) == sizeof (double) ? rpl_ ## func ## d (value) \ + : rpl_ ## func ## l (value)) + #ifdef __cplusplus extern "C" { @@ -74,7 +107,7 @@ _NaN () #if @GNULIB_FREXP@ # if @REPLACE_FREXP@ # define frexp rpl_frexp -extern double frexp (double x, int *expptr); +extern double frexp (double x, int *expptr) _GL_ARG_NONNULL ((2)); # endif #elif defined GNULIB_POSIXCHECK # undef frexp @@ -211,7 +244,7 @@ extern long double floorl (long double x); # define frexpl rpl_frexpl #endif #if (@GNULIB_FREXPL@ && @REPLACE_FREXPL@) || !@HAVE_DECL_FREXPL@ -extern long double frexpl (long double x, int *expptr); +extern long double frexpl (long double x, int *expptr) _GL_ARG_NONNULL ((2)); #endif #if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK # undef frexpl @@ -384,7 +417,11 @@ extern int gl_isfinitel (long double x); gl_isfinitef (x)) # endif #elif defined GNULIB_POSIXCHECK - /* How to override a macro? */ +# if defined isfinite +_GL_WARN_REAL_FLOATING_DECL (isfinite); +# undef isfinite +# define isfinite(x) _GL_WARN_REAL_FLOATING_IMPL (isfinite, x) +# endif #endif @@ -400,7 +437,11 @@ extern int gl_isinfl (long double x); gl_isinff (x)) # endif #elif defined GNULIB_POSIXCHECK - /* How to override a macro? */ +# if defined isinf +_GL_WARN_REAL_FLOATING_DECL (isinf); +# undef isinf +# define isinf(x) _GL_WARN_REAL_FLOATING_IMPL (isinf, x) +# endif #endif @@ -409,7 +450,6 @@ extern int gl_isinfl (long double x); # if @HAVE_ISNANF@ /* The original included above provides a declaration of isnan macro or (older) isnanf function. */ -# include # if __GNUC__ >= 4 /* GCC 4.0 and newer provides three built-ins for isnan. */ # undef isnanf @@ -432,7 +472,6 @@ extern int isnanf (float x); to 'double' numbers earlier but now is a type-generic macro. */ # if @HAVE_ISNAND@ /* The original included above provides a declaration of isnan macro. */ -# include # if __GNUC__ >= 4 /* GCC 4.0 and newer provides three built-ins for isnan. */ # undef isnand @@ -453,7 +492,6 @@ extern int isnand (double x); /* Test for NaN for 'long double' numbers. */ # if @HAVE_ISNANL@ /* The original included above provides a declaration of isnan macro or (older) isnanl function. */ -# include # if __GNUC__ >= 4 /* GCC 4.0 and newer provides three built-ins for isnan. */ # undef isnanl @@ -502,7 +540,11 @@ extern int rpl_isnanl (long double x); gl_isnan_f (x)) # endif #elif defined GNULIB_POSIXCHECK - /* How to override a macro? */ +# if defined isnan +_GL_WARN_REAL_FLOATING_DECL (isnan); +# undef isnan +# define isnan(x) _GL_WARN_REAL_FLOATING_IMPL (isnan, x) +# endif #endif @@ -524,31 +566,31 @@ extern int gl_signbitl (long double arg); # if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT && !defined gl_signbitf # define gl_signbitf_OPTIMIZED_MACRO # define gl_signbitf(arg) \ - ({ union { float _value; \ + ({ union { float _value; \ unsigned int _word[(sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ - } _m; \ - _m._value = (arg); \ - (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \ + } _m; \ + _m._value = (arg); \ + (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \ }) # endif # if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT && !defined gl_signbitd # define gl_signbitd_OPTIMIZED_MACRO # define gl_signbitd(arg) \ - ({ union { double _value; \ + ({ union { double _value; \ unsigned int _word[(sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ - } _m; \ - _m._value = (arg); \ - (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \ + } _m; \ + _m._value = (arg); \ + (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \ }) # endif # if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT && !defined gl_signbitl # define gl_signbitl_OPTIMIZED_MACRO # define gl_signbitl(arg) \ - ({ union { long double _value; \ + ({ union { long double _value; \ unsigned int _word[(sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ - } _m; \ - _m._value = (arg); \ - (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \ + } _m; \ + _m._value = (arg); \ + (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \ }) # endif # endif @@ -558,7 +600,11 @@ extern int gl_signbitl (long double arg); gl_signbitf (x)) # endif #elif defined GNULIB_POSIXCHECK - /* How to override a macro? */ +# if defined signbit +_GL_WARN_REAL_FLOATING_DECL (signbit); +# undef signbit +# define signbit(x) _GL_WARN_REAL_FLOATING_IMPL (signbit, x) +# endif #endif diff --git a/src/bin/coreutils/lib/mbchar.c b/src/bin/coreutils/lib/mbchar.c index 6fa14b09c0..6ec01950de 100644 --- a/src/bin/coreutils/lib/mbchar.c +++ b/src/bin/coreutils/lib/mbchar.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2006 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2006, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,10 +25,10 @@ /* Bit table of characters in the ISO C "basic character set". */ const unsigned int is_basic_table [UCHAR_MAX / 32 + 1] = { - 0x00001a00, /* '\t' '\v' '\f' */ - 0xffffffef, /* ' '...'#' '%'...'?' */ - 0xfffffffe, /* 'A'...'Z' '[' '\\' ']' '^' '_' */ - 0x7ffffffe /* 'a'...'z' '{' '|' '}' '~' */ + 0x00001a00, /* '\t' '\v' '\f' */ + 0xffffffef, /* ' '...'#' '%'...'?' */ + 0xfffffffe, /* 'A'...'Z' '[' '\\' ']' '^' '_' */ + 0x7ffffffe /* 'a'...'z' '{' '|' '}' '~' */ /* The remaining bits are 0. */ }; diff --git a/src/bin/coreutils/lib/mbchar.h b/src/bin/coreutils/lib/mbchar.h index 5d47a0a9c5..012bfcb118 100644 --- a/src/bin/coreutils/lib/mbchar.h +++ b/src/bin/coreutils/lib/mbchar.h @@ -1,5 +1,5 @@ /* Multibyte character data type. - Copyright (C) 2001, 2005-2007 Free Software Foundation, Inc. + Copyright (C) 2001, 2005-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -114,31 +114,31 @@ Here are the function prototypes of the macros. - extern const char * mb_ptr (const mbchar_t mbc); - extern size_t mb_len (const mbchar_t mbc); - extern bool mb_iseq (const mbchar_t mbc, char sc); - extern bool mb_isnul (const mbchar_t mbc); - extern int mb_cmp (const mbchar_t mbc1, const mbchar_t mbc2); - extern int mb_casecmp (const mbchar_t mbc1, const mbchar_t mbc2); - extern bool mb_equal (const mbchar_t mbc1, const mbchar_t mbc2); - extern bool mb_caseequal (const mbchar_t mbc1, const mbchar_t mbc2); - extern bool mb_isalnum (const mbchar_t mbc); - extern bool mb_isalpha (const mbchar_t mbc); - extern bool mb_isascii (const mbchar_t mbc); - extern bool mb_isblank (const mbchar_t mbc); - extern bool mb_iscntrl (const mbchar_t mbc); - extern bool mb_isdigit (const mbchar_t mbc); - extern bool mb_isgraph (const mbchar_t mbc); - extern bool mb_islower (const mbchar_t mbc); - extern bool mb_isprint (const mbchar_t mbc); - extern bool mb_ispunct (const mbchar_t mbc); - extern bool mb_isspace (const mbchar_t mbc); - extern bool mb_isupper (const mbchar_t mbc); - extern bool mb_isxdigit (const mbchar_t mbc); - extern int mb_width (const mbchar_t mbc); - extern void mb_putc (const mbchar_t mbc, FILE *stream); + extern const char * mb_ptr (const mbchar_t mbc); + extern size_t mb_len (const mbchar_t mbc); + extern bool mb_iseq (const mbchar_t mbc, char sc); + extern bool mb_isnul (const mbchar_t mbc); + extern int mb_cmp (const mbchar_t mbc1, const mbchar_t mbc2); + extern int mb_casecmp (const mbchar_t mbc1, const mbchar_t mbc2); + extern bool mb_equal (const mbchar_t mbc1, const mbchar_t mbc2); + extern bool mb_caseequal (const mbchar_t mbc1, const mbchar_t mbc2); + extern bool mb_isalnum (const mbchar_t mbc); + extern bool mb_isalpha (const mbchar_t mbc); + extern bool mb_isascii (const mbchar_t mbc); + extern bool mb_isblank (const mbchar_t mbc); + extern bool mb_iscntrl (const mbchar_t mbc); + extern bool mb_isdigit (const mbchar_t mbc); + extern bool mb_isgraph (const mbchar_t mbc); + extern bool mb_islower (const mbchar_t mbc); + extern bool mb_isprint (const mbchar_t mbc); + extern bool mb_ispunct (const mbchar_t mbc); + extern bool mb_isspace (const mbchar_t mbc); + extern bool mb_isupper (const mbchar_t mbc); + extern bool mb_isxdigit (const mbchar_t mbc); + extern int mb_width (const mbchar_t mbc); + extern void mb_putc (const mbchar_t mbc, FILE *stream); extern void mb_setascii (mbchar_t *new, char sc); - extern void mb_copy (mbchar_t *new, const mbchar_t *old); + extern void mb_copy (mbchar_t *new, const mbchar_t *old); */ #ifndef _MBCHAR_H @@ -160,10 +160,10 @@ struct mbchar { - const char *ptr; /* pointer to current character */ - size_t bytes; /* number of bytes of current character, > 0 */ - bool wc_valid; /* true if wc is a valid wide character */ - wchar_t wc; /* if wc_valid: the current character */ + const char *ptr; /* pointer to current character */ + size_t bytes; /* number of bytes of current character, > 0 */ + bool wc_valid; /* true if wc is a valid wide character */ + wchar_t wc; /* if wc_valid: the current character */ char buf[MBCHAR_BUF_SIZE]; /* room for the bytes, used for file input only */ }; @@ -180,38 +180,38 @@ typedef struct mbchar mbchar_t; #define mb_iseq(mbc, sc) ((mbc).wc_valid && (mbc).wc == (sc)) #define mb_isnul(mbc) ((mbc).wc_valid && (mbc).wc == 0) #define mb_cmp(mbc1, mbc2) \ - ((mbc1).wc_valid \ - ? ((mbc2).wc_valid \ - ? (int) (mbc1).wc - (int) (mbc2).wc \ - : -1) \ - : ((mbc2).wc_valid \ - ? 1 \ - : (mbc1).bytes == (mbc2).bytes \ - ? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) \ - : (mbc1).bytes < (mbc2).bytes \ + ((mbc1).wc_valid \ + ? ((mbc2).wc_valid \ + ? (int) (mbc1).wc - (int) (mbc2).wc \ + : -1) \ + : ((mbc2).wc_valid \ + ? 1 \ + : (mbc1).bytes == (mbc2).bytes \ + ? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) \ + : (mbc1).bytes < (mbc2).bytes \ ? (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) > 0 ? 1 : -1) \ : (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc2).bytes) >= 0 ? 1 : -1))) #define mb_casecmp(mbc1, mbc2) \ - ((mbc1).wc_valid \ - ? ((mbc2).wc_valid \ - ? (int) towlower ((mbc1).wc) - (int) towlower ((mbc2).wc) \ - : -1) \ - : ((mbc2).wc_valid \ - ? 1 \ - : (mbc1).bytes == (mbc2).bytes \ - ? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) \ - : (mbc1).bytes < (mbc2).bytes \ + ((mbc1).wc_valid \ + ? ((mbc2).wc_valid \ + ? (int) towlower ((mbc1).wc) - (int) towlower ((mbc2).wc) \ + : -1) \ + : ((mbc2).wc_valid \ + ? 1 \ + : (mbc1).bytes == (mbc2).bytes \ + ? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) \ + : (mbc1).bytes < (mbc2).bytes \ ? (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) > 0 ? 1 : -1) \ : (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc2).bytes) >= 0 ? 1 : -1))) #define mb_equal(mbc1, mbc2) \ - ((mbc1).wc_valid && (mbc2).wc_valid \ - ? (mbc1).wc == (mbc2).wc \ - : (mbc1).bytes == (mbc2).bytes \ + ((mbc1).wc_valid && (mbc2).wc_valid \ + ? (mbc1).wc == (mbc2).wc \ + : (mbc1).bytes == (mbc2).bytes \ && memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) == 0) #define mb_caseequal(mbc1, mbc2) \ - ((mbc1).wc_valid && (mbc2).wc_valid \ - ? towlower ((mbc1).wc) == towlower ((mbc2).wc) \ - : (mbc1).bytes == (mbc2).bytes \ + ((mbc1).wc_valid && (mbc2).wc_valid \ + ? towlower ((mbc1).wc) == towlower ((mbc2).wc) \ + : (mbc1).bytes == (mbc2).bytes \ && memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) == 0) /* , classification. */ @@ -308,7 +308,7 @@ static inline bool is_basic (char c) { return (is_basic_table [(unsigned char) c >> 5] >> ((unsigned char) c & 31)) - & 1; + & 1; } #else diff --git a/src/bin/coreutils/lib/mbiter.h b/src/bin/coreutils/lib/mbiter.h index b274da747e..6b738268f6 100644 --- a/src/bin/coreutils/lib/mbiter.h +++ b/src/bin/coreutils/lib/mbiter.h @@ -1,5 +1,5 @@ /* Iterating through multibyte strings: macros for multi-byte encodings. - Copyright (C) 2001, 2005, 2007 Free Software Foundation, Inc. + Copyright (C) 2001, 2005, 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -69,14 +69,14 @@ Here are the function prototypes of the macros. - extern void mbi_init (mbi_iterator_t iter, - const char *startptr, size_t length); - extern bool mbi_avail (mbi_iterator_t iter); - extern void mbi_advance (mbi_iterator_t iter); - extern mbchar_t mbi_cur (mbi_iterator_t iter); - extern const char * mbi_cur_ptr (mbi_iterator_t iter); - extern void mbi_reloc (mbi_iterator_t iter, ptrdiff_t ptrdiff); - extern void mbi_copy (mbi_iterator_t *new, const mbi_iterator_t *old); + extern void mbi_init (mbi_iterator_t iter, + const char *startptr, size_t length); + extern bool mbi_avail (mbi_iterator_t iter); + extern void mbi_advance (mbi_iterator_t iter); + extern mbchar_t mbi_cur (mbi_iterator_t iter); + extern const char * mbi_cur_ptr (mbi_iterator_t iter); + extern void mbi_reloc (mbi_iterator_t iter, ptrdiff_t ptrdiff); + extern void mbi_copy (mbi_iterator_t *new, const mbi_iterator_t *old); */ #ifndef _MBITER_H @@ -99,17 +99,17 @@ struct mbiter_multi { - const char *limit; /* pointer to end of string */ - bool in_shift; /* true if next byte may not be interpreted as ASCII */ - mbstate_t state; /* if in_shift: current shift state */ - bool next_done; /* true if mbi_avail has already filled the following */ - struct mbchar cur; /* the current character: - const char *cur.ptr pointer to current character - The following are only valid after mbi_avail. - size_t cur.bytes number of bytes of current character - bool cur.wc_valid true if wc is a valid wide character - wchar_t cur.wc if wc_valid: the current character - */ + const char *limit; /* pointer to end of string */ + bool in_shift; /* true if next byte may not be interpreted as ASCII */ + mbstate_t state; /* if in_shift: current shift state */ + bool next_done; /* true if mbi_avail has already filled the following */ + struct mbchar cur; /* the current character: + const char *cur.ptr pointer to current character + The following are only valid after mbi_avail. + size_t cur.bytes number of bytes of current character + bool cur.wc_valid true if wc is a valid wide character + wchar_t cur.wc if wc_valid: the current character + */ }; static inline void @@ -123,8 +123,8 @@ mbiter_multi_next (struct mbiter_multi *iter) if (is_basic (*iter->cur.ptr)) { /* These characters are part of the basic character set. ISO C 99 - guarantees that their wide character code is identical to their - char code. */ + guarantees that their wide character code is identical to their + char code. */ iter->cur.bytes = 1; iter->cur.wc = *iter->cur.ptr; iter->cur.wc_valid = true; @@ -135,39 +135,39 @@ mbiter_multi_next (struct mbiter_multi *iter) iter->in_shift = true; with_shift: iter->cur.bytes = mbrtowc (&iter->cur.wc, iter->cur.ptr, - iter->limit - iter->cur.ptr, &iter->state); + iter->limit - iter->cur.ptr, &iter->state); if (iter->cur.bytes == (size_t) -1) - { - /* An invalid multibyte sequence was encountered. */ - iter->cur.bytes = 1; - iter->cur.wc_valid = false; - /* Whether to set iter->in_shift = false and reset iter->state - or not is not very important; the string is bogus anyway. */ - } + { + /* An invalid multibyte sequence was encountered. */ + iter->cur.bytes = 1; + iter->cur.wc_valid = false; + /* Whether to set iter->in_shift = false and reset iter->state + or not is not very important; the string is bogus anyway. */ + } else if (iter->cur.bytes == (size_t) -2) - { - /* An incomplete multibyte character at the end. */ - iter->cur.bytes = iter->limit - iter->cur.ptr; - iter->cur.wc_valid = false; - /* Whether to set iter->in_shift = false and reset iter->state - or not is not important; the string end is reached anyway. */ - } + { + /* An incomplete multibyte character at the end. */ + iter->cur.bytes = iter->limit - iter->cur.ptr; + iter->cur.wc_valid = false; + /* Whether to set iter->in_shift = false and reset iter->state + or not is not important; the string end is reached anyway. */ + } else - { - if (iter->cur.bytes == 0) - { - /* A null wide character was encountered. */ - iter->cur.bytes = 1; - assert (*iter->cur.ptr == '\0'); - assert (iter->cur.wc == 0); - } - iter->cur.wc_valid = true; + { + if (iter->cur.bytes == 0) + { + /* A null wide character was encountered. */ + iter->cur.bytes = 1; + assert (*iter->cur.ptr == '\0'); + assert (iter->cur.wc == 0); + } + iter->cur.wc_valid = true; - /* When in the initial state, we can go back treating ASCII - characters more quickly. */ - if (mbsinit (&iter->state)) - iter->in_shift = false; - } + /* When in the initial state, we can go back treating ASCII + characters more quickly. */ + if (mbsinit (&iter->state)) + iter->in_shift = false; + } } iter->next_done = true; } diff --git a/src/bin/coreutils/lib/mbrlen.c b/src/bin/coreutils/lib/mbrlen.c index 32a0c8195c..01ee094454 100644 --- a/src/bin/coreutils/lib/mbrlen.c +++ b/src/bin/coreutils/lib/mbrlen.c @@ -1,5 +1,5 @@ /* Recognize multibyte character. - Copyright (C) 1999-2000, 2008 Free Software Foundation, Inc. + Copyright (C) 1999-2000, 2008-2010 Free Software Foundation, Inc. Written by Bruno Haible , 2008. This program is free software: you can redistribute it and/or modify diff --git a/src/bin/coreutils/lib/mbrtowc.c b/src/bin/coreutils/lib/mbrtowc.c index 0fec5f1c9f..5c2650e952 100644 --- a/src/bin/coreutils/lib/mbrtowc.c +++ b/src/bin/coreutils/lib/mbrtowc.c @@ -1,5 +1,5 @@ /* Convert multibyte character to wide character. - Copyright (C) 1999-2002, 2005-2009 Free Software Foundation, Inc. + Copyright (C) 1999-2002, 2005-2010 Free Software Foundation, Inc. Written by Bruno Haible , 2008. This program is free software: you can redistribute it and/or modify @@ -63,30 +63,30 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) switch (nstate) { case 0: - p = s; - m = n; - break; + p = s; + m = n; + break; case 3: - buf[2] = pstate[3]; - /*FALLTHROUGH*/ + buf[2] = pstate[3]; + /*FALLTHROUGH*/ case 2: - buf[1] = pstate[2]; - /*FALLTHROUGH*/ + buf[1] = pstate[2]; + /*FALLTHROUGH*/ case 1: - buf[0] = pstate[1]; - p = buf; - m = nstate; - buf[m++] = s[0]; - if (n >= 2 && m < 4) - { - buf[m++] = s[1]; - if (n >= 3 && m < 4) - buf[m++] = s[2]; - } - break; + buf[0] = pstate[1]; + p = buf; + m = nstate; + buf[m++] = s[0]; + if (n >= 2 && m < 4) + { + buf[m++] = s[1]; + if (n >= 3 && m < 4) + buf[m++] = s[2]; + } + break; default: - errno = EINVAL; - return (size_t)(-1); + errno = EINVAL; + return (size_t)(-1); } /* Here m > 0. */ @@ -99,208 +99,208 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) int res = mbtowc (pwc, p, m); if (res >= 0) - { - if (pwc != NULL && ((*pwc == 0) != (res == 0))) - abort (); - if (nstate >= (res > 0 ? res : 1)) - abort (); - res -= nstate; - pstate[0] = 0; - return res; - } + { + if (pwc != NULL && ((*pwc == 0) != (res == 0))) + abort (); + if (nstate >= (res > 0 ? res : 1)) + abort (); + res -= nstate; + pstate[0] = 0; + return res; + } /* mbtowc does not distinguish between invalid and incomplete multibyte - sequences. But mbrtowc needs to make this distinction. - There are two possible approaches: - - Use iconv() and its return value. - - Use built-in knowledge about the possible encodings. - Given the low quality of implementation of iconv() on the systems that - lack mbrtowc(), we use the second approach. - The possible encodings are: - - 8-bit encodings, - - EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS, - - UTF-8. - Use specialized code for each. */ + sequences. But mbrtowc needs to make this distinction. + There are two possible approaches: + - Use iconv() and its return value. + - Use built-in knowledge about the possible encodings. + Given the low quality of implementation of iconv() on the systems that + lack mbrtowc(), we use the second approach. + The possible encodings are: + - 8-bit encodings, + - EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS, + - UTF-8. + Use specialized code for each. */ if (m >= 4 || m >= MB_CUR_MAX) - goto invalid; + goto invalid; /* Here MB_CUR_MAX > 1 and 0 < m < 4. */ { - const char *encoding = locale_charset (); + const char *encoding = locale_charset (); - if (STREQ (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0)) - { - /* Cf. unistr/u8-mblen.c. */ - unsigned char c = (unsigned char) p[0]; + if (STREQ (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0)) + { + /* Cf. unistr/u8-mblen.c. */ + unsigned char c = (unsigned char) p[0]; - if (c >= 0xc2) - { - if (c < 0xe0) - { - if (m == 1) - goto incomplete; - } - else if (c < 0xf0) - { - if (m == 1) - goto incomplete; - if (m == 2) - { - unsigned char c2 = (unsigned char) p[1]; + if (c >= 0xc2) + { + if (c < 0xe0) + { + if (m == 1) + goto incomplete; + } + else if (c < 0xf0) + { + if (m == 1) + goto incomplete; + if (m == 2) + { + unsigned char c2 = (unsigned char) p[1]; - if ((c2 ^ 0x80) < 0x40 - && (c >= 0xe1 || c2 >= 0xa0) - && (c != 0xed || c2 < 0xa0)) - goto incomplete; - } - } - else if (c <= 0xf4) - { - if (m == 1) - goto incomplete; - else /* m == 2 || m == 3 */ - { - unsigned char c2 = (unsigned char) p[1]; + if ((c2 ^ 0x80) < 0x40 + && (c >= 0xe1 || c2 >= 0xa0) + && (c != 0xed || c2 < 0xa0)) + goto incomplete; + } + } + else if (c <= 0xf4) + { + if (m == 1) + goto incomplete; + else /* m == 2 || m == 3 */ + { + unsigned char c2 = (unsigned char) p[1]; - if ((c2 ^ 0x80) < 0x40 - && (c >= 0xf1 || c2 >= 0x90) - && (c < 0xf4 || (c == 0xf4 && c2 < 0x90))) - { - if (m == 2) - goto incomplete; - else /* m == 3 */ - { - unsigned char c3 = (unsigned char) p[2]; + if ((c2 ^ 0x80) < 0x40 + && (c >= 0xf1 || c2 >= 0x90) + && (c < 0xf4 || (c == 0xf4 && c2 < 0x90))) + { + if (m == 2) + goto incomplete; + else /* m == 3 */ + { + unsigned char c3 = (unsigned char) p[2]; - if ((c3 ^ 0x80) < 0x40) - goto incomplete; - } - } - } - } - } - goto invalid; - } + if ((c3 ^ 0x80) < 0x40) + goto incomplete; + } + } + } + } + } + goto invalid; + } - /* As a reference for this code, you can use the GNU libiconv - implementation. Look for uses of the RET_TOOFEW macro. */ + /* As a reference for this code, you can use the GNU libiconv + implementation. Look for uses of the RET_TOOFEW macro. */ - if (STREQ (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0)) - { - if (m == 1) - { - unsigned char c = (unsigned char) p[0]; + if (STREQ (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0)) + { + if (m == 1) + { + unsigned char c = (unsigned char) p[0]; - if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f) - goto incomplete; - } - if (m == 2) - { - unsigned char c = (unsigned char) p[0]; + if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f) + goto incomplete; + } + if (m == 2) + { + unsigned char c = (unsigned char) p[0]; - if (c == 0x8f) - { - unsigned char c2 = (unsigned char) p[1]; + if (c == 0x8f) + { + unsigned char c2 = (unsigned char) p[1]; - if (c2 >= 0xa1 && c2 < 0xff) - goto incomplete; - } - } - goto invalid; - } - if (STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0) - || STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0) - || STREQ (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0)) - { - if (m == 1) - { - unsigned char c = (unsigned char) p[0]; + if (c2 >= 0xa1 && c2 < 0xff) + goto incomplete; + } + } + goto invalid; + } + if (STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0) + || STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0) + || STREQ (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0)) + { + if (m == 1) + { + unsigned char c = (unsigned char) p[0]; - if (c >= 0xa1 && c < 0xff) - goto incomplete; - } - goto invalid; - } - if (STREQ (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0)) - { - if (m == 1) - { - unsigned char c = (unsigned char) p[0]; + if (c >= 0xa1 && c < 0xff) + goto incomplete; + } + goto invalid; + } + if (STREQ (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0)) + { + if (m == 1) + { + unsigned char c = (unsigned char) p[0]; - if ((c >= 0xa1 && c < 0xff) || c == 0x8e) - goto incomplete; - } - else /* m == 2 || m == 3 */ - { - unsigned char c = (unsigned char) p[0]; + if ((c >= 0xa1 && c < 0xff) || c == 0x8e) + goto incomplete; + } + else /* m == 2 || m == 3 */ + { + unsigned char c = (unsigned char) p[0]; - if (c == 0x8e) - goto incomplete; - } - goto invalid; - } - if (STREQ (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0)) - { - if (m == 1) - { - unsigned char c = (unsigned char) p[0]; + if (c == 0x8e) + goto incomplete; + } + goto invalid; + } + if (STREQ (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0)) + { + if (m == 1) + { + unsigned char c = (unsigned char) p[0]; - if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe)) - goto incomplete; - } - else /* m == 2 || m == 3 */ - { - unsigned char c = (unsigned char) p[0]; + if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe)) + goto incomplete; + } + else /* m == 2 || m == 3 */ + { + unsigned char c = (unsigned char) p[0]; - if (c >= 0x90 && c <= 0xe3) - { - unsigned char c2 = (unsigned char) p[1]; + if (c >= 0x90 && c <= 0xe3) + { + unsigned char c2 = (unsigned char) p[1]; - if (c2 >= 0x30 && c2 <= 0x39) - { - if (m == 2) - goto incomplete; - else /* m == 3 */ - { - unsigned char c3 = (unsigned char) p[2]; + if (c2 >= 0x30 && c2 <= 0x39) + { + if (m == 2) + goto incomplete; + else /* m == 3 */ + { + unsigned char c3 = (unsigned char) p[2]; - if (c3 >= 0x81 && c3 <= 0xfe) - goto incomplete; - } - } - } - } - goto invalid; - } - if (STREQ (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0)) - { - if (m == 1) - { - unsigned char c = (unsigned char) p[0]; + if (c3 >= 0x81 && c3 <= 0xfe) + goto incomplete; + } + } + } + } + goto invalid; + } + if (STREQ (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0)) + { + if (m == 1) + { + unsigned char c = (unsigned char) p[0]; - if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea) - || (c >= 0xf0 && c <= 0xf9)) - goto incomplete; - } - goto invalid; - } + if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea) + || (c >= 0xf0 && c <= 0xf9)) + goto incomplete; + } + goto invalid; + } - /* An unknown multibyte encoding. */ - goto incomplete; + /* An unknown multibyte encoding. */ + goto incomplete; } incomplete: { - size_t k = nstate; - /* Here 0 <= k < m < 4. */ - pstate[++k] = s[0]; - if (k < m) - { - pstate[++k] = s[1]; - if (k < m) - pstate[++k] = s[2]; - } - if (k != m) - abort (); + size_t k = nstate; + /* Here 0 <= k < m < 4. */ + pstate[++k] = s[0]; + if (k < m) + { + pstate[++k] = s[1]; + if (k < m) + pstate[++k] = s[2]; + } + if (k != m) + abort (); } pstate[0] = m; return (size_t)(-2); @@ -341,25 +341,25 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) if (!mbsinit (ps)) { - /* Parse the rest of the multibyte character byte for byte. */ - size_t count = 0; - for (; n > 0; s++, n--) - { - wchar_t wc; - size_t ret = mbrtowc (&wc, s, 1, ps); + /* Parse the rest of the multibyte character byte for byte. */ + size_t count = 0; + for (; n > 0; s++, n--) + { + wchar_t wc; + size_t ret = mbrtowc (&wc, s, 1, ps); - if (ret == (size_t)(-1)) - return (size_t)(-1); - count++; - if (ret != (size_t)(-2)) - { - /* The multibyte character has been completed. */ - if (pwc != NULL) - *pwc = wc; - return (wc == 0 ? 0 : count); - } - } - return (size_t)(-2); + if (ret == (size_t)(-1)) + return (size_t)(-1); + count++; + if (ret != (size_t)(-2)) + { + /* The multibyte character has been completed. */ + if (pwc != NULL) + *pwc = wc; + return (wc == 0 ? 0 : count); + } + } + return (size_t)(-2); } } # endif @@ -371,10 +371,10 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) if (ret != (size_t)(-1) && ret != (size_t)(-2)) { - if (pwc != NULL) - *pwc = wc; - if (wc == 0) - ret = 0; + if (pwc != NULL) + *pwc = wc; + if (wc == 0) + ret = 0; } return ret; } diff --git a/src/bin/coreutils/lib/mbsalign.c b/src/bin/coreutils/lib/mbsalign.c index a0757471d7..be259568d7 100644 --- a/src/bin/coreutils/lib/mbsalign.c +++ b/src/bin/coreutils/lib/mbsalign.c @@ -1,5 +1,5 @@ /* Align/Truncate a string in a given screen width - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -129,7 +129,7 @@ mbs_align_pad (char *dest, const char* dest_end, size_t n_spaces) size_t mbsalign (const char *src, char *dest, size_t dest_size, - size_t *width, mbs_align_t align, int flags) + size_t *width, mbs_align_t align, int flags _UNUSED_PARAMETER_) { size_t ret = -1; size_t src_size = strlen (src) + 1; diff --git a/src/bin/coreutils/lib/mbsalign.h b/src/bin/coreutils/lib/mbsalign.h index 3d92daee1d..a4ec693953 100644 --- a/src/bin/coreutils/lib/mbsalign.h +++ b/src/bin/coreutils/lib/mbsalign.h @@ -1,5 +1,5 @@ /* Align/Truncate a string in a given screen width - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/mbscasecmp.c b/src/bin/coreutils/lib/mbscasecmp.c index 7fdfdeb3d6..ba9feef487 100644 --- a/src/bin/coreutils/lib/mbscasecmp.c +++ b/src/bin/coreutils/lib/mbscasecmp.c @@ -1,5 +1,5 @@ /* Case-insensitive string comparison function. - Copyright (C) 1998-1999, 2005-2008 Free Software Foundation, Inc. + Copyright (C) 1998-1999, 2005-2010 Free Software Foundation, Inc. Written by Bruno Haible , 2005, based on earlier glibc code. @@ -51,21 +51,21 @@ mbscasecmp (const char *s1, const char *s2) mbui_init (iter2, s2); while (mbui_avail (iter1) && mbui_avail (iter2)) - { - int cmp = mb_casecmp (mbui_cur (iter1), mbui_cur (iter2)); + { + int cmp = mb_casecmp (mbui_cur (iter1), mbui_cur (iter2)); - if (cmp != 0) - return cmp; + if (cmp != 0) + return cmp; - mbui_advance (iter1); - mbui_advance (iter2); - } + mbui_advance (iter1); + mbui_advance (iter2); + } if (mbui_avail (iter1)) - /* s2 terminated before s1. */ - return 1; + /* s2 terminated before s1. */ + return 1; if (mbui_avail (iter2)) - /* s1 terminated before s2. */ - return -1; + /* s1 terminated before s2. */ + return -1; return 0; } else @@ -75,24 +75,24 @@ mbscasecmp (const char *s1, const char *s2) unsigned char c1, c2; do - { - c1 = TOLOWER (*p1); - c2 = TOLOWER (*p2); + { + c1 = TOLOWER (*p1); + c2 = TOLOWER (*p2); - if (c1 == '\0') - break; + if (c1 == '\0') + break; - ++p1; - ++p2; - } + ++p1; + ++p2; + } while (c1 == c2); if (UCHAR_MAX <= INT_MAX) - return c1 - c2; + return c1 - c2; else - /* On machines where 'char' and 'int' are types of the same size, the - difference of two 'unsigned char' values - including the sign bit - - doesn't fit in an 'int'. */ - return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0); + /* On machines where 'char' and 'int' are types of the same size, the + difference of two 'unsigned char' values - including the sign bit - + doesn't fit in an 'int'. */ + return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0); } } diff --git a/src/bin/coreutils/lib/mbsinit.c b/src/bin/coreutils/lib/mbsinit.c index 81fed5a12b..066ddfe5bf 100644 --- a/src/bin/coreutils/lib/mbsinit.c +++ b/src/bin/coreutils/lib/mbsinit.c @@ -1,5 +1,5 @@ /* Test for initial conversion state. - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. Written by Bruno Haible , 2008. This program is free software: you can redistribute it and/or modify diff --git a/src/bin/coreutils/lib/mbslen.c b/src/bin/coreutils/lib/mbslen.c index 2dd6ea8bb6..5ccede643a 100644 --- a/src/bin/coreutils/lib/mbslen.c +++ b/src/bin/coreutils/lib/mbslen.c @@ -1,5 +1,5 @@ /* Counting the multibyte characters in a string. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. Written by Bruno Haible , 2007. This program is free software: you can redistribute it and/or modify @@ -35,7 +35,7 @@ mbslen (const char *string) count = 0; for (mbui_init (iter, string); mbui_avail (iter); mbui_advance (iter)) - count++; + count++; return count; } diff --git a/src/bin/coreutils/lib/mbsrtowcs-state.c b/src/bin/coreutils/lib/mbsrtowcs-state.c index 89011183fd..35045f6574 100644 --- a/src/bin/coreutils/lib/mbsrtowcs-state.c +++ b/src/bin/coreutils/lib/mbsrtowcs-state.c @@ -1,5 +1,5 @@ /* Convert string to wide string. - Copyright (C) 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. Written by Bruno Haible , 2008. This program is free software: you can redistribute it and/or modify diff --git a/src/bin/coreutils/lib/mbsrtowcs.c b/src/bin/coreutils/lib/mbsrtowcs.c index ea6a018721..c577f36f2a 100644 --- a/src/bin/coreutils/lib/mbsrtowcs.c +++ b/src/bin/coreutils/lib/mbsrtowcs.c @@ -1,5 +1,5 @@ /* Convert string to wide string. - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. Written by Bruno Haible , 2008. This program is free software: you can redistribute it and/or modify @@ -39,92 +39,92 @@ mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps) if (dest != NULL) { - wchar_t *destptr = dest; + wchar_t *destptr = dest; - for (; len > 0; destptr++, len--) - { - size_t src_avail; - size_t ret; + for (; len > 0; destptr++, len--) + { + size_t src_avail; + size_t ret; - /* An optimized variant of - src_avail = strnlen1 (src, MB_LEN_MAX); */ - if (src[0] == '\0') - src_avail = 1; - else if (src[1] == '\0') - src_avail = 2; - else if (src[2] == '\0') - src_avail = 3; - else if (MB_LEN_MAX <= 4 || src[3] == '\0') - src_avail = 4; - else - src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4); + /* An optimized variant of + src_avail = strnlen1 (src, MB_LEN_MAX); */ + if (src[0] == '\0') + src_avail = 1; + else if (src[1] == '\0') + src_avail = 2; + else if (src[2] == '\0') + src_avail = 3; + else if (MB_LEN_MAX <= 4 || src[3] == '\0') + src_avail = 4; + else + src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4); - /* Parse the next multibyte character. */ - ret = mbrtowc (destptr, src, src_avail, ps); + /* Parse the next multibyte character. */ + ret = mbrtowc (destptr, src, src_avail, ps); - if (ret == (size_t)(-2)) - /* Encountered a multibyte character that extends past a '\0' byte - or that is longer than MB_LEN_MAX bytes. Cannot happen. */ - abort (); + if (ret == (size_t)(-2)) + /* Encountered a multibyte character that extends past a '\0' byte + or that is longer than MB_LEN_MAX bytes. Cannot happen. */ + abort (); - if (ret == (size_t)(-1)) - goto bad_input; - if (ret == 0) - { - src = NULL; - /* Here mbsinit (ps). */ - break; - } - src += ret; - } + if (ret == (size_t)(-1)) + goto bad_input; + if (ret == 0) + { + src = NULL; + /* Here mbsinit (ps). */ + break; + } + src += ret; + } - *srcp = src; - return destptr - dest; + *srcp = src; + return destptr - dest; } else { - /* Ignore dest and len, don't store *srcp at the end, and - don't clobber *ps. */ - mbstate_t state = *ps; - size_t totalcount = 0; + /* Ignore dest and len, don't store *srcp at the end, and + don't clobber *ps. */ + mbstate_t state = *ps; + size_t totalcount = 0; - for (;; totalcount++) - { - size_t src_avail; - size_t ret; + for (;; totalcount++) + { + size_t src_avail; + size_t ret; - /* An optimized variant of - src_avail = strnlen1 (src, MB_LEN_MAX); */ - if (src[0] == '\0') - src_avail = 1; - else if (src[1] == '\0') - src_avail = 2; - else if (src[2] == '\0') - src_avail = 3; - else if (MB_LEN_MAX <= 4 || src[3] == '\0') - src_avail = 4; - else - src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4); + /* An optimized variant of + src_avail = strnlen1 (src, MB_LEN_MAX); */ + if (src[0] == '\0') + src_avail = 1; + else if (src[1] == '\0') + src_avail = 2; + else if (src[2] == '\0') + src_avail = 3; + else if (MB_LEN_MAX <= 4 || src[3] == '\0') + src_avail = 4; + else + src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4); - /* Parse the next multibyte character. */ - ret = mbrtowc (NULL, src, src_avail, &state); + /* Parse the next multibyte character. */ + ret = mbrtowc (NULL, src, src_avail, &state); - if (ret == (size_t)(-2)) - /* Encountered a multibyte character that extends past a '\0' byte - or that is longer than MB_LEN_MAX bytes. Cannot happen. */ - abort (); + if (ret == (size_t)(-2)) + /* Encountered a multibyte character that extends past a '\0' byte + or that is longer than MB_LEN_MAX bytes. Cannot happen. */ + abort (); - if (ret == (size_t)(-1)) - goto bad_input2; - if (ret == 0) - { - /* Here mbsinit (&state). */ - break; - } - src += ret; - } + if (ret == (size_t)(-1)) + goto bad_input2; + if (ret == 0) + { + /* Here mbsinit (&state). */ + break; + } + src += ret; + } - return totalcount; + return totalcount; } bad_input: diff --git a/src/bin/coreutils/lib/mbsstr.c b/src/bin/coreutils/lib/mbsstr.c index c84946b630..d44b4c3d4a 100644 --- a/src/bin/coreutils/lib/mbsstr.c +++ b/src/bin/coreutils/lib/mbsstr.c @@ -1,5 +1,5 @@ /* Searching in a string. - Copyright (C) 2005-2008 Free Software Foundation, Inc. + Copyright (C) 2005-2010 Free Software Foundation, Inc. Written by Bruno Haible , 2005. This program is free software: you can redistribute it and/or modify @@ -37,7 +37,7 @@ Return false if it was aborted because not enough memory was available. */ static bool knuth_morris_pratt_multibyte (const char *haystack, const char *needle, - const char **resultp) + const char **resultp) { size_t m = mbslen (needle); mbchar_t *needle_mbchars; @@ -84,46 +84,46 @@ knuth_morris_pratt_multibyte (const char *haystack, const char *needle, for (i = 2; i < m; i++) { - /* Here: j = i-1 - table[i-1]. - The inequality needle[x..i-1] != needle[0..i-1-x] is known to hold - for x < table[i-1], by induction. - Furthermore, if j>0: needle[i-1-j..i-2] = needle[0..j-1]. */ - mbchar_t *b = &needle_mbchars[i - 1]; + /* Here: j = i-1 - table[i-1]. + The inequality needle[x..i-1] != needle[0..i-1-x] is known to hold + for x < table[i-1], by induction. + Furthermore, if j>0: needle[i-1-j..i-2] = needle[0..j-1]. */ + mbchar_t *b = &needle_mbchars[i - 1]; - for (;;) - { - /* Invariants: The inequality needle[x..i-1] != needle[0..i-1-x] - is known to hold for x < i-1-j. - Furthermore, if j>0: needle[i-1-j..i-2] = needle[0..j-1]. */ - if (mb_equal (*b, needle_mbchars[j])) - { - /* Set table[i] := i-1-j. */ - table[i] = i - ++j; - break; - } - /* The inequality needle[x..i-1] != needle[0..i-1-x] also holds - for x = i-1-j, because - needle[i-1] != needle[j] = needle[i-1-x]. */ - if (j == 0) - { - /* The inequality holds for all possible x. */ - table[i] = i; - break; - } - /* The inequality needle[x..i-1] != needle[0..i-1-x] also holds - for i-1-j < x < i-1-j+table[j], because for these x: - needle[x..i-2] - = needle[x-(i-1-j)..j-1] - != needle[0..j-1-(x-(i-1-j))] (by definition of table[j]) - = needle[0..i-2-x], - hence needle[x..i-1] != needle[0..i-1-x]. - Furthermore - needle[i-1-j+table[j]..i-2] - = needle[table[j]..j-1] - = needle[0..j-1-table[j]] (by definition of table[j]). */ - j = j - table[j]; - } - /* Here: j = i - table[i]. */ + for (;;) + { + /* Invariants: The inequality needle[x..i-1] != needle[0..i-1-x] + is known to hold for x < i-1-j. + Furthermore, if j>0: needle[i-1-j..i-2] = needle[0..j-1]. */ + if (mb_equal (*b, needle_mbchars[j])) + { + /* Set table[i] := i-1-j. */ + table[i] = i - ++j; + break; + } + /* The inequality needle[x..i-1] != needle[0..i-1-x] also holds + for x = i-1-j, because + needle[i-1] != needle[j] = needle[i-1-x]. */ + if (j == 0) + { + /* The inequality holds for all possible x. */ + table[i] = i; + break; + } + /* The inequality needle[x..i-1] != needle[0..i-1-x] also holds + for i-1-j < x < i-1-j+table[j], because for these x: + needle[x..i-2] + = needle[x-(i-1-j)..j-1] + != needle[0..j-1-(x-(i-1-j))] (by definition of table[j]) + = needle[0..i-2-x], + hence needle[x..i-1] != needle[0..i-1-x]. + Furthermore + needle[i-1-j+table[j]..i-2] + = needle[table[j]..j-1] + = needle[0..j-1-table[j]] (by definition of table[j]). */ + j = j - table[j]; + } + /* Here: j = i - table[i]. */ } } @@ -140,36 +140,36 @@ knuth_morris_pratt_multibyte (const char *haystack, const char *needle, /* Invariant: phaystack = rhaystack + j. */ while (mbui_avail (phaystack)) if (mb_equal (needle_mbchars[j], mbui_cur (phaystack))) - { - j++; - mbui_advance (phaystack); - if (j == m) - { - /* The entire needle has been found. */ - *resultp = mbui_cur_ptr (rhaystack); - break; - } - } + { + j++; + mbui_advance (phaystack); + if (j == m) + { + /* The entire needle has been found. */ + *resultp = mbui_cur_ptr (rhaystack); + break; + } + } else if (j > 0) - { - /* Found a match of needle[0..j-1], mismatch at needle[j]. */ - size_t count = table[j]; - j -= count; - for (; count > 0; count--) - { - if (!mbui_avail (rhaystack)) - abort (); - mbui_advance (rhaystack); - } - } + { + /* Found a match of needle[0..j-1], mismatch at needle[j]. */ + size_t count = table[j]; + j -= count; + for (; count > 0; count--) + { + if (!mbui_avail (rhaystack)) + abort (); + mbui_advance (rhaystack); + } + } else - { - /* Found a mismatch at needle[0] already. */ - if (!mbui_avail (rhaystack)) - abort (); - mbui_advance (rhaystack); - mbui_advance (phaystack); - } + { + /* Found a mismatch at needle[0] already. */ + if (!mbui_avail (rhaystack)) + abort (); + mbui_advance (rhaystack); + mbui_advance (phaystack); + } } freea (memory); @@ -192,188 +192,188 @@ mbsstr (const char *haystack, const char *needle) mbui_init (iter_needle, needle); if (mbui_avail (iter_needle)) - { - /* Minimizing the worst-case complexity: - Let n = mbslen(haystack), m = mbslen(needle). - The naïve algorithm is O(n*m) worst-case. - The Knuth-Morris-Pratt algorithm is O(n) worst-case but it needs a - memory allocation. - To achieve linear complexity and yet amortize the cost of the - memory allocation, we activate the Knuth-Morris-Pratt algorithm - only once the naïve algorithm has already run for some time; more - precisely, when - - the outer loop count is >= 10, - - the average number of comparisons per outer loop is >= 5, - - the total number of comparisons is >= m. - But we try it only once. If the memory allocation attempt failed, - we don't retry it. */ - bool try_kmp = true; - size_t outer_loop_count = 0; - size_t comparison_count = 0; - size_t last_ccount = 0; /* last comparison count */ - mbui_iterator_t iter_needle_last_ccount; /* = needle + last_ccount */ + { + /* Minimizing the worst-case complexity: + Let n = mbslen(haystack), m = mbslen(needle). + The naïve algorithm is O(n*m) worst-case. + The Knuth-Morris-Pratt algorithm is O(n) worst-case but it needs a + memory allocation. + To achieve linear complexity and yet amortize the cost of the + memory allocation, we activate the Knuth-Morris-Pratt algorithm + only once the naïve algorithm has already run for some time; more + precisely, when + - the outer loop count is >= 10, + - the average number of comparisons per outer loop is >= 5, + - the total number of comparisons is >= m. + But we try it only once. If the memory allocation attempt failed, + we don't retry it. */ + bool try_kmp = true; + size_t outer_loop_count = 0; + size_t comparison_count = 0; + size_t last_ccount = 0; /* last comparison count */ + mbui_iterator_t iter_needle_last_ccount; /* = needle + last_ccount */ - mbui_iterator_t iter_haystack; + mbui_iterator_t iter_haystack; - mbui_init (iter_needle_last_ccount, needle); - mbui_init (iter_haystack, haystack); - for (;; mbui_advance (iter_haystack)) - { - if (!mbui_avail (iter_haystack)) - /* No match. */ - return NULL; + mbui_init (iter_needle_last_ccount, needle); + mbui_init (iter_haystack, haystack); + for (;; mbui_advance (iter_haystack)) + { + if (!mbui_avail (iter_haystack)) + /* No match. */ + return NULL; - /* See whether it's advisable to use an asymptotically faster - algorithm. */ - if (try_kmp - && outer_loop_count >= 10 - && comparison_count >= 5 * outer_loop_count) - { - /* See if needle + comparison_count now reaches the end of - needle. */ - size_t count = comparison_count - last_ccount; - for (; - count > 0 && mbui_avail (iter_needle_last_ccount); - count--) - mbui_advance (iter_needle_last_ccount); - last_ccount = comparison_count; - if (!mbui_avail (iter_needle_last_ccount)) - { - /* Try the Knuth-Morris-Pratt algorithm. */ - const char *result; - bool success = - knuth_morris_pratt_multibyte (haystack, needle, - &result); - if (success) - return (char *) result; - try_kmp = false; - } - } + /* See whether it's advisable to use an asymptotically faster + algorithm. */ + if (try_kmp + && outer_loop_count >= 10 + && comparison_count >= 5 * outer_loop_count) + { + /* See if needle + comparison_count now reaches the end of + needle. */ + size_t count = comparison_count - last_ccount; + for (; + count > 0 && mbui_avail (iter_needle_last_ccount); + count--) + mbui_advance (iter_needle_last_ccount); + last_ccount = comparison_count; + if (!mbui_avail (iter_needle_last_ccount)) + { + /* Try the Knuth-Morris-Pratt algorithm. */ + const char *result; + bool success = + knuth_morris_pratt_multibyte (haystack, needle, + &result); + if (success) + return (char *) result; + try_kmp = false; + } + } - outer_loop_count++; - comparison_count++; - if (mb_equal (mbui_cur (iter_haystack), mbui_cur (iter_needle))) - /* The first character matches. */ - { - mbui_iterator_t rhaystack; - mbui_iterator_t rneedle; + outer_loop_count++; + comparison_count++; + if (mb_equal (mbui_cur (iter_haystack), mbui_cur (iter_needle))) + /* The first character matches. */ + { + mbui_iterator_t rhaystack; + mbui_iterator_t rneedle; - memcpy (&rhaystack, &iter_haystack, sizeof (mbui_iterator_t)); - mbui_advance (rhaystack); + memcpy (&rhaystack, &iter_haystack, sizeof (mbui_iterator_t)); + mbui_advance (rhaystack); - mbui_init (rneedle, needle); - if (!mbui_avail (rneedle)) - abort (); - mbui_advance (rneedle); + mbui_init (rneedle, needle); + if (!mbui_avail (rneedle)) + abort (); + mbui_advance (rneedle); - for (;; mbui_advance (rhaystack), mbui_advance (rneedle)) - { - if (!mbui_avail (rneedle)) - /* Found a match. */ - return (char *) mbui_cur_ptr (iter_haystack); - if (!mbui_avail (rhaystack)) - /* No match. */ - return NULL; - comparison_count++; - if (!mb_equal (mbui_cur (rhaystack), mbui_cur (rneedle))) - /* Nothing in this round. */ - break; - } - } - } - } + for (;; mbui_advance (rhaystack), mbui_advance (rneedle)) + { + if (!mbui_avail (rneedle)) + /* Found a match. */ + return (char *) mbui_cur_ptr (iter_haystack); + if (!mbui_avail (rhaystack)) + /* No match. */ + return NULL; + comparison_count++; + if (!mb_equal (mbui_cur (rhaystack), mbui_cur (rneedle))) + /* Nothing in this round. */ + break; + } + } + } + } else - return (char *) haystack; + return (char *) haystack; } else { if (*needle != '\0') - { - /* Minimizing the worst-case complexity: - Let n = strlen(haystack), m = strlen(needle). - The naïve algorithm is O(n*m) worst-case. - The Knuth-Morris-Pratt algorithm is O(n) worst-case but it needs a - memory allocation. - To achieve linear complexity and yet amortize the cost of the - memory allocation, we activate the Knuth-Morris-Pratt algorithm - only once the naïve algorithm has already run for some time; more - precisely, when - - the outer loop count is >= 10, - - the average number of comparisons per outer loop is >= 5, - - the total number of comparisons is >= m. - But we try it only once. If the memory allocation attempt failed, - we don't retry it. */ - bool try_kmp = true; - size_t outer_loop_count = 0; - size_t comparison_count = 0; - size_t last_ccount = 0; /* last comparison count */ - const char *needle_last_ccount = needle; /* = needle + last_ccount */ + { + /* Minimizing the worst-case complexity: + Let n = strlen(haystack), m = strlen(needle). + The naïve algorithm is O(n*m) worst-case. + The Knuth-Morris-Pratt algorithm is O(n) worst-case but it needs a + memory allocation. + To achieve linear complexity and yet amortize the cost of the + memory allocation, we activate the Knuth-Morris-Pratt algorithm + only once the naïve algorithm has already run for some time; more + precisely, when + - the outer loop count is >= 10, + - the average number of comparisons per outer loop is >= 5, + - the total number of comparisons is >= m. + But we try it only once. If the memory allocation attempt failed, + we don't retry it. */ + bool try_kmp = true; + size_t outer_loop_count = 0; + size_t comparison_count = 0; + size_t last_ccount = 0; /* last comparison count */ + const char *needle_last_ccount = needle; /* = needle + last_ccount */ - /* Speed up the following searches of needle by caching its first - character. */ - char b = *needle++; + /* Speed up the following searches of needle by caching its first + character. */ + char b = *needle++; - for (;; haystack++) - { - if (*haystack == '\0') - /* No match. */ - return NULL; + for (;; haystack++) + { + if (*haystack == '\0') + /* No match. */ + return NULL; - /* See whether it's advisable to use an asymptotically faster - algorithm. */ - if (try_kmp - && outer_loop_count >= 10 - && comparison_count >= 5 * outer_loop_count) - { - /* See if needle + comparison_count now reaches the end of - needle. */ - if (needle_last_ccount != NULL) - { - needle_last_ccount += - strnlen (needle_last_ccount, - comparison_count - last_ccount); - if (*needle_last_ccount == '\0') - needle_last_ccount = NULL; - last_ccount = comparison_count; - } - if (needle_last_ccount == NULL) - { - /* Try the Knuth-Morris-Pratt algorithm. */ - const char *result; - bool success = - knuth_morris_pratt_unibyte (haystack, needle - 1, - &result); - if (success) - return (char *) result; - try_kmp = false; - } - } + /* See whether it's advisable to use an asymptotically faster + algorithm. */ + if (try_kmp + && outer_loop_count >= 10 + && comparison_count >= 5 * outer_loop_count) + { + /* See if needle + comparison_count now reaches the end of + needle. */ + if (needle_last_ccount != NULL) + { + needle_last_ccount += + strnlen (needle_last_ccount, + comparison_count - last_ccount); + if (*needle_last_ccount == '\0') + needle_last_ccount = NULL; + last_ccount = comparison_count; + } + if (needle_last_ccount == NULL) + { + /* Try the Knuth-Morris-Pratt algorithm. */ + const char *result; + bool success = + knuth_morris_pratt_unibyte (haystack, needle - 1, + &result); + if (success) + return (char *) result; + try_kmp = false; + } + } - outer_loop_count++; - comparison_count++; - if (*haystack == b) - /* The first character matches. */ - { - const char *rhaystack = haystack + 1; - const char *rneedle = needle; + outer_loop_count++; + comparison_count++; + if (*haystack == b) + /* The first character matches. */ + { + const char *rhaystack = haystack + 1; + const char *rneedle = needle; - for (;; rhaystack++, rneedle++) - { - if (*rneedle == '\0') - /* Found a match. */ - return (char *) haystack; - if (*rhaystack == '\0') - /* No match. */ - return NULL; - comparison_count++; - if (*rhaystack != *rneedle) - /* Nothing in this round. */ - break; - } - } - } - } + for (;; rhaystack++, rneedle++) + { + if (*rneedle == '\0') + /* Found a match. */ + return (char *) haystack; + if (*rhaystack == '\0') + /* No match. */ + return NULL; + comparison_count++; + if (*rhaystack != *rneedle) + /* Nothing in this round. */ + break; + } + } + } + } else - return (char *) haystack; + return (char *) haystack; } } diff --git a/src/bin/coreutils/lib/mbswidth.c b/src/bin/coreutils/lib/mbswidth.c index 0f380a9dcc..caf0c4d125 100644 --- a/src/bin/coreutils/lib/mbswidth.c +++ b/src/bin/coreutils/lib/mbswidth.c @@ -1,5 +1,5 @@ /* Determine the number of screen columns needed for a string. - Copyright (C) 2000-2008 Free Software Foundation, Inc. + Copyright (C) 2000-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -63,92 +63,92 @@ mbsnwidth (const char *string, size_t nbytes, int flags) if (MB_CUR_MAX > 1) { while (p < plimit) - switch (*p) - { - case ' ': case '!': case '"': case '#': case '%': - case '&': case '\'': case '(': case ')': case '*': - case '+': case ',': case '-': case '.': case '/': - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - case ':': case ';': case '<': case '=': case '>': - case '?': - case 'A': case 'B': case 'C': case 'D': case 'E': - case 'F': case 'G': case 'H': case 'I': case 'J': - case 'K': case 'L': case 'M': case 'N': case 'O': - case 'P': case 'Q': case 'R': case 'S': case 'T': - case 'U': case 'V': case 'W': case 'X': case 'Y': - case 'Z': - case '[': case '\\': case ']': case '^': case '_': - case 'a': case 'b': case 'c': case 'd': case 'e': - case 'f': case 'g': case 'h': case 'i': case 'j': - case 'k': case 'l': case 'm': case 'n': case 'o': - case 'p': case 'q': case 'r': case 's': case 't': - case 'u': case 'v': case 'w': case 'x': case 'y': - case 'z': case '{': case '|': case '}': case '~': - /* These characters are printable ASCII characters. */ - p++; - width++; - break; - default: - /* If we have a multibyte sequence, scan it up to its end. */ - { - mbstate_t mbstate; - memset (&mbstate, 0, sizeof mbstate); - do - { - wchar_t wc; - size_t bytes; - int w; + switch (*p) + { + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '[': case '\\': case ']': case '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': case '{': case '|': case '}': case '~': + /* These characters are printable ASCII characters. */ + p++; + width++; + break; + default: + /* If we have a multibyte sequence, scan it up to its end. */ + { + mbstate_t mbstate; + memset (&mbstate, 0, sizeof mbstate); + do + { + wchar_t wc; + size_t bytes; + int w; - bytes = mbrtowc (&wc, p, plimit - p, &mbstate); + bytes = mbrtowc (&wc, p, plimit - p, &mbstate); - if (bytes == (size_t) -1) - /* An invalid multibyte sequence was encountered. */ - { - if (!(flags & MBSW_REJECT_INVALID)) - { - p++; - width++; - break; - } - else - return -1; - } + if (bytes == (size_t) -1) + /* An invalid multibyte sequence was encountered. */ + { + if (!(flags & MBSW_REJECT_INVALID)) + { + p++; + width++; + break; + } + else + return -1; + } - if (bytes == (size_t) -2) - /* An incomplete multibyte character at the end. */ - { - if (!(flags & MBSW_REJECT_INVALID)) - { - p = plimit; - width++; - break; - } - else - return -1; - } + if (bytes == (size_t) -2) + /* An incomplete multibyte character at the end. */ + { + if (!(flags & MBSW_REJECT_INVALID)) + { + p = plimit; + width++; + break; + } + else + return -1; + } - if (bytes == 0) - /* A null wide character was encountered. */ - bytes = 1; + if (bytes == 0) + /* A null wide character was encountered. */ + bytes = 1; - w = wcwidth (wc); - if (w >= 0) - /* A printable multibyte character. */ - width += w; - else - /* An unprintable multibyte character. */ - if (!(flags & MBSW_REJECT_UNPRINTABLE)) - width += (iswcntrl (wc) ? 0 : 1); - else - return -1; + w = wcwidth (wc); + if (w >= 0) + /* A printable multibyte character. */ + width += w; + else + /* An unprintable multibyte character. */ + if (!(flags & MBSW_REJECT_UNPRINTABLE)) + width += (iswcntrl (wc) ? 0 : 1); + else + return -1; - p += bytes; - } - while (! mbsinit (&mbstate)); - } - break; - } + p += bytes; + } + while (! mbsinit (&mbstate)); + } + break; + } return width; } @@ -157,11 +157,11 @@ mbsnwidth (const char *string, size_t nbytes, int flags) unsigned char c = (unsigned char) *p++; if (isprint (c)) - width++; + width++; else if (!(flags & MBSW_REJECT_UNPRINTABLE)) - width += (iscntrl (c) ? 0 : 1); + width += (iscntrl (c) ? 0 : 1); else - return -1; + return -1; } return width; } diff --git a/src/bin/coreutils/lib/mbswidth.h b/src/bin/coreutils/lib/mbswidth.h index 15da406dce..0383b232c9 100644 --- a/src/bin/coreutils/lib/mbswidth.h +++ b/src/bin/coreutils/lib/mbswidth.h @@ -1,5 +1,5 @@ /* Determine the number of screen columns needed for a string. - Copyright (C) 2000-2004, 2007 Free Software Foundation, Inc. + Copyright (C) 2000-2004, 2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -43,7 +43,7 @@ extern "C" { /* If this bit is set, return -1 upon finding a non-printable character. Otherwise, assume unprintable characters have width 0 if they are control characters and 1 otherwise. */ -#define MBSW_REJECT_UNPRINTABLE 2 +#define MBSW_REJECT_UNPRINTABLE 2 /* Returns the number of screen columns needed for STRING. */ diff --git a/src/bin/coreutils/lib/mbuiter.h b/src/bin/coreutils/lib/mbuiter.h index 213e710307..3015c4efe9 100644 --- a/src/bin/coreutils/lib/mbuiter.h +++ b/src/bin/coreutils/lib/mbuiter.h @@ -1,5 +1,5 @@ /* Iterating through multibyte strings: macros for multi-byte encodings. - Copyright (C) 2001, 2005, 2007 Free Software Foundation, Inc. + Copyright (C) 2001, 2005, 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -77,13 +77,13 @@ Here are the function prototypes of the macros. - extern void mbui_init (mbui_iterator_t iter, const char *startptr); - extern bool mbui_avail (mbui_iterator_t iter); - extern void mbui_advance (mbui_iterator_t iter); - extern mbchar_t mbui_cur (mbui_iterator_t iter); - extern const char * mbui_cur_ptr (mbui_iterator_t iter); - extern void mbui_reloc (mbui_iterator_t iter, ptrdiff_t ptrdiff); - extern void mbui_copy (mbui_iterator_t *new, const mbui_iterator_t *old); + extern void mbui_init (mbui_iterator_t iter, const char *startptr); + extern bool mbui_avail (mbui_iterator_t iter); + extern void mbui_advance (mbui_iterator_t iter); + extern mbchar_t mbui_cur (mbui_iterator_t iter); + extern const char * mbui_cur_ptr (mbui_iterator_t iter); + extern void mbui_reloc (mbui_iterator_t iter, ptrdiff_t ptrdiff); + extern void mbui_copy (mbui_iterator_t *new, const mbui_iterator_t *old); */ #ifndef _MBUITER_H @@ -108,16 +108,16 @@ struct mbuiter_multi { - bool in_shift; /* true if next byte may not be interpreted as ASCII */ - mbstate_t state; /* if in_shift: current shift state */ - bool next_done; /* true if mbui_avail has already filled the following */ - struct mbchar cur; /* the current character: - const char *cur.ptr pointer to current character - The following are only valid after mbui_avail. - size_t cur.bytes number of bytes of current character - bool cur.wc_valid true if wc is a valid wide character - wchar_t cur.wc if wc_valid: the current character - */ + bool in_shift; /* true if next byte may not be interpreted as ASCII */ + mbstate_t state; /* if in_shift: current shift state */ + bool next_done; /* true if mbui_avail has already filled the following */ + struct mbchar cur; /* the current character: + const char *cur.ptr pointer to current character + The following are only valid after mbui_avail. + size_t cur.bytes number of bytes of current character + bool cur.wc_valid true if wc is a valid wide character + wchar_t cur.wc if wc_valid: the current character + */ }; static inline void @@ -131,8 +131,8 @@ mbuiter_multi_next (struct mbuiter_multi *iter) if (is_basic (*iter->cur.ptr)) { /* These characters are part of the basic character set. ISO C 99 - guarantees that their wide character code is identical to their - char code. */ + guarantees that their wide character code is identical to their + char code. */ iter->cur.bytes = 1; iter->cur.wc = *iter->cur.ptr; iter->cur.wc_valid = true; @@ -143,40 +143,40 @@ mbuiter_multi_next (struct mbuiter_multi *iter) iter->in_shift = true; with_shift: iter->cur.bytes = mbrtowc (&iter->cur.wc, iter->cur.ptr, - strnlen1 (iter->cur.ptr, MB_CUR_MAX), - &iter->state); + strnlen1 (iter->cur.ptr, MB_CUR_MAX), + &iter->state); if (iter->cur.bytes == (size_t) -1) - { - /* An invalid multibyte sequence was encountered. */ - iter->cur.bytes = 1; - iter->cur.wc_valid = false; - /* Whether to set iter->in_shift = false and reset iter->state - or not is not very important; the string is bogus anyway. */ - } + { + /* An invalid multibyte sequence was encountered. */ + iter->cur.bytes = 1; + iter->cur.wc_valid = false; + /* Whether to set iter->in_shift = false and reset iter->state + or not is not very important; the string is bogus anyway. */ + } else if (iter->cur.bytes == (size_t) -2) - { - /* An incomplete multibyte character at the end. */ - iter->cur.bytes = strlen (iter->cur.ptr); - iter->cur.wc_valid = false; - /* Whether to set iter->in_shift = false and reset iter->state - or not is not important; the string end is reached anyway. */ - } + { + /* An incomplete multibyte character at the end. */ + iter->cur.bytes = strlen (iter->cur.ptr); + iter->cur.wc_valid = false; + /* Whether to set iter->in_shift = false and reset iter->state + or not is not important; the string end is reached anyway. */ + } else - { - if (iter->cur.bytes == 0) - { - /* A null wide character was encountered. */ - iter->cur.bytes = 1; - assert (*iter->cur.ptr == '\0'); - assert (iter->cur.wc == 0); - } - iter->cur.wc_valid = true; + { + if (iter->cur.bytes == 0) + { + /* A null wide character was encountered. */ + iter->cur.bytes = 1; + assert (*iter->cur.ptr == '\0'); + assert (iter->cur.wc == 0); + } + iter->cur.wc_valid = true; - /* When in the initial state, we can go back treating ASCII - characters more quickly. */ - if (mbsinit (&iter->state)) - iter->in_shift = false; - } + /* When in the initial state, we can go back treating ASCII + characters more quickly. */ + if (mbsinit (&iter->state)) + iter->in_shift = false; + } } iter->next_done = true; } diff --git a/src/bin/coreutils/lib/md5.c b/src/bin/coreutils/lib/md5.c index 1e5f3c6346..ba2d9f8e7a 100644 --- a/src/bin/coreutils/lib/md5.c +++ b/src/bin/coreutils/lib/md5.c @@ -3,8 +3,8 @@ #line 1 /* Functions to compute MD5 message digest of files or memory blocks. according to the definition of MD5 in RFC 1321 from April 1992. - Copyright (C) 1995,1996,1997,1999,2000,2001,2005,2006,2008 - Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1999, 2000, 2001, 2005, 2006, 2008, 2009, + 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software; you can redistribute it and/or modify it @@ -53,13 +53,13 @@ #endif #ifdef WORDS_BIGENDIAN -# define SWAP(n) \ +# define SWAP(n) \ (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24)) #else # define SWAP(n) (n) #endif -#define BLOCKSIZE 4096 +#define BLOCKSIZE 32768 #if BLOCKSIZE % 64 != 0 # error "invalid BLOCKSIZE" #endif @@ -139,9 +139,12 @@ int md5_stream (FILE *stream, void *resblock) { struct md5_ctx ctx; - char buffer[BLOCKSIZE + 72]; size_t sum; + char *buffer = malloc (BLOCKSIZE + 72); + if (!buffer) + return 1; + /* Initialize the computation context. */ md5_init_ctx (&ctx); @@ -156,30 +159,33 @@ md5_stream (FILE *stream, void *resblock) /* Read block. Take care for partial reads. */ while (1) - { - n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); + { + n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); - sum += n; + sum += n; - if (sum == BLOCKSIZE) - break; + if (sum == BLOCKSIZE) + break; - if (n == 0) - { - /* Check for the error flag IFF N == 0, so that we don't - exit the loop after a partial read due to e.g., EAGAIN - or EWOULDBLOCK. */ - if (ferror (stream)) - return 1; - goto process_partial_block; - } + if (n == 0) + { + /* Check for the error flag IFF N == 0, so that we don't + exit the loop after a partial read due to e.g., EAGAIN + or EWOULDBLOCK. */ + if (ferror (stream)) + { + free (buffer); + return 1; + } + goto process_partial_block; + } - /* We've read at least one byte, so ignore errors. But always - check for EOF, since feof may be true even though N > 0. - Otherwise, we could end up calling fread after EOF. */ - if (feof (stream)) - goto process_partial_block; - } + /* We've read at least one byte, so ignore errors. But always + check for EOF, since feof may be true even though N > 0. + Otherwise, we could end up calling fread after EOF. */ + if (feof (stream)) + goto process_partial_block; + } /* Process buffer with BLOCKSIZE bytes. Note that BLOCKSIZE % 64 == 0 @@ -195,6 +201,7 @@ process_partial_block: /* Construct result in desired memory. */ md5_finish_ctx (&ctx, resblock); + free (buffer); return 0; } @@ -232,15 +239,15 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) ctx->buflen += add; if (ctx->buflen > 64) - { - md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx); + { + md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx); - ctx->buflen &= 63; - /* The regions in the following copy operation cannot overlap. */ - memcpy (ctx->buffer, - &((char *) ctx->buffer)[(left_over + add) & ~63], - ctx->buflen); - } + ctx->buflen &= 63; + /* The regions in the following copy operation cannot overlap. */ + memcpy (ctx->buffer, + &((char *) ctx->buffer)[(left_over + add) & ~63], + ctx->buflen); + } buffer = (const char *) buffer + add; len -= add; @@ -253,19 +260,19 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) # define alignof(type) offsetof (struct { char c; type x; }, x) # define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) if (UNALIGNED_P (buffer)) - while (len > 64) - { - md5_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); - buffer = (const char *) buffer + 64; - len -= 64; - } + while (len > 64) + { + md5_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); + buffer = (const char *) buffer + 64; + len -= 64; + } else #endif - { - md5_process_block (buffer, len & ~63, ctx); - buffer = (const char *) buffer + (len & ~63); - len &= 63; - } + { + md5_process_block (buffer, len & ~63, ctx); + buffer = (const char *) buffer + (len & ~63); + len &= 63; + } } /* Move remaining bytes in internal buffer. */ @@ -276,11 +283,11 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) memcpy (&((char *) ctx->buffer)[left_over], buffer, len); left_over += len; if (left_over >= 64) - { - md5_process_block (ctx->buffer, 64, ctx); - left_over -= 64; - memcpy (ctx->buffer, &ctx->buffer[16], left_over); - } + { + md5_process_block (ctx->buffer, 64, ctx); + left_over -= 64; + memcpy (ctx->buffer, &ctx->buffer[16], left_over); + } ctx->buflen = left_over; } } @@ -334,14 +341,14 @@ md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) before the computation. To reduce the work for the next steps we store the swapped words in the array CORRECT_WORDS. */ -#define OP(a, b, c, d, s, T) \ - do \ - { \ - a += FF (b, c, d) + (*cwp++ = SWAP (*words)) + T; \ - ++words; \ - CYCLIC (a, s); \ - a += b; \ - } \ +#define OP(a, b, c, d, s, T) \ + do \ + { \ + a += FF (b, c, d) + (*cwp++ = SWAP (*words)) + T; \ + ++words; \ + CYCLIC (a, s); \ + a += b; \ + } \ while (0) /* It is unfortunate that C does not provide an operator for @@ -380,13 +387,13 @@ md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) in CORRECT_WORDS. Redefine the macro to take an additional first argument specifying the function to use. */ #undef OP -#define OP(f, a, b, c, d, k, s, T) \ - do \ - { \ - a += f (b, c, d) + correct_words[k] + T; \ - CYCLIC (a, s); \ - a += b; \ - } \ +#define OP(f, a, b, c, d, k, s, T) \ + do \ + { \ + a += f (b, c, d) + correct_words[k] + T; \ + CYCLIC (a, s); \ + a += b; \ + } \ while (0) /* Round 2. */ diff --git a/src/bin/coreutils/lib/md5.h b/src/bin/coreutils/lib/md5.h index 0b120716c3..fbbbc9d5b0 100644 --- a/src/bin/coreutils/lib/md5.h +++ b/src/bin/coreutils/lib/md5.h @@ -3,8 +3,8 @@ #line 1 /* Declaration of functions and data types used for MD5 sum computing library functions. - Copyright (C) 1995-1997,1999,2000,2001,2004,2005,2006,2008,2009 - Free Software Foundation, Inc. + Copyright (C) 1995-1997, 1999-2001, 2004-2006, 2008-2010 Free Software + Foundation, Inc. This file is part of the GNU C Library. This program is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ #ifndef __GNUC_PREREQ # if defined __GNUC__ && defined __GNUC_MINOR__ -# define __GNUC_PREREQ(maj, min) \ +# define __GNUC_PREREQ(maj, min) \ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) # else # define __GNUC_PREREQ(maj, min) 0 @@ -41,7 +41,7 @@ #ifndef __THROW # if defined __cplusplus && __GNUC_PREREQ (2,8) -# define __THROW throw () +# define __THROW throw () # else # define __THROW # endif @@ -88,14 +88,14 @@ extern void __md5_init_ctx (struct md5_ctx *ctx) __THROW; starting at BUFFER. It is necessary that LEN is a multiple of 64!!! */ extern void __md5_process_block (const void *buffer, size_t len, - struct md5_ctx *ctx) __THROW; + struct md5_ctx *ctx) __THROW; /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is NOT required that LEN is a multiple of 64. */ extern void __md5_process_bytes (const void *buffer, size_t len, - struct md5_ctx *ctx) __THROW; + struct md5_ctx *ctx) __THROW; /* Process the remaining bytes in the buffer and put result from CTX in first 16 bytes following RESBUF. The result is always in little @@ -120,7 +120,7 @@ extern int __md5_stream (FILE *stream, void *resblock) __THROW; output yields to the wanted ASCII representation of the message digest. */ extern void *__md5_buffer (const char *buffer, size_t len, - void *resblock) __THROW; + void *resblock) __THROW; # ifdef __cplusplus } diff --git a/src/bin/coreutils/lib/memcasecmp.c b/src/bin/coreutils/lib/memcasecmp.c index 4873651b3f..d326e8e036 100644 --- a/src/bin/coreutils/lib/memcasecmp.c +++ b/src/bin/coreutils/lib/memcasecmp.c @@ -1,5 +1,6 @@ /* Case-insensitive buffer comparator. - Copyright (C) 1996, 1997, 2000, 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 1996-1997, 2000, 2003, 2006, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -40,9 +41,9 @@ memcasecmp (const void *vs1, const void *vs2, size_t n) int U1 = toupper (u1); int U2 = toupper (u2); int diff = (UCHAR_MAX <= INT_MAX ? U1 - U2 - : U1 < U2 ? -1 : U2 < U1); + : U1 < U2 ? -1 : U2 < U1); if (diff) - return diff; + return diff; } return 0; } diff --git a/src/bin/coreutils/lib/memcasecmp.h b/src/bin/coreutils/lib/memcasecmp.h index 1eedecbd76..78a9e68abf 100644 --- a/src/bin/coreutils/lib/memcasecmp.h +++ b/src/bin/coreutils/lib/memcasecmp.h @@ -1,6 +1,6 @@ /* Case-insensitive buffer comparator. - Copyright (C) 1996, 1998, 2003 Free Software Foundation, Inc. + Copyright (C) 1996, 1998, 2003, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/memchr.c b/src/bin/coreutils/lib/memchr.c index 2253d2d651..6c2b2d6c7d 100644 --- a/src/bin/coreutils/lib/memchr.c +++ b/src/bin/coreutils/lib/memchr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1993, 1996, 1997, 1999, 2000, 2003, 2004, 2006, 2008 +/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2010 Free Software Foundation, Inc. Based on strlen implementation by Torbjorn Granlund (tege@sics.se), @@ -97,15 +97,15 @@ __memchr (void const *s, int c_in, size_t n) repeated_one |= repeated_one << 31 << 1; repeated_c |= repeated_c << 31 << 1; if (8 < sizeof (longword)) - { - size_t i; + { + size_t i; - for (i = 64; i < sizeof (longword) * 8; i *= 2) - { - repeated_one |= repeated_one << i; - repeated_c |= repeated_c << i; - } - } + for (i = 64; i < sizeof (longword) * 8; i *= 2) + { + repeated_one |= repeated_one << i; + repeated_c |= repeated_c << i; + } + } } /* Instead of the traditional loop which tests each byte, we will test a @@ -144,8 +144,8 @@ __memchr (void const *s, int c_in, size_t n) longword longword1 = *longword_ptr ^ repeated_c; if ((((longword1 - repeated_one) & ~longword1) - & (repeated_one << 7)) != 0) - break; + & (repeated_one << 7)) != 0) + break; longword_ptr++; n -= sizeof (longword); } @@ -162,7 +162,7 @@ __memchr (void const *s, int c_in, size_t n) for (; n > 0; --n, ++char_ptr) { if (*char_ptr == c) - return (void *) char_ptr; + return (void *) char_ptr; } return NULL; diff --git a/src/bin/coreutils/lib/memchr2.c b/src/bin/coreutils/lib/memchr2.c index ad78195ee3..1ad936be96 100644 --- a/src/bin/coreutils/lib/memchr2.c +++ b/src/bin/coreutils/lib/memchr2.c @@ -1,5 +1,5 @@ -/* Copyright (C) 1991, 1993, 1996, 1997, 1999, 2000, 2003, 2004, 2006, - 2008 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1993, 1996, 1997, 1999, 2000, 2003, 2004, 2006, 2008, + 2009, 2010 Free Software Foundation, Inc. Based on strlen implementation by Torbjorn Granlund (tege@sics.se), with help from Dan Sahlin (dan@sics.se) and @@ -84,16 +84,16 @@ memchr2 (void const *s, int c1_in, int c2_in, size_t n) repeated_c1 |= repeated_c1 << 31 << 1; repeated_c2 |= repeated_c2 << 31 << 1; if (8 < sizeof (longword)) - { - size_t i; + { + size_t i; - for (i = 64; i < sizeof (longword) * 8; i *= 2) - { - repeated_one |= repeated_one << i; - repeated_c1 |= repeated_c1 << i; - repeated_c2 |= repeated_c2 << i; - } - } + for (i = 64; i < sizeof (longword) * 8; i *= 2) + { + repeated_one |= repeated_one << i; + repeated_c1 |= repeated_c1 << i; + repeated_c2 |= repeated_c2 << i; + } + } } /* Instead of the traditional loop which tests each byte, we will test a @@ -138,9 +138,9 @@ memchr2 (void const *s, int c1_in, int c2_in, size_t n) longword longword2 = *longword_ptr ^ repeated_c2; if (((((longword1 - repeated_one) & ~longword1) - | ((longword2 - repeated_one) & ~longword2)) - & (repeated_one << 7)) != 0) - break; + | ((longword2 - repeated_one) & ~longword2)) + & (repeated_one << 7)) != 0) + break; longword_ptr++; n -= sizeof (longword); } @@ -157,7 +157,7 @@ memchr2 (void const *s, int c1_in, int c2_in, size_t n) for (; n > 0; --n, ++char_ptr) { if (*char_ptr == c1 || *char_ptr == c2) - return (void *) char_ptr; + return (void *) char_ptr; } return NULL; diff --git a/src/bin/coreutils/lib/memchr2.h b/src/bin/coreutils/lib/memchr2.h index e35b475eca..f5db8b7932 100644 --- a/src/bin/coreutils/lib/memchr2.h +++ b/src/bin/coreutils/lib/memchr2.h @@ -1,5 +1,5 @@ /* Scan memory for the first of two bytes. - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/memcmp.c b/src/bin/coreutils/lib/memcmp.c index 01810715b0..847867ab93 100644 --- a/src/bin/coreutils/lib/memcmp.c +++ b/src/bin/coreutils/lib/memcmp.c @@ -1,5 +1,5 @@ -/* Copyright (C) 1991, 1993, 1995, 1997, 1998, 2003, 2006, 2009 Free Software - Foundation, Inc. +/* Copyright (C) 1991, 1993, 1995, 1997-1998, 2003, 2006, 2009-2010 Free + Software Foundation, Inc. Contributed by Torbjorn Granlund (tege@sics.se). @@ -38,18 +38,18 @@ # define WORDS_BIGENDIAN # endif -#else /* Not in the GNU C library. */ +#else /* Not in the GNU C library. */ # include /* Type to use for aligned memory operations. This should normally be the biggest type supported by a single load and store. Must be an unsigned type. */ -# define op_t unsigned long int -# define OPSIZ (sizeof(op_t)) +# define op_t unsigned long int +# define OPSIZ (sizeof(op_t)) /* Threshold value for when to enter the unrolled loops. */ -# define OP_T_THRES 16 +# define OP_T_THRES 16 /* Type to use for unaligned operations. */ typedef unsigned char byte; @@ -60,7 +60,7 @@ typedef unsigned char byte; # define MERGE(w0, sh_1, w1, sh_2) (((w0) << (sh_1)) | ((w1) >> (sh_2))) # endif -#endif /* In the GNU C library. */ +#endif /* In the GNU C library. */ #ifdef WORDS_BIGENDIAN # define CMP_LT_OR_GT(a, b) ((a) > (b) ? 1 : -1) @@ -111,7 +111,7 @@ memcmp_bytes (op_t a, op_t b) /* memcmp_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN `op_t' objects (not LEN bytes!). Both SRCP1 and SRCP2 should be aligned for memory operations on `op_t's. */ -#ifdef __GNUC__ +#ifdef __GNUC__ __inline #endif static int @@ -139,7 +139,7 @@ memcmp_common_alignment (uintptr_t srcp1, uintptr_t srcp2, size_t len) goto do2; case 0: if (OP_T_THRES <= 3 * OPSIZ && len == 0) - return 0; + return 0; a0 = ((op_t *) srcp1)[0]; b0 = ((op_t *) srcp2)[0]; goto do3; @@ -150,7 +150,7 @@ memcmp_common_alignment (uintptr_t srcp1, uintptr_t srcp2, size_t len) srcp2 += OPSIZ; len -= 1; if (OP_T_THRES <= 3 * OPSIZ && len == 0) - goto do0; + goto do0; /* Fall through. */ } @@ -159,25 +159,25 @@ memcmp_common_alignment (uintptr_t srcp1, uintptr_t srcp2, size_t len) a0 = ((op_t *) srcp1)[0]; b0 = ((op_t *) srcp2)[0]; if (a1 != b1) - return CMP_LT_OR_GT (a1, b1); + return CMP_LT_OR_GT (a1, b1); do3: a1 = ((op_t *) srcp1)[1]; b1 = ((op_t *) srcp2)[1]; if (a0 != b0) - return CMP_LT_OR_GT (a0, b0); + return CMP_LT_OR_GT (a0, b0); do2: a0 = ((op_t *) srcp1)[2]; b0 = ((op_t *) srcp2)[2]; if (a1 != b1) - return CMP_LT_OR_GT (a1, b1); + return CMP_LT_OR_GT (a1, b1); do1: a1 = ((op_t *) srcp1)[3]; b1 = ((op_t *) srcp2)[3]; if (a0 != b0) - return CMP_LT_OR_GT (a0, b0); + return CMP_LT_OR_GT (a0, b0); srcp1 += 4 * OPSIZ; srcp2 += 4 * OPSIZ; @@ -196,7 +196,7 @@ memcmp_common_alignment (uintptr_t srcp1, uintptr_t srcp2, size_t len) /* memcmp_not_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN `op_t' objects (not LEN bytes!). SRCP2 should be aligned for memory operations on `op_t', but SRCP1 *should be unaligned*. */ -#ifdef __GNUC__ +#ifdef __GNUC__ __inline #endif static int @@ -237,7 +237,7 @@ memcmp_not_common_alignment (uintptr_t srcp1, uintptr_t srcp2, size_t len) goto do2; case 0: if (OP_T_THRES <= 3 * OPSIZ && len == 0) - return 0; + return 0; a3 = ((op_t *) srcp1)[0]; a0 = ((op_t *) srcp1)[1]; b0 = ((op_t *) srcp2)[0]; @@ -251,7 +251,7 @@ memcmp_not_common_alignment (uintptr_t srcp1, uintptr_t srcp2, size_t len) srcp2 += 1 * OPSIZ; len -= 1; if (OP_T_THRES <= 3 * OPSIZ && len == 0) - goto do0; + goto do0; /* Fall through. */ } @@ -261,28 +261,28 @@ memcmp_not_common_alignment (uintptr_t srcp1, uintptr_t srcp2, size_t len) b0 = ((op_t *) srcp2)[0]; x = MERGE(a2, shl, a3, shr); if (x != b3) - return CMP_LT_OR_GT (x, b3); + return CMP_LT_OR_GT (x, b3); do3: a1 = ((op_t *) srcp1)[1]; b1 = ((op_t *) srcp2)[1]; x = MERGE(a3, shl, a0, shr); if (x != b0) - return CMP_LT_OR_GT (x, b0); + return CMP_LT_OR_GT (x, b0); do2: a2 = ((op_t *) srcp1)[2]; b2 = ((op_t *) srcp2)[2]; x = MERGE(a0, shl, a1, shr); if (x != b1) - return CMP_LT_OR_GT (x, b1); + return CMP_LT_OR_GT (x, b1); do1: a3 = ((op_t *) srcp1)[3]; b3 = ((op_t *) srcp2)[3]; x = MERGE(a1, shl, a2, shr); if (x != b2) - return CMP_LT_OR_GT (x, b2); + return CMP_LT_OR_GT (x, b2); srcp1 += 4 * OPSIZ; srcp2 += 4 * OPSIZ; @@ -311,29 +311,29 @@ rpl_memcmp (const void *s1, const void *s2, size_t len) if (len >= OP_T_THRES) { /* There are at least some bytes to compare. No need to test - for LEN == 0 in this alignment loop. */ + for LEN == 0 in this alignment loop. */ while (srcp2 % OPSIZ != 0) - { - a0 = ((byte *) srcp1)[0]; - b0 = ((byte *) srcp2)[0]; - srcp1 += 1; - srcp2 += 1; - res = a0 - b0; - if (res != 0) - return res; - len -= 1; - } + { + a0 = ((byte *) srcp1)[0]; + b0 = ((byte *) srcp2)[0]; + srcp1 += 1; + srcp2 += 1; + res = a0 - b0; + if (res != 0) + return res; + len -= 1; + } /* SRCP2 is now aligned for memory operations on `op_t'. - SRCP1 alignment determines if we can do a simple, - aligned compare or need to shuffle bits. */ + SRCP1 alignment determines if we can do a simple, + aligned compare or need to shuffle bits. */ if (srcp1 % OPSIZ == 0) - res = memcmp_common_alignment (srcp1, srcp2, len / OPSIZ); + res = memcmp_common_alignment (srcp1, srcp2, len / OPSIZ); else - res = memcmp_not_common_alignment (srcp1, srcp2, len / OPSIZ); + res = memcmp_not_common_alignment (srcp1, srcp2, len / OPSIZ); if (res != 0) - return res; + return res; /* Number of bytes remaining in the interval [0..OPSIZ-1]. */ srcp1 += len & -OPSIZ; @@ -350,7 +350,7 @@ rpl_memcmp (const void *s1, const void *s2, size_t len) srcp2 += 1; res = a0 - b0; if (res != 0) - return res; + return res; len -= 1; } diff --git a/src/bin/coreutils/lib/memcmp2.c b/src/bin/coreutils/lib/memcmp2.c index dd04cae132..4e0cddc164 100644 --- a/src/bin/coreutils/lib/memcmp2.c +++ b/src/bin/coreutils/lib/memcmp2.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Compare two memory areas with possibly different lengths. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -31,9 +31,9 @@ memcmp2 (const char *s1, size_t n1, const char *s2, size_t n2) if (cmp == 0) { if (n1 < n2) - cmp = -1; + cmp = -1; else if (n1 > n2) - cmp = 1; + cmp = 1; } return cmp; } diff --git a/src/bin/coreutils/lib/memcmp2.h b/src/bin/coreutils/lib/memcmp2.h index 7b8d7a40eb..2d7a5d9a95 100644 --- a/src/bin/coreutils/lib/memcmp2.h +++ b/src/bin/coreutils/lib/memcmp2.h @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Compare two memory areas with possibly different lengths. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published diff --git a/src/bin/coreutils/lib/memcoll.c b/src/bin/coreutils/lib/memcoll.c index 9d0c434c22..e08ffa5469 100644 --- a/src/bin/coreutils/lib/memcoll.c +++ b/src/bin/coreutils/lib/memcoll.c @@ -1,6 +1,7 @@ /* Locale-specific memory comparison. - Copyright (C) 1999, 2002, 2003, 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 1999, 2002-2004, 2006, 2009-2010 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -54,29 +55,29 @@ memcoll (char *s1, size_t s1len, char *s2, size_t s2len) s2[s2len++] = '\0'; while (! (errno = 0, (diff = strcoll (s1, s2)) || errno)) - { - /* strcoll found no difference, but perhaps it was fooled by NUL - characters in the data. Work around this problem by advancing - past the NUL chars. */ - size_t size1 = strlen (s1) + 1; - size_t size2 = strlen (s2) + 1; - s1 += size1; - s2 += size2; - s1len -= size1; - s2len -= size2; + { + /* strcoll found no difference, but perhaps it was fooled by NUL + characters in the data. Work around this problem by advancing + past the NUL chars. */ + size_t size1 = strlen (s1) + 1; + size_t size2 = strlen (s2) + 1; + s1 += size1; + s2 += size2; + s1len -= size1; + s2len -= size2; - if (s1len == 0) - { - if (s2len != 0) - diff = -1; - break; - } - else if (s2len == 0) - { - diff = 1; - break; - } - } + if (s1len == 0) + { + if (s2len != 0) + diff = -1; + break; + } + else if (s2len == 0) + { + diff = 1; + break; + } + } s1[s1len - 1] = n1; s2[s2len - 1] = n2; diff --git a/src/bin/coreutils/lib/memcoll.h b/src/bin/coreutils/lib/memcoll.h index 853d55983c..8f2e1b15a4 100644 --- a/src/bin/coreutils/lib/memcoll.h +++ b/src/bin/coreutils/lib/memcoll.h @@ -1,6 +1,6 @@ /* Locale-specific memory comparison. - Copyright (C) 1999, 2003 Free Software Foundation, Inc. + Copyright (C) 1999, 2003, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/memcpy.c b/src/bin/coreutils/lib/memcpy.c index 1da71dd01d..2d87e5dcf9 100644 --- a/src/bin/coreutils/lib/memcpy.c +++ b/src/bin/coreutils/lib/memcpy.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1995, 1997, 2000, 2003, 2006 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1997, 2000, 2003, 2006, 2009-2010 Free Software + * Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/memmove.c b/src/bin/coreutils/lib/memmove.c index c5ff8b520d..0f040540c0 100644 --- a/src/bin/coreutils/lib/memmove.c +++ b/src/bin/coreutils/lib/memmove.c @@ -20,7 +20,7 @@ memmove (void *dest0, void const *source0, size_t length) { /* Moving from hi mem to low mem; start at beginning. */ for (; length; --length) - *dest++ = *source++; + *dest++ = *source++; } return dest0; } diff --git a/src/bin/coreutils/lib/mempcpy.c b/src/bin/coreutils/lib/mempcpy.c index 1a6e53ece4..37884e294f 100644 --- a/src/bin/coreutils/lib/mempcpy.c +++ b/src/bin/coreutils/lib/mempcpy.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Copy memory area and return pointer after last written byte. - Copyright (C) 2003, 2007 Free Software Foundation, Inc. + Copyright (C) 2003, 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/memrchr.c b/src/bin/coreutils/lib/memrchr.c index da93ca0ba5..358f61834b 100644 --- a/src/bin/coreutils/lib/memrchr.c +++ b/src/bin/coreutils/lib/memrchr.c @@ -1,7 +1,7 @@ /* memrchr -- find the last occurrence of a byte in a memory block - Copyright (C) 1991, 1993, 1996, 1997, 1999, 2000, 2003, 2004, 2005, - 2006, 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2010 Free Software + Foundation, Inc. Based on strlen implementation by Torbjorn Granlund (tege@sics.se), with help from Dan Sahlin (dan@sics.se) and @@ -84,15 +84,15 @@ __memrchr (void const *s, int c_in, size_t n) repeated_one |= repeated_one << 31 << 1; repeated_c |= repeated_c << 31 << 1; if (8 < sizeof (longword)) - { - size_t i; + { + size_t i; - for (i = 64; i < sizeof (longword) * 8; i *= 2) - { - repeated_one |= repeated_one << i; - repeated_c |= repeated_c << i; - } - } + for (i = 64; i < sizeof (longword) * 8; i *= 2) + { + repeated_one |= repeated_one << i; + repeated_c |= repeated_c << i; + } + } } /* Instead of the traditional loop which tests each byte, we will test a @@ -131,11 +131,11 @@ __memrchr (void const *s, int c_in, size_t n) longword longword1 = *--longword_ptr ^ repeated_c; if ((((longword1 - repeated_one) & ~longword1) - & (repeated_one << 7)) != 0) - { - longword_ptr++; - break; - } + & (repeated_one << 7)) != 0) + { + longword_ptr++; + break; + } n -= sizeof (longword); } @@ -151,7 +151,7 @@ __memrchr (void const *s, int c_in, size_t n) while (n-- > 0) { if (*--char_ptr == c) - return (void *) char_ptr; + return (void *) char_ptr; } return NULL; diff --git a/src/bin/coreutils/lib/memset.c b/src/bin/coreutils/lib/memset.c index b5fb7a535f..0de5a699a4 100644 --- a/src/bin/coreutils/lib/memset.c +++ b/src/bin/coreutils/lib/memset.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* memset.c -- set an area of memory to a given value - Copyright (C) 1991, 2003 Free Software Foundation, Inc. + Copyright (C) 1991, 2003, 2009-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/memxfrm.c b/src/bin/coreutils/lib/memxfrm.c index a186ed87aa..12a1ae9e48 100644 --- a/src/bin/coreutils/lib/memxfrm.c +++ b/src/bin/coreutils/lib/memxfrm.c @@ -1,6 +1,6 @@ /* Locale-specific memory transformation - Copyright (C) 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/mgetgroups.c b/src/bin/coreutils/lib/mgetgroups.c index 0ebc2be151..76474c21b9 100644 --- a/src/bin/coreutils/lib/mgetgroups.c +++ b/src/bin/coreutils/lib/mgetgroups.c @@ -1,6 +1,6 @@ -/* mgetgroups.c -- return a list of the groups a user is in +/* mgetgroups.c -- return a list of the groups a user or current process is in - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,36 +29,39 @@ #if HAVE_GETGROUPLIST # include #endif + #include "getugroups.h" #include "xalloc.h" - -static GETGROUPS_T * -realloc_groupbuf (GETGROUPS_T *g, size_t num) +static gid_t * +realloc_groupbuf (gid_t *g, size_t num) { - if (xalloc_oversized (num, sizeof (*g))) + if (xalloc_oversized (num, sizeof *g)) { errno = ENOMEM; return NULL; } - return realloc (g, num * sizeof (*g)); + return realloc (g, num * sizeof *g); } /* Like getugroups, but store the result in malloc'd storage. Set *GROUPS to the malloc'd list of all group IDs of which USERNAME is a member. If GID is not -1, store it first. GID should be the group ID (pw_gid) obtained from getpwuid, in case USERNAME is not - listed in the groups database (e.g., /etc/groups). Upon failure, + listed in the groups database (e.g., /etc/groups). If USERNAME is + NULL, store the supplementary groups of the current process, and GID + should be -1 or the effective group ID (getegid). Upon failure, don't modify *GROUPS, set errno, and return -1. Otherwise, return - the number of groups. */ + the number of groups. The resulting list may contain duplicates, + but adjacent members will be distinct. */ int -mgetgroups (char const *username, gid_t gid, GETGROUPS_T **groups) +mgetgroups (char const *username, gid_t gid, gid_t **groups) { int max_n_groups; int ng; - GETGROUPS_T *g; + gid_t *g; #if HAVE_GETGROUPLIST /* We prefer to use getgrouplist if available, because it has better @@ -80,7 +83,7 @@ mgetgroups (char const *username, gid_t gid, GETGROUPS_T **groups) while (1) { - GETGROUPS_T *h; + gid_t *h; int last_n_groups = max_n_groups; /* getgrouplist updates max_n_groups to num required. */ @@ -116,27 +119,88 @@ mgetgroups (char const *username, gid_t gid, GETGROUPS_T **groups) ? getugroups (0, NULL, username, gid) : getgroups (0, NULL)); - /* If we failed to count groups with NULL for a buffer, - try again with a non-NULL one, just in case. */ + /* If we failed to count groups because there is no supplemental + group support, then return an array containing just GID. + Otherwise, we fail for the same reason. */ if (max_n_groups < 0) - max_n_groups = 5; + { + if (errno == ENOSYS && (g = realloc_groupbuf (NULL, 1))) + { + *groups = g; + *g = gid; + return gid != (gid_t) -1; + } + return -1; + } + if (!username && gid != (gid_t) -1) + max_n_groups++; g = realloc_groupbuf (NULL, max_n_groups); if (g == NULL) return -1; ng = (username ? getugroups (max_n_groups, g, username, gid) - : getgroups (max_n_groups, g)); + : getgroups (max_n_groups - (gid != (gid_t) -1), + g + (gid != (gid_t) -1))); if (ng < 0) { + /* Failure is unexpected, but handle it anyway. */ int saved_errno = errno; free (g); errno = saved_errno; return -1; } + if (!username && gid != (gid_t) -1) + { + *g = gid; + ng++; + } *groups = g; + + /* Reduce the number of duplicates. On some systems, getgroups + returns the effective gid twice: once as the first element, and + once in its position within the supplementary groups. On other + systems, getgroups does not return the effective gid at all, + which is why we provide a GID argument. Meanwhile, the GID + argument, if provided, is typically any member of the + supplementary groups, and not necessarily the effective gid. So, + the most likely duplicates are the first element with an + arbitrary other element, or pair-wise duplication between the + first and second elements returned by getgroups. It is possible + that this O(n) pass will not remove all duplicates, but it is not + worth the effort to slow down to an O(n log n) algorithm that + sorts the array in place, nor the extra memory needed for + duplicate removal via an O(n) hash-table. Hence, this function + is only documented as guaranteeing no pair-wise duplicates, + rather than returning the minimal set. */ + if (1 < ng) + { + gid_t first = *g; + gid_t *next; + gid_t *groups_end = g + ng; + + for (next = g + 1; next < groups_end; next++) + { + if (*next == first || *next == *g) + ng--; + else + *++g = *next; + } + } + return ng; } + +/* Like mgetgroups, but call xalloc_die on allocation failure. */ + +int +xgetgroups (char const *username, gid_t gid, gid_t **groups) +{ + int result = mgetgroups (username, gid, groups); + if (result == -1 && errno == ENOMEM) + xalloc_die (); + return result; +} diff --git a/src/bin/coreutils/lib/mgetgroups.h b/src/bin/coreutils/lib/mgetgroups.h index 4779fecf01..f9a8d89357 100644 --- a/src/bin/coreutils/lib/mgetgroups.h +++ b/src/bin/coreutils/lib/mgetgroups.h @@ -1,5 +1,5 @@ /* Get a list of all group IDs associated with a specified user ID. - Copyright (C) 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,4 +16,5 @@ #include -int mgetgroups (const char *username, gid_t gid, GETGROUPS_T **groups); +int mgetgroups (const char *username, gid_t gid, gid_t **groups); +int xgetgroups (const char *username, gid_t gid, gid_t **groups); diff --git a/src/bin/coreutils/lib/mkancesdirs.c b/src/bin/coreutils/lib/mkancesdirs.c index e44cf3e059..709e93bcba 100644 --- a/src/bin/coreutils/lib/mkancesdirs.c +++ b/src/bin/coreutils/lib/mkancesdirs.c @@ -1,6 +1,6 @@ /* Make a file's ancestor directories. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -65,8 +65,8 @@ ptrdiff_t mkancesdirs (char *file, struct savewd *wd, - int (*make_dir) (char const *, char const *, void *), - void *make_dir_arg) + int (*make_dir) (char const *, char const *, void *), + void *make_dir_arg) { /* Address of the previous directory separator that follows an ordinary byte in a file name in the left-to-right scan, or NULL @@ -90,63 +90,63 @@ mkancesdirs (char *file, struct savewd *wd, while ((c = *p++)) if (ISSLASH (*p)) { - if (! ISSLASH (c)) - sep = p; + if (! ISSLASH (c)) + sep = p; } else if (ISSLASH (c) && *p && sep) { - /* Don't bother to make or test for "." since it does not - affect the algorithm. */ - if (! (sep - component == 1 && component[0] == '.')) - { - int make_dir_errno = 0; - int savewd_chdir_options = 0; - int chdir_result; + /* Don't bother to make or test for "." since it does not + affect the algorithm. */ + if (! (sep - component == 1 && component[0] == '.')) + { + int make_dir_errno = 0; + int savewd_chdir_options = 0; + int chdir_result; - /* Temporarily modify FILE to isolate this file name - component. */ - *sep = '\0'; + /* Temporarily modify FILE to isolate this file name + component. */ + *sep = '\0'; - /* Invoke MAKE_DIR on this component, except don't bother - with ".." since it must exist if its "parent" does. */ - if (sep - component == 2 - && component[0] == '.' && component[1] == '.') - made_dir = false; - else - switch (make_dir (file, component, make_dir_arg)) - { - case -1: - make_dir_errno = errno; - break; + /* Invoke MAKE_DIR on this component, except don't bother + with ".." since it must exist if its "parent" does. */ + if (sep - component == 2 + && component[0] == '.' && component[1] == '.') + made_dir = false; + else + switch (make_dir (file, component, make_dir_arg)) + { + case -1: + make_dir_errno = errno; + break; - case 0: - savewd_chdir_options |= SAVEWD_CHDIR_READABLE; - /* Fall through. */ - case 1: - made_dir = true; - break; - } + case 0: + savewd_chdir_options |= SAVEWD_CHDIR_READABLE; + /* Fall through. */ + case 1: + made_dir = true; + break; + } - if (made_dir) - savewd_chdir_options |= SAVEWD_CHDIR_NOFOLLOW; + if (made_dir) + savewd_chdir_options |= SAVEWD_CHDIR_NOFOLLOW; - chdir_result = - savewd_chdir (wd, component, savewd_chdir_options, NULL); + chdir_result = + savewd_chdir (wd, component, savewd_chdir_options, NULL); - /* Undo the temporary modification to FILE, unless there - was a failure. */ - if (chdir_result != -1) - *sep = '/'; + /* Undo the temporary modification to FILE, unless there + was a failure. */ + if (chdir_result != -1) + *sep = '/'; - if (chdir_result != 0) - { - if (make_dir_errno != 0 && errno == ENOENT) - errno = make_dir_errno; - return chdir_result; - } - } + if (chdir_result != 0) + { + if (make_dir_errno != 0 && errno == ENOENT) + errno = make_dir_errno; + return chdir_result; + } + } - component = p; + component = p; } return component - file; diff --git a/src/bin/coreutils/lib/mkancesdirs.h b/src/bin/coreutils/lib/mkancesdirs.h index 08fb50cbd7..5f7b2d6427 100644 --- a/src/bin/coreutils/lib/mkancesdirs.h +++ b/src/bin/coreutils/lib/mkancesdirs.h @@ -1,4 +1,4 @@ #include struct savewd; ptrdiff_t mkancesdirs (char *, struct savewd *, - int (*) (char const *, char const *, void *), void *); + int (*) (char const *, char const *, void *), void *); diff --git a/src/bin/coreutils/lib/mkdir-p.c b/src/bin/coreutils/lib/mkdir-p.c index f38dbc71f8..058508c8e2 100644 --- a/src/bin/coreutils/lib/mkdir-p.c +++ b/src/bin/coreutils/lib/mkdir-p.c @@ -1,7 +1,7 @@ /* mkdir-p.c -- Ensure that a directory and its parents exist. - Copyright (C) 1990, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, - 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 1990, 1997-2000, 2002-2007, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -84,15 +84,15 @@ bool make_dir_parents (char *dir, - struct savewd *wd, - int (*make_ancestor) (char const *, char const *, void *), - void *options, - mode_t mode, - void (*announce) (char const *, void *), - mode_t mode_bits, - uid_t owner, - gid_t group, - bool preserve_existing) + struct savewd *wd, + int (*make_ancestor) (char const *, char const *, void *), + void *options, + mode_t mode, + void (*announce) (char const *, void *), + mode_t mode_bits, + uid_t owner, + gid_t group, + bool preserve_existing) { int mkdir_errno = (IS_ABSOLUTE_FILE_NAME (dir) ? 0 : savewd_errno (wd)); @@ -102,105 +102,105 @@ make_dir_parents (char *dir, int savewd_chdir_options = (HAVE_FCHMOD ? SAVEWD_CHDIR_SKIP_READABLE : 0); if (make_ancestor) - { - prefix_len = mkancesdirs (dir, wd, make_ancestor, options); - if (prefix_len < 0) - { - if (prefix_len < -1) - return true; - mkdir_errno = errno; - } - } + { + prefix_len = mkancesdirs (dir, wd, make_ancestor, options); + if (prefix_len < 0) + { + if (prefix_len < -1) + return true; + mkdir_errno = errno; + } + } if (0 <= prefix_len) - { - /* If the ownership might change, or if the directory will be - writeable to other users and its special mode bits may - change after the directory is created, create it with - more restrictive permissions at first, so unauthorized - users cannot nip in before the directory is ready. */ - bool keep_owner = owner == (uid_t) -1 && group == (gid_t) -1; - bool keep_special_mode_bits = - ((mode_bits & (S_ISUID | S_ISGID)) | (mode & S_ISVTX)) == 0; - mode_t mkdir_mode = mode; - if (! keep_owner) - mkdir_mode &= ~ (S_IRWXG | S_IRWXO); - else if (! keep_special_mode_bits) - mkdir_mode &= ~ (S_IWGRP | S_IWOTH); + { + /* If the ownership might change, or if the directory will be + writeable to other users and its special mode bits may + change after the directory is created, create it with + more restrictive permissions at first, so unauthorized + users cannot nip in before the directory is ready. */ + bool keep_owner = owner == (uid_t) -1 && group == (gid_t) -1; + bool keep_special_mode_bits = + ((mode_bits & (S_ISUID | S_ISGID)) | (mode & S_ISVTX)) == 0; + mode_t mkdir_mode = mode; + if (! keep_owner) + mkdir_mode &= ~ (S_IRWXG | S_IRWXO); + else if (! keep_special_mode_bits) + mkdir_mode &= ~ (S_IWGRP | S_IWOTH); - if (mkdir (dir + prefix_len, mkdir_mode) == 0) - { - announce (dir, options); - preserve_existing = keep_owner & keep_special_mode_bits; - savewd_chdir_options |= - (SAVEWD_CHDIR_NOFOLLOW - | (mode & S_IRUSR ? SAVEWD_CHDIR_READABLE : 0)); - } - else - { - mkdir_errno = errno; - mkdir_mode = -1; - } + if (mkdir (dir + prefix_len, mkdir_mode) == 0) + { + announce (dir, options); + preserve_existing = keep_owner & keep_special_mode_bits; + savewd_chdir_options |= + (SAVEWD_CHDIR_NOFOLLOW + | (mode & S_IRUSR ? SAVEWD_CHDIR_READABLE : 0)); + } + else + { + mkdir_errno = errno; + mkdir_mode = -1; + } - if (preserve_existing) - { - struct stat st; - if (mkdir_errno == 0 - || (mkdir_errno != ENOENT && make_ancestor - && stat (dir + prefix_len, &st) == 0 - && S_ISDIR (st.st_mode))) - return true; - } - else - { - int open_result[2]; - int chdir_result = - savewd_chdir (wd, dir + prefix_len, - savewd_chdir_options, open_result); - if (chdir_result < -1) - return true; - else - { - bool chdir_ok = (chdir_result == 0); - int chdir_errno = errno; - int fd = open_result[0]; - bool chdir_failed_unexpectedly = - (mkdir_errno == 0 - && ((! chdir_ok && (mode & S_IXUSR)) - || (fd < 0 && (mode & S_IRUSR)))); + if (preserve_existing) + { + struct stat st; + if (mkdir_errno == 0 + || (mkdir_errno != ENOENT && make_ancestor + && stat (dir + prefix_len, &st) == 0 + && S_ISDIR (st.st_mode))) + return true; + } + else + { + int open_result[2]; + int chdir_result = + savewd_chdir (wd, dir + prefix_len, + savewd_chdir_options, open_result); + if (chdir_result < -1) + return true; + else + { + bool chdir_ok = (chdir_result == 0); + int chdir_errno = errno; + int fd = open_result[0]; + bool chdir_failed_unexpectedly = + (mkdir_errno == 0 + && ((! chdir_ok && (mode & S_IXUSR)) + || (fd < 0 && (mode & S_IRUSR)))); - if (chdir_failed_unexpectedly) - { - /* No need to save errno here; it's irrelevant. */ - if (0 <= fd) - close (fd); - } - else - { - char const *subdir = (chdir_ok ? "." : dir + prefix_len); - if (dirchownmod (fd, subdir, mkdir_mode, owner, group, - mode, mode_bits) - == 0) - return true; - } + if (chdir_failed_unexpectedly) + { + /* No need to save errno here; it's irrelevant. */ + if (0 <= fd) + close (fd); + } + else + { + char const *subdir = (chdir_ok ? "." : dir + prefix_len); + if (dirchownmod (fd, subdir, mkdir_mode, owner, group, + mode, mode_bits) + == 0) + return true; + } - if (mkdir_errno == 0 - || (mkdir_errno != ENOENT && make_ancestor - && errno != ENOTDIR)) - { - error (0, - (! chdir_failed_unexpectedly ? errno - : ! chdir_ok && (mode & S_IXUSR) ? chdir_errno - : open_result[1]), - _(keep_owner - ? "cannot change permissions of %s" - : "cannot change owner and permissions of %s"), - quote (dir)); - return false; - } - } - } - } + if (mkdir_errno == 0 + || (mkdir_errno != ENOENT && make_ancestor + && errno != ENOTDIR)) + { + error (0, + (! chdir_failed_unexpectedly ? errno + : ! chdir_ok && (mode & S_IXUSR) ? chdir_errno + : open_result[1]), + _(keep_owner + ? "cannot change permissions of %s" + : "cannot change owner and permissions of %s"), + quote (dir)); + return false; + } + } + } + } } error (0, mkdir_errno, _("cannot create directory %s"), quote (dir)); diff --git a/src/bin/coreutils/lib/mkdir-p.h b/src/bin/coreutils/lib/mkdir-p.h index 487e6ebebf..26d3b4698d 100644 --- a/src/bin/coreutils/lib/mkdir-p.h +++ b/src/bin/coreutils/lib/mkdir-p.h @@ -1,7 +1,7 @@ /* mkdir-p.h -- Ensure that a directory and its parents exist. - Copyright (C) 1994, 1995, 1996, 1997, 2000, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. + Copyright (C) 1994-1997, 2000, 2003-2006, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,13 +23,13 @@ struct savewd; bool make_dir_parents (char *dir, - struct savewd *wd, - int (*make_ancestor) (char const *, char const *, - void *), - void *options, - mode_t mode, - void (*announce) (char const *, void *), - mode_t mode_bits, - uid_t owner, - gid_t group, - bool preserve_existing); + struct savewd *wd, + int (*make_ancestor) (char const *, char const *, + void *), + void *options, + mode_t mode, + void (*announce) (char const *, void *), + mode_t mode_bits, + uid_t owner, + gid_t group, + bool preserve_existing); diff --git a/src/bin/coreutils/lib/mkdir.c b/src/bin/coreutils/lib/mkdir.c index 5f4d235e3b..b117b76b53 100644 --- a/src/bin/coreutils/lib/mkdir.c +++ b/src/bin/coreutils/lib/mkdir.c @@ -1,7 +1,7 @@ /* On some systems, mkdir ("foo/", 0700) fails because of the trailing slash. On those systems, this wrapper removes the trailing slash. - Copyright (C) 2001, 2003, 2006, 2008 Free Software Foundation, Inc. + Copyright (C) 2001, 2003, 2006, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,15 +21,14 @@ #include /* Specification. */ -#include #include +#include #include #include #include #include "dirname.h" -#include "xalloc.h" /* Disable the definition of mkdir to rpl_mkdir (from the substitute) in this file. Otherwise, we'd get an endless recursion. */ @@ -40,7 +39,7 @@ alias mkdir), only in the nonstandard io.h. */ #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ # define mkdir(name,mode) _mkdir (name) -# define maybe_unused _UNUSED_PARAMETER_ +# define maybe_unused _GL_UNUSED #else # define maybe_unused /* empty */ #endif @@ -56,13 +55,33 @@ rpl_mkdir (char const *dir, mode_t mode maybe_unused) if (len && dir[len - 1] == '/') { - tmp_dir = xstrdup (dir); + tmp_dir = strdup (dir); + if (!tmp_dir) + { + /* Rather than rely on strdup-posix, we set errno ourselves. */ + errno = ENOMEM; + return -1; + } strip_trailing_slashes (tmp_dir); } else { tmp_dir = (char *) dir; } +#if FUNC_MKDIR_DOT_BUG + /* Additionally, cygwin 1.5 mistakenly creates a directory "d/./". */ + { + char *last = last_component (tmp_dir); + if (*last == '.' && (last[1] == '\0' + || (last[1] == '.' && last[2] == '\0'))) + { + struct stat st; + if (stat (tmp_dir, &st) == 0) + errno = EEXIST; + return -1; + } + } +#endif /* FUNC_MKDIR_DOT_BUG */ ret_val = mkdir (tmp_dir, mode); diff --git a/src/bin/coreutils/lib/mkdirat.c b/src/bin/coreutils/lib/mkdirat.c index 33ece9ccd6..9e68222aa0 100644 --- a/src/bin/coreutils/lib/mkdirat.c +++ b/src/bin/coreutils/lib/mkdirat.c @@ -1,5 +1,5 @@ /* fd-relative mkdir - Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,11 +20,6 @@ #include -#include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ -#include "openat.h" -#include "openat-priv.h" -#include "save-cwd.h" - /* Solaris 10 has no function like this. Create a subdirectory, FILE, with mode MODE, in the directory open on descriptor FD. If possible, do it without changing the diff --git a/src/bin/coreutils/lib/mkstemp-safer.c b/src/bin/coreutils/lib/mkstemp-safer.c index 4ba97c3790..47d3b2c614 100644 --- a/src/bin/coreutils/lib/mkstemp-safer.c +++ b/src/bin/coreutils/lib/mkstemp-safer.c @@ -1,6 +1,6 @@ /* Invoke mkstemp, but avoid some glitches. - Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2005-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -32,3 +32,32 @@ mkstemp_safer (char *templ) { return fd_safer (mkstemp (templ)); } + +#if GNULIB_MKOSTEMP +/* Like mkostemp, but do not return STDIN_FILENO, STDOUT_FILENO, or + STDERR_FILENO. */ +int +mkostemp_safer (char *templ, int flags) +{ + return fd_safer_flag (mkostemp (templ, flags), flags); +} +#endif + +#if GNULIB_MKOSTEMPS +/* Like mkostemps, but do not return STDIN_FILENO, STDOUT_FILENO, or + STDERR_FILENO. */ +int +mkostemps_safer (char *templ, int suffixlen, int flags) +{ + return fd_safer_flag (mkostemps (templ, suffixlen, flags), flags); +} +#endif + +#if GNULIB_MKSTEMPS +/* Like mkstemps, but do not return STDIN_FILENO, STDOUT_FILENO, or + STDERR_FILENO. */ +int mkstemps_safer (char *templ, int suffixlen) +{ + return fd_safer (mkstemps (templ, suffixlen)); +} +#endif diff --git a/src/bin/coreutils/lib/mkstemp.c b/src/bin/coreutils/lib/mkstemp.c index ccf7a7beed..c1dc796488 100644 --- a/src/bin/coreutils/lib/mkstemp.c +++ b/src/bin/coreutils/lib/mkstemp.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1998, 1999, 2001, 2005, 2006, 2007, 2009 Free Software Foundation, Inc. +/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2010 Free Software + Foundation, Inc. This file is derived from the one in the GNU C Library. This program is free software: you can redistribute it and/or modify @@ -23,7 +24,9 @@ #if !_LIBC # include "tempname.h" # define __gen_tempname gen_tempname -# define __GT_FILE GT_FILE +# ifndef __GT_FILE +# define __GT_FILE GT_FILE +# endif #endif #include @@ -32,13 +35,12 @@ # define __GT_FILE 0 #endif -/* Generate a unique temporary file name from TEMPLATE. - The last six characters of TEMPLATE must be "XXXXXX"; +/* Generate a unique temporary file name from XTEMPLATE. + The last six characters of XTEMPLATE must be "XXXXXX"; they are replaced with a string that makes the file name unique. Then open the file and return a fd. */ int -mkstemp (template) - char *template; +mkstemp (char *xtemplate) { - return __gen_tempname (template, 0, __GT_FILE); + return __gen_tempname (xtemplate, 0, 0, __GT_FILE); } diff --git a/src/bin/coreutils/lib/mktime-internal.h b/src/bin/coreutils/lib/mktime-internal.h new file mode 100644 index 0000000000..4287acf4ac --- /dev/null +++ b/src/bin/coreutils/lib/mktime-internal.h @@ -0,0 +1,4 @@ +#include +time_t mktime_internal (struct tm *, + struct tm * (*) (time_t const *, struct tm *), + time_t *); diff --git a/src/bin/coreutils/lib/mktime.c b/src/bin/coreutils/lib/mktime.c index d3e7a3852c..0a6f06446b 100644 --- a/src/bin/coreutils/lib/mktime.c +++ b/src/bin/coreutils/lib/mktime.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Convert a `struct tm' to a time_t value. - Copyright (C) 1993-1999, 2002-2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 1993-1999, 2002-2007, 2009-2010 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Paul Eggert . @@ -39,7 +39,7 @@ #include -#include /* For the real memcpy prototype. */ +#include /* For the real memcpy prototype. */ #if DEBUG # include @@ -58,9 +58,9 @@ implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift right in the usual way when A < 0, so SHR falls back on division if ordinary A >> B doesn't seem to be the usual signed shift. */ -#define SHR(a, b) \ - (-1 >> 1 == -1 \ - ? (a) >> (b) \ +#define SHR(a, b) \ + (-1 >> 1 == -1 \ + ? (a) >> (b) \ : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0)) /* The extra casts in the following macros work around compiler bugs, @@ -87,14 +87,14 @@ your host. */ #define TYPE_MINIMUM(t) \ ((t) (! TYPE_SIGNED (t) \ - ? (t) 0 \ - : TYPE_SIGNED_MAGNITUDE (t) \ - ? ~ (t) 0 \ - : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))) + ? (t) 0 \ + : TYPE_SIGNED_MAGNITUDE (t) \ + ? ~ (t) 0 \ + : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))) #define TYPE_MAXIMUM(t) \ ((t) (! TYPE_SIGNED (t) \ - ? (t) -1 \ - : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))) + ? (t) -1 \ + : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))) #ifndef TIME_T_MIN # define TIME_T_MIN TYPE_MINIMUM (time_t) @@ -126,7 +126,7 @@ leapyear (long int year) return ((year & 3) == 0 && (year % 100 != 0 - || ((year / 100) & 3) == (- (TM_YEAR_BASE / 100) & 3))); + || ((year / 100) & 3) == (- (TM_YEAR_BASE / 100) & 3))); } /* How many days come before each month (0-12). */ @@ -150,6 +150,7 @@ const unsigned short int __mon_yday[2][13] = # undef __localtime_r # define __localtime_r localtime_r # define __mktime_internal mktime_internal +# include "mktime-internal.h" #endif /* Return an integer value measuring (YEAR1-YDAY1 HOUR1:MIN1:SEC1) - @@ -165,11 +166,14 @@ const unsigned short int __mon_yday[2][13] = static inline time_t ydhms_diff (long int year1, long int yday1, int hour1, int min1, int sec1, - int year0, int yday0, int hour0, int min0, int sec0) + int year0, int yday0, int hour0, int min0, int sec0) { verify (C99_integer_division, -1 / 2 == 0); +#if 0 /* This assertion fails on 32-bit systems with 64-bit time_t, such as + NetBSD 5 on i386. */ verify (long_int_year_and_yday_are_wide_enough, - INT_MAX <= LONG_MAX / 2 || TIME_T_MAX <= UINT_MAX); + INT_MAX <= LONG_MAX / 2 || TIME_T_MAX <= UINT_MAX); +#endif /* Compute intervening leap days correctly even if year is negative. Take care to avoid integer overflow here. */ @@ -201,16 +205,16 @@ ydhms_diff (long int year1, long int yday1, int hour1, int min1, int sec1, yield a value equal to *T. */ static time_t guess_time_tm (long int year, long int yday, int hour, int min, int sec, - const time_t *t, const struct tm *tp) + const time_t *t, const struct tm *tp) { if (tp) { time_t d = ydhms_diff (year, yday, hour, min, sec, - tp->tm_year, tp->tm_yday, - tp->tm_hour, tp->tm_min, tp->tm_sec); + tp->tm_year, tp->tm_yday, + tp->tm_hour, tp->tm_min, tp->tm_sec); time_t t1 = *t + d; if ((t1 < *t) == (TYPE_SIGNED (time_t) ? d < 0 : TIME_T_MAX / 2 < d)) - return t1; + return t1; } /* Overflow occurred one way or another. Return the nearest result @@ -219,8 +223,8 @@ guess_time_tm (long int year, long int yday, int hour, int min, int sec, match; and don't oscillate between two values, as that would confuse the spring-forward gap detector. */ return (*t < TIME_T_MIDPOINT - ? (*t <= TIME_T_MIN + 1 ? *t + 1 : TIME_T_MIN) - : (TIME_T_MAX - 1 <= *t ? *t - 1 : TIME_T_MAX)); + ? (*t <= TIME_T_MIN + 1 ? *t + 1 : TIME_T_MIN) + : (TIME_T_MAX - 1 <= *t ? *t - 1 : TIME_T_MAX)); } /* Use CONVERT to convert *T to a broken down time in *TP. @@ -228,7 +232,7 @@ guess_time_tm (long int year, long int yday, int hour, int min, int sec, it is the nearest in-range value and then convert that. */ static struct tm * ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), - time_t *t, struct tm *tp) + time_t *t, struct tm *tp) { struct tm *r = convert (t, tp); @@ -238,27 +242,27 @@ ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), time_t ok = 0; /* BAD is a known unconvertible time_t, and OK is a known good one. - Use binary search to narrow the range between BAD and OK until - they differ by 1. */ + Use binary search to narrow the range between BAD and OK until + they differ by 1. */ while (bad != ok + (bad < 0 ? -1 : 1)) - { - time_t mid = *t = (bad < 0 - ? bad + ((ok - bad) >> 1) - : ok + ((bad - ok) >> 1)); - r = convert (t, tp); - if (r) - ok = mid; - else - bad = mid; - } + { + time_t mid = *t = (bad < 0 + ? bad + ((ok - bad) >> 1) + : ok + ((bad - ok) >> 1)); + r = convert (t, tp); + if (r) + ok = mid; + else + bad = mid; + } if (!r && ok) - { - /* The last conversion attempt failed; - revert to the most recent successful attempt. */ - *t = ok; - r = convert (t, tp); - } + { + /* The last conversion attempt failed; + revert to the most recent successful attempt. */ + *t = ok; + r = convert (t, tp); + } } return r; @@ -273,8 +277,8 @@ ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), This function is external because it is used also by timegm.c. */ time_t __mktime_internal (struct tm *tp, - struct tm *(*convert) (const time_t *, struct tm *), - time_t *offset) + struct tm *(*convert) (const time_t *, struct tm *), + time_t *offset) { time_t t, gt, t0, t1, t2; struct tm tm; @@ -295,7 +299,7 @@ __mktime_internal (struct tm *tp, int year_requested = tp->tm_year; /* Normalize the value. */ int isdst = ((tp->tm_isdst >> (8 * sizeof (tp->tm_isdst) - 1)) - | (tp->tm_isdst != 0)); + | (tp->tm_isdst != 0)); /* 1 if the previous probe was DST. */ int dst2; @@ -315,8 +319,8 @@ __mktime_internal (struct tm *tp, /* Calculate day of year from year, month, and day of month. The result need not be in range. */ int mon_yday = ((__mon_yday[leapyear (year)] - [mon_remainder + 12 * negative_mon_remainder]) - - 1); + [mon_remainder + 12 * negative_mon_remainder]) + - 1); long int lmday = mday; long int yday = mon_yday + lmday; @@ -327,33 +331,33 @@ __mktime_internal (struct tm *tp, if (LEAP_SECONDS_POSSIBLE) { /* Handle out-of-range seconds specially, - since ydhms_tm_diff assumes every minute has 60 seconds. */ + since ydhms_tm_diff assumes every minute has 60 seconds. */ if (sec < 0) - sec = 0; + sec = 0; if (59 < sec) - sec = 59; + sec = 59; } /* Invert CONVERT by probing. First assume the same offset as last time. */ t0 = ydhms_diff (year, yday, hour, min, sec, - EPOCH_YEAR - TM_YEAR_BASE, 0, 0, 0, - guessed_offset); + EPOCH_YEAR - TM_YEAR_BASE, 0, 0, 0, - guessed_offset); if (TIME_T_MAX / INT_MAX / 366 / 24 / 60 / 60 < 3) { /* time_t isn't large enough to rule out overflows, so check - for major overflows. A gross check suffices, since if t0 - has overflowed, it is off by a multiple of TIME_T_MAX - - TIME_T_MIN + 1. So ignore any component of the difference - that is bounded by a small value. */ + for major overflows. A gross check suffices, since if t0 + has overflowed, it is off by a multiple of TIME_T_MAX - + TIME_T_MIN + 1. So ignore any component of the difference + that is bounded by a small value. */ /* Approximate log base 2 of the number of time units per - biennium. A biennium is 2 years; use this unit instead of - years to avoid integer overflow. For example, 2 average - Gregorian years are 2 * 365.2425 * 24 * 60 * 60 seconds, - which is 63113904 seconds, and rint (log2 (63113904)) is - 26. */ + biennium. A biennium is 2 years; use this unit instead of + years to avoid integer overflow. For example, 2 average + Gregorian years are 2 * 365.2425 * 24 * 60 * 60 seconds, + which is 63113904 seconds, and rint (log2 (63113904)) is + 26. */ int ALOG2_SECONDS_PER_BIENNIUM = 26; int ALOG2_MINUTES_PER_BIENNIUM = 20; int ALOG2_HOURS_PER_BIENNIUM = 14; @@ -361,64 +365,64 @@ __mktime_internal (struct tm *tp, int LOG2_YEARS_PER_BIENNIUM = 1; int approx_requested_biennia = - (SHR (year_requested, LOG2_YEARS_PER_BIENNIUM) - - SHR (EPOCH_YEAR - TM_YEAR_BASE, LOG2_YEARS_PER_BIENNIUM) - + SHR (mday, ALOG2_DAYS_PER_BIENNIUM) - + SHR (hour, ALOG2_HOURS_PER_BIENNIUM) - + SHR (min, ALOG2_MINUTES_PER_BIENNIUM) - + (LEAP_SECONDS_POSSIBLE - ? 0 - : SHR (sec, ALOG2_SECONDS_PER_BIENNIUM))); + (SHR (year_requested, LOG2_YEARS_PER_BIENNIUM) + - SHR (EPOCH_YEAR - TM_YEAR_BASE, LOG2_YEARS_PER_BIENNIUM) + + SHR (mday, ALOG2_DAYS_PER_BIENNIUM) + + SHR (hour, ALOG2_HOURS_PER_BIENNIUM) + + SHR (min, ALOG2_MINUTES_PER_BIENNIUM) + + (LEAP_SECONDS_POSSIBLE + ? 0 + : SHR (sec, ALOG2_SECONDS_PER_BIENNIUM))); int approx_biennia = SHR (t0, ALOG2_SECONDS_PER_BIENNIUM); int diff = approx_biennia - approx_requested_biennia; int abs_diff = diff < 0 ? - diff : diff; /* IRIX 4.0.5 cc miscaculates TIME_T_MIN / 3: it erroneously - gives a positive value of 715827882. Setting a variable - first then doing math on it seems to work. - (ghazi@caip.rutgers.edu) */ + gives a positive value of 715827882. Setting a variable + first then doing math on it seems to work. + (ghazi@caip.rutgers.edu) */ time_t time_t_max = TIME_T_MAX; time_t time_t_min = TIME_T_MIN; time_t overflow_threshold = - (time_t_max / 3 - time_t_min / 3) >> ALOG2_SECONDS_PER_BIENNIUM; + (time_t_max / 3 - time_t_min / 3) >> ALOG2_SECONDS_PER_BIENNIUM; if (overflow_threshold < abs_diff) - { - /* Overflow occurred. Try repairing it; this might work if - the time zone offset is enough to undo the overflow. */ - time_t repaired_t0 = -1 - t0; - approx_biennia = SHR (repaired_t0, ALOG2_SECONDS_PER_BIENNIUM); - diff = approx_biennia - approx_requested_biennia; - abs_diff = diff < 0 ? - diff : diff; - if (overflow_threshold < abs_diff) - return -1; - guessed_offset += repaired_t0 - t0; - t0 = repaired_t0; - } + { + /* Overflow occurred. Try repairing it; this might work if + the time zone offset is enough to undo the overflow. */ + time_t repaired_t0 = -1 - t0; + approx_biennia = SHR (repaired_t0, ALOG2_SECONDS_PER_BIENNIUM); + diff = approx_biennia - approx_requested_biennia; + abs_diff = diff < 0 ? - diff : diff; + if (overflow_threshold < abs_diff) + return -1; + guessed_offset += repaired_t0 - t0; + t0 = repaired_t0; + } } /* Repeatedly use the error to improve the guess. */ for (t = t1 = t2 = t0, dst2 = 0; (gt = guess_time_tm (year, yday, hour, min, sec, &t, - ranged_convert (convert, &t, &tm)), - t != gt); + ranged_convert (convert, &t, &tm)), + t != gt); t1 = t2, t2 = t, t = gt, dst2 = tm.tm_isdst != 0) if (t == t1 && t != t2 - && (tm.tm_isdst < 0 - || (isdst < 0 - ? dst2 <= (tm.tm_isdst != 0) - : (isdst != 0) != (tm.tm_isdst != 0)))) + && (tm.tm_isdst < 0 + || (isdst < 0 + ? dst2 <= (tm.tm_isdst != 0) + : (isdst != 0) != (tm.tm_isdst != 0)))) /* We can't possibly find a match, as we are oscillating - between two values. The requested time probably falls - within a spring-forward gap of size GT - T. Follow the common - practice in this case, which is to return a time that is GT - T - away from the requested time, preferring a time whose - tm_isdst differs from the requested value. (If no tm_isdst - was requested and only one of the two values has a nonzero - tm_isdst, prefer that value.) In practice, this is more - useful than returning -1. */ + between two values. The requested time probably falls + within a spring-forward gap of size GT - T. Follow the common + practice in this case, which is to return a time that is GT - T + away from the requested time, preferring a time whose + tm_isdst differs from the requested value. (If no tm_isdst + was requested and only one of the two values has a nonzero + tm_isdst, prefer that value.) In practice, this is more + useful than returning -1. */ goto offset_found; else if (--remaining_probes == 0) return -1; @@ -428,52 +432,52 @@ __mktime_internal (struct tm *tp, if (isdst != tm.tm_isdst && 0 <= isdst && 0 <= tm.tm_isdst) { /* tm.tm_isdst has the wrong value. Look for a neighboring - time with the right value, and use its UTC offset. + time with the right value, and use its UTC offset. - Heuristic: probe the adjacent timestamps in both directions, - looking for the desired isdst. This should work for all real - time zone histories in the tz database. */ + Heuristic: probe the adjacent timestamps in both directions, + looking for the desired isdst. This should work for all real + time zone histories in the tz database. */ /* Distance between probes when looking for a DST boundary. In - tzdata2003a, the shortest period of DST is 601200 seconds - (e.g., America/Recife starting 2000-10-08 01:00), and the - shortest period of non-DST surrounded by DST is 694800 - seconds (Africa/Tunis starting 1943-04-17 01:00). Use the - minimum of these two values, so we don't miss these short - periods when probing. */ + tzdata2003a, the shortest period of DST is 601200 seconds + (e.g., America/Recife starting 2000-10-08 01:00), and the + shortest period of non-DST surrounded by DST is 694800 + seconds (Africa/Tunis starting 1943-04-17 01:00). Use the + minimum of these two values, so we don't miss these short + periods when probing. */ int stride = 601200; /* The longest period of DST in tzdata2003a is 536454000 seconds - (e.g., America/Jujuy starting 1946-10-01 01:00). The longest - period of non-DST is much longer, but it makes no real sense - to search for more than a year of non-DST, so use the DST - max. */ + (e.g., America/Jujuy starting 1946-10-01 01:00). The longest + period of non-DST is much longer, but it makes no real sense + to search for more than a year of non-DST, so use the DST + max. */ int duration_max = 536454000; /* Search in both directions, so the maximum distance is half - the duration; add the stride to avoid off-by-1 problems. */ + the duration; add the stride to avoid off-by-1 problems. */ int delta_bound = duration_max / 2 + stride; int delta, direction; for (delta = stride; delta < delta_bound; delta += stride) - for (direction = -1; direction <= 1; direction += 2) - { - time_t ot = t + delta * direction; - if ((ot < t) == (direction < 0)) - { - struct tm otm; - ranged_convert (convert, &ot, &otm); - if (otm.tm_isdst == isdst) - { - /* We found the desired tm_isdst. - Extrapolate back to the desired time. */ - t = guess_time_tm (year, yday, hour, min, sec, &ot, &otm); - ranged_convert (convert, &t, &tm); - goto offset_found; - } - } - } + for (direction = -1; direction <= 1; direction += 2) + { + time_t ot = t + delta * direction; + if ((ot < t) == (direction < 0)) + { + struct tm otm; + ranged_convert (convert, &ot, &otm); + if (otm.tm_isdst == isdst) + { + /* We found the desired tm_isdst. + Extrapolate back to the desired time. */ + t = guess_time_tm (year, yday, hour, min, sec, &ot, &otm); + ranged_convert (convert, &t, &tm); + goto offset_found; + } + } + } } offset_found: @@ -482,14 +486,14 @@ __mktime_internal (struct tm *tp, if (LEAP_SECONDS_POSSIBLE && sec_requested != tm.tm_sec) { /* Adjust time to reflect the tm_sec requested, not the normalized value. - Also, repair any damage from a false match due to a leap second. */ + Also, repair any damage from a false match due to a leap second. */ int sec_adjustment = (sec == 0 && tm.tm_sec == 60) - sec; t1 = t + sec_requested; t2 = t1 + sec_adjustment; if (((t1 < t) != (sec_requested < 0)) - | ((t2 < t1) != (sec_adjustment < 0)) - | ! convert (&t2, &tm)) - return -1; + | ((t2 < t1) != (sec_adjustment < 0)) + | ! convert (&t2, &tm)) + return -1; t = t2; } @@ -533,13 +537,13 @@ static int not_equal_tm (const struct tm *a, const struct tm *b) { return ((a->tm_sec ^ b->tm_sec) - | (a->tm_min ^ b->tm_min) - | (a->tm_hour ^ b->tm_hour) - | (a->tm_mday ^ b->tm_mday) - | (a->tm_mon ^ b->tm_mon) - | (a->tm_year ^ b->tm_year) - | (a->tm_yday ^ b->tm_yday) - | (a->tm_isdst ^ b->tm_isdst)); + | (a->tm_min ^ b->tm_min) + | (a->tm_hour ^ b->tm_hour) + | (a->tm_mday ^ b->tm_mday) + | (a->tm_mon ^ b->tm_mon) + | (a->tm_year ^ b->tm_year) + | (a->tm_yday ^ b->tm_yday) + | (a->tm_isdst ^ b->tm_isdst)); } static void @@ -547,9 +551,9 @@ print_tm (const struct tm *tp) { if (tp) printf ("%04d-%02d-%02d %02d:%02d:%02d yday %03d wday %d isdst %d", - tp->tm_year + TM_YEAR_BASE, tp->tm_mon + 1, tp->tm_mday, - tp->tm_hour, tp->tm_min, tp->tm_sec, - tp->tm_yday, tp->tm_wday, tp->tm_isdst); + tp->tm_year + TM_YEAR_BASE, tp->tm_mon + 1, tp->tm_mday, + tp->tm_hour, tp->tm_min, tp->tm_sec, + tp->tm_yday, tp->tm_wday, tp->tm_isdst); else printf ("0"); } @@ -581,11 +585,11 @@ main (int argc, char **argv) if ((argc == 3 || argc == 4) && (sscanf (argv[1], "%d-%d-%d%c", - &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &trailer) - == 3) + &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &trailer) + == 3) && (sscanf (argv[2], "%d:%d:%d%c", - &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &trailer) - == 3)) + &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &trailer) + == 3)) { tm.tm_year -= TM_YEAR_BASE; tm.tm_mon--; @@ -594,10 +598,10 @@ main (int argc, char **argv) tl = mktime (&tmk); lt = localtime (&tl); if (lt) - { - tml = *lt; - lt = &tml; - } + { + tml = *lt; + lt = &tml; + } printf ("mktime returns %ld == ", (long int) tl); print_tm (&tmk); printf ("\n"); @@ -610,51 +614,51 @@ main (int argc, char **argv) time_t to = atol (argv[3]); if (argc == 4) - for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1) - { - lt = localtime (&tl); - if (lt) - { - tmk = tml = *lt; - tk = mktime (&tmk); - status |= check_result (tk, tmk, tl, &tml); - } - else - { - printf ("localtime (%ld) yields 0\n", (long int) tl); - status = 1; - } - tl1 = tl + by; - if ((tl1 < tl) != (by < 0)) - break; - } + for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1) + { + lt = localtime (&tl); + if (lt) + { + tmk = tml = *lt; + tk = mktime (&tmk); + status |= check_result (tk, tmk, tl, &tml); + } + else + { + printf ("localtime (%ld) yields 0\n", (long int) tl); + status = 1; + } + tl1 = tl + by; + if ((tl1 < tl) != (by < 0)) + break; + } else - for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1) - { - /* Null benchmark. */ - lt = localtime (&tl); - if (lt) - { - tmk = tml = *lt; - tk = tl; - status |= check_result (tk, tmk, tl, &tml); - } - else - { - printf ("localtime (%ld) yields 0\n", (long int) tl); - status = 1; - } - tl1 = tl + by; - if ((tl1 < tl) != (by < 0)) - break; - } + for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1) + { + /* Null benchmark. */ + lt = localtime (&tl); + if (lt) + { + tmk = tml = *lt; + tk = tl; + status |= check_result (tk, tmk, tl, &tml); + } + else + { + printf ("localtime (%ld) yields 0\n", (long int) tl); + status = 1; + } + tl1 = tl + by; + if ((tl1 < tl) != (by < 0)) + break; + } } else printf ("Usage:\ \t%s YYYY-MM-DD HH:MM:SS [ISDST] # Test given time.\n\ \t%s FROM BY TO # Test values FROM, FROM+BY, ..., TO.\n\ \t%s FROM BY TO - # Do not test those values (for benchmark).\n", - argv[0], argv[0], argv[0]); + argv[0], argv[0], argv[0]); return status; } diff --git a/src/bin/coreutils/lib/modechange.c b/src/bin/coreutils/lib/modechange.c index 1296717c5f..9b4e23f4be 100644 --- a/src/bin/coreutils/lib/modechange.c +++ b/src/bin/coreutils/lib/modechange.c @@ -1,7 +1,7 @@ /* modechange.c -- file mode manipulation - Copyright (C) 1989, 1990, 1997, 1998, 1999, 2001, 2003, 2004, 2005, - 2006 Free Software Foundation, Inc. + Copyright (C) 1989-1990, 1997-1999, 2001, 2003-2006, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -56,22 +56,22 @@ octal_to_mode (unsigned int octal) /* Help the compiler optimize the usual case where mode_t uses the traditional octal representation. */ return ((S_ISUID == SUID && S_ISGID == SGID && S_ISVTX == SVTX - && S_IRUSR == RUSR && S_IWUSR == WUSR && S_IXUSR == XUSR - && S_IRGRP == RGRP && S_IWGRP == WGRP && S_IXGRP == XGRP - && S_IROTH == ROTH && S_IWOTH == WOTH && S_IXOTH == XOTH) - ? octal - : (mode_t) ((octal & SUID ? S_ISUID : 0) - | (octal & SGID ? S_ISGID : 0) - | (octal & SVTX ? S_ISVTX : 0) - | (octal & RUSR ? S_IRUSR : 0) - | (octal & WUSR ? S_IWUSR : 0) - | (octal & XUSR ? S_IXUSR : 0) - | (octal & RGRP ? S_IRGRP : 0) - | (octal & WGRP ? S_IWGRP : 0) - | (octal & XGRP ? S_IXGRP : 0) - | (octal & ROTH ? S_IROTH : 0) - | (octal & WOTH ? S_IWOTH : 0) - | (octal & XOTH ? S_IXOTH : 0))); + && S_IRUSR == RUSR && S_IWUSR == WUSR && S_IXUSR == XUSR + && S_IRGRP == RGRP && S_IWGRP == WGRP && S_IXGRP == XGRP + && S_IROTH == ROTH && S_IWOTH == WOTH && S_IXOTH == XOTH) + ? octal + : (mode_t) ((octal & SUID ? S_ISUID : 0) + | (octal & SGID ? S_ISGID : 0) + | (octal & SVTX ? S_ISVTX : 0) + | (octal & RUSR ? S_IRUSR : 0) + | (octal & WUSR ? S_IWUSR : 0) + | (octal & XUSR ? S_IXUSR : 0) + | (octal & RGRP ? S_IRGRP : 0) + | (octal & WGRP ? S_IWGRP : 0) + | (octal & XGRP ? S_IXGRP : 0) + | (octal & ROTH ? S_IROTH : 0) + | (octal & WOTH ? S_IWOTH : 0) + | (octal & XOTH ? S_IXOTH : 0))); } /* Special operations flags. */ @@ -97,11 +97,11 @@ enum /* Description of a mode change. */ struct mode_change { - char op; /* One of "=+-". */ - char flag; /* Special operations flag. */ - mode_t affected; /* Set for u, g, o, or a. */ - mode_t value; /* Bits to add/remove. */ - mode_t mentioned; /* Bits explicitly mentioned. */ + char op; /* One of "=+-". */ + char flag; /* Special operations flag. */ + mode_t affected; /* Set for u, g, o, or a. */ + mode_t value; /* Bits to add/remove. */ + mode_t mentioned; /* Bits explicitly mentioned. */ }; /* Return a mode_change array with the specified `=ddd'-style @@ -144,15 +144,15 @@ mode_compile (char const *mode_string) mode_t mentioned; do - { - octal_mode = 8 * octal_mode + *mode_string++ - '0'; - if (ALLM < octal_mode) - return NULL; - } + { + octal_mode = 8 * octal_mode + *mode_string++ - '0'; + if (ALLM < octal_mode) + return NULL; + } while ('0' <= *mode_string && *mode_string < '8'); if (*mode_string) - return NULL; + return NULL; mode = octal_to_mode (octal_mode); mentioned = (mode & (S_ISUID | S_ISGID)) | S_ISVTX | S_IRWXUGO; @@ -176,97 +176,97 @@ mode_compile (char const *mode_string) /* Turn on all the bits in `affected' for each group given. */ for (;; mode_string++) - switch (*mode_string) - { - default: - goto invalid; - case 'u': - affected |= S_ISUID | S_IRWXU; - break; - case 'g': - affected |= S_ISGID | S_IRWXG; - break; - case 'o': - affected |= S_ISVTX | S_IRWXO; - break; - case 'a': - affected |= CHMOD_MODE_BITS; - break; - case '=': case '+': case '-': - goto no_more_affected; - } + switch (*mode_string) + { + default: + goto invalid; + case 'u': + affected |= S_ISUID | S_IRWXU; + break; + case 'g': + affected |= S_ISGID | S_IRWXG; + break; + case 'o': + affected |= S_ISVTX | S_IRWXO; + break; + case 'a': + affected |= CHMOD_MODE_BITS; + break; + case '=': case '+': case '-': + goto no_more_affected; + } no_more_affected:; do - { - char op = *mode_string++; - mode_t value; - char flag = MODE_COPY_EXISTING; - struct mode_change *change; + { + char op = *mode_string++; + mode_t value; + char flag = MODE_COPY_EXISTING; + struct mode_change *change; - switch (*mode_string++) - { - case 'u': - /* Set the affected bits to the value of the `u' bits - on the same file. */ - value = S_IRWXU; - break; - case 'g': - /* Set the affected bits to the value of the `g' bits - on the same file. */ - value = S_IRWXG; - break; - case 'o': - /* Set the affected bits to the value of the `o' bits - on the same file. */ - value = S_IRWXO; - break; + switch (*mode_string++) + { + case 'u': + /* Set the affected bits to the value of the `u' bits + on the same file. */ + value = S_IRWXU; + break; + case 'g': + /* Set the affected bits to the value of the `g' bits + on the same file. */ + value = S_IRWXG; + break; + case 'o': + /* Set the affected bits to the value of the `o' bits + on the same file. */ + value = S_IRWXO; + break; - default: - value = 0; - flag = MODE_ORDINARY_CHANGE; + default: + value = 0; + flag = MODE_ORDINARY_CHANGE; - for (mode_string--;; mode_string++) - switch (*mode_string) - { - case 'r': - value |= S_IRUSR | S_IRGRP | S_IROTH; - break; - case 'w': - value |= S_IWUSR | S_IWGRP | S_IWOTH; - break; - case 'x': - value |= S_IXUSR | S_IXGRP | S_IXOTH; - break; - case 'X': - flag = MODE_X_IF_ANY_X; - break; - case 's': - /* Set the setuid/gid bits if `u' or `g' is selected. */ - value |= S_ISUID | S_ISGID; - break; - case 't': - /* Set the "save text image" bit if `o' is selected. */ - value |= S_ISVTX; - break; - default: - goto no_more_values; - } - no_more_values:; - } + for (mode_string--;; mode_string++) + switch (*mode_string) + { + case 'r': + value |= S_IRUSR | S_IRGRP | S_IROTH; + break; + case 'w': + value |= S_IWUSR | S_IWGRP | S_IWOTH; + break; + case 'x': + value |= S_IXUSR | S_IXGRP | S_IXOTH; + break; + case 'X': + flag = MODE_X_IF_ANY_X; + break; + case 's': + /* Set the setuid/gid bits if `u' or `g' is selected. */ + value |= S_ISUID | S_ISGID; + break; + case 't': + /* Set the "save text image" bit if `o' is selected. */ + value |= S_ISVTX; + break; + default: + goto no_more_values; + } + no_more_values:; + } - change = &mc[used++]; - change->op = op; - change->flag = flag; - change->affected = affected; - change->value = value; - change->mentioned = (affected ? affected & value : value); - } + change = &mc[used++]; + change->op = op; + change->flag = flag; + change->affected = affected; + change->value = value; + change->mentioned = (affected ? affected & value : value); + } while (*mode_string == '=' || *mode_string == '+' - || *mode_string == '-'); + || *mode_string == '-'); if (*mode_string != ',') - break; + break; } if (*mode_string == 0) @@ -308,7 +308,7 @@ mode_create_from_ref (const char *ref_file) mode_t mode_adjust (mode_t oldmode, bool dir, mode_t umask_value, - struct mode_change const *changes, mode_t *pmode_bits) + struct mode_change const *changes, mode_t *pmode_bits) { /* The adjusted mode. */ mode_t newmode = oldmode & CHMOD_MODE_BITS; @@ -320,63 +320,63 @@ mode_adjust (mode_t oldmode, bool dir, mode_t umask_value, { mode_t affected = changes->affected; mode_t omit_change = - (dir ? S_ISUID | S_ISGID : 0) & ~ changes->mentioned; + (dir ? S_ISUID | S_ISGID : 0) & ~ changes->mentioned; mode_t value = changes->value; switch (changes->flag) - { - case MODE_ORDINARY_CHANGE: - break; + { + case MODE_ORDINARY_CHANGE: + break; - case MODE_COPY_EXISTING: - /* Isolate in `value' the bits in `newmode' to copy. */ - value &= newmode; + case MODE_COPY_EXISTING: + /* Isolate in `value' the bits in `newmode' to copy. */ + value &= newmode; - /* Copy the isolated bits to the other two parts. */ - value |= ((value & (S_IRUSR | S_IRGRP | S_IROTH) - ? S_IRUSR | S_IRGRP | S_IROTH : 0) - | (value & (S_IWUSR | S_IWGRP | S_IWOTH) - ? S_IWUSR | S_IWGRP | S_IWOTH : 0) - | (value & (S_IXUSR | S_IXGRP | S_IXOTH) - ? S_IXUSR | S_IXGRP | S_IXOTH : 0)); - break; + /* Copy the isolated bits to the other two parts. */ + value |= ((value & (S_IRUSR | S_IRGRP | S_IROTH) + ? S_IRUSR | S_IRGRP | S_IROTH : 0) + | (value & (S_IWUSR | S_IWGRP | S_IWOTH) + ? S_IWUSR | S_IWGRP | S_IWOTH : 0) + | (value & (S_IXUSR | S_IXGRP | S_IXOTH) + ? S_IXUSR | S_IXGRP | S_IXOTH : 0)); + break; - case MODE_X_IF_ANY_X: - /* Affect the execute bits if execute bits are already set - or if the file is a directory. */ - if ((newmode & (S_IXUSR | S_IXGRP | S_IXOTH)) | dir) - value |= S_IXUSR | S_IXGRP | S_IXOTH; - break; - } + case MODE_X_IF_ANY_X: + /* Affect the execute bits if execute bits are already set + or if the file is a directory. */ + if ((newmode & (S_IXUSR | S_IXGRP | S_IXOTH)) | dir) + value |= S_IXUSR | S_IXGRP | S_IXOTH; + break; + } /* If WHO was specified, limit the change to the affected bits. - Otherwise, apply the umask. Either way, omit changes as - requested. */ + Otherwise, apply the umask. Either way, omit changes as + requested. */ value &= (affected ? affected : ~umask_value) & ~ omit_change; switch (changes->op) - { - case '=': - /* If WHO was specified, preserve the previous values of - bits that are not affected by this change operation. - Otherwise, clear all the bits. */ - { - mode_t preserved = (affected ? ~affected : 0) | omit_change; - mode_bits |= CHMOD_MODE_BITS & ~preserved; - newmode = (newmode & preserved) | value; - break; - } + { + case '=': + /* If WHO was specified, preserve the previous values of + bits that are not affected by this change operation. + Otherwise, clear all the bits. */ + { + mode_t preserved = (affected ? ~affected : 0) | omit_change; + mode_bits |= CHMOD_MODE_BITS & ~preserved; + newmode = (newmode & preserved) | value; + break; + } - case '+': - mode_bits |= value; - newmode |= value; - break; + case '+': + mode_bits |= value; + newmode |= value; + break; - case '-': - mode_bits |= value; - newmode &= ~value; - break; - } + case '-': + mode_bits |= value; + newmode &= ~value; + break; + } } if (pmode_bits) diff --git a/src/bin/coreutils/lib/modechange.h b/src/bin/coreutils/lib/modechange.h index f6f8e744d6..3cc4bf9dbc 100644 --- a/src/bin/coreutils/lib/modechange.h +++ b/src/bin/coreutils/lib/modechange.h @@ -1,7 +1,7 @@ /* modechange.h -- definitions for file mode manipulation - Copyright (C) 1989, 1990, 1997, 2003, 2004, 2005, 2006 Free - Software Foundation, Inc. + Copyright (C) 1989-1990, 1997, 2003-2006, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,6 +25,6 @@ struct mode_change *mode_compile (const char *); struct mode_change *mode_create_from_ref (const char *); mode_t mode_adjust (mode_t, bool, mode_t, struct mode_change const *, - mode_t *); + mode_t *); #endif diff --git a/src/bin/coreutils/lib/mountlist.c b/src/bin/coreutils/lib/mountlist.c index 50e90eed47..ccb08dde6c 100644 --- a/src/bin/coreutils/lib/mountlist.c +++ b/src/bin/coreutils/lib/mountlist.c @@ -1,6 +1,6 @@ /* mountlist.c -- return a list of mounted file systems - Copyright (C) 1991, 1992, 1997-2009 Free Software Foundation, Inc. + Copyright (C) 1991-1992, 1997-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,10 +37,10 @@ # include #endif -#if defined MOUNTED_GETFSSTAT /* OSF_1 and Darwin1.3.x */ +#if defined MOUNTED_GETFSSTAT /* OSF_1 and Darwin1.3.x */ # if HAVE_SYS_UCRED_H # include /* needed on OSF V4.0 for definition of NGROUPS, - NGROUPS is used as an array dimension in ucred.h */ + NGROUPS is used as an array dimension in ucred.h */ # include /* needed by powerpc-apple-darwin1.3.7 */ # endif # if HAVE_SYS_MOUNT_H @@ -56,44 +56,44 @@ # endif #endif /* MOUNTED_GETFSSTAT */ -#ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */ +#ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */ # include # if !defined MOUNTED -# if defined _PATH_MOUNTED /* GNU libc */ +# if defined _PATH_MOUNTED /* GNU libc */ # define MOUNTED _PATH_MOUNTED # endif -# if defined MNT_MNTTAB /* HP-UX. */ +# if defined MNT_MNTTAB /* HP-UX. */ # define MOUNTED MNT_MNTTAB # endif -# if defined MNTTABNAME /* Dynix. */ +# if defined MNTTABNAME /* Dynix. */ # define MOUNTED MNTTABNAME # endif # endif #endif -#ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */ +#ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */ # include #endif -#ifdef MOUNTED_GETMNTINFO2 /* NetBSD 3.0. */ +#ifdef MOUNTED_GETMNTINFO2 /* NetBSD 3.0. */ # include #endif -#ifdef MOUNTED_GETMNT /* Ultrix. */ +#ifdef MOUNTED_GETMNT /* Ultrix. */ # include # include #endif -#ifdef MOUNTED_FS_STAT_DEV /* BeOS. */ +#ifdef MOUNTED_FS_STAT_DEV /* BeOS. */ # include # include #endif -#ifdef MOUNTED_FREAD /* SVR2. */ +#ifdef MOUNTED_FREAD /* SVR2. */ # include #endif -#ifdef MOUNTED_FREAD_FSTYP /* SVR3. */ +#ifdef MOUNTED_FREAD_FSTYP /* SVR3. */ # include # include # include @@ -103,11 +103,11 @@ # include #endif -#ifdef MOUNTED_GETMNTENT2 /* SVR4. */ +#ifdef MOUNTED_GETMNTENT2 /* SVR4. */ # include #endif -#ifdef MOUNTED_VMOUNT /* AIX. */ +#ifdef MOUNTED_VMOUNT /* AIX. */ # include # include #endif @@ -145,26 +145,26 @@ #undef closedir #ifndef ME_DUMMY -# define ME_DUMMY(Fs_name, Fs_type) \ - (strcmp (Fs_type, "autofs") == 0 \ - || strcmp (Fs_type, "none") == 0 \ - || strcmp (Fs_type, "proc") == 0 \ - || strcmp (Fs_type, "subfs") == 0 \ - /* for NetBSD 3.0 */ \ - || strcmp (Fs_type, "kernfs") == 0 \ - /* for Irix 6.5 */ \ +# define ME_DUMMY(Fs_name, Fs_type) \ + (strcmp (Fs_type, "autofs") == 0 \ + || strcmp (Fs_type, "none") == 0 \ + || strcmp (Fs_type, "proc") == 0 \ + || strcmp (Fs_type, "subfs") == 0 \ + /* for NetBSD 3.0 */ \ + || strcmp (Fs_type, "kernfs") == 0 \ + /* for Irix 6.5 */ \ || strcmp (Fs_type, "ignore") == 0) #endif #ifndef ME_REMOTE /* A file system is `remote' if its Fs_name contains a `:' or if (it is of type (smbfs or cifs) and its Fs_name starts with `//'). */ -# define ME_REMOTE(Fs_name, Fs_type) \ - (strchr (Fs_name, ':') != NULL \ - || ((Fs_name)[0] == '/' \ - && (Fs_name)[1] == '/' \ - && (strcmp (Fs_type, "smbfs") == 0 \ - || strcmp (Fs_type, "cifs") == 0))) +# define ME_REMOTE(Fs_name, Fs_type) \ + (strchr (Fs_name, ':') != NULL \ + || ((Fs_name)[0] == '/' \ + && (Fs_name)[1] == '/' \ + && (strcmp (Fs_type, "smbfs") == 0 \ + || strcmp (Fs_type, "cifs") == 0))) #endif #if MOUNTED_GETMNTINFO @@ -277,7 +277,7 @@ fsp_to_string (const struct statfs *fsp) #endif /* MOUNTED_GETMNTINFO */ -#ifdef MOUNTED_VMOUNT /* AIX. */ +#ifdef MOUNTED_VMOUNT /* AIX. */ static char * fstype_to_string (int t) { @@ -315,10 +315,10 @@ dev_from_mount_options (char const *mount_options) errno = 0; dev = strtoul (optval, &optvalend, 16); if (optval != optvalend - && (*optvalend == '\0' || *optvalend == ',') - && ! (dev == ULONG_MAX && errno == ERANGE) - && dev == (dev_t) dev) - return dev; + && (*optvalend == '\0' || *optvalend == ',') + && ! (dev == ULONG_MAX && errno == ERANGE) + && dev == (dev_t) dev) + return dev; } # endif @@ -383,18 +383,18 @@ read_file_system_list (bool need_fs_type) while ((mnt = getmntent (fp))) { - me = xmalloc (sizeof *me); - me->me_devname = xstrdup (mnt->mnt_fsname); - me->me_mountdir = xstrdup (mnt->mnt_dir); - me->me_type = xstrdup (mnt->mnt_type); - me->me_type_malloced = 1; - me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); - me->me_remote = ME_REMOTE (me->me_devname, me->me_type); - me->me_dev = dev_from_mount_options (mnt->mnt_opts); + me = xmalloc (sizeof *me); + me->me_devname = xstrdup (mnt->mnt_fsname); + me->me_mountdir = xstrdup (mnt->mnt_dir); + me->me_type = xstrdup (mnt->mnt_type); + me->me_type_malloced = 1; + me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); + me->me_remote = ME_REMOTE (me->me_devname, me->me_type); + me->me_dev = dev_from_mount_options (mnt->mnt_opts); - /* Add to the linked list. */ - *mtail = me; - mtail = &me->me_next; + /* Add to the linked list. */ + *mtail = me; + mtail = &me->me_next; } if (endmntent (fp) == 0) @@ -402,7 +402,7 @@ read_file_system_list (bool need_fs_type) } #endif /* MOUNTED_GETMNTENT1. */ -#ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */ +#ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */ { struct statfs *fsp; int entries; @@ -412,25 +412,25 @@ read_file_system_list (bool need_fs_type) return NULL; for (; entries-- > 0; fsp++) { - char *fs_type = fsp_to_string (fsp); + char *fs_type = fsp_to_string (fsp); - me = xmalloc (sizeof *me); - me->me_devname = xstrdup (fsp->f_mntfromname); - me->me_mountdir = xstrdup (fsp->f_mntonname); - me->me_type = fs_type; - me->me_type_malloced = 0; - me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); - me->me_remote = ME_REMOTE (me->me_devname, me->me_type); - me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ + me = xmalloc (sizeof *me); + me->me_devname = xstrdup (fsp->f_mntfromname); + me->me_mountdir = xstrdup (fsp->f_mntonname); + me->me_type = fs_type; + me->me_type_malloced = 0; + me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); + me->me_remote = ME_REMOTE (me->me_devname, me->me_type); + me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ - /* Add to the linked list. */ - *mtail = me; - mtail = &me->me_next; + /* Add to the linked list. */ + *mtail = me; + mtail = &me->me_next; } } #endif /* MOUNTED_GETMNTINFO */ -#ifdef MOUNTED_GETMNTINFO2 /* NetBSD 3.0. */ +#ifdef MOUNTED_GETMNTINFO2 /* NetBSD 3.0. */ { struct statvfs *fsp; int entries; @@ -440,44 +440,44 @@ read_file_system_list (bool need_fs_type) return NULL; for (; entries-- > 0; fsp++) { - me = xmalloc (sizeof *me); - me->me_devname = xstrdup (fsp->f_mntfromname); - me->me_mountdir = xstrdup (fsp->f_mntonname); - me->me_type = xstrdup (fsp->f_fstypename); - me->me_type_malloced = 1; - me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); - me->me_remote = ME_REMOTE (me->me_devname, me->me_type); - me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ + me = xmalloc (sizeof *me); + me->me_devname = xstrdup (fsp->f_mntfromname); + me->me_mountdir = xstrdup (fsp->f_mntonname); + me->me_type = xstrdup (fsp->f_fstypename); + me->me_type_malloced = 1; + me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); + me->me_remote = ME_REMOTE (me->me_devname, me->me_type); + me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ - /* Add to the linked list. */ - *mtail = me; - mtail = &me->me_next; + /* Add to the linked list. */ + *mtail = me; + mtail = &me->me_next; } } #endif /* MOUNTED_GETMNTINFO2 */ -#ifdef MOUNTED_GETMNT /* Ultrix. */ +#ifdef MOUNTED_GETMNT /* Ultrix. */ { int offset = 0; int val; struct fs_data fsd; while (errno = 0, - 0 < (val = getmnt (&offset, &fsd, sizeof (fsd), NOSTAT_MANY, - (char *) 0))) + 0 < (val = getmnt (&offset, &fsd, sizeof (fsd), NOSTAT_MANY, + (char *) 0))) { - me = xmalloc (sizeof *me); - me->me_devname = xstrdup (fsd.fd_req.devname); - me->me_mountdir = xstrdup (fsd.fd_req.path); - me->me_type = gt_names[fsd.fd_req.fstype]; - me->me_type_malloced = 0; - me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); - me->me_remote = ME_REMOTE (me->me_devname, me->me_type); - me->me_dev = fsd.fd_req.dev; + me = xmalloc (sizeof *me); + me->me_devname = xstrdup (fsd.fd_req.devname); + me->me_mountdir = xstrdup (fsd.fd_req.path); + me->me_type = gt_names[fsd.fd_req.fstype]; + me->me_type_malloced = 0; + me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); + me->me_remote = ME_REMOTE (me->me_devname, me->me_type); + me->me_dev = fsd.fd_req.dev; - /* Add to the linked list. */ - *mtail = me; - mtail = &me->me_next; + /* Add to the linked list. */ + *mtail = me; + mtail = &me->me_next; } if (val < 0) goto free_then_fail; @@ -537,7 +537,7 @@ read_file_system_list (bool need_fs_type) if (lstat (name, &statbuf) >= 0 && S_ISDIR (statbuf.st_mode)) { - struct rootdir_entry *re = xmalloc (sizeof *re); + struct rootdir_entry *re = xmalloc (sizeof *re); re->name = name; re->dev = statbuf.st_dev; re->ino = statbuf.st_ino; @@ -563,11 +563,11 @@ read_file_system_list (bool need_fs_type) if (re->dev == fi.dev && re->ino == fi.root) break; - me = xmalloc (sizeof *me); + me = xmalloc (sizeof *me); me->me_devname = xstrdup (fi.device_name[0] != '\0' ? fi.device_name : fi.fsh_name); me->me_mountdir = xstrdup (re != NULL ? re->name : fi.fsh_name); me->me_type = xstrdup (fi.fsh_name); - me->me_type_malloced = 1; + me->me_type_malloced = 1; me->me_dev = fi.dev; me->me_dummy = 0; me->me_remote = (fi.flags & B_FS_IS_SHARED) != 0; @@ -588,7 +588,7 @@ read_file_system_list (bool need_fs_type) } #endif /* MOUNTED_FS_STAT_DEV */ -#if defined MOUNTED_GETFSSTAT /* __alpha running OSF_1 */ +#if defined MOUNTED_GETFSSTAT /* __alpha running OSF_1 */ { int numsys, counter; size_t bufsize; @@ -606,24 +606,24 @@ read_file_system_list (bool need_fs_type) if (numsys < 0) { - free (stats); - return (NULL); + free (stats); + return (NULL); } for (counter = 0; counter < numsys; counter++) { - me = xmalloc (sizeof *me); - me->me_devname = xstrdup (stats[counter].f_mntfromname); - me->me_mountdir = xstrdup (stats[counter].f_mntonname); - me->me_type = xstrdup (FS_TYPE (stats[counter])); - me->me_type_malloced = 1; - me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); - me->me_remote = ME_REMOTE (me->me_devname, me->me_type); - me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ + me = xmalloc (sizeof *me); + me->me_devname = xstrdup (stats[counter].f_mntfromname); + me->me_mountdir = xstrdup (stats[counter].f_mntonname); + me->me_type = xstrdup (FS_TYPE (stats[counter])); + me->me_type_malloced = 1; + me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); + me->me_remote = ME_REMOTE (me->me_devname, me->me_type); + me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ - /* Add to the linked list. */ - *mtail = me; - mtail = &me->me_next; + /* Add to the linked list. */ + *mtail = me; + mtail = &me->me_next; } free (stats); @@ -642,47 +642,47 @@ read_file_system_list (bool need_fs_type) while (fread (&mnt, sizeof mnt, 1, fp) > 0) { - me = xmalloc (sizeof *me); -# ifdef GETFSTYP /* SVR3. */ - me->me_devname = xstrdup (mnt.mt_dev); + me = xmalloc (sizeof *me); +# ifdef GETFSTYP /* SVR3. */ + me->me_devname = xstrdup (mnt.mt_dev); # else - me->me_devname = xmalloc (strlen (mnt.mt_dev) + 6); - strcpy (me->me_devname, "/dev/"); - strcpy (me->me_devname + 5, mnt.mt_dev); + me->me_devname = xmalloc (strlen (mnt.mt_dev) + 6); + strcpy (me->me_devname, "/dev/"); + strcpy (me->me_devname + 5, mnt.mt_dev); # endif - me->me_mountdir = xstrdup (mnt.mt_filsys); - me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ - me->me_type = ""; - me->me_type_malloced = 0; -# ifdef GETFSTYP /* SVR3. */ - if (need_fs_type) - { - struct statfs fsd; - char typebuf[FSTYPSZ]; + me->me_mountdir = xstrdup (mnt.mt_filsys); + me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ + me->me_type = ""; + me->me_type_malloced = 0; +# ifdef GETFSTYP /* SVR3. */ + if (need_fs_type) + { + struct statfs fsd; + char typebuf[FSTYPSZ]; - if (statfs (me->me_mountdir, &fsd, sizeof fsd, 0) != -1 - && sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1) - { - me->me_type = xstrdup (typebuf); - me->me_type_malloced = 1; - } - } + if (statfs (me->me_mountdir, &fsd, sizeof fsd, 0) != -1 + && sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1) + { + me->me_type = xstrdup (typebuf); + me->me_type_malloced = 1; + } + } # endif - me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); - me->me_remote = ME_REMOTE (me->me_devname, me->me_type); + me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); + me->me_remote = ME_REMOTE (me->me_devname, me->me_type); - /* Add to the linked list. */ - *mtail = me; - mtail = &me->me_next; + /* Add to the linked list. */ + *mtail = me; + mtail = &me->me_next; } if (ferror (fp)) { - /* The last fread() call must have failed. */ - int saved_errno = errno; - fclose (fp); - errno = saved_errno; - goto free_then_fail; + /* The last fread() call must have failed. */ + int saved_errno = errno; + fclose (fp); + errno = saved_errno; + goto free_then_fail; } if (fclose (fp) == EOF) @@ -690,29 +690,29 @@ read_file_system_list (bool need_fs_type) } #endif /* MOUNTED_FREAD || MOUNTED_FREAD_FSTYP. */ -#ifdef MOUNTED_GETMNTTBL /* DolphinOS goes its own way. */ +#ifdef MOUNTED_GETMNTTBL /* DolphinOS goes its own way. */ { struct mntent **mnttbl = getmnttbl (), **ent; for (ent=mnttbl;*ent;ent++) { - me = xmalloc (sizeof *me); - me->me_devname = xstrdup ( (*ent)->mt_resource); - me->me_mountdir = xstrdup ( (*ent)->mt_directory); - me->me_type = xstrdup ((*ent)->mt_fstype); - me->me_type_malloced = 1; - me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); - me->me_remote = ME_REMOTE (me->me_devname, me->me_type); - me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ + me = xmalloc (sizeof *me); + me->me_devname = xstrdup ( (*ent)->mt_resource); + me->me_mountdir = xstrdup ( (*ent)->mt_directory); + me->me_type = xstrdup ((*ent)->mt_fstype); + me->me_type_malloced = 1; + me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); + me->me_remote = ME_REMOTE (me->me_devname, me->me_type); + me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ - /* Add to the linked list. */ - *mtail = me; - mtail = &me->me_next; + /* Add to the linked list. */ + *mtail = me; + mtail = &me->me_next; } endmnttbl (); } #endif -#ifdef MOUNTED_GETMNTENT2 /* SVR4. */ +#ifdef MOUNTED_GETMNTENT2 /* SVR4. */ { struct mnttab mnt; char *table = MNTTAB; @@ -731,19 +731,19 @@ read_file_system_list (bool need_fs_type) lockfd = open (MNTTAB_LOCK, O_RDONLY); if (0 <= lockfd) { - struct flock flock; - flock.l_type = F_RDLCK; - flock.l_whence = SEEK_SET; - flock.l_start = 0; - flock.l_len = 0; - while (fcntl (lockfd, F_SETLKW, &flock) == -1) - if (errno != EINTR) - { - int saved_errno = errno; - close (lockfd); - errno = saved_errno; - return NULL; - } + struct flock flock; + flock.l_type = F_RDLCK; + flock.l_whence = SEEK_SET; + flock.l_start = 0; + flock.l_len = 0; + while (fcntl (lockfd, F_SETLKW, &flock) == -1) + if (errno != EINTR) + { + int saved_errno = errno; + close (lockfd); + errno = saved_errno; + return NULL; + } } else if (errno != ENOENT) return NULL; @@ -755,23 +755,23 @@ read_file_system_list (bool need_fs_type) ret = errno; else { - while ((ret = getmntent (fp, &mnt)) == 0) - { - me = xmalloc (sizeof *me); - me->me_devname = xstrdup (mnt.mnt_special); - me->me_mountdir = xstrdup (mnt.mnt_mountp); - me->me_type = xstrdup (mnt.mnt_fstype); - me->me_type_malloced = 1; - me->me_dummy = MNT_IGNORE (&mnt) != 0; - me->me_remote = ME_REMOTE (me->me_devname, me->me_type); - me->me_dev = dev_from_mount_options (mnt.mnt_mntopts); + while ((ret = getmntent (fp, &mnt)) == 0) + { + me = xmalloc (sizeof *me); + me->me_devname = xstrdup (mnt.mnt_special); + me->me_mountdir = xstrdup (mnt.mnt_mountp); + me->me_type = xstrdup (mnt.mnt_fstype); + me->me_type_malloced = 1; + me->me_dummy = MNT_IGNORE (&mnt) != 0; + me->me_remote = ME_REMOTE (me->me_devname, me->me_type); + me->me_dev = dev_from_mount_options (mnt.mnt_mntopts); - /* Add to the linked list. */ - *mtail = me; - mtail = &me->me_next; - } + /* Add to the linked list. */ + *mtail = me; + mtail = &me->me_next; + } - ret = fclose (fp) == EOF ? errno : 0 < ret ? 0 : -1; + ret = fclose (fp) == EOF ? errno : 0 < ret ? 0 : -1; } if (0 <= lockfd && close (lockfd) != 0) @@ -779,13 +779,13 @@ read_file_system_list (bool need_fs_type) if (0 <= ret) { - errno = ret; - goto free_then_fail; + errno = ret; + goto free_then_fail; } } #endif /* MOUNTED_GETMNTENT2. */ -#ifdef MOUNTED_VMOUNT /* AIX. */ +#ifdef MOUNTED_VMOUNT /* AIX. */ { int bufsize; char *entries, *thisent; @@ -802,53 +802,53 @@ read_file_system_list (bool need_fs_type) n_entries = mntctl (MCTL_QUERY, bufsize, (struct vmount *) entries); if (n_entries < 0) { - int saved_errno = errno; - free (entries); - errno = saved_errno; - return NULL; + int saved_errno = errno; + free (entries); + errno = saved_errno; + return NULL; } for (i = 0, thisent = entries; - i < n_entries; - i++, thisent += vmp->vmt_length) + i < n_entries; + i++, thisent += vmp->vmt_length) { - char *options, *ignore; + char *options, *ignore; - vmp = (struct vmount *) thisent; - me = xmalloc (sizeof *me); - if (vmp->vmt_flags & MNT_REMOTE) - { - char *host, *dir; + vmp = (struct vmount *) thisent; + me = xmalloc (sizeof *me); + if (vmp->vmt_flags & MNT_REMOTE) + { + char *host, *dir; - me->me_remote = 1; - /* Prepend the remote dirname. */ - host = thisent + vmp->vmt_data[VMT_HOSTNAME].vmt_off; - dir = thisent + vmp->vmt_data[VMT_OBJECT].vmt_off; - me->me_devname = xmalloc (strlen (host) + strlen (dir) + 2); - strcpy (me->me_devname, host); - strcat (me->me_devname, ":"); - strcat (me->me_devname, dir); - } - else - { - me->me_remote = 0; - me->me_devname = xstrdup (thisent + - vmp->vmt_data[VMT_OBJECT].vmt_off); - } - me->me_mountdir = xstrdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off); - me->me_type = xstrdup (fstype_to_string (vmp->vmt_gfstype)); - me->me_type_malloced = 1; - options = thisent + vmp->vmt_data[VMT_ARGS].vmt_off; - ignore = strstr (options, "ignore"); - me->me_dummy = (ignore - && (ignore == options || ignore[-1] == ',') - && (ignore[sizeof "ignore" - 1] == ',' - || ignore[sizeof "ignore" - 1] == '\0')); - me->me_dev = (dev_t) -1; /* vmt_fsid might be the info we want. */ + me->me_remote = 1; + /* Prepend the remote dirname. */ + host = thisent + vmp->vmt_data[VMT_HOSTNAME].vmt_off; + dir = thisent + vmp->vmt_data[VMT_OBJECT].vmt_off; + me->me_devname = xmalloc (strlen (host) + strlen (dir) + 2); + strcpy (me->me_devname, host); + strcat (me->me_devname, ":"); + strcat (me->me_devname, dir); + } + else + { + me->me_remote = 0; + me->me_devname = xstrdup (thisent + + vmp->vmt_data[VMT_OBJECT].vmt_off); + } + me->me_mountdir = xstrdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off); + me->me_type = xstrdup (fstype_to_string (vmp->vmt_gfstype)); + me->me_type_malloced = 1; + options = thisent + vmp->vmt_data[VMT_ARGS].vmt_off; + ignore = strstr (options, "ignore"); + me->me_dummy = (ignore + && (ignore == options || ignore[-1] == ',') + && (ignore[sizeof "ignore" - 1] == ',' + || ignore[sizeof "ignore" - 1] == '\0')); + me->me_dev = (dev_t) -1; /* vmt_fsid might be the info we want. */ - /* Add to the linked list. */ - *mtail = me; - mtail = &me->me_next; + /* Add to the linked list. */ + *mtail = me; + mtail = &me->me_next; } free (entries); } @@ -865,13 +865,13 @@ read_file_system_list (bool need_fs_type) while (mount_list) { - me = mount_list->me_next; - free (mount_list->me_devname); - free (mount_list->me_mountdir); - if (mount_list->me_type_malloced) - free (mount_list->me_type); - free (mount_list); - mount_list = me; + me = mount_list->me_next; + free (mount_list->me_devname); + free (mount_list->me_mountdir); + if (mount_list->me_type_malloced) + free (mount_list->me_type); + free (mount_list); + mount_list = me; } errno = saved_errno; diff --git a/src/bin/coreutils/lib/mountlist.h b/src/bin/coreutils/lib/mountlist.h index e54bb49ef8..ad66def57a 100644 --- a/src/bin/coreutils/lib/mountlist.h +++ b/src/bin/coreutils/lib/mountlist.h @@ -1,7 +1,7 @@ /* mountlist.h -- declarations for list of mounted file systems - Copyright (C) 1991, 1992, 1998, 2000, 2001, 2002, 2003, 2004, 2005 - Free Software Foundation, Inc. + Copyright (C) 1991-1992, 1998, 2000-2005, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,12 +25,12 @@ /* A mount table entry. */ struct mount_entry { - char *me_devname; /* Device node name, including "/dev/". */ - char *me_mountdir; /* Mount point directory name. */ - char *me_type; /* "nfs", "4.2", etc. */ - dev_t me_dev; /* Device number of me_mountdir. */ - unsigned int me_dummy : 1; /* Nonzero for dummy file systems. */ - unsigned int me_remote : 1; /* Nonzero for remote fileystems. */ + char *me_devname; /* Device node name, including "/dev/". */ + char *me_mountdir; /* Mount point directory name. */ + char *me_type; /* "nfs", "4.2", etc. */ + dev_t me_dev; /* Device number of me_mountdir. */ + unsigned int me_dummy : 1; /* Nonzero for dummy file systems. */ + unsigned int me_remote : 1; /* Nonzero for remote fileystems. */ unsigned int me_type_malloced : 1; /* Nonzero if me_type was malloced. */ struct mount_entry *me_next; }; diff --git a/src/bin/coreutils/lib/mpsort.c b/src/bin/coreutils/lib/mpsort.c index 43b25b6be4..dfa092222a 100644 --- a/src/bin/coreutils/lib/mpsort.c +++ b/src/bin/coreutils/lib/mpsort.c @@ -1,6 +1,6 @@ /* Sort a vector of pointers to data. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,15 +28,15 @@ typedef int (*comparison_function) (void const *, void const *); static void mpsort_with_tmp (void const **restrict, size_t, - void const **restrict, comparison_function); + void const **restrict, comparison_function); /* Sort a vector BASE containing N pointers, placing the sorted array into TMP. Compare pointers with CMP. N must be at least 2. */ static void mpsort_into_tmp (void const **restrict base, size_t n, - void const **restrict tmp, - comparison_function cmp) + void const **restrict tmp, + comparison_function cmp) { size_t n1 = n / 2; size_t n2 = n - n1; @@ -56,23 +56,23 @@ mpsort_into_tmp (void const **restrict base, size_t n, for (;;) if (cmp (ba, bb) <= 0) { - *tmp++ = ba; - a++; - if (a == alim) - { - a = b; - alim = blim; - break; - } - ba = base[a]; + *tmp++ = ba; + a++; + if (a == alim) + { + a = b; + alim = blim; + break; + } + ba = base[a]; } else { - *tmp++ = bb; - b++; - if (b == blim) - break; - bb = base[b]; + *tmp++ = bb; + b++; + if (b == blim) + break; + bb = base[b]; } memcpy (tmp, base + a, (alim - a) * sizeof *base); @@ -84,21 +84,21 @@ mpsort_into_tmp (void const **restrict base, size_t n, static void mpsort_with_tmp (void const **restrict base, size_t n, - void const **restrict tmp, - comparison_function cmp) + void const **restrict tmp, + comparison_function cmp) { if (n <= 2) { if (n == 2) - { - void const *p0 = base[0]; - void const *p1 = base[1]; - if (! (cmp (p0, p1) <= 0)) - { - base[0] = p1; - base[1] = p0; - } - } + { + void const *p0 = base[0]; + void const *p1 = base[1]; + if (! (cmp (p0, p1) <= 0)) + { + base[0] = p1; + base[1] = p0; + } + } } else { @@ -115,33 +115,33 @@ mpsort_with_tmp (void const **restrict base, size_t n, mpsort_with_tmp (base + n1, n2, tmp, cmp); if (n1 < 2) - tmp[0] = base[0]; + tmp[0] = base[0]; else - mpsort_into_tmp (base, n1, tmp, cmp); + mpsort_into_tmp (base, n1, tmp, cmp); tt = tmp[t]; bb = base[b]; for (i = 0; ; ) - if (cmp (tt, bb) <= 0) - { - base[i++] = tt; - t++; - if (t == tlim) - break; - tt = tmp[t]; - } - else - { - base[i++] = bb; - b++; - if (b == blim) - { - memcpy (base + i, tmp + t, (tlim - t) * sizeof *base); - break; - } - bb = base[b]; - } + if (cmp (tt, bb) <= 0) + { + base[i++] = tt; + t++; + if (t == tlim) + break; + tt = tmp[t]; + } + else + { + base[i++] = bb; + b++; + if (b == blim) + { + memcpy (base + i, tmp + t, (tlim - t) * sizeof *base); + break; + } + bb = base[b]; + } } } diff --git a/src/bin/coreutils/lib/nanosleep.c b/src/bin/coreutils/lib/nanosleep.c index 7a7cc02fd9..58fc7881ec 100644 --- a/src/bin/coreutils/lib/nanosleep.c +++ b/src/bin/coreutils/lib/nanosleep.c @@ -1,7 +1,6 @@ /* Provide a replacement for the POSIX nanosleep function. - Copyright (C) 1999, 2000, 2002, 2004, 2005, 2006, 2007, 2008 Free - Software Foundation, Inc. + Copyright (C) 1999-2000, 2002, 2004-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,8 +21,9 @@ #include +#include "intprops.h" #include "sig-handler.h" -#include "timespec.h" +#include "verify.h" #include #include @@ -42,56 +42,45 @@ enum { BILLION = 1000 * 1000 * 1000 }; #if HAVE_BUG_BIG_NANOSLEEP -static void -getnow (struct timespec *t) -{ -# if defined CLOCK_MONOTONIC && HAVE_CLOCK_GETTIME - if (clock_gettime (CLOCK_MONOTONIC, t) == 0) - return; -# endif - gettime (t); -} - int rpl_nanosleep (const struct timespec *requested_delay, - struct timespec *remaining_delay) + struct timespec *remaining_delay) { /* nanosleep mishandles large sleeps due to internal overflow - problems, so check that the proper amount of time has actually - elapsed. */ + problems. The worst known case of this is cygwin 1.5.x, which + can't sleep more than 49.7 days (2**32 milliseconds). Solve this + by breaking the sleep up into smaller chunks. Verify that time_t + is large enough. */ + verify (TYPE_MAXIMUM (time_t) / 49 / 24 / 60 / 60); + const time_t limit = 49 * 24 * 60 * 60; + time_t seconds = requested_delay->tv_sec; + struct timespec intermediate; + intermediate.tv_nsec = 0; - struct timespec delay = *requested_delay; - struct timespec t0; - getnow (&t0); - - for (;;) + while (limit < seconds) { - int r = nanosleep (&delay, remaining_delay); - if (r == 0) - { - time_t secs_sofar; - struct timespec now; - getnow (&now); - - secs_sofar = now.tv_sec - t0.tv_sec; - if (requested_delay->tv_sec < secs_sofar) - return 0; - delay.tv_sec = requested_delay->tv_sec - secs_sofar; - delay.tv_nsec = requested_delay->tv_nsec - (now.tv_nsec - t0.tv_nsec); - if (delay.tv_nsec < 0) - { - if (delay.tv_sec == 0) - return 0; - delay.tv_nsec += BILLION; - delay.tv_sec--; - } - else if (BILLION <= delay.tv_nsec) - { - delay.tv_nsec -= BILLION; - delay.tv_sec++; - } - } + int result; + intermediate.tv_sec = limit; + result = nanosleep (&intermediate, remaining_delay); + seconds -= limit; + if (result) + { + if (remaining_delay) + { + remaining_delay->tv_sec += seconds; + remaining_delay->tv_nsec += requested_delay->tv_nsec; + if (BILLION <= requested_delay->tv_nsec) + { + remaining_delay->tv_sec++; + remaining_delay->tv_nsec -= BILLION; + } + } + return result; + } } + intermediate.tv_sec = seconds; + intermediate.tv_nsec = requested_delay->tv_nsec; + return nanosleep (&intermediate, remaining_delay); } #else @@ -125,12 +114,12 @@ my_usleep (const struct timespec *ts_delay) { time_t t1 = tv_delay.tv_sec + 1; if (t1 < tv_delay.tv_sec) - tv_delay.tv_usec = 1000000 - 1; /* close enough */ + tv_delay.tv_usec = 1000000 - 1; /* close enough */ else - { - tv_delay.tv_sec = t1; - tv_delay.tv_usec = 0; - } + { + tv_delay.tv_sec = t1; + tv_delay.tv_usec = 0; + } } select (0, NULL, NULL, NULL, &tv_delay); } @@ -140,10 +129,16 @@ my_usleep (const struct timespec *ts_delay) int rpl_nanosleep (const struct timespec *requested_delay, - struct timespec *remaining_delay) + struct timespec *remaining_delay) { static bool initialized; + if (requested_delay->tv_nsec < 0 || BILLION <= requested_delay->tv_nsec) + { + errno = EINVAL; + return -1; + } + /* set up sig handler */ if (! initialized) { @@ -151,14 +146,14 @@ rpl_nanosleep (const struct timespec *requested_delay, sigaction (SIGCONT, NULL, &oldact); if (get_handler (&oldact) != SIG_IGN) - { - struct sigaction newact; + { + struct sigaction newact; - newact.sa_handler = sighandler; - sigemptyset (&newact.sa_mask); - newact.sa_flags = 0; - sigaction (SIGCONT, &newact, NULL); - } + newact.sa_handler = sighandler; + sigemptyset (&newact.sa_mask); + newact.sa_flags = 0; + sigaction (SIGCONT, &newact, NULL); + } initialized = true; } @@ -170,7 +165,7 @@ rpl_nanosleep (const struct timespec *requested_delay, { /* Calculate time remaining. */ /* FIXME: the code in sleep doesn't use this, so there's no - rush to implement it. */ + rush to implement it. */ errno = EINTR; } diff --git a/src/bin/coreutils/lib/netdb.h b/src/bin/coreutils/lib/netdb.h new file mode 100644 index 0000000000..283f2836a2 --- /dev/null +++ b/src/bin/coreutils/lib/netdb.h @@ -0,0 +1,200 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +#line 1 +/* Provide a netdb.h header file for systems lacking it (read: MinGW). + Copyright (C) 2008-2010 Free Software Foundation, Inc. + Written by Simon Josefsson. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* This file is supposed to be used on platforms that lack . + It is intended to provide definitions and prototypes needed by an + application. */ + +#ifndef _GL_NETDB_H + +#if 1 + +# if __GNUC__ >= 3 +#pragma GCC system_header +# endif + +/* The include_next requires a split double-inclusion guard. */ +# include_next + +#endif + +#ifndef _GL_NETDB_H +#define _GL_NETDB_H + +/* Get netdb.h definitions such as struct hostent for MinGW. */ +#include + +/* The definition of _GL_ARG_NONNULL is copied here. */ +/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools + that the values passed as arguments n, ..., m must be non-NULL pointers. + n = 1 stands for the first argument, n = 2 for the second argument etc. */ +#ifndef _GL_ARG_NONNULL +# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 +# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) +# else +# define _GL_ARG_NONNULL(params) +# endif +#endif + +/* Declarations for a platform that lacks , or where it is + incomplete. */ + +#if 1 + +# if !1 + +/* Structure to contain information about address of a service provider. */ +struct addrinfo +{ + int ai_flags; /* Input flags. */ + int ai_family; /* Protocol family for socket. */ + int ai_socktype; /* Socket type. */ + int ai_protocol; /* Protocol for socket. */ + socklen_t ai_addrlen; /* Length of socket address. */ + struct sockaddr *ai_addr; /* Socket address for socket. */ + char *ai_canonname; /* Canonical name for service location. */ + struct addrinfo *ai_next; /* Pointer to next in list. */ +}; +# endif + +/* Possible values for `ai_flags' field in `addrinfo' structure. */ +# ifndef AI_PASSIVE +# define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */ +# endif +# ifndef AI_CANONNAME +# define AI_CANONNAME 0x0002 /* Request for canonical name. */ +# endif +# ifndef AI_NUMERICSERV +# define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */ +# endif + +# if 0 +/* The commented out definitions below are not yet implemented in the + GNULIB getaddrinfo() replacement, so are not yet needed and may, in fact, + cause conflicts on systems with a getaddrinfo() function which does not + define them. + + If they are restored, be sure to protect the definitions with #ifndef. */ +# define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */ +# define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable. */ +# define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */ +# define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose + returned address type.. */ +# endif /* 0 */ + +/* Error values for `getaddrinfo' function. */ +# ifndef EAI_BADFLAGS +# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */ +# define EAI_NONAME -2 /* NAME or SERVICE is unknown. */ +# define EAI_AGAIN -3 /* Temporary failure in name resolution. */ +# define EAI_FAIL -4 /* Non-recoverable failure in name res. */ +# define EAI_NODATA -5 /* No address associated with NAME. */ +# define EAI_FAMILY -6 /* `ai_family' not supported. */ +# define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */ +# define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */ +# define EAI_MEMORY -10 /* Memory allocation failure. */ +# endif + +/* Since EAI_NODATA is deprecated by RFC3493, some systems (at least + FreeBSD, which does define EAI_BADFLAGS) have removed the definition + in favor of EAI_NONAME. */ +# if !defined EAI_NODATA && defined EAI_NONAME +# define EAI_NODATA EAI_NONAME +# endif + +# ifndef EAI_OVERFLOW +/* Not defined on mingw32 and Haiku. */ +# define EAI_OVERFLOW -12 /* Argument buffer overflow. */ +# endif +# ifndef EAI_ADDRFAMILY +/* Not defined on mingw32. */ +# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */ +# endif +# ifndef EAI_SYSTEM +/* Not defined on mingw32. */ +# define EAI_SYSTEM -11 /* System error returned in `errno'. */ +# endif + +# if 0 +/* The commented out definitions below are not yet implemented in the + GNULIB getaddrinfo() replacement, so are not yet needed. + + If they are restored, be sure to protect the definitions with #ifndef. */ +# ifndef EAI_INPROGRESS +# define EAI_INPROGRESS -100 /* Processing request in progress. */ +# define EAI_CANCELED -101 /* Request canceled. */ +# define EAI_NOTCANCELED -102 /* Request not canceled. */ +# define EAI_ALLDONE -103 /* All requests done. */ +# define EAI_INTR -104 /* Interrupted by a signal. */ +# define EAI_IDN_ENCODE -105 /* IDN encoding failed. */ +# endif +# endif + +# if !1 +/* Translate name of a service location and/or a service name to set of + socket addresses. + For more details, see the POSIX:2001 specification + . */ +extern int getaddrinfo (const char *restrict nodename, + const char *restrict servname, + const struct addrinfo *restrict hints, + struct addrinfo **restrict res) + _GL_ARG_NONNULL ((4)); +# endif + +# if !1 +/* Free `addrinfo' structure AI including associated storage. + For more details, see the POSIX:2001 specification + . */ +extern void freeaddrinfo (struct addrinfo *ai) _GL_ARG_NONNULL ((1)); +# endif + +# if !1 +/* Convert error return from getaddrinfo() to a string. + For more details, see the POSIX:2001 specification + . */ +extern const char *gai_strerror (int ecode); +# endif + +# if !1 +/* Convert socket address to printable node and service names. + For more details, see the POSIX:2001 specification + . */ +extern int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen, + char *restrict node, socklen_t nodelen, + char *restrict service, socklen_t servicelen, + int flags) + _GL_ARG_NONNULL ((1)); +# endif + +/* Possible flags for getnameinfo. */ +# ifndef NI_NUMERICHOST +# define NI_NUMERICHOST 1 +# endif +# ifndef NI_NUMERICSERV +# define NI_NUMERICSERV 2 +# endif + +#endif /* 1 */ + +#endif /* _GL_NETDB_H */ +#endif /* _GL_NETDB_H */ diff --git a/src/bin/coreutils/lib/netdb.in.h b/src/bin/coreutils/lib/netdb.in.h index 0466977859..6c7eaead71 100644 --- a/src/bin/coreutils/lib/netdb.in.h +++ b/src/bin/coreutils/lib/netdb.in.h @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Provide a netdb.h header file for systems lacking it (read: MinGW). - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. Written by Simon Josefsson. This program is free software; you can redistribute it and/or modify @@ -42,6 +42,8 @@ /* Get netdb.h definitions such as struct hostent for MinGW. */ #include +/* The definition of _GL_ARG_NONNULL is copied here. */ + /* Declarations for a platform that lacks , or where it is incomplete. */ @@ -52,26 +54,26 @@ /* Structure to contain information about address of a service provider. */ struct addrinfo { - int ai_flags; /* Input flags. */ - int ai_family; /* Protocol family for socket. */ - int ai_socktype; /* Socket type. */ - int ai_protocol; /* Protocol for socket. */ - socklen_t ai_addrlen; /* Length of socket address. */ - struct sockaddr *ai_addr; /* Socket address for socket. */ - char *ai_canonname; /* Canonical name for service location. */ - struct addrinfo *ai_next; /* Pointer to next in list. */ + int ai_flags; /* Input flags. */ + int ai_family; /* Protocol family for socket. */ + int ai_socktype; /* Socket type. */ + int ai_protocol; /* Protocol for socket. */ + socklen_t ai_addrlen; /* Length of socket address. */ + struct sockaddr *ai_addr; /* Socket address for socket. */ + char *ai_canonname; /* Canonical name for service location. */ + struct addrinfo *ai_next; /* Pointer to next in list. */ }; # endif /* Possible values for `ai_flags' field in `addrinfo' structure. */ # ifndef AI_PASSIVE -# define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */ +# define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */ # endif # ifndef AI_CANONNAME -# define AI_CANONNAME 0x0002 /* Request for canonical name. */ +# define AI_CANONNAME 0x0002 /* Request for canonical name. */ # endif # ifndef AI_NUMERICSERV -# define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */ +# define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */ # endif # if 0 @@ -81,24 +83,24 @@ struct addrinfo define them. If they are restored, be sure to protect the definitions with #ifndef. */ -# define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */ -# define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable. */ -# define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */ -# define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose - returned address type.. */ +# define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */ +# define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable. */ +# define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */ +# define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose + returned address type.. */ # endif /* 0 */ /* Error values for `getaddrinfo' function. */ # ifndef EAI_BADFLAGS -# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */ -# define EAI_NONAME -2 /* NAME or SERVICE is unknown. */ -# define EAI_AGAIN -3 /* Temporary failure in name resolution. */ -# define EAI_FAIL -4 /* Non-recoverable failure in name res. */ -# define EAI_NODATA -5 /* No address associated with NAME. */ -# define EAI_FAMILY -6 /* `ai_family' not supported. */ -# define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */ -# define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */ -# define EAI_MEMORY -10 /* Memory allocation failure. */ +# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */ +# define EAI_NONAME -2 /* NAME or SERVICE is unknown. */ +# define EAI_AGAIN -3 /* Temporary failure in name resolution. */ +# define EAI_FAIL -4 /* Non-recoverable failure in name res. */ +# define EAI_NODATA -5 /* No address associated with NAME. */ +# define EAI_FAMILY -6 /* `ai_family' not supported. */ +# define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */ +# define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */ +# define EAI_MEMORY -10 /* Memory allocation failure. */ # endif /* Since EAI_NODATA is deprecated by RFC3493, some systems (at least @@ -110,15 +112,15 @@ struct addrinfo # ifndef EAI_OVERFLOW /* Not defined on mingw32 and Haiku. */ -# define EAI_OVERFLOW -12 /* Argument buffer overflow. */ +# define EAI_OVERFLOW -12 /* Argument buffer overflow. */ # endif # ifndef EAI_ADDRFAMILY /* Not defined on mingw32. */ -# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */ +# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */ # endif # ifndef EAI_SYSTEM /* Not defined on mingw32. */ -# define EAI_SYSTEM -11 /* System error returned in `errno'. */ +# define EAI_SYSTEM -11 /* System error returned in `errno'. */ # endif # if 0 @@ -127,12 +129,12 @@ struct addrinfo If they are restored, be sure to protect the definitions with #ifndef. */ # ifndef EAI_INPROGRESS -# define EAI_INPROGRESS -100 /* Processing request in progress. */ -# define EAI_CANCELED -101 /* Request canceled. */ -# define EAI_NOTCANCELED -102 /* Request not canceled. */ -# define EAI_ALLDONE -103 /* All requests done. */ -# define EAI_INTR -104 /* Interrupted by a signal. */ -# define EAI_IDN_ENCODE -105 /* IDN encoding failed. */ +# define EAI_INPROGRESS -100 /* Processing request in progress. */ +# define EAI_CANCELED -101 /* Request canceled. */ +# define EAI_NOTCANCELED -102 /* Request not canceled. */ +# define EAI_ALLDONE -103 /* All requests done. */ +# define EAI_INTR -104 /* Interrupted by a signal. */ +# define EAI_IDN_ENCODE -105 /* IDN encoding failed. */ # endif # endif @@ -142,16 +144,17 @@ struct addrinfo For more details, see the POSIX:2001 specification . */ extern int getaddrinfo (const char *restrict nodename, - const char *restrict servname, - const struct addrinfo *restrict hints, - struct addrinfo **restrict res); + const char *restrict servname, + const struct addrinfo *restrict hints, + struct addrinfo **restrict res) + _GL_ARG_NONNULL ((4)); # endif # if !@HAVE_DECL_FREEADDRINFO@ /* Free `addrinfo' structure AI including associated storage. For more details, see the POSIX:2001 specification . */ -extern void freeaddrinfo (struct addrinfo *ai); +extern void freeaddrinfo (struct addrinfo *ai) _GL_ARG_NONNULL ((1)); # endif # if !@HAVE_DECL_GAI_STRERROR@ @@ -166,9 +169,10 @@ extern const char *gai_strerror (int ecode); For more details, see the POSIX:2001 specification . */ extern int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen, - char *restrict node, socklen_t nodelen, - char *restrict service, socklen_t servicelen, - int flags); + char *restrict node, socklen_t nodelen, + char *restrict service, socklen_t servicelen, + int flags) + _GL_ARG_NONNULL ((1)); # endif /* Possible flags for getnameinfo. */ diff --git a/src/bin/coreutils/lib/netinet_in.in.h b/src/bin/coreutils/lib/netinet_in.in.h index cd59d716a8..3b6c3a8647 100644 --- a/src/bin/coreutils/lib/netinet_in.in.h +++ b/src/bin/coreutils/lib/netinet_in.in.h @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Substitute for . - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/nl_langinfo.c b/src/bin/coreutils/lib/nl_langinfo.c new file mode 100644 index 0000000000..e81c81e7d2 --- /dev/null +++ b/src/bin/coreutils/lib/nl_langinfo.c @@ -0,0 +1,260 @@ +/* nl_langinfo() replacement: query locale dependent information. + + Copyright (C) 2007-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#if REPLACE_NL_LANGINFO + +/* Override nl_langinfo with support for added nl_item values. */ + +# include +# include + +# undef nl_langinfo + +char * +rpl_nl_langinfo (nl_item item) +{ + switch (item) + { +# if GNULIB_defined_CODESET + case CODESET: + { + const char *locale; + static char buf[2 + 10 + 1]; + + locale = setlocale (LC_CTYPE, NULL); + if (locale != NULL && locale[0] != '\0') + { + /* If the locale name contains an encoding after the dot, return + it. */ + const char *dot = strchr (locale, '.'); + + if (dot != NULL) + { + const char *modifier; + + dot++; + /* Look for the possible @... trailer and remove it, if any. */ + modifier = strchr (dot, '@'); + if (modifier == NULL) + return dot; + if (modifier - dot < sizeof (buf)) + { + memcpy (buf, dot, modifier - dot); + buf [modifier - dot] = '\0'; + return buf; + } + } + } + return ""; + } +# endif +# if GNULIB_defined_ERA + case ERA: + /* The format is not standardized. In glibc it is a sequence of strings + of the form "direction:offset:start_date:end_date:era_name:era_format" + with an empty string at the end. */ + return ""; + case ERA_D_FMT: + /* The %Ex conversion in strftime behaves like %x if the locale does not + have an alternative time format. */ + item = D_FMT; + break; + case ERA_D_T_FMT: + /* The %Ec conversion in strftime behaves like %c if the locale does not + have an alternative time format. */ + item = D_T_FMT; + break; + case ERA_T_FMT: + /* The %EX conversion in strftime behaves like %X if the locale does not + have an alternative time format. */ + item = T_FMT; + break; + case ALT_DIGITS: + /* The format is not standardized. In glibc it is a sequence of 10 + strings, appended in memory. */ + return "\0\0\0\0\0\0\0\0\0\0"; +# endif + default: + break; + } + return nl_langinfo (item); +} + +#else + +/* Provide nl_langinfo from scratch. */ + +# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ + +/* Native Windows platforms. */ + +# define WIN32_LEAN_AND_MEAN /* avoid including junk */ +# include + +# include + +# else + +/* An old Unix platform without locales, such as Linux libc5 or BeOS. */ + +# endif + +# include + +char * +nl_langinfo (nl_item item) +{ + switch (item) + { + /* nl_langinfo items of the LC_CTYPE category */ + case CODESET: +# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ + { + static char buf[2 + 10 + 1]; + + /* Woe32 has a function returning the locale's codepage as a number. */ + sprintf (buf, "CP%u", GetACP ()); + return buf; + } +# elif defined __BEOS__ + return "UTF-8"; +# else + return "ISO-8859-1"; +# endif + /* nl_langinfo items of the LC_NUMERIC category */ + case RADIXCHAR: + return localeconv () ->decimal_point; + case THOUSEP: + return localeconv () ->thousands_sep; + /* nl_langinfo items of the LC_TIME category. + TODO: Really use the locale. */ + case D_T_FMT: + case ERA_D_T_FMT: + return "%a %b %e %H:%M:%S %Y"; + case D_FMT: + case ERA_D_FMT: + return "%m/%d/%y"; + case T_FMT: + case ERA_T_FMT: + return "%H:%M:%S"; + case T_FMT_AMPM: + return "%I:%M:%S %p"; + case AM_STR: + return "AM"; + case PM_STR: + return "PM"; + case DAY_1: + return "Sunday"; + case DAY_2: + return "Monday"; + case DAY_3: + return "Tuesday"; + case DAY_4: + return "Wednesday"; + case DAY_5: + return "Thursday"; + case DAY_6: + return "Friday"; + case DAY_7: + return "Saturday"; + case ABDAY_1: + return "Sun"; + case ABDAY_2: + return "Mon"; + case ABDAY_3: + return "Tue"; + case ABDAY_4: + return "Wed"; + case ABDAY_5: + return "Thu"; + case ABDAY_6: + return "Fri"; + case ABDAY_7: + return "Sat"; + case MON_1: + return "January"; + case MON_2: + return "February"; + case MON_3: + return "March"; + case MON_4: + return "April"; + case MON_5: + return "May"; + case MON_6: + return "June"; + case MON_7: + return "July"; + case MON_8: + return "August"; + case MON_9: + return "September"; + case MON_10: + return "October"; + case MON_11: + return "November"; + case MON_12: + return "December"; + case ABMON_1: + return "Jan"; + case ABMON_2: + return "Feb"; + case ABMON_3: + return "Mar"; + case ABMON_4: + return "Apr"; + case ABMON_5: + return "May"; + case ABMON_6: + return "Jun"; + case ABMON_7: + return "Jul"; + case ABMON_8: + return "Aug"; + case ABMON_9: + return "Sep"; + case ABMON_10: + return "Oct"; + case ABMON_11: + return "Nov"; + case ABMON_12: + return "Dec"; + case ERA: + return ""; + case ALT_DIGITS: + return "\0\0\0\0\0\0\0\0\0\0"; + /* nl_langinfo items of the LC_MONETARY category + TODO: Really use the locale. */ + case CRNCYSTR: + return "-"; + /* nl_langinfo items of the LC_MESSAGES category + TODO: Really use the locale. */ + case YESEXPR: + return "^[yY]"; + case NOEXPR: + return "^[nN]"; + default: + return ""; + } +} + +#endif diff --git a/src/bin/coreutils/lib/nproc.c b/src/bin/coreutils/lib/nproc.c new file mode 100644 index 0000000000..6aa23dd4b0 --- /dev/null +++ b/src/bin/coreutils/lib/nproc.c @@ -0,0 +1,361 @@ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +#line 1 +/* Detect the number of processors. + + Copyright (C) 2009-2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Glen Lenker and Bruno Haible. */ + +#include +#include "nproc.h" + +#include +#include + +#if HAVE_PTHREAD_AFFINITY_NP && 0 +# include +# include +#endif +#if HAVE_SCHED_GETAFFINITY_LIKE_GLIBC || HAVE_SCHED_GETAFFINITY_NP +# include +#endif + +#include + +#if HAVE_SYS_PSTAT_H +# include +#endif + +#if HAVE_SYS_SYSMP_H +# include +#endif + +#if HAVE_SYS_PARAM_H +# include +#endif + +#if HAVE_SYS_SYSCTL_H +# include +#endif + +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# define WIN32_LEAN_AND_MEAN +# include +#endif + +#include "c-ctype.h" + +#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) + +/* Return the number of processors available to the current process, based + on a modern system call that returns the "affinity" between the current + process and each CPU. Return 0 if unknown or if such a system call does + not exist. */ +static unsigned long +num_processors_via_affinity_mask (void) +{ + /* glibc >= 2.3.3 with NPTL and NetBSD 5 have pthread_getaffinity_np, + but with different APIs. Also it requires linking with -lpthread. + Therefore this code is not enabled. + glibc >= 2.3.4 has sched_getaffinity whereas NetBSD 5 has + sched_getaffinity_np. */ +#if HAVE_PTHREAD_AFFINITY_NP && defined __GLIBC__ && 0 + { + cpu_set_t set; + + if (pthread_getaffinity_np (pthread_self (), sizeof (set), &set) == 0) + { + unsigned long count; + +# ifdef CPU_COUNT + /* glibc >= 2.6 has the CPU_COUNT macro. */ + count = CPU_COUNT (&set); +# else + size_t i; + + count = 0; + for (i = 0; i < CPU_SETSIZE; i++) + if (CPU_ISSET (i, &set)) + count++; +# endif + if (count > 0) + return count; + } + } +#elif HAVE_PTHREAD_AFFINITY_NP && defined __NetBSD__ && 0 + { + cpuset_t *set; + + set = cpuset_create (); + if (set != NULL) + { + unsigned long count = 0; + + if (pthread_getaffinity_np (pthread_self (), cpuset_size (set), set) + == 0) + { + cpuid_t i; + + for (i = 0;; i++) + { + int ret = cpuset_isset (i, set); + if (ret < 0) + break; + if (ret > 0) + count++; + } + } + cpuset_destroy (set); + if (count > 0) + return count; + } + } +#elif HAVE_SCHED_GETAFFINITY_LIKE_GLIBC /* glibc >= 2.3.4 */ + { + cpu_set_t set; + + if (sched_getaffinity (0, sizeof (set), &set) == 0) + { + unsigned long count; + +# ifdef CPU_COUNT + /* glibc >= 2.6 has the CPU_COUNT macro. */ + count = CPU_COUNT (&set); +# else + size_t i; + + count = 0; + for (i = 0; i < CPU_SETSIZE; i++) + if (CPU_ISSET (i, &set)) + count++; +# endif + if (count > 0) + return count; + } + } +#elif HAVE_SCHED_GETAFFINITY_NP /* NetBSD >= 5 */ + { + cpuset_t *set; + + set = cpuset_create (); + if (set != NULL) + { + unsigned long count = 0; + + if (sched_getaffinity_np (getpid (), cpuset_size (set), set) == 0) + { + cpuid_t i; + + for (i = 0;; i++) + { + int ret = cpuset_isset (i, set); + if (ret < 0) + break; + if (ret > 0) + count++; + } + } + cpuset_destroy (set); + if (count > 0) + return count; + } + } +#endif + +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ + { /* This works on native Windows platforms. */ + DWORD_PTR process_mask; + DWORD_PTR system_mask; + + if (GetProcessAffinityMask (GetCurrentProcess (), + &process_mask, &system_mask)) + { + DWORD_PTR mask = process_mask; + unsigned long count = 0; + + for (; mask != 0; mask = mask >> 1) + if (mask & 1) + count++; + if (count > 0) + return count; + } + } +#endif + + return 0; +} + +unsigned long int +num_processors (enum nproc_query query) +{ + if (query == NPROC_CURRENT_OVERRIDABLE) + { + /* Test the environment variable OMP_NUM_THREADS, recognized also by all + programs that are based on OpenMP. The OpenMP spec says that the + value assigned to the environment variable "may have leading and + trailing white space". */ + const char *envvalue = getenv ("OMP_NUM_THREADS"); + + if (envvalue != NULL) + { + while (*envvalue != '\0' && c_isspace (*envvalue)) + envvalue++; + /* Convert it from decimal to 'unsigned long'. */ + if (c_isdigit (*envvalue)) + { + char *endptr = NULL; + unsigned long int value = strtoul (envvalue, &endptr, 10); + + if (endptr != NULL) + { + while (*endptr != '\0' && c_isspace (*endptr)) + endptr++; + if (*endptr == '\0') + return (value > 0 ? value : 1); + } + } + } + + query = NPROC_CURRENT; + } + /* Here query is one of NPROC_ALL, NPROC_CURRENT. */ + + /* On systems with a modern affinity mask system call, we have + sysconf (_SC_NPROCESSORS_CONF) + >= sysconf (_SC_NPROCESSORS_ONLN) + >= num_processors_via_affinity_mask () + The first number is the number of CPUs configured in the system. + The second number is the number of CPUs available to the scheduler. + The third number is the number of CPUs available to the current process. + + Note! On Linux systems with glibc, the first and second number come from + the /sys and /proc file systems (see + glibc/sysdeps/unix/sysv/linux/getsysstats.c). + In some situations these file systems are not mounted, and the sysconf + call returns 1, which does not reflect the reality. */ + + if (query == NPROC_CURRENT) + { + /* Try the modern affinity mask system call. */ + { + unsigned long nprocs = num_processors_via_affinity_mask (); + + if (nprocs > 0) + return nprocs; + } + +#if defined _SC_NPROCESSORS_ONLN + { /* This works on glibc, MacOS X 10.5, FreeBSD, AIX, OSF/1, Solaris, + Cygwin, Haiku. */ + long int nprocs = sysconf (_SC_NPROCESSORS_ONLN); + if (nprocs > 0) + return nprocs; + } +#endif + } + else /* query == NPROC_ALL */ + { +#if defined _SC_NPROCESSORS_CONF + { /* This works on glibc, MacOS X 10.5, FreeBSD, AIX, OSF/1, Solaris, + Cygwin, Haiku. */ + long int nprocs = sysconf (_SC_NPROCESSORS_CONF); + +# if __GLIBC__ >= 2 && defined __linux__ + /* On Linux systems with glibc, this information comes from the /sys and + /proc file systems (see glibc/sysdeps/unix/sysv/linux/getsysstats.c). + In some situations these file systems are not mounted, and the + sysconf call returns 1. But we wish to guarantee that + num_processors (NPROC_ALL) >= num_processors (NPROC_CURRENT). */ + if (nprocs == 1) + { + unsigned long nprocs_current = num_processors_via_affinity_mask (); + + if (nprocs_current > 0) + nprocs = nprocs_current; + } +# endif + + if (nprocs > 0) + return nprocs; + } +#endif + } + +#if HAVE_PSTAT_GETDYNAMIC + { /* This works on HP-UX. */ + struct pst_dynamic psd; + if (pstat_getdynamic (&psd, sizeof psd, 1, 0) >= 0) + { + /* The field psd_proc_cnt contains the number of active processors. + In newer releases of HP-UX 11, the field psd_max_proc_cnt includes + deactivated processors. */ + if (query == NPROC_CURRENT) + { + if (psd.psd_proc_cnt > 0) + return psd.psd_proc_cnt; + } + else + { + if (psd.psd_max_proc_cnt > 0) + return psd.psd_max_proc_cnt; + } + } + } +#endif + +#if HAVE_SYSMP && defined MP_NAPROCS && defined MP_NPROCS + { /* This works on IRIX. */ + /* MP_NPROCS yields the number of installed processors. + MP_NAPROCS yields the number of processors available to unprivileged + processes. */ + int nprocs = + sysmp (query == NPROC_CURRENT && getpid () != 0 + ? MP_NAPROCS + : MP_NPROCS); + if (nprocs > 0) + return nprocs; + } +#endif + + /* Finally, as fallback, use the APIs that don't distinguish between + NPROC_CURRENT and NPROC_ALL. */ + +#if HAVE_SYSCTL && defined HW_NCPU + { /* This works on MacOS X, FreeBSD, NetBSD, OpenBSD. */ + int nprocs; + size_t len = sizeof (nprocs); + static int mib[2] = { CTL_HW, HW_NCPU }; + + if (sysctl (mib, ARRAY_SIZE (mib), &nprocs, &len, NULL, 0) == 0 + && len == sizeof (nprocs) + && 0 < nprocs) + return nprocs; + } +#endif + +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ + { /* This works on native Windows platforms. */ + SYSTEM_INFO system_info; + GetSystemInfo (&system_info); + if (0 < system_info.dwNumberOfProcessors) + return system_info.dwNumberOfProcessors; + } +#endif + + return 1; +} diff --git a/src/bin/coreutils/lib/nproc.h b/src/bin/coreutils/lib/nproc.h new file mode 100644 index 0000000000..61fe4f994e --- /dev/null +++ b/src/bin/coreutils/lib/nproc.h @@ -0,0 +1,50 @@ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +#line 1 +/* Detect the number of processors. + + Copyright (C) 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Glen Lenker and Bruno Haible. */ + +/* Allow the use in C++ code. */ +#ifdef __cplusplus +extern "C" { +#endif + +/* A "processor" in this context means a thread execution unit, that is either + - an execution core in a (possibly multi-core) chip, in a (possibly multi- + chip) module, in a single computer, or + - a thread execution unit inside a core + (hyper-threading, see ). + Which of the two definitions is used, is unspecified. */ + +enum nproc_query +{ + NPROC_ALL, /* total number of processors */ + NPROC_CURRENT, /* processors available to the current process */ + NPROC_CURRENT_OVERRIDABLE /* likewise, but overridable through the + OMP_NUM_THREADS environment variable */ +}; + +/* Return the total number of processors. The result is guaranteed to + be at least 1. */ +extern unsigned long int num_processors (enum nproc_query query); + +#ifdef __cplusplus +} +#endif /* C++ */ diff --git a/src/bin/coreutils/lib/obstack.c b/src/bin/coreutils/lib/obstack.c index 5b87466d88..7c71acdeaf 100644 --- a/src/bin/coreutils/lib/obstack.c +++ b/src/bin/coreutils/lib/obstack.c @@ -1,7 +1,7 @@ /* obstack.c - subroutines used implicitly by object stack macros - Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, - 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software + Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, + 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -39,7 +39,7 @@ program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ -#include /* Random thing to get __GNU_LIBRARY__. */ +#include /* Random thing to get __GNU_LIBRARY__. */ #if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1 # include # if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION @@ -141,9 +141,9 @@ compat_symbol (libc, _obstack_compat, _obstack, GLIBC_2_0); int _obstack_begin (struct obstack *h, - int size, int alignment, - void *(*chunkfun) (long), - void (*freefun) (void *)) + int size, int alignment, + void *(*chunkfun) (long), + void (*freefun) (void *)) { register struct _obstack_chunk *chunk; /* points to new chunk */ @@ -153,16 +153,16 @@ _obstack_begin (struct obstack *h, /* Default size is what GNU malloc can fit in a 4096-byte block. */ { /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc. - Use the values for range checking, because if range checking is off, - the extra bytes won't be missed terribly, but if range checking is on - and we used a larger request, a whole extra 4096 bytes would be - allocated. + Use the values for range checking, because if range checking is off, + the extra bytes won't be missed terribly, but if range checking is on + and we used a larger request, a whole extra 4096 bytes would be + allocated. - These number are irrelevant to the new GNU malloc. I suspect it is - less sensitive to the size of the request. */ + These number are irrelevant to the new GNU malloc. I suspect it is + less sensitive to the size of the request. */ int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1)) - + 4 + DEFAULT_ROUNDING - 1) - & ~(DEFAULT_ROUNDING - 1)); + + 4 + DEFAULT_ROUNDING - 1) + & ~(DEFAULT_ROUNDING - 1)); size = 4096 - extra; } @@ -176,7 +176,7 @@ _obstack_begin (struct obstack *h, if (!chunk) (*obstack_alloc_failed_handler) (); h->next_free = h->object_base = __PTR_ALIGN ((char *) chunk, chunk->contents, - alignment - 1); + alignment - 1); h->chunk_limit = chunk->limit = (char *) chunk + h->chunk_size; chunk->prev = 0; @@ -188,9 +188,9 @@ _obstack_begin (struct obstack *h, int _obstack_begin_1 (struct obstack *h, int size, int alignment, - void *(*chunkfun) (void *, long), - void (*freefun) (void *, void *), - void *arg) + void *(*chunkfun) (void *, long), + void (*freefun) (void *, void *), + void *arg) { register struct _obstack_chunk *chunk; /* points to new chunk */ @@ -200,16 +200,16 @@ _obstack_begin_1 (struct obstack *h, int size, int alignment, /* Default size is what GNU malloc can fit in a 4096-byte block. */ { /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc. - Use the values for range checking, because if range checking is off, - the extra bytes won't be missed terribly, but if range checking is on - and we used a larger request, a whole extra 4096 bytes would be - allocated. + Use the values for range checking, because if range checking is off, + the extra bytes won't be missed terribly, but if range checking is on + and we used a larger request, a whole extra 4096 bytes would be + allocated. - These number are irrelevant to the new GNU malloc. I suspect it is - less sensitive to the size of the request. */ + These number are irrelevant to the new GNU malloc. I suspect it is + less sensitive to the size of the request. */ int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1)) - + 4 + DEFAULT_ROUNDING - 1) - & ~(DEFAULT_ROUNDING - 1)); + + 4 + DEFAULT_ROUNDING - 1) + & ~(DEFAULT_ROUNDING - 1)); size = 4096 - extra; } @@ -224,7 +224,7 @@ _obstack_begin_1 (struct obstack *h, int size, int alignment, if (!chunk) (*obstack_alloc_failed_handler) (); h->next_free = h->object_base = __PTR_ALIGN ((char *) chunk, chunk->contents, - alignment - 1); + alignment - 1); h->chunk_limit = chunk->limit = (char *) chunk + h->chunk_size; chunk->prev = 0; @@ -245,7 +245,7 @@ _obstack_newchunk (struct obstack *h, int length) { register struct _obstack_chunk *old_chunk = h->chunk; register struct _obstack_chunk *new_chunk; - register long new_size; + register long new_size; register long obj_size = h->next_free - h->object_base; register long i; long already; @@ -274,12 +274,12 @@ _obstack_newchunk (struct obstack *h, int length) if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT) { for (i = obj_size / sizeof (COPYING_UNIT) - 1; - i >= 0; i--) - ((COPYING_UNIT *)object_base)[i] - = ((COPYING_UNIT *)h->object_base)[i]; + i >= 0; i--) + ((COPYING_UNIT *)object_base)[i] + = ((COPYING_UNIT *)h->object_base)[i]; /* We used to copy the odd few remaining bytes as one extra COPYING_UNIT, - but that can cross a page boundary on a machine - which does not do strict alignment for COPYING_UNITS. */ + but that can cross a page boundary on a machine + which does not do strict alignment for COPYING_UNITS. */ already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT); } else @@ -293,8 +293,8 @@ _obstack_newchunk (struct obstack *h, int length) But not if that chunk might contain an empty object. */ if (! h->maybe_empty_object && (h->object_base - == __PTR_ALIGN ((char *) old_chunk, old_chunk->contents, - h->alignment_mask))) + == __PTR_ALIGN ((char *) old_chunk, old_chunk->contents, + h->alignment_mask))) { new_chunk->prev = old_chunk->prev; CALL_FREEFUN (h, old_chunk); @@ -320,8 +320,8 @@ int _obstack_allocated_p (struct obstack *h, void *obj); int _obstack_allocated_p (struct obstack *h, void *obj) { - register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ - register struct _obstack_chunk *plp; /* point to previous chunk if any */ + register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ + register struct _obstack_chunk *plp; /* point to previous chunk if any */ lp = (h)->chunk; /* We use >= rather than > since the object cannot be exactly at @@ -343,8 +343,8 @@ _obstack_allocated_p (struct obstack *h, void *obj) void __obstack_free (struct obstack *h, void *obj) { - register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ - register struct _obstack_chunk *plp; /* point to previous chunk if any */ + register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ + register struct _obstack_chunk *plp; /* point to previous chunk if any */ lp = h->chunk; /* We use >= because there cannot be an object at the beginning of a chunk. @@ -356,7 +356,7 @@ __obstack_free (struct obstack *h, void *obj) CALL_FREEFUN (h, lp); lp = plp; /* If we switch chunks, we can't tell whether the new current - chunk contains an empty object, so assume that it may. */ + chunk contains an empty object, so assume that it may. */ h->maybe_empty_object = 1; } if (lp) @@ -427,4 +427,4 @@ print_and_abort (void) exit (obstack_exit_failure); } -#endif /* !ELIDE_CODE */ +#endif /* !ELIDE_CODE */ diff --git a/src/bin/coreutils/lib/obstack.h b/src/bin/coreutils/lib/obstack.h index 1bf4b2f1a6..27b732d5da 100644 --- a/src/bin/coreutils/lib/obstack.h +++ b/src/bin/coreutils/lib/obstack.h @@ -1,6 +1,6 @@ /* obstack.h - object stack macros - Copyright (C) 1988-1994,1996-1999,2003,2004,2005,2006 - Free Software Foundation, Inc. + Copyright (C) 1988-1994, 1996-1999, 2003-2006, 2009-2010 Free Software + Foundation, Inc. This file is part of the GNU C Library. This program is free software: you can redistribute it and/or modify @@ -85,17 +85,17 @@ growing object. This allows the use of register variables, which break the ordinary 'growth' macro. Summary: - We allocate large chunks. - We carve out one object at a time from the current chunk. - Once carved, an object never moves. - We are free to append data of any size to the currently - growing object. - Exactly one object is growing in an obstack at any one time. - You can run one obstack per control block. - You may have as many control blocks as you dare. - Because of the way we do it, you can `unwind' an obstack - back to a previous state. (You may remove objects much - as you would with a stack.) + We allocate large chunks. + We carve out one object at a time from the current chunk. + Once carved, an object never moves. + We are free to append data of any size to the currently + growing object. + Exactly one object is growing in an obstack at any one time. + You can run one obstack per control block. + You may have as many control blocks as you dare. + Because of the way we do it, you can `unwind' an obstack + back to a previous state. (You may remove objects much + as you would with a stack.) */ @@ -133,56 +133,56 @@ extern "C" { relative to B. Otherwise, use the faster strategy of computing the alignment relative to 0. */ -#define __PTR_ALIGN(B, P, A) \ +#define __PTR_ALIGN(B, P, A) \ __BPTR_ALIGN (sizeof (PTR_INT_TYPE) < sizeof (void *) ? (B) : (char *) 0, \ - P, A) + P, A) #include -struct _obstack_chunk /* Lives at front of each chunk. */ +struct _obstack_chunk /* Lives at front of each chunk. */ { - char *limit; /* 1 past end of this chunk */ - struct _obstack_chunk *prev; /* address of prior chunk or NULL */ - char contents[4]; /* objects begin here */ + char *limit; /* 1 past end of this chunk */ + struct _obstack_chunk *prev; /* address of prior chunk or NULL */ + char contents[4]; /* objects begin here */ }; -struct obstack /* control current object in current chunk */ +struct obstack /* control current object in current chunk */ { - long chunk_size; /* preferred size to allocate chunks in */ - struct _obstack_chunk *chunk; /* address of current struct obstack_chunk */ - char *object_base; /* address of object we are building */ - char *next_free; /* where to add next char to current object */ - char *chunk_limit; /* address of char after current chunk */ + long chunk_size; /* preferred size to allocate chunks in */ + struct _obstack_chunk *chunk; /* address of current struct obstack_chunk */ + char *object_base; /* address of object we are building */ + char *next_free; /* where to add next char to current object */ + char *chunk_limit; /* address of char after current chunk */ union { PTR_INT_TYPE tempint; void *tempptr; - } temp; /* Temporary for some macros. */ - int alignment_mask; /* Mask of alignment for each object. */ + } temp; /* Temporary for some macros. */ + int alignment_mask; /* Mask of alignment for each object. */ /* These prototypes vary based on `use_extra_arg', and we use casts to the prototypeless function type in all assignments, but having prototypes here quiets -Wstrict-prototypes. */ struct _obstack_chunk *(*chunkfun) (void *, long); void (*freefun) (void *, struct _obstack_chunk *); - void *extra_arg; /* first arg for chunk alloc/dealloc funcs */ - unsigned use_extra_arg:1; /* chunk alloc/dealloc funcs take extra arg */ + void *extra_arg; /* first arg for chunk alloc/dealloc funcs */ + unsigned use_extra_arg:1; /* chunk alloc/dealloc funcs take extra arg */ unsigned maybe_empty_object:1;/* There is a possibility that the current - chunk contains a zero-length object. This - prevents freeing the chunk if we allocate - a bigger chunk to replace it. */ - unsigned alloc_failed:1; /* No longer used, as we now call the failed - handler on error, but retained for binary - compatibility. */ + chunk contains a zero-length object. This + prevents freeing the chunk if we allocate + a bigger chunk to replace it. */ + unsigned alloc_failed:1; /* No longer used, as we now call the failed + handler on error, but retained for binary + compatibility. */ }; /* Declare the external functions we use; they are in obstack.c. */ extern void _obstack_newchunk (struct obstack *, int); extern int _obstack_begin (struct obstack *, int, int, - void *(*) (long), void (*) (void *)); + void *(*) (long), void (*) (void *)); extern int _obstack_begin_1 (struct obstack *, int, int, - void *(*) (void *, long), - void (*) (void *, void *), void *); + void *(*) (void *, long), + void (*) (void *, void *), void *); extern int _obstack_memory_used (struct obstack *); /* The default name of the function for freeing a chunk is 'obstack_free', @@ -214,32 +214,32 @@ extern int obstack_exit_failure; /* Pointer to next byte not yet allocated in current chunk. */ -#define obstack_next_free(h) ((h)->next_free) +#define obstack_next_free(h) ((h)->next_free) /* Mask specifying low bits that should be clear in address of an object. */ #define obstack_alignment_mask(h) ((h)->alignment_mask) /* To prevent prototype warnings provide complete argument list. */ -#define obstack_init(h) \ - _obstack_begin ((h), 0, 0, \ - (void *(*) (long)) obstack_chunk_alloc, \ - (void (*) (void *)) obstack_chunk_free) +#define obstack_init(h) \ + _obstack_begin ((h), 0, 0, \ + (void *(*) (long)) obstack_chunk_alloc, \ + (void (*) (void *)) obstack_chunk_free) -#define obstack_begin(h, size) \ - _obstack_begin ((h), (size), 0, \ - (void *(*) (long)) obstack_chunk_alloc, \ - (void (*) (void *)) obstack_chunk_free) +#define obstack_begin(h, size) \ + _obstack_begin ((h), (size), 0, \ + (void *(*) (long)) obstack_chunk_alloc, \ + (void (*) (void *)) obstack_chunk_free) #define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \ - _obstack_begin ((h), (size), (alignment), \ - (void *(*) (long)) (chunkfun), \ - (void (*) (void *)) (freefun)) + _obstack_begin ((h), (size), (alignment), \ + (void *(*) (long)) (chunkfun), \ + (void (*) (void *)) (freefun)) #define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \ - _obstack_begin_1 ((h), (size), (alignment), \ - (void *(*) (void *, long)) (chunkfun), \ - (void (*) (void *, void *)) (freefun), (arg)) + _obstack_begin_1 ((h), (size), (alignment), \ + (void *(*) (void *, long)) (chunkfun), \ + (void (*) (void *, void *)) (freefun), (arg)) #define obstack_chunkfun(h, newchunkfun) \ ((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun)) @@ -266,143 +266,143 @@ extern int obstack_exit_failure; without using a global variable. Also, we can avoid using the `temp' slot, to make faster code. */ -# define obstack_object_size(OBSTACK) \ - __extension__ \ - ({ struct obstack const *__o = (OBSTACK); \ +# define obstack_object_size(OBSTACK) \ + __extension__ \ + ({ struct obstack const *__o = (OBSTACK); \ (unsigned) (__o->next_free - __o->object_base); }) -# define obstack_room(OBSTACK) \ - __extension__ \ - ({ struct obstack const *__o = (OBSTACK); \ +# define obstack_room(OBSTACK) \ + __extension__ \ + ({ struct obstack const *__o = (OBSTACK); \ (unsigned) (__o->chunk_limit - __o->next_free); }) -# define obstack_make_room(OBSTACK,length) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - if (__o->chunk_limit - __o->next_free < __len) \ - _obstack_newchunk (__o, __len); \ +# define obstack_make_room(OBSTACK,length) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + int __len = (length); \ + if (__o->chunk_limit - __o->next_free < __len) \ + _obstack_newchunk (__o, __len); \ (void) 0; }) -# define obstack_empty_p(OBSTACK) \ - __extension__ \ - ({ struct obstack const *__o = (OBSTACK); \ - (__o->chunk->prev == 0 \ - && __o->next_free == __PTR_ALIGN ((char *) __o->chunk, \ - __o->chunk->contents, \ - __o->alignment_mask)); }) +# define obstack_empty_p(OBSTACK) \ + __extension__ \ + ({ struct obstack const *__o = (OBSTACK); \ + (__o->chunk->prev == 0 \ + && __o->next_free == __PTR_ALIGN ((char *) __o->chunk, \ + __o->chunk->contents, \ + __o->alignment_mask)); }) -# define obstack_grow(OBSTACK,where,length) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - if (__o->next_free + __len > __o->chunk_limit) \ - _obstack_newchunk (__o, __len); \ - memcpy (__o->next_free, where, __len); \ - __o->next_free += __len; \ +# define obstack_grow(OBSTACK,where,length) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + int __len = (length); \ + if (__o->next_free + __len > __o->chunk_limit) \ + _obstack_newchunk (__o, __len); \ + memcpy (__o->next_free, where, __len); \ + __o->next_free += __len; \ (void) 0; }) -# define obstack_grow0(OBSTACK,where,length) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - if (__o->next_free + __len + 1 > __o->chunk_limit) \ - _obstack_newchunk (__o, __len + 1); \ - memcpy (__o->next_free, where, __len); \ - __o->next_free += __len; \ - *(__o->next_free)++ = 0; \ +# define obstack_grow0(OBSTACK,where,length) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + int __len = (length); \ + if (__o->next_free + __len + 1 > __o->chunk_limit) \ + _obstack_newchunk (__o, __len + 1); \ + memcpy (__o->next_free, where, __len); \ + __o->next_free += __len; \ + *(__o->next_free)++ = 0; \ (void) 0; }) -# define obstack_1grow(OBSTACK,datum) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - if (__o->next_free + 1 > __o->chunk_limit) \ - _obstack_newchunk (__o, 1); \ - obstack_1grow_fast (__o, datum); \ +# define obstack_1grow(OBSTACK,datum) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + if (__o->next_free + 1 > __o->chunk_limit) \ + _obstack_newchunk (__o, 1); \ + obstack_1grow_fast (__o, datum); \ (void) 0; }) /* These assume that the obstack alignment is good enough for pointers or ints, and that the data added so far to the current object shares that much alignment. */ -# define obstack_ptr_grow(OBSTACK,datum) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - if (__o->next_free + sizeof (void *) > __o->chunk_limit) \ - _obstack_newchunk (__o, sizeof (void *)); \ - obstack_ptr_grow_fast (__o, datum); }) \ +# define obstack_ptr_grow(OBSTACK,datum) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + if (__o->next_free + sizeof (void *) > __o->chunk_limit) \ + _obstack_newchunk (__o, sizeof (void *)); \ + obstack_ptr_grow_fast (__o, datum); }) \ -# define obstack_int_grow(OBSTACK,datum) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - if (__o->next_free + sizeof (int) > __o->chunk_limit) \ - _obstack_newchunk (__o, sizeof (int)); \ +# define obstack_int_grow(OBSTACK,datum) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + if (__o->next_free + sizeof (int) > __o->chunk_limit) \ + _obstack_newchunk (__o, sizeof (int)); \ obstack_int_grow_fast (__o, datum); }) -# define obstack_ptr_grow_fast(OBSTACK,aptr) \ -__extension__ \ -({ struct obstack *__o1 = (OBSTACK); \ - *(const void **) __o1->next_free = (aptr); \ - __o1->next_free += sizeof (const void *); \ +# define obstack_ptr_grow_fast(OBSTACK,aptr) \ +__extension__ \ +({ struct obstack *__o1 = (OBSTACK); \ + *(const void **) __o1->next_free = (aptr); \ + __o1->next_free += sizeof (const void *); \ (void) 0; }) -# define obstack_int_grow_fast(OBSTACK,aint) \ -__extension__ \ -({ struct obstack *__o1 = (OBSTACK); \ - *(int *) __o1->next_free = (aint); \ - __o1->next_free += sizeof (int); \ +# define obstack_int_grow_fast(OBSTACK,aint) \ +__extension__ \ +({ struct obstack *__o1 = (OBSTACK); \ + *(int *) __o1->next_free = (aint); \ + __o1->next_free += sizeof (int); \ (void) 0; }) -# define obstack_blank(OBSTACK,length) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - if (__o->chunk_limit - __o->next_free < __len) \ - _obstack_newchunk (__o, __len); \ - obstack_blank_fast (__o, __len); \ +# define obstack_blank(OBSTACK,length) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + int __len = (length); \ + if (__o->chunk_limit - __o->next_free < __len) \ + _obstack_newchunk (__o, __len); \ + obstack_blank_fast (__o, __len); \ (void) 0; }) -# define obstack_alloc(OBSTACK,length) \ -__extension__ \ -({ struct obstack *__h = (OBSTACK); \ - obstack_blank (__h, (length)); \ +# define obstack_alloc(OBSTACK,length) \ +__extension__ \ +({ struct obstack *__h = (OBSTACK); \ + obstack_blank (__h, (length)); \ obstack_finish (__h); }) -# define obstack_copy(OBSTACK,where,length) \ -__extension__ \ -({ struct obstack *__h = (OBSTACK); \ - obstack_grow (__h, (where), (length)); \ +# define obstack_copy(OBSTACK,where,length) \ +__extension__ \ +({ struct obstack *__h = (OBSTACK); \ + obstack_grow (__h, (where), (length)); \ obstack_finish (__h); }) -# define obstack_copy0(OBSTACK,where,length) \ -__extension__ \ -({ struct obstack *__h = (OBSTACK); \ - obstack_grow0 (__h, (where), (length)); \ +# define obstack_copy0(OBSTACK,where,length) \ +__extension__ \ +({ struct obstack *__h = (OBSTACK); \ + obstack_grow0 (__h, (where), (length)); \ obstack_finish (__h); }) /* The local variable is named __o1 to avoid a name conflict when obstack_blank is called. */ -# define obstack_finish(OBSTACK) \ -__extension__ \ -({ struct obstack *__o1 = (OBSTACK); \ - void *__value = (void *) __o1->object_base; \ - if (__o1->next_free == __value) \ - __o1->maybe_empty_object = 1; \ - __o1->next_free \ - = __PTR_ALIGN (__o1->object_base, __o1->next_free, \ - __o1->alignment_mask); \ - if (__o1->next_free - (char *)__o1->chunk \ - > __o1->chunk_limit - (char *)__o1->chunk) \ - __o1->next_free = __o1->chunk_limit; \ - __o1->object_base = __o1->next_free; \ +# define obstack_finish(OBSTACK) \ +__extension__ \ +({ struct obstack *__o1 = (OBSTACK); \ + void *__value = (void *) __o1->object_base; \ + if (__o1->next_free == __value) \ + __o1->maybe_empty_object = 1; \ + __o1->next_free \ + = __PTR_ALIGN (__o1->object_base, __o1->next_free, \ + __o1->alignment_mask); \ + if (__o1->next_free - (char *)__o1->chunk \ + > __o1->chunk_limit - (char *)__o1->chunk) \ + __o1->next_free = __o1->chunk_limit; \ + __o1->object_base = __o1->next_free; \ __value; }) -# define obstack_free(OBSTACK, OBJ) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - void *__obj = (OBJ); \ +# define obstack_free(OBSTACK, OBJ) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + void *__obj = (OBJ); \ if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \ - __o->next_free = __o->object_base = (char *)__obj; \ + __o->next_free = __o->object_base = (char *)__obj; \ else (__obstack_free) (__o, __obj); }) #else /* not __GNUC__ or not __STDC__ */ @@ -410,14 +410,14 @@ __extension__ \ # define obstack_object_size(h) \ (unsigned) ((h)->next_free - (h)->object_base) -# define obstack_room(h) \ +# define obstack_room(h) \ (unsigned) ((h)->chunk_limit - (h)->next_free) # define obstack_empty_p(h) \ - ((h)->chunk->prev == 0 \ - && (h)->next_free == __PTR_ALIGN ((char *) (h)->chunk, \ - (h)->chunk->contents, \ - (h)->alignment_mask)) + ((h)->chunk->prev == 0 \ + && (h)->next_free == __PTR_ALIGN ((char *) (h)->chunk, \ + (h)->chunk->contents, \ + (h)->alignment_mask)) /* Note that the call to _obstack_newchunk is enclosed in (..., 0) so that we can avoid having void expressions @@ -425,88 +425,88 @@ __extension__ \ Casting the third operand to void was tried before, but some compilers won't accept it. */ -# define obstack_make_room(h,length) \ -( (h)->temp.tempint = (length), \ - (((h)->next_free + (h)->temp.tempint > (h)->chunk_limit) \ +# define obstack_make_room(h,length) \ +( (h)->temp.tempint = (length), \ + (((h)->next_free + (h)->temp.tempint > (h)->chunk_limit) \ ? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0)) -# define obstack_grow(h,where,length) \ -( (h)->temp.tempint = (length), \ - (((h)->next_free + (h)->temp.tempint > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0), \ - memcpy ((h)->next_free, where, (h)->temp.tempint), \ +# define obstack_grow(h,where,length) \ +( (h)->temp.tempint = (length), \ + (((h)->next_free + (h)->temp.tempint > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0), \ + memcpy ((h)->next_free, where, (h)->temp.tempint), \ (h)->next_free += (h)->temp.tempint) -# define obstack_grow0(h,where,length) \ -( (h)->temp.tempint = (length), \ - (((h)->next_free + (h)->temp.tempint + 1 > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), (h)->temp.tempint + 1), 0) : 0), \ - memcpy ((h)->next_free, where, (h)->temp.tempint), \ - (h)->next_free += (h)->temp.tempint, \ +# define obstack_grow0(h,where,length) \ +( (h)->temp.tempint = (length), \ + (((h)->next_free + (h)->temp.tempint + 1 > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), (h)->temp.tempint + 1), 0) : 0), \ + memcpy ((h)->next_free, where, (h)->temp.tempint), \ + (h)->next_free += (h)->temp.tempint, \ *((h)->next_free)++ = 0) -# define obstack_1grow(h,datum) \ -( (((h)->next_free + 1 > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), 1), 0) : 0), \ +# define obstack_1grow(h,datum) \ +( (((h)->next_free + 1 > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), 1), 0) : 0), \ obstack_1grow_fast (h, datum)) -# define obstack_ptr_grow(h,datum) \ -( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \ +# define obstack_ptr_grow(h,datum) \ +( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \ obstack_ptr_grow_fast (h, datum)) -# define obstack_int_grow(h,datum) \ -( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \ +# define obstack_int_grow(h,datum) \ +( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \ obstack_int_grow_fast (h, datum)) -# define obstack_ptr_grow_fast(h,aptr) \ +# define obstack_ptr_grow_fast(h,aptr) \ (((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr)) -# define obstack_int_grow_fast(h,aint) \ +# define obstack_int_grow_fast(h,aint) \ (((int *) ((h)->next_free += sizeof (int)))[-1] = (aint)) -# define obstack_blank(h,length) \ -( (h)->temp.tempint = (length), \ - (((h)->chunk_limit - (h)->next_free < (h)->temp.tempint) \ - ? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0), \ +# define obstack_blank(h,length) \ +( (h)->temp.tempint = (length), \ + (((h)->chunk_limit - (h)->next_free < (h)->temp.tempint) \ + ? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0), \ obstack_blank_fast (h, (h)->temp.tempint)) -# define obstack_alloc(h,length) \ +# define obstack_alloc(h,length) \ (obstack_blank ((h), (length)), obstack_finish ((h))) -# define obstack_copy(h,where,length) \ +# define obstack_copy(h,where,length) \ (obstack_grow ((h), (where), (length)), obstack_finish ((h))) -# define obstack_copy0(h,where,length) \ +# define obstack_copy0(h,where,length) \ (obstack_grow0 ((h), (where), (length)), obstack_finish ((h))) -# define obstack_finish(h) \ -( ((h)->next_free == (h)->object_base \ - ? (((h)->maybe_empty_object = 1), 0) \ - : 0), \ - (h)->temp.tempptr = (h)->object_base, \ - (h)->next_free \ - = __PTR_ALIGN ((h)->object_base, (h)->next_free, \ - (h)->alignment_mask), \ - (((h)->next_free - (char *) (h)->chunk \ - > (h)->chunk_limit - (char *) (h)->chunk) \ - ? ((h)->next_free = (h)->chunk_limit) : 0), \ - (h)->object_base = (h)->next_free, \ +# define obstack_finish(h) \ +( ((h)->next_free == (h)->object_base \ + ? (((h)->maybe_empty_object = 1), 0) \ + : 0), \ + (h)->temp.tempptr = (h)->object_base, \ + (h)->next_free \ + = __PTR_ALIGN ((h)->object_base, (h)->next_free, \ + (h)->alignment_mask), \ + (((h)->next_free - (char *) (h)->chunk \ + > (h)->chunk_limit - (char *) (h)->chunk) \ + ? ((h)->next_free = (h)->chunk_limit) : 0), \ + (h)->object_base = (h)->next_free, \ (h)->temp.tempptr) -# define obstack_free(h,obj) \ -( (h)->temp.tempint = (char *) (obj) - (char *) (h)->chunk, \ - ((((h)->temp.tempint > 0 \ - && (h)->temp.tempint < (h)->chunk_limit - (char *) (h)->chunk)) \ - ? (int) ((h)->next_free = (h)->object_base \ - = (h)->temp.tempint + (char *) (h)->chunk) \ +# define obstack_free(h,obj) \ +( (h)->temp.tempint = (char *) (obj) - (char *) (h)->chunk, \ + ((((h)->temp.tempint > 0 \ + && (h)->temp.tempint < (h)->chunk_limit - (char *) (h)->chunk)) \ + ? (int) ((h)->next_free = (h)->object_base \ + = (h)->temp.tempint + (char *) (h)->chunk) \ : (((__obstack_free) ((h), (h)->temp.tempint + (char *) (h)->chunk), 0), 0))) #endif /* not __GNUC__ or not __STDC__ */ #ifdef __cplusplus -} /* C++ */ +} /* C++ */ #endif #endif /* obstack.h */ diff --git a/src/bin/coreutils/lib/offtostr.c b/src/bin/coreutils/lib/offtostr.c index 45196e28a4..3a60c6e744 100644 --- a/src/bin/coreutils/lib/offtostr.c +++ b/src/bin/coreutils/lib/offtostr.c @@ -1,3 +1,4 @@ #define inttostr offtostr #define inttype off_t +#define inttype_is_signed 1 #include "inttostr.c" diff --git a/src/bin/coreutils/lib/open-safer.c b/src/bin/coreutils/lib/open-safer.c index 48d558fa57..3b36471f23 100644 --- a/src/bin/coreutils/lib/open-safer.c +++ b/src/bin/coreutils/lib/open-safer.c @@ -1,6 +1,6 @@ /* Invoke open, but avoid some glitches. - Copyright (C) 2005, 2006, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -36,7 +36,7 @@ open_safer (char const *file, int flags, ...) va_start (ap, flags); /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4 - creates crashing code when 'mode_t' is smaller than 'int'. */ + creates crashing code when 'mode_t' is smaller than 'int'. */ mode = va_arg (ap, PROMOTED_MODE_T); va_end (ap); diff --git a/src/bin/coreutils/lib/open.c b/src/bin/coreutils/lib/open.c index 08ecaff44b..f612b802d2 100644 --- a/src/bin/coreutils/lib/open.c +++ b/src/bin/coreutils/lib/open.c @@ -1,5 +1,5 @@ /* Open a descriptor to a file. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -57,7 +57,7 @@ open (const char *filename, int flags, ...) va_start (arg, flags); /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4 - creates crashing code when 'mode_t' is smaller than 'int'. */ + creates crashing code when 'mode_t' is smaller than 'int'. */ mode = va_arg (arg, PROMOTED_MODE_T); va_end (arg); @@ -94,10 +94,10 @@ open (const char *filename, int flags, ...) { size_t len = strlen (filename); if (len > 0 && filename[len - 1] == '/') - { - errno = EISDIR; - return -1; - } + { + errno = EISDIR; + return -1; + } } #endif @@ -111,7 +111,7 @@ open (const char *filename, int flags, ...) override fstat() in fchdir.c to hide the fact that we have a dummy. */ if (REPLACE_OPEN_DIRECTORY && fd < 0 && errno == EACCES - && (mode & O_ACCMODE) == O_RDONLY) + && (flags & O_ACCMODE) == O_RDONLY) { struct stat statbuf; if (stat (filename, &statbuf) == 0 && S_ISDIR (statbuf.st_mode)) @@ -141,18 +141,19 @@ open (const char *filename, int flags, ...) with ENOTDIR. */ if (fd >= 0) { + /* We know len is positive, since open did not fail with ENOENT. */ size_t len = strlen (filename); - if (len > 0 && filename[len - 1] == '/') - { - struct stat statbuf; + if (filename[len - 1] == '/') + { + struct stat statbuf; - if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode)) - { - close (fd); - errno = ENOTDIR; - return -1; - } - } + if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode)) + { + close (fd); + errno = ENOTDIR; + return -1; + } + } } #endif diff --git a/src/bin/coreutils/lib/openat-die.c b/src/bin/coreutils/lib/openat-die.c index 677f3e02cb..a8639e11de 100644 --- a/src/bin/coreutils/lib/openat-die.c +++ b/src/bin/coreutils/lib/openat-die.c @@ -1,6 +1,6 @@ /* Report a save- or restore-cwd failure in our openat replacement and then exit. - Copyright (C) 2005, 2006, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,7 +31,7 @@ void openat_save_fail (int errnum) { error (exit_failure, errnum, - _("unable to record current working directory")); + _("unable to record current working directory")); /* The `noreturn' attribute cannot be applied to error, since it returns when its first argument is 0. To help compilers understand that this @@ -40,11 +40,16 @@ openat_save_fail (int errnum) abort (); } + +/* Exit with an error about failure to restore the working directory + during an openat emulation. The caller must ensure that fd 2 is + not a just-opened fd, even when openat_safer is not in use. */ + void openat_restore_fail (int errnum) { error (exit_failure, errnum, - _("failed to return to initial working directory")); + _("failed to return to initial working directory")); /* As above. */ abort (); diff --git a/src/bin/coreutils/lib/openat-priv.h b/src/bin/coreutils/lib/openat-priv.h index 2280416292..e0818731f4 100644 --- a/src/bin/coreutils/lib/openat-priv.h +++ b/src/bin/coreutils/lib/openat-priv.h @@ -1,6 +1,6 @@ /* Internals for openat-like functions. - Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,6 +17,9 @@ /* written by Jim Meyering */ +#ifndef _GL_HEADER_OPENAT_PRIV +#define _GL_HEADER_OPENAT_PRIV + #include #include @@ -27,8 +30,15 @@ char *openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file); /proc support, and even on systems *with* ProcFS support. Return nonzero if the failure may be legitimate, e.g., because /proc is not readable, or the particular .../fd/N directory is not present. */ -#define EXPECTED_ERRNO(Errno) \ - ((Errno) == ENOTDIR || (Errno) == ENOENT \ - || (Errno) == EPERM || (Errno) == EACCES \ - || (Errno) == ENOSYS /* Solaris 8 */ \ +#define EXPECTED_ERRNO(Errno) \ + ((Errno) == ENOTDIR || (Errno) == ENOENT \ + || (Errno) == EPERM || (Errno) == EACCES \ + || (Errno) == ENOSYS /* Solaris 8 */ \ || (Errno) == EOPNOTSUPP /* FreeBSD */) + +/* Wrapper function shared among linkat and renameat. */ +int at_func2 (int fd1, char const *file1, + int fd2, char const *file2, + int (*func) (char const *file1, char const *file2)); + +#endif /* _GL_HEADER_OPENAT_PRIV */ diff --git a/src/bin/coreutils/lib/openat-proc.c b/src/bin/coreutils/lib/openat-proc.c index 76e1c6dd51..25384127eb 100644 --- a/src/bin/coreutils/lib/openat-proc.c +++ b/src/bin/coreutils/lib/openat-proc.c @@ -1,6 +1,6 @@ /* Create /proc/self/fd-related names for subfiles of open directories. - Copyright (C) 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,6 +27,7 @@ #include #include +#include #include "dirname.h" #include "intprops.h" @@ -67,29 +68,29 @@ openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file) if (! proc_status) { /* Set PROC_STATUS to a positive value if /proc/self/fd is - reliable, and a negative value otherwise. Solaris 10 - /proc/self/fd mishandles "..", and any file name might expand - to ".." after symbolic link expansion, so avoid /proc/self/fd - if it mishandles "..". Solaris 10 has openat, but this - problem is exhibited on code that built on Solaris 8 and - running on Solaris 10. */ + reliable, and a negative value otherwise. Solaris 10 + /proc/self/fd mishandles "..", and any file name might expand + to ".." after symbolic link expansion, so avoid /proc/self/fd + if it mishandles "..". Solaris 10 has openat, but this + problem is exhibited on code that built on Solaris 8 and + running on Solaris 10. */ int proc_self_fd = open ("/proc/self/fd", O_RDONLY); if (proc_self_fd < 0) - proc_status = -1; + proc_status = -1; else - { - struct stat proc_self_fd_dotdot_st; - struct stat proc_self_st; - char dotdot_buf[PROC_SELF_FD_NAME_SIZE_BOUND (sizeof ".." - 1)]; - sprintf (dotdot_buf, PROC_SELF_FD_FORMAT, proc_self_fd, ".."); - proc_status = - ((stat (dotdot_buf, &proc_self_fd_dotdot_st) == 0 - && stat ("/proc/self", &proc_self_st) == 0 - && SAME_INODE (proc_self_fd_dotdot_st, proc_self_st)) - ? 1 : -1); - close (proc_self_fd); - } + { + struct stat proc_self_fd_dotdot_st; + struct stat proc_self_st; + char dotdot_buf[PROC_SELF_FD_NAME_SIZE_BOUND (sizeof ".." - 1)]; + sprintf (dotdot_buf, PROC_SELF_FD_FORMAT, proc_self_fd, ".."); + proc_status = + ((stat (dotdot_buf, &proc_self_fd_dotdot_st) == 0 + && stat ("/proc/self", &proc_self_st) == 0 + && SAME_INODE (proc_self_fd_dotdot_st, proc_self_st)) + ? 1 : -1); + close (proc_self_fd); + } } if (proc_status < 0) diff --git a/src/bin/coreutils/lib/openat-safer.c b/src/bin/coreutils/lib/openat-safer.c index 58d9a5e5f0..f573f97d4c 100644 --- a/src/bin/coreutils/lib/openat-safer.c +++ b/src/bin/coreutils/lib/openat-safer.c @@ -1,6 +1,6 @@ /* Invoke openat, but avoid some glitches. - Copyright (C) 2005, 2006, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -36,7 +36,7 @@ openat_safer (int fd, char const *file, int flags, ...) va_start (ap, flags); /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4 - creates crashing code when 'mode_t' is smaller than 'int'. */ + creates crashing code when 'mode_t' is smaller than 'int'. */ mode = va_arg (ap, PROMOTED_MODE_T); va_end (ap); diff --git a/src/bin/coreutils/lib/openat.c b/src/bin/coreutils/lib/openat.c index e1471b8c0f..f2eac868d4 100644 --- a/src/bin/coreutils/lib/openat.c +++ b/src/bin/coreutils/lib/openat.c @@ -1,5 +1,5 @@ /* provide a replacement openat function - Copyright (C) 2004-2009 Free Software Foundation, Inc. + Copyright (C) 2004-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,19 +22,108 @@ #include #include +#include #include #include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ #include "openat-priv.h" #include "save-cwd.h" -/* We can't use "fcntl--.h", so that openat_safer does not interfere. */ -#if GNULIB_FCNTL_SAFER -# include "fcntl-safer.h" -# undef open -# define open open_safer +#if HAVE_OPENAT + +# undef openat + +/* Like openat, but work around Solaris 9 bugs with trailing slash. */ +int +rpl_openat (int dfd, char const *filename, int flags, ...) +{ + mode_t mode; + int fd; + + mode = 0; + if (flags & O_CREAT) + { + va_list arg; + va_start (arg, flags); + + /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4 + creates crashing code when 'mode_t' is smaller than 'int'. */ + mode = va_arg (arg, PROMOTED_MODE_T); + + va_end (arg); + } + +#if OPEN_TRAILING_SLASH_BUG + /* If the filename ends in a slash and one of O_CREAT, O_WRONLY, O_RDWR + is specified, then fail. + Rationale: POSIX + says that + "A pathname that contains at least one non-slash character and that + ends with one or more trailing slashes shall be resolved as if a + single dot character ( '.' ) were appended to the pathname." + and + "The special filename dot shall refer to the directory specified by + its predecessor." + If the named file already exists as a directory, then + - if O_CREAT is specified, open() must fail because of the semantics + of O_CREAT, + - if O_WRONLY or O_RDWR is specified, open() must fail because POSIX + says that it + fails with errno = EISDIR in this case. + If the named file does not exist or does not name a directory, then + - if O_CREAT is specified, open() must fail since open() cannot create + directories, + - if O_WRONLY or O_RDWR is specified, open() must fail because the + file does not contain a '.' directory. */ + if (flags & (O_CREAT | O_WRONLY | O_RDWR)) + { + size_t len = strlen (filename); + if (len > 0 && filename[len - 1] == '/') + { + errno = EISDIR; + return -1; + } + } #endif + fd = openat (dfd, filename, flags, mode); + +#if OPEN_TRAILING_SLASH_BUG + /* If the filename ends in a slash and fd does not refer to a directory, + then fail. + Rationale: POSIX + says that + "A pathname that contains at least one non-slash character and that + ends with one or more trailing slashes shall be resolved as if a + single dot character ( '.' ) were appended to the pathname." + and + "The special filename dot shall refer to the directory specified by + its predecessor." + If the named file without the slash is not a directory, open() must fail + with ENOTDIR. */ + if (fd >= 0) + { + /* We know len is positive, since open did not fail with ENOENT. */ + size_t len = strlen (filename); + if (filename[len - 1] == '/') + { + struct stat statbuf; + + if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode)) + { + close (fd); + errno = ENOTDIR; + return -1; + } + } + } +#endif + + return fd; +} + +#else /* !HAVE_OPENAT */ + /* Replacement for Solaris' openat function. First, try to simulate it via open ("/proc/self/fd/FD/FILE"). @@ -54,7 +143,7 @@ openat (int fd, char const *file, int flags, ...) va_start (arg, flags); /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4 - creates crashing code when 'mode_t' is smaller than 'int'. */ + creates crashing code when 'mode_t' is smaller than 'int'. */ mode = va_arg (arg, PROMOTED_MODE_T); va_end (arg); @@ -76,7 +165,7 @@ openat (int fd, char const *file, int flags, ...) int openat_permissive (int fd, char const *file, int flags, mode_t mode, - int *cwd_errno) + int *cwd_errno) { struct saved_cwd saved_cwd; int saved_errno; @@ -91,18 +180,18 @@ openat_permissive (int fd, char const *file, int flags, mode_t mode, char *proc_file = openat_proc_name (buf, fd, file); if (proc_file) { - int open_result = open (proc_file, flags, mode); - int open_errno = errno; - if (proc_file != buf) - free (proc_file); - /* If the syscall succeeds, or if it fails with an unexpected - errno value, then return right away. Otherwise, fall through - and resort to using save_cwd/restore_cwd. */ - if (0 <= open_result || ! EXPECTED_ERRNO (open_errno)) - { - errno = open_errno; - return open_result; - } + int open_result = open (proc_file, flags, mode); + int open_errno = errno; + if (proc_file != buf) + free (proc_file); + /* If the syscall succeeds, or if it fails with an unexpected + errno value, then return right away. Otherwise, fall through + and resort to using save_cwd/restore_cwd. */ + if (0 <= open_result || ! EXPECTED_ERRNO (open_errno)) + { + errno = open_errno; + return open_result; + } } } @@ -110,9 +199,18 @@ openat_permissive (int fd, char const *file, int flags, mode_t mode, if (! save_ok) { if (! cwd_errno) - openat_save_fail (errno); + openat_save_fail (errno); *cwd_errno = errno; } + if (0 <= fd && fd == saved_cwd.desc) + { + /* If saving the working directory collides with the user's + requested fd, then the user's fd must have been closed to + begin with. */ + free_cwd (&saved_cwd); + errno = EBADF; + return -1; + } err = fchdir (fd); saved_errno = errno; @@ -122,11 +220,17 @@ openat_permissive (int fd, char const *file, int flags, mode_t mode, err = open (file, flags, mode); saved_errno = errno; if (save_ok && restore_cwd (&saved_cwd) != 0) - { - if (! cwd_errno) - openat_restore_fail (errno); - *cwd_errno = errno; - } + { + if (! cwd_errno) + { + /* Don't write a message to just-created fd 2. */ + saved_errno = errno; + if (err == STDERR_FILENO) + close (err); + openat_restore_fail (saved_errno); + } + *cwd_errno = errno; + } } free_cwd (&saved_cwd); @@ -147,57 +251,15 @@ openat_needs_fchdir (void) char buf[OPENAT_BUFFER_SIZE]; char *proc_file = openat_proc_name (buf, fd, "."); if (proc_file) - { - needs_fchdir = false; - if (proc_file != buf) - free (proc_file); - } + { + needs_fchdir = false; + if (proc_file != buf) + free (proc_file); + } close (fd); } return needs_fchdir; } -/* Replacement for Solaris' function by the same name. - - First, try to simulate it via l?stat ("/proc/self/fd/FD/FILE"). - Failing that, simulate it via save_cwd/fchdir/(stat|lstat)/restore_cwd. - If either the save_cwd or the restore_cwd fails (relatively unlikely), - then give a diagnostic and exit nonzero. - Otherwise, this function works just like Solaris' fstatat. */ - -#define AT_FUNC_NAME fstatat -#define AT_FUNC_F1 lstat -#define AT_FUNC_F2 stat -#define AT_FUNC_USE_F1_COND AT_SYMLINK_NOFOLLOW -#define AT_FUNC_POST_FILE_PARAM_DECLS , struct stat *st, int flag -#define AT_FUNC_POST_FILE_ARGS , st -#include "at-func.c" -#undef AT_FUNC_NAME -#undef AT_FUNC_F1 -#undef AT_FUNC_F2 -#undef AT_FUNC_USE_F1_COND -#undef AT_FUNC_POST_FILE_PARAM_DECLS -#undef AT_FUNC_POST_FILE_ARGS - -/* Replacement for Solaris' function by the same name. - - First, try to simulate it via (unlink|rmdir) ("/proc/self/fd/FD/FILE"). - Failing that, simulate it via save_cwd/fchdir/(unlink|rmdir)/restore_cwd. - If either the save_cwd or the restore_cwd fails (relatively unlikely), - then give a diagnostic and exit nonzero. - Otherwise, this function works just like Solaris' unlinkat. */ - -#define AT_FUNC_NAME unlinkat -#define AT_FUNC_F1 rmdir -#define AT_FUNC_F2 unlink -#define AT_FUNC_USE_F1_COND AT_REMOVEDIR -#define AT_FUNC_POST_FILE_PARAM_DECLS , int flag -#define AT_FUNC_POST_FILE_ARGS /* empty */ -#include "at-func.c" -#undef AT_FUNC_NAME -#undef AT_FUNC_F1 -#undef AT_FUNC_F2 -#undef AT_FUNC_USE_F1_COND -#undef AT_FUNC_POST_FILE_PARAM_DECLS -#undef AT_FUNC_POST_FILE_ARGS +#endif /* !HAVE_OPENAT */ diff --git a/src/bin/coreutils/lib/openat.h b/src/bin/coreutils/lib/openat.h index 433b9983df..11a0314d24 100644 --- a/src/bin/coreutils/lib/openat.h +++ b/src/bin/coreutils/lib/openat.h @@ -1,5 +1,5 @@ /* provide a replacement openat function - Copyright (C) 2004-2006, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2004-2006, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -40,7 +40,7 @@ #if !HAVE_OPENAT int openat_permissive (int fd, char const *file, int flags, mode_t mode, - int *cwd_errno); + int *cwd_errno); bool openat_needs_fchdir (void); #else diff --git a/src/bin/coreutils/lib/opendir-safer.c b/src/bin/coreutils/lib/opendir-safer.c index 8c399d0ca0..36d47329bb 100644 --- a/src/bin/coreutils/lib/opendir-safer.c +++ b/src/bin/coreutils/lib/opendir-safer.c @@ -1,6 +1,6 @@ /* Invoke opendir, but avoid some glitches. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/pathmax.h b/src/bin/coreutils/lib/pathmax.h index c542c4ba91..dc2e3110a0 100644 --- a/src/bin/coreutils/lib/pathmax.h +++ b/src/bin/coreutils/lib/pathmax.h @@ -2,7 +2,8 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Define PATH_MAX somehow. Requires sys/types.h. - Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009 Free Software Foundation, Inc. + Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2010 Free Software + Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,7 +32,7 @@ # if !defined PATH_MAX && defined _PC_PATH_MAX && defined HAVE_PATHCONF # define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 \ - : pathconf ("/", _PC_PATH_MAX)) + : pathconf ("/", _PC_PATH_MAX)) # endif /* Don't include sys/param.h if it already has been. */ diff --git a/src/bin/coreutils/lib/physmem.c b/src/bin/coreutils/lib/physmem.c index e168717060..c39bae9b73 100644 --- a/src/bin/coreutils/lib/physmem.c +++ b/src/bin/coreutils/lib/physmem.c @@ -1,6 +1,6 @@ /* Calculate the size of physical memory. - Copyright (C) 2000, 2001, 2003, 2005, 2006 Free Software + Copyright (C) 2000-2001, 2003, 2005-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -96,10 +96,10 @@ physmem_total (void) struct pst_static pss; if (0 <= pstat_getstatic (&pss, sizeof pss, 1, 0)) { - double pages = pss.physical_memory; - double pagesize = pss.page_size; - if (0 <= pages && 0 <= pagesize) - return pages * pagesize; + double pages = pss.physical_memory; + double pagesize = pss.page_size; + if (0 <= pages && 0 <= pagesize) + return pages * pagesize; } } #endif @@ -109,10 +109,10 @@ physmem_total (void) struct rminfo realmem; if (sysmp (MP_SAGET, MPSA_RMINFO, &realmem, sizeof realmem) == 0) { - double pagesize = sysconf (_SC_PAGESIZE); - double pages = realmem.physmem; - if (0 <= pages && 0 <= pagesize) - return pages * pagesize; + double pagesize = sysconf (_SC_PAGESIZE); + double pages = realmem.physmem; + if (0 <= pages && 0 <= pagesize) + return pages * pagesize; } } #endif @@ -122,12 +122,12 @@ physmem_total (void) int physmem; if (getsysinfo (GSI_PHYSMEM, (caddr_t) &physmem, sizeof (physmem), - NULL, NULL, NULL) == 1) + NULL, NULL, NULL) == 1) { - double kbytes = physmem; + double kbytes = physmem; - if (0 <= kbytes) - return kbytes * 1024.0; + if (0 <= kbytes) + return kbytes * 1024.0; } } #endif @@ -139,7 +139,7 @@ physmem_total (void) static int mib[2] = { CTL_HW, HW_PHYSMEM }; if (sysctl (mib, ARRAY_SIZE (mib), &physmem, &len, NULL, 0) == 0 - && len == sizeof (physmem)) + && len == sizeof (physmem)) return (double) physmem; } #endif @@ -160,20 +160,20 @@ physmem_total (void) /* Use GlobalMemoryStatusEx if available. */ if ((pfnex = (PFN_MS_EX) GetProcAddress (h, "GlobalMemoryStatusEx"))) { - lMEMORYSTATUSEX lms_ex; - lms_ex.dwLength = sizeof lms_ex; - if (!pfnex (&lms_ex)) - return 0.0; - return (double) lms_ex.ullTotalPhys; + lMEMORYSTATUSEX lms_ex; + lms_ex.dwLength = sizeof lms_ex; + if (!pfnex (&lms_ex)) + return 0.0; + return (double) lms_ex.ullTotalPhys; } /* Fall back to GlobalMemoryStatus which is always available. but returns wrong results for physical memory > 4GB. */ else { - MEMORYSTATUS ms; - GlobalMemoryStatus (&ms); - return (double) ms.dwTotalPhys; + MEMORYSTATUS ms; + GlobalMemoryStatus (&ms); + return (double) ms.dwTotalPhys; } } #endif @@ -200,12 +200,12 @@ physmem_available (void) struct pst_static pss; struct pst_dynamic psd; if (0 <= pstat_getstatic (&pss, sizeof pss, 1, 0) - && 0 <= pstat_getdynamic (&psd, sizeof psd, 1, 0)) + && 0 <= pstat_getdynamic (&psd, sizeof psd, 1, 0)) { - double pages = psd.psd_free; - double pagesize = pss.page_size; - if (0 <= pages && 0 <= pagesize) - return pages * pagesize; + double pages = psd.psd_free; + double pagesize = pss.page_size; + if (0 <= pages && 0 <= pagesize) + return pages * pagesize; } } #endif @@ -215,10 +215,10 @@ physmem_available (void) struct rminfo realmem; if (sysmp (MP_SAGET, MPSA_RMINFO, &realmem, sizeof realmem) == 0) { - double pagesize = sysconf (_SC_PAGESIZE); - double pages = realmem.availrmem; - if (0 <= pages && 0 <= pagesize) - return pages * pagesize; + double pagesize = sysconf (_SC_PAGESIZE); + double pages = realmem.availrmem; + if (0 <= pages && 0 <= pagesize) + return pages * pagesize; } } #endif @@ -229,11 +229,11 @@ physmem_available (void) if (table (TBL_VMSTATS, 0, &vmstats, 1, sizeof (vmstats)) == 1) { - double pages = vmstats.free_count; - double pagesize = vmstats.pagesize; + double pages = vmstats.free_count; + double pagesize = vmstats.pagesize; - if (0 <= pages && 0 <= pagesize) - return pages * pagesize; + if (0 <= pages && 0 <= pagesize) + return pages * pagesize; } } #endif @@ -245,7 +245,7 @@ physmem_available (void) static int mib[2] = { CTL_HW, HW_USERMEM }; if (sysctl (mib, ARRAY_SIZE (mib), &usermem, &len, NULL, 0) == 0 - && len == sizeof (usermem)) + && len == sizeof (usermem)) return (double) usermem; } #endif @@ -261,20 +261,20 @@ physmem_available (void) /* Use GlobalMemoryStatusEx if available. */ if ((pfnex = (PFN_MS_EX) GetProcAddress (h, "GlobalMemoryStatusEx"))) { - lMEMORYSTATUSEX lms_ex; - lms_ex.dwLength = sizeof lms_ex; - if (!pfnex (&lms_ex)) - return 0.0; - return (double) lms_ex.ullAvailPhys; + lMEMORYSTATUSEX lms_ex; + lms_ex.dwLength = sizeof lms_ex; + if (!pfnex (&lms_ex)) + return 0.0; + return (double) lms_ex.ullAvailPhys; } /* Fall back to GlobalMemoryStatus which is always available. but returns wrong results for physical memory > 4GB */ else { - MEMORYSTATUS ms; - GlobalMemoryStatus (&ms); - return (double) ms.dwAvailPhys; + MEMORYSTATUS ms; + GlobalMemoryStatus (&ms); + return (double) ms.dwAvailPhys; } } #endif diff --git a/src/bin/coreutils/lib/physmem.h b/src/bin/coreutils/lib/physmem.h index 95375d797a..f77d85beb4 100644 --- a/src/bin/coreutils/lib/physmem.h +++ b/src/bin/coreutils/lib/physmem.h @@ -1,6 +1,6 @@ /* Calculate the size of physical memory. - Copyright (C) 2000, 2003 Free Software Foundation, Inc. + Copyright (C) 2000, 2003, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/pipe-safer.c b/src/bin/coreutils/lib/pipe-safer.c index 0fc685054b..ae9f2e3e0f 100644 --- a/src/bin/coreutils/lib/pipe-safer.c +++ b/src/bin/coreutils/lib/pipe-safer.c @@ -1,5 +1,5 @@ /* Invoke pipe, but avoid some glitches. - Copyright (C) 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -35,16 +35,16 @@ pipe_safer (int fd[2]) { int i; for (i = 0; i < 2; i++) - { - fd[i] = fd_safer (fd[i]); - if (fd[i] < 0) - { - int e = errno; - close (fd[1 - i]); - errno = e; - return -1; - } - } + { + fd[i] = fd_safer (fd[i]); + if (fd[i] < 0) + { + int e = errno; + close (fd[1 - i]); + errno = e; + return -1; + } + } return 0; } diff --git a/src/bin/coreutils/lib/posixtm.c b/src/bin/coreutils/lib/posixtm.c index 4d044a30bf..c786adb878 100644 --- a/src/bin/coreutils/lib/posixtm.c +++ b/src/bin/coreutils/lib/posixtm.c @@ -1,7 +1,6 @@ /* Parse dates for touch and date. - Copyright (C) 1989, 1990, 1991, 1998, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007 Free Software Foundation Inc. + Copyright (C) 1989-1991, 1998, 2000-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -66,33 +65,33 @@ year (struct tm *tm, const int *digit_pair, size_t n, unsigned int syntax_bits) case 1: tm->tm_year = *digit_pair; /* Deduce the century based on the year. - POSIX requires that 00-68 be interpreted as 2000-2068, - and that 69-99 be interpreted as 1969-1999. */ + POSIX requires that 00-68 be interpreted as 2000-2068, + and that 69-99 be interpreted as 1969-1999. */ if (digit_pair[0] <= 68) - { - if (syntax_bits & PDS_PRE_2000) - return 1; - tm->tm_year += 100; - } + { + if (syntax_bits & PDS_PRE_2000) + return 1; + tm->tm_year += 100; + } break; case 2: if (! (syntax_bits & PDS_CENTURY)) - return 1; + return 1; tm->tm_year = digit_pair[0] * 100 + digit_pair[1] - 1900; break; case 0: { - time_t now; - struct tm *tmp; + time_t now; + struct tm *tmp; - /* Use current year. */ - time (&now); - tmp = localtime (&now); - if (! tmp) - return 1; - tm->tm_year = tmp->tm_year; + /* Use current year. */ + time (&now); + tmp = localtime (&now); + if (! tmp) + return 1; + tm->tm_year = tmp->tm_year; } break; @@ -113,8 +112,8 @@ posix_time_parse (struct tm *tm, const char *s, unsigned int syntax_bits) size_t s_len = strlen (s); size_t len = (((syntax_bits & PDS_SECONDS) && (dot = strchr (s, '.'))) - ? (size_t) (dot - s) - : s_len); + ? (size_t) (dot - s) + : s_len); if (len != 8 && len != 10 && len != 12) return 1; @@ -122,10 +121,10 @@ posix_time_parse (struct tm *tm, const char *s, unsigned int syntax_bits) if (dot) { if (!(syntax_bits & PDS_SECONDS)) - return 1; + return 1; if (s_len - len != 3) - return 1; + return 1; } for (i = 0; i < len; i++) @@ -140,7 +139,7 @@ posix_time_parse (struct tm *tm, const char *s, unsigned int syntax_bits) if (syntax_bits & PDS_LEADING_YEAR) { if (year (tm, p, len - 4, syntax_bits)) - return 1; + return 1; p += len - 4; len = 4; } @@ -156,7 +155,7 @@ posix_time_parse (struct tm *tm, const char *s, unsigned int syntax_bits) if (syntax_bits & PDS_TRAILING_YEAR) { if (year (tm, p, len, syntax_bits)) - return 1; + return 1; } /* Handle seconds. */ @@ -170,7 +169,7 @@ posix_time_parse (struct tm *tm, const char *s, unsigned int syntax_bits) ++dot; if (!ISDIGIT (dot[0]) || !ISDIGIT (dot[1])) - return 1; + return 1; seconds = 10 * (dot[0] - '0') + dot[1] - '0'; tm->tm_sec = seconds; @@ -201,117 +200,36 @@ posixtime (time_t *p, const char *s, unsigned int syntax_bits) else { /* mktime returns -1 for errors, but -1 is also a valid time_t - value. Check whether an error really occurred. */ + value. Check whether an error really occurred. */ tm = localtime (&t); if (! tm) - return false; + return false; } - /* Reject dates like "September 31" and times like "25:61". */ + /* Reject dates like "September 31" and times like "25:61". + Do not reject times that specify "60" as the number of seconds. */ if ((tm0.tm_year ^ tm->tm_year) | (tm0.tm_mon ^ tm->tm_mon) | (tm0.tm_mday ^ tm->tm_mday) | (tm0.tm_hour ^ tm->tm_hour) | (tm0.tm_min ^ tm->tm_min) | (tm0.tm_sec ^ tm->tm_sec)) - return false; + { + /* Any mismatch without 60 in the tm_sec field is invalid. */ + if (tm0.tm_sec != 60) + return false; + + { + /* Allow times like 01:35:60 or 23:59:60. */ + time_t dummy; + char buf[16]; + char *b = stpcpy (buf, s); + strcpy (b - 2, "59"); + if (!posixtime (&dummy, buf, syntax_bits)) + return false; + } + } *p = t; return true; } - -#ifdef TEST_POSIXTIME -/* - Test mainly with syntax_bits == 13 - (aka: (PDS_LEADING_YEAR | PDS_CENTURY | PDS_SECONDS)) - - This test data assumes Universal Time, e.g., TZ="UTC0". - - This test data also assumes that time_t is signed and is at least - 39 bits wide, so that it can represent all years from 0000 through - 9999. A host with 32-bit signed time_t can represent only time - stamps in the range 1901-12-13 20:45:52 through 2038-01-18 - 03:14:07 UTC, assuming POSIX time_t with no leap seconds, so test - cases outside this range will not work on such a host. - - Also, the first two lines of test data assume that the current - year is 2002. - -BEGIN-DATA -12131415.16 13 1039788916 Fri Dec 13 14:15:16 2002 -12131415.16 13 1039788916 Fri Dec 13 14:15:16 2002 -000001010000.00 13 -62167132800 Sun Jan 1 00:00:00 0000 -190112132045.52 13 -2147483648 Fri Dec 13 20:45:52 1901 -190112132045.53 13 -2147483647 Fri Dec 13 20:45:53 1901 -190112132046.52 13 -2147483588 Fri Dec 13 20:46:52 1901 -190112132145.52 13 -2147480048 Fri Dec 13 21:45:52 1901 -190112142045.52 13 -2147397248 Sat Dec 14 20:45:52 1901 -190201132045.52 13 -2144805248 Mon Jan 13 20:45:52 1902 -196912312359.59 13 -1 Wed Dec 31 23:59:59 1969 -197001010000.00 13 0 Thu Jan 1 00:00:00 1970 -197001010000.01 13 1 Thu Jan 1 00:00:01 1970 -197001010001.00 13 60 Thu Jan 1 00:01:00 1970 -197001010100.00 13 3600 Thu Jan 1 01:00:00 1970 -197001020000.00 13 86400 Fri Jan 2 00:00:00 1970 -197002010000.00 13 2678400 Sun Feb 1 00:00:00 1970 -197101010000.00 13 31536000 Fri Jan 1 00:00:00 1971 -197001000000.00 13 * * -197000010000.00 13 * * -197001010000.60 13 * * -197001010060.00 13 * * -197001012400.00 13 * * -197001320000.00 13 * * -197013010000.00 13 * * -203801190314.06 13 2147483646 Tue Jan 19 03:14:06 2038 -203801190314.07 13 2147483647 Tue Jan 19 03:14:07 2038 -203801190314.08 13 2147483648 Tue Jan 19 03:14:08 2038 -999912312359.59 13 253402300799 Fri Dec 31 23:59:59 9999 -1112131415 13 1323785700 Tue Dec 13 14:15:00 2011 -1112131415.16 13 1323785716 Tue Dec 13 14:15:16 2011 -201112131415.16 13 1323785716 Tue Dec 13 14:15:16 2011 -191112131415.16 13 -1831974284 Wed Dec 13 14:15:16 1911 -203712131415.16 13 2144326516 Sun Dec 13 14:15:16 2037 -3712131415.16 13 2144326516 Sun Dec 13 14:15:16 2037 -6812131415.16 13 3122633716 Thu Dec 13 14:15:16 2068 -6912131415.16 13 -1590284 Sat Dec 13 14:15:16 1969 -7012131415.16 13 29945716 Sun Dec 13 14:15:16 1970 -1213141599 2 945094500 Mon Dec 13 14:15:00 1999 -1213141500 2 976716900 Wed Dec 13 14:15:00 2000 -END-DATA - -*/ - -# define MAX_BUFF_LEN 1024 - -int -main (void) -{ - char buff[MAX_BUFF_LEN + 1]; - - buff[MAX_BUFF_LEN] = 0; - while (fgets (buff, MAX_BUFF_LEN, stdin) && buff[0]) - { - char time_str[MAX_BUFF_LEN]; - unsigned int syntax_bits; - time_t t; - if (sscanf (buff, "%s %u", time_str, &syntax_bits) != 2) - printf ("*\n"); - else - { - printf ("%-15s %2u ", time_str, syntax_bits); - if (posixtime (&t, time_str, syntax_bits)) - printf ("%12ld %s", (long int) t, ctime (&t)); - else - printf ("%12s %s", "*", "*\n"); - } - } - exit (0); - -} -#endif - -/* -Local Variables: -compile-command: "gcc -DTEST_POSIXTIME -g -O -Wall -W posixtm.c" -End: -*/ diff --git a/src/bin/coreutils/lib/posixtm.h b/src/bin/coreutils/lib/posixtm.h index e42573e2d7..ae504d7a8b 100644 --- a/src/bin/coreutils/lib/posixtm.h +++ b/src/bin/coreutils/lib/posixtm.h @@ -1,6 +1,6 @@ /* Parse dates for touch and date. - Copyright (C) 1998, 2003, 2005, 2007 Free Software Foundation Inc. + Copyright (C) 1998, 2003, 2005, 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/posixver.c b/src/bin/coreutils/lib/posixver.c index 73a6482566..7964173926 100644 --- a/src/bin/coreutils/lib/posixver.c +++ b/src/bin/coreutils/lib/posixver.c @@ -1,7 +1,6 @@ /* Which POSIX version to conform to, for utilities. - Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software - Foundation, Inc. + Copyright (C) 2002-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -48,7 +47,7 @@ posix2_version (void) char *e; long int i = strtol (s, &e, 10); if (! *e) - v = i; + v = i; } return v < INT_MIN ? INT_MIN : v < INT_MAX ? v : INT_MAX; diff --git a/src/bin/coreutils/lib/printf-args.c b/src/bin/coreutils/lib/printf-args.c index 15d3c56910..73b57bfeb9 100644 --- a/src/bin/coreutils/lib/printf-args.c +++ b/src/bin/coreutils/lib/printf-args.c @@ -2,7 +2,8 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Decomposed printf argument list. - Copyright (C) 1999, 2002-2003, 2005-2007 Free Software Foundation, Inc. + Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2010 Free Software + Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -45,146 +46,146 @@ PRINTF_FETCHARGS (va_list args, arguments *a) switch (ap->type) { case TYPE_SCHAR: - ap->a.a_schar = va_arg (args, /*signed char*/ int); - break; + ap->a.a_schar = va_arg (args, /*signed char*/ int); + break; case TYPE_UCHAR: - ap->a.a_uchar = va_arg (args, /*unsigned char*/ int); - break; + ap->a.a_uchar = va_arg (args, /*unsigned char*/ int); + break; case TYPE_SHORT: - ap->a.a_short = va_arg (args, /*short*/ int); - break; + ap->a.a_short = va_arg (args, /*short*/ int); + break; case TYPE_USHORT: - ap->a.a_ushort = va_arg (args, /*unsigned short*/ int); - break; + ap->a.a_ushort = va_arg (args, /*unsigned short*/ int); + break; case TYPE_INT: - ap->a.a_int = va_arg (args, int); - break; + ap->a.a_int = va_arg (args, int); + break; case TYPE_UINT: - ap->a.a_uint = va_arg (args, unsigned int); - break; + ap->a.a_uint = va_arg (args, unsigned int); + break; case TYPE_LONGINT: - ap->a.a_longint = va_arg (args, long int); - break; + ap->a.a_longint = va_arg (args, long int); + break; case TYPE_ULONGINT: - ap->a.a_ulongint = va_arg (args, unsigned long int); - break; + ap->a.a_ulongint = va_arg (args, unsigned long int); + break; #if HAVE_LONG_LONG_INT case TYPE_LONGLONGINT: - ap->a.a_longlongint = va_arg (args, long long int); - break; + ap->a.a_longlongint = va_arg (args, long long int); + break; case TYPE_ULONGLONGINT: - ap->a.a_ulonglongint = va_arg (args, unsigned long long int); - break; + ap->a.a_ulonglongint = va_arg (args, unsigned long long int); + break; #endif case TYPE_DOUBLE: - ap->a.a_double = va_arg (args, double); - break; + ap->a.a_double = va_arg (args, double); + break; case TYPE_LONGDOUBLE: - ap->a.a_longdouble = va_arg (args, long double); - break; + ap->a.a_longdouble = va_arg (args, long double); + break; case TYPE_CHAR: - ap->a.a_char = va_arg (args, int); - break; + ap->a.a_char = va_arg (args, int); + break; #if HAVE_WINT_T case TYPE_WIDE_CHAR: - /* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by - default argument promotions", this is not the case in mingw32, - where wint_t is 'unsigned short'. */ - ap->a.a_wide_char = - (sizeof (wint_t) < sizeof (int) - ? va_arg (args, int) - : va_arg (args, wint_t)); - break; + /* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by + default argument promotions", this is not the case in mingw32, + where wint_t is 'unsigned short'. */ + ap->a.a_wide_char = + (sizeof (wint_t) < sizeof (int) + ? (wint_t) va_arg (args, int) + : va_arg (args, wint_t)); + break; #endif case TYPE_STRING: - ap->a.a_string = va_arg (args, const char *); - /* A null pointer is an invalid argument for "%s", but in practice - it occurs quite frequently in printf statements that produce - debug output. Use a fallback in this case. */ - if (ap->a.a_string == NULL) - ap->a.a_string = "(NULL)"; - break; + ap->a.a_string = va_arg (args, const char *); + /* A null pointer is an invalid argument for "%s", but in practice + it occurs quite frequently in printf statements that produce + debug output. Use a fallback in this case. */ + if (ap->a.a_string == NULL) + ap->a.a_string = "(NULL)"; + break; #if HAVE_WCHAR_T case TYPE_WIDE_STRING: - ap->a.a_wide_string = va_arg (args, const wchar_t *); - /* A null pointer is an invalid argument for "%ls", but in practice - it occurs quite frequently in printf statements that produce - debug output. Use a fallback in this case. */ - if (ap->a.a_wide_string == NULL) - { - static const wchar_t wide_null_string[] = - { - (wchar_t)'(', - (wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L', - (wchar_t)')', - (wchar_t)0 - }; - ap->a.a_wide_string = wide_null_string; - } - break; + ap->a.a_wide_string = va_arg (args, const wchar_t *); + /* A null pointer is an invalid argument for "%ls", but in practice + it occurs quite frequently in printf statements that produce + debug output. Use a fallback in this case. */ + if (ap->a.a_wide_string == NULL) + { + static const wchar_t wide_null_string[] = + { + (wchar_t)'(', + (wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L', + (wchar_t)')', + (wchar_t)0 + }; + ap->a.a_wide_string = wide_null_string; + } + break; #endif case TYPE_POINTER: - ap->a.a_pointer = va_arg (args, void *); - break; + ap->a.a_pointer = va_arg (args, void *); + break; case TYPE_COUNT_SCHAR_POINTER: - ap->a.a_count_schar_pointer = va_arg (args, signed char *); - break; + ap->a.a_count_schar_pointer = va_arg (args, signed char *); + break; case TYPE_COUNT_SHORT_POINTER: - ap->a.a_count_short_pointer = va_arg (args, short *); - break; + ap->a.a_count_short_pointer = va_arg (args, short *); + break; case TYPE_COUNT_INT_POINTER: - ap->a.a_count_int_pointer = va_arg (args, int *); - break; + ap->a.a_count_int_pointer = va_arg (args, int *); + break; case TYPE_COUNT_LONGINT_POINTER: - ap->a.a_count_longint_pointer = va_arg (args, long int *); - break; + ap->a.a_count_longint_pointer = va_arg (args, long int *); + break; #if HAVE_LONG_LONG_INT case TYPE_COUNT_LONGLONGINT_POINTER: - ap->a.a_count_longlongint_pointer = va_arg (args, long long int *); - break; + ap->a.a_count_longlongint_pointer = va_arg (args, long long int *); + break; #endif #if ENABLE_UNISTDIO /* The unistdio extensions. */ case TYPE_U8_STRING: - ap->a.a_u8_string = va_arg (args, const uint8_t *); - /* A null pointer is an invalid argument for "%U", but in practice - it occurs quite frequently in printf statements that produce - debug output. Use a fallback in this case. */ - if (ap->a.a_u8_string == NULL) - { - static const uint8_t u8_null_string[] = - { '(', 'N', 'U', 'L', 'L', ')', 0 }; - ap->a.a_u8_string = u8_null_string; - } - break; + ap->a.a_u8_string = va_arg (args, const uint8_t *); + /* A null pointer is an invalid argument for "%U", but in practice + it occurs quite frequently in printf statements that produce + debug output. Use a fallback in this case. */ + if (ap->a.a_u8_string == NULL) + { + static const uint8_t u8_null_string[] = + { '(', 'N', 'U', 'L', 'L', ')', 0 }; + ap->a.a_u8_string = u8_null_string; + } + break; case TYPE_U16_STRING: - ap->a.a_u16_string = va_arg (args, const uint16_t *); - /* A null pointer is an invalid argument for "%lU", but in practice - it occurs quite frequently in printf statements that produce - debug output. Use a fallback in this case. */ - if (ap->a.a_u16_string == NULL) - { - static const uint16_t u16_null_string[] = - { '(', 'N', 'U', 'L', 'L', ')', 0 }; - ap->a.a_u16_string = u16_null_string; - } - break; + ap->a.a_u16_string = va_arg (args, const uint16_t *); + /* A null pointer is an invalid argument for "%lU", but in practice + it occurs quite frequently in printf statements that produce + debug output. Use a fallback in this case. */ + if (ap->a.a_u16_string == NULL) + { + static const uint16_t u16_null_string[] = + { '(', 'N', 'U', 'L', 'L', ')', 0 }; + ap->a.a_u16_string = u16_null_string; + } + break; case TYPE_U32_STRING: - ap->a.a_u32_string = va_arg (args, const uint32_t *); - /* A null pointer is an invalid argument for "%llU", but in practice - it occurs quite frequently in printf statements that produce - debug output. Use a fallback in this case. */ - if (ap->a.a_u32_string == NULL) - { - static const uint32_t u32_null_string[] = - { '(', 'N', 'U', 'L', 'L', ')', 0 }; - ap->a.a_u32_string = u32_null_string; - } - break; + ap->a.a_u32_string = va_arg (args, const uint32_t *); + /* A null pointer is an invalid argument for "%llU", but in practice + it occurs quite frequently in printf statements that produce + debug output. Use a fallback in this case. */ + if (ap->a.a_u32_string == NULL) + { + static const uint32_t u32_null_string[] = + { '(', 'N', 'U', 'L', 'L', ')', 0 }; + ap->a.a_u32_string = u32_null_string; + } + break; #endif default: - /* Unknown type. */ - return -1; + /* Unknown type. */ + return -1; } return 0; } diff --git a/src/bin/coreutils/lib/printf-args.h b/src/bin/coreutils/lib/printf-args.h index 1b0d869ae0..9f0bf1b088 100644 --- a/src/bin/coreutils/lib/printf-args.h +++ b/src/bin/coreutils/lib/printf-args.h @@ -2,7 +2,8 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Decomposed printf argument list. - Copyright (C) 1999, 2002-2003, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 1999, 2002-2003, 2006-2007, 2009-2010 Free Software + Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -96,42 +97,42 @@ typedef struct arg_type type; union { - signed char a_schar; - unsigned char a_uchar; - short a_short; - unsigned short a_ushort; - int a_int; - unsigned int a_uint; - long int a_longint; - unsigned long int a_ulongint; + signed char a_schar; + unsigned char a_uchar; + short a_short; + unsigned short a_ushort; + int a_int; + unsigned int a_uint; + long int a_longint; + unsigned long int a_ulongint; #if HAVE_LONG_LONG_INT - long long int a_longlongint; - unsigned long long int a_ulonglongint; + long long int a_longlongint; + unsigned long long int a_ulonglongint; #endif - float a_float; - double a_double; - long double a_longdouble; - int a_char; + float a_float; + double a_double; + long double a_longdouble; + int a_char; #if HAVE_WINT_T - wint_t a_wide_char; + wint_t a_wide_char; #endif - const char* a_string; + const char* a_string; #if HAVE_WCHAR_T - const wchar_t* a_wide_string; + const wchar_t* a_wide_string; #endif - void* a_pointer; - signed char * a_count_schar_pointer; - short * a_count_short_pointer; - int * a_count_int_pointer; - long int * a_count_longint_pointer; + void* a_pointer; + signed char * a_count_schar_pointer; + short * a_count_short_pointer; + int * a_count_int_pointer; + long int * a_count_longint_pointer; #if HAVE_LONG_LONG_INT - long long int * a_count_longlongint_pointer; + long long int * a_count_longlongint_pointer; #endif #if ENABLE_UNISTDIO /* The unistdio extensions. */ - const uint8_t * a_u8_string; - const uint16_t * a_u16_string; - const uint32_t * a_u32_string; + const uint8_t * a_u8_string; + const uint16_t * a_u16_string; + const uint32_t * a_u32_string; #endif } a; diff --git a/src/bin/coreutils/lib/printf-frexp.c b/src/bin/coreutils/lib/printf-frexp.c index da5c9c3a45..1a53846851 100644 --- a/src/bin/coreutils/lib/printf-frexp.c +++ b/src/bin/coreutils/lib/printf-frexp.c @@ -1,5 +1,5 @@ /* Split a double into fraction and mantissa, for hexadecimal printf. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -92,76 +92,76 @@ FUNC (DOUBLE x, int *expptr) exponent = 0; if (x >= L_(1.0)) { - /* A nonnegative exponent. */ - { - DOUBLE pow2_i; /* = pow2[i] */ - DOUBLE powh_i; /* = powh[i] */ + /* A nonnegative exponent. */ + { + DOUBLE pow2_i; /* = pow2[i] */ + DOUBLE powh_i; /* = powh[i] */ - /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i, - x * 2^exponent = argument, x >= 1.0. */ - for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5); - ; - i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i) - { - if (x >= pow2_i) - { - exponent += (1 << i); - x *= powh_i; - } - else - break; + /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i, + x * 2^exponent = argument, x >= 1.0. */ + for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5); + ; + i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i) + { + if (x >= pow2_i) + { + exponent += (1 << i); + x *= powh_i; + } + else + break; - pow2[i] = pow2_i; - powh[i] = powh_i; - } - } - /* Here 1.0 <= x < 2^2^i. */ + pow2[i] = pow2_i; + powh[i] = powh_i; + } + } + /* Here 1.0 <= x < 2^2^i. */ } else { - /* A negative exponent. */ - { - DOUBLE pow2_i; /* = pow2[i] */ - DOUBLE powh_i; /* = powh[i] */ + /* A negative exponent. */ + { + DOUBLE pow2_i; /* = pow2[i] */ + DOUBLE powh_i; /* = powh[i] */ - /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i, - x * 2^exponent = argument, x < 1.0, exponent >= MIN_EXP - 1. */ - for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5); - ; - i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i) - { - if (exponent - (1 << i) < MIN_EXP - 1) - break; + /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i, + x * 2^exponent = argument, x < 1.0, exponent >= MIN_EXP - 1. */ + for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5); + ; + i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i) + { + if (exponent - (1 << i) < MIN_EXP - 1) + break; - exponent -= (1 << i); - x *= pow2_i; - if (x >= L_(1.0)) - break; + exponent -= (1 << i); + x *= pow2_i; + if (x >= L_(1.0)) + break; - pow2[i] = pow2_i; - powh[i] = powh_i; - } - } - /* Here either x < 1.0 and exponent - 2^i < MIN_EXP - 1 <= exponent, - or 1.0 <= x < 2^2^i and exponent >= MIN_EXP - 1. */ + pow2[i] = pow2_i; + powh[i] = powh_i; + } + } + /* Here either x < 1.0 and exponent - 2^i < MIN_EXP - 1 <= exponent, + or 1.0 <= x < 2^2^i and exponent >= MIN_EXP - 1. */ - if (x < L_(1.0)) - /* Invariants: x * 2^exponent = argument, x < 1.0 and - exponent - 2^i < MIN_EXP - 1 <= exponent. */ - while (i > 0) - { - i--; - if (exponent - (1 << i) >= MIN_EXP - 1) - { - exponent -= (1 << i); - x *= pow2[i]; - if (x >= L_(1.0)) - break; - } - } + if (x < L_(1.0)) + /* Invariants: x * 2^exponent = argument, x < 1.0 and + exponent - 2^i < MIN_EXP - 1 <= exponent. */ + while (i > 0) + { + i--; + if (exponent - (1 << i) >= MIN_EXP - 1) + { + exponent -= (1 << i); + x *= pow2[i]; + if (x >= L_(1.0)) + break; + } + } - /* Here either x < 1.0 and exponent = MIN_EXP - 1, - or 1.0 <= x < 2^2^i and exponent >= MIN_EXP - 1. */ + /* Here either x < 1.0 and exponent = MIN_EXP - 1, + or 1.0 <= x < 2^2^i and exponent >= MIN_EXP - 1. */ } /* Invariants: x * 2^exponent = argument, and @@ -169,12 +169,12 @@ FUNC (DOUBLE x, int *expptr) or 1.0 <= x < 2^2^i and exponent >= MIN_EXP - 1. */ while (i > 0) { - i--; - if (x >= pow2[i]) - { - exponent += (1 << i); - x *= powh[i]; - } + i--; + if (x >= pow2[i]) + { + exponent += (1 << i); + x *= powh[i]; + } } /* Here either x < 1.0 and exponent = MIN_EXP - 1, or 1.0 <= x < 2.0 and exponent >= MIN_EXP - 1. */ diff --git a/src/bin/coreutils/lib/printf-frexp.h b/src/bin/coreutils/lib/printf-frexp.h index 46c32765dd..0dc60f8ff5 100644 --- a/src/bin/coreutils/lib/printf-frexp.h +++ b/src/bin/coreutils/lib/printf-frexp.h @@ -1,5 +1,5 @@ /* Split a double into fraction and mantissa, for hexadecimal printf. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/printf-frexpl.c b/src/bin/coreutils/lib/printf-frexpl.c index 460b609b40..36bac7492b 100644 --- a/src/bin/coreutils/lib/printf-frexpl.c +++ b/src/bin/coreutils/lib/printf-frexpl.c @@ -1,5 +1,5 @@ /* Split a 'long double' into fraction and mantissa, for hexadecimal printf. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/printf-frexpl.h b/src/bin/coreutils/lib/printf-frexpl.h index 6c2d214b6d..1b5f7f779b 100644 --- a/src/bin/coreutils/lib/printf-frexpl.h +++ b/src/bin/coreutils/lib/printf-frexpl.h @@ -1,5 +1,5 @@ /* Split a 'long double' into fraction and mantissa, for hexadecimal printf. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/printf-parse.c b/src/bin/coreutils/lib/printf-parse.c index 04d21c04c8..15acf311b1 100644 --- a/src/bin/coreutils/lib/printf-parse.c +++ b/src/bin/coreutils/lib/printf-parse.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Formatted output to strings. - Copyright (C) 1999-2000, 2002-2003, 2006-2008 Free Software Foundation, Inc. + Copyright (C) 1999-2000, 2002-2003, 2006-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -83,10 +83,10 @@ STATIC int PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) { - const CHAR_T *cp = format; /* pointer into format */ - size_t arg_posn = 0; /* number of regular arguments consumed */ - size_t d_allocated; /* allocated elements of d->dir */ - size_t a_allocated; /* allocated elements of a->arg */ + const CHAR_T *cp = format; /* pointer into format */ + size_t arg_posn = 0; /* number of regular arguments consumed */ + size_t d_allocated; /* allocated elements of d->dir */ + size_t a_allocated; /* allocated elements of a->arg */ size_t max_width_length = 0; size_t max_precision_length = 0; @@ -102,501 +102,501 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) a->arg = NULL; #define REGISTER_ARG(_index_,_type_) \ - { \ - size_t n = (_index_); \ - if (n >= a_allocated) \ - { \ - size_t memory_size; \ - argument *memory; \ - \ - a_allocated = xtimes (a_allocated, 2); \ - if (a_allocated <= n) \ - a_allocated = xsum (n, 1); \ - memory_size = xtimes (a_allocated, sizeof (argument)); \ - if (size_overflow_p (memory_size)) \ - /* Overflow, would lead to out of memory. */ \ - goto out_of_memory; \ - memory = (argument *) (a->arg \ - ? realloc (a->arg, memory_size) \ - : malloc (memory_size)); \ - if (memory == NULL) \ - /* Out of memory. */ \ - goto out_of_memory; \ - a->arg = memory; \ - } \ - while (a->count <= n) \ - a->arg[a->count++].type = TYPE_NONE; \ - if (a->arg[n].type == TYPE_NONE) \ - a->arg[n].type = (_type_); \ - else if (a->arg[n].type != (_type_)) \ - /* Ambiguous type for positional argument. */ \ - goto error; \ + { \ + size_t n = (_index_); \ + if (n >= a_allocated) \ + { \ + size_t memory_size; \ + argument *memory; \ + \ + a_allocated = xtimes (a_allocated, 2); \ + if (a_allocated <= n) \ + a_allocated = xsum (n, 1); \ + memory_size = xtimes (a_allocated, sizeof (argument)); \ + if (size_overflow_p (memory_size)) \ + /* Overflow, would lead to out of memory. */ \ + goto out_of_memory; \ + memory = (argument *) (a->arg \ + ? realloc (a->arg, memory_size) \ + : malloc (memory_size)); \ + if (memory == NULL) \ + /* Out of memory. */ \ + goto out_of_memory; \ + a->arg = memory; \ + } \ + while (a->count <= n) \ + a->arg[a->count++].type = TYPE_NONE; \ + if (a->arg[n].type == TYPE_NONE) \ + a->arg[n].type = (_type_); \ + else if (a->arg[n].type != (_type_)) \ + /* Ambiguous type for positional argument. */ \ + goto error; \ } while (*cp != '\0') { CHAR_T c = *cp++; if (c == '%') - { - size_t arg_index = ARG_NONE; - DIRECTIVE *dp = &d->dir[d->count]; /* pointer to next directive */ + { + size_t arg_index = ARG_NONE; + DIRECTIVE *dp = &d->dir[d->count]; /* pointer to next directive */ - /* Initialize the next directive. */ - dp->dir_start = cp - 1; - dp->flags = 0; - dp->width_start = NULL; - dp->width_end = NULL; - dp->width_arg_index = ARG_NONE; - dp->precision_start = NULL; - dp->precision_end = NULL; - dp->precision_arg_index = ARG_NONE; - dp->arg_index = ARG_NONE; + /* Initialize the next directive. */ + dp->dir_start = cp - 1; + dp->flags = 0; + dp->width_start = NULL; + dp->width_end = NULL; + dp->width_arg_index = ARG_NONE; + dp->precision_start = NULL; + dp->precision_end = NULL; + dp->precision_arg_index = ARG_NONE; + dp->arg_index = ARG_NONE; - /* Test for positional argument. */ - if (*cp >= '0' && *cp <= '9') - { - const CHAR_T *np; + /* Test for positional argument. */ + if (*cp >= '0' && *cp <= '9') + { + const CHAR_T *np; - for (np = cp; *np >= '0' && *np <= '9'; np++) - ; - if (*np == '$') - { - size_t n = 0; + for (np = cp; *np >= '0' && *np <= '9'; np++) + ; + if (*np == '$') + { + size_t n = 0; - for (np = cp; *np >= '0' && *np <= '9'; np++) - n = xsum (xtimes (n, 10), *np - '0'); - if (n == 0) - /* Positional argument 0. */ - goto error; - if (size_overflow_p (n)) - /* n too large, would lead to out of memory later. */ - goto error; - arg_index = n - 1; - cp = np + 1; - } - } + for (np = cp; *np >= '0' && *np <= '9'; np++) + n = xsum (xtimes (n, 10), *np - '0'); + if (n == 0) + /* Positional argument 0. */ + goto error; + if (size_overflow_p (n)) + /* n too large, would lead to out of memory later. */ + goto error; + arg_index = n - 1; + cp = np + 1; + } + } - /* Read the flags. */ - for (;;) - { - if (*cp == '\'') - { - dp->flags |= FLAG_GROUP; - cp++; - } - else if (*cp == '-') - { - dp->flags |= FLAG_LEFT; - cp++; - } - else if (*cp == '+') - { - dp->flags |= FLAG_SHOWSIGN; - cp++; - } - else if (*cp == ' ') - { - dp->flags |= FLAG_SPACE; - cp++; - } - else if (*cp == '#') - { - dp->flags |= FLAG_ALT; - cp++; - } - else if (*cp == '0') - { - dp->flags |= FLAG_ZERO; - cp++; - } - else - break; - } + /* Read the flags. */ + for (;;) + { + if (*cp == '\'') + { + dp->flags |= FLAG_GROUP; + cp++; + } + else if (*cp == '-') + { + dp->flags |= FLAG_LEFT; + cp++; + } + else if (*cp == '+') + { + dp->flags |= FLAG_SHOWSIGN; + cp++; + } + else if (*cp == ' ') + { + dp->flags |= FLAG_SPACE; + cp++; + } + else if (*cp == '#') + { + dp->flags |= FLAG_ALT; + cp++; + } + else if (*cp == '0') + { + dp->flags |= FLAG_ZERO; + cp++; + } + else + break; + } - /* Parse the field width. */ - if (*cp == '*') - { - dp->width_start = cp; - cp++; - dp->width_end = cp; - if (max_width_length < 1) - max_width_length = 1; + /* Parse the field width. */ + if (*cp == '*') + { + dp->width_start = cp; + cp++; + dp->width_end = cp; + if (max_width_length < 1) + max_width_length = 1; - /* Test for positional argument. */ - if (*cp >= '0' && *cp <= '9') - { - const CHAR_T *np; + /* Test for positional argument. */ + if (*cp >= '0' && *cp <= '9') + { + const CHAR_T *np; - for (np = cp; *np >= '0' && *np <= '9'; np++) - ; - if (*np == '$') - { - size_t n = 0; + for (np = cp; *np >= '0' && *np <= '9'; np++) + ; + if (*np == '$') + { + size_t n = 0; - for (np = cp; *np >= '0' && *np <= '9'; np++) - n = xsum (xtimes (n, 10), *np - '0'); - if (n == 0) - /* Positional argument 0. */ - goto error; - if (size_overflow_p (n)) - /* n too large, would lead to out of memory later. */ - goto error; - dp->width_arg_index = n - 1; - cp = np + 1; - } - } - if (dp->width_arg_index == ARG_NONE) - { - dp->width_arg_index = arg_posn++; - if (dp->width_arg_index == ARG_NONE) - /* arg_posn wrapped around. */ - goto error; - } - REGISTER_ARG (dp->width_arg_index, TYPE_INT); - } - else if (*cp >= '0' && *cp <= '9') - { - size_t width_length; + for (np = cp; *np >= '0' && *np <= '9'; np++) + n = xsum (xtimes (n, 10), *np - '0'); + if (n == 0) + /* Positional argument 0. */ + goto error; + if (size_overflow_p (n)) + /* n too large, would lead to out of memory later. */ + goto error; + dp->width_arg_index = n - 1; + cp = np + 1; + } + } + if (dp->width_arg_index == ARG_NONE) + { + dp->width_arg_index = arg_posn++; + if (dp->width_arg_index == ARG_NONE) + /* arg_posn wrapped around. */ + goto error; + } + REGISTER_ARG (dp->width_arg_index, TYPE_INT); + } + else if (*cp >= '0' && *cp <= '9') + { + size_t width_length; - dp->width_start = cp; - for (; *cp >= '0' && *cp <= '9'; cp++) - ; - dp->width_end = cp; - width_length = dp->width_end - dp->width_start; - if (max_width_length < width_length) - max_width_length = width_length; - } + dp->width_start = cp; + for (; *cp >= '0' && *cp <= '9'; cp++) + ; + dp->width_end = cp; + width_length = dp->width_end - dp->width_start; + if (max_width_length < width_length) + max_width_length = width_length; + } - /* Parse the precision. */ - if (*cp == '.') - { - cp++; - if (*cp == '*') - { - dp->precision_start = cp - 1; - cp++; - dp->precision_end = cp; - if (max_precision_length < 2) - max_precision_length = 2; + /* Parse the precision. */ + if (*cp == '.') + { + cp++; + if (*cp == '*') + { + dp->precision_start = cp - 1; + cp++; + dp->precision_end = cp; + if (max_precision_length < 2) + max_precision_length = 2; - /* Test for positional argument. */ - if (*cp >= '0' && *cp <= '9') - { - const CHAR_T *np; + /* Test for positional argument. */ + if (*cp >= '0' && *cp <= '9') + { + const CHAR_T *np; - for (np = cp; *np >= '0' && *np <= '9'; np++) - ; - if (*np == '$') - { - size_t n = 0; + for (np = cp; *np >= '0' && *np <= '9'; np++) + ; + if (*np == '$') + { + size_t n = 0; - for (np = cp; *np >= '0' && *np <= '9'; np++) - n = xsum (xtimes (n, 10), *np - '0'); - if (n == 0) - /* Positional argument 0. */ - goto error; - if (size_overflow_p (n)) - /* n too large, would lead to out of memory - later. */ - goto error; - dp->precision_arg_index = n - 1; - cp = np + 1; - } - } - if (dp->precision_arg_index == ARG_NONE) - { - dp->precision_arg_index = arg_posn++; - if (dp->precision_arg_index == ARG_NONE) - /* arg_posn wrapped around. */ - goto error; - } - REGISTER_ARG (dp->precision_arg_index, TYPE_INT); - } - else - { - size_t precision_length; + for (np = cp; *np >= '0' && *np <= '9'; np++) + n = xsum (xtimes (n, 10), *np - '0'); + if (n == 0) + /* Positional argument 0. */ + goto error; + if (size_overflow_p (n)) + /* n too large, would lead to out of memory + later. */ + goto error; + dp->precision_arg_index = n - 1; + cp = np + 1; + } + } + if (dp->precision_arg_index == ARG_NONE) + { + dp->precision_arg_index = arg_posn++; + if (dp->precision_arg_index == ARG_NONE) + /* arg_posn wrapped around. */ + goto error; + } + REGISTER_ARG (dp->precision_arg_index, TYPE_INT); + } + else + { + size_t precision_length; - dp->precision_start = cp - 1; - for (; *cp >= '0' && *cp <= '9'; cp++) - ; - dp->precision_end = cp; - precision_length = dp->precision_end - dp->precision_start; - if (max_precision_length < precision_length) - max_precision_length = precision_length; - } - } + dp->precision_start = cp - 1; + for (; *cp >= '0' && *cp <= '9'; cp++) + ; + dp->precision_end = cp; + precision_length = dp->precision_end - dp->precision_start; + if (max_precision_length < precision_length) + max_precision_length = precision_length; + } + } - { - arg_type type; + { + arg_type type; - /* Parse argument type/size specifiers. */ - { - int flags = 0; + /* Parse argument type/size specifiers. */ + { + int flags = 0; - for (;;) - { - if (*cp == 'h') - { - flags |= (1 << (flags & 1)); - cp++; - } - else if (*cp == 'L') - { - flags |= 4; - cp++; - } - else if (*cp == 'l') - { - flags += 8; - cp++; - } - else if (*cp == 'j') - { - if (sizeof (intmax_t) > sizeof (long)) - { - /* intmax_t = long long */ - flags += 16; - } - else if (sizeof (intmax_t) > sizeof (int)) - { - /* intmax_t = long */ - flags += 8; - } - cp++; - } - else if (*cp == 'z' || *cp == 'Z') - { - /* 'z' is standardized in ISO C 99, but glibc uses 'Z' - because the warning facility in gcc-2.95.2 understands - only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */ - if (sizeof (size_t) > sizeof (long)) - { - /* size_t = long long */ - flags += 16; - } - else if (sizeof (size_t) > sizeof (int)) - { - /* size_t = long */ - flags += 8; - } - cp++; - } - else if (*cp == 't') - { - if (sizeof (ptrdiff_t) > sizeof (long)) - { - /* ptrdiff_t = long long */ - flags += 16; - } - else if (sizeof (ptrdiff_t) > sizeof (int)) - { - /* ptrdiff_t = long */ - flags += 8; - } - cp++; - } + for (;;) + { + if (*cp == 'h') + { + flags |= (1 << (flags & 1)); + cp++; + } + else if (*cp == 'L') + { + flags |= 4; + cp++; + } + else if (*cp == 'l') + { + flags += 8; + cp++; + } + else if (*cp == 'j') + { + if (sizeof (intmax_t) > sizeof (long)) + { + /* intmax_t = long long */ + flags += 16; + } + else if (sizeof (intmax_t) > sizeof (int)) + { + /* intmax_t = long */ + flags += 8; + } + cp++; + } + else if (*cp == 'z' || *cp == 'Z') + { + /* 'z' is standardized in ISO C 99, but glibc uses 'Z' + because the warning facility in gcc-2.95.2 understands + only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */ + if (sizeof (size_t) > sizeof (long)) + { + /* size_t = long long */ + flags += 16; + } + else if (sizeof (size_t) > sizeof (int)) + { + /* size_t = long */ + flags += 8; + } + cp++; + } + else if (*cp == 't') + { + if (sizeof (ptrdiff_t) > sizeof (long)) + { + /* ptrdiff_t = long long */ + flags += 16; + } + else if (sizeof (ptrdiff_t) > sizeof (int)) + { + /* ptrdiff_t = long */ + flags += 8; + } + cp++; + } #if defined __APPLE__ && defined __MACH__ - /* On MacOS X 10.3, PRIdMAX is defined as "qd". - We cannot change it to "lld" because PRIdMAX must also - be understood by the system's printf routines. */ - else if (*cp == 'q') - { - if (64 / 8 > sizeof (long)) - { - /* int64_t = long long */ - flags += 16; - } - else - { - /* int64_t = long */ - flags += 8; - } - cp++; - } + /* On MacOS X 10.3, PRIdMAX is defined as "qd". + We cannot change it to "lld" because PRIdMAX must also + be understood by the system's printf routines. */ + else if (*cp == 'q') + { + if (64 / 8 > sizeof (long)) + { + /* int64_t = long long */ + flags += 16; + } + else + { + /* int64_t = long */ + flags += 8; + } + cp++; + } #endif #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - /* On native Win32, PRIdMAX is defined as "I64d". - We cannot change it to "lld" because PRIdMAX must also - be understood by the system's printf routines. */ - else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4') - { - if (64 / 8 > sizeof (long)) - { - /* __int64 = long long */ - flags += 16; - } - else - { - /* __int64 = long */ - flags += 8; - } - cp += 3; - } + /* On native Win32, PRIdMAX is defined as "I64d". + We cannot change it to "lld" because PRIdMAX must also + be understood by the system's printf routines. */ + else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4') + { + if (64 / 8 > sizeof (long)) + { + /* __int64 = long long */ + flags += 16; + } + else + { + /* __int64 = long */ + flags += 8; + } + cp += 3; + } #endif - else - break; - } + else + break; + } - /* Read the conversion character. */ - c = *cp++; - switch (c) - { - case 'd': case 'i': + /* Read the conversion character. */ + c = *cp++; + switch (c) + { + case 'd': case 'i': #if HAVE_LONG_LONG_INT - /* If 'long long' exists and is larger than 'long': */ - if (flags >= 16 || (flags & 4)) - type = TYPE_LONGLONGINT; - else + /* If 'long long' exists and is larger than 'long': */ + if (flags >= 16 || (flags & 4)) + type = TYPE_LONGLONGINT; + else #endif - /* If 'long long' exists and is the same as 'long', we parse - "lld" into TYPE_LONGINT. */ - if (flags >= 8) - type = TYPE_LONGINT; - else if (flags & 2) - type = TYPE_SCHAR; - else if (flags & 1) - type = TYPE_SHORT; - else - type = TYPE_INT; - break; - case 'o': case 'u': case 'x': case 'X': + /* If 'long long' exists and is the same as 'long', we parse + "lld" into TYPE_LONGINT. */ + if (flags >= 8) + type = TYPE_LONGINT; + else if (flags & 2) + type = TYPE_SCHAR; + else if (flags & 1) + type = TYPE_SHORT; + else + type = TYPE_INT; + break; + case 'o': case 'u': case 'x': case 'X': #if HAVE_LONG_LONG_INT - /* If 'long long' exists and is larger than 'long': */ - if (flags >= 16 || (flags & 4)) - type = TYPE_ULONGLONGINT; - else + /* If 'long long' exists and is larger than 'long': */ + if (flags >= 16 || (flags & 4)) + type = TYPE_ULONGLONGINT; + else #endif - /* If 'unsigned long long' exists and is the same as - 'unsigned long', we parse "llu" into TYPE_ULONGINT. */ - if (flags >= 8) - type = TYPE_ULONGINT; - else if (flags & 2) - type = TYPE_UCHAR; - else if (flags & 1) - type = TYPE_USHORT; - else - type = TYPE_UINT; - break; - case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': - case 'a': case 'A': - if (flags >= 16 || (flags & 4)) - type = TYPE_LONGDOUBLE; - else - type = TYPE_DOUBLE; - break; - case 'c': - if (flags >= 8) + /* If 'unsigned long long' exists and is the same as + 'unsigned long', we parse "llu" into TYPE_ULONGINT. */ + if (flags >= 8) + type = TYPE_ULONGINT; + else if (flags & 2) + type = TYPE_UCHAR; + else if (flags & 1) + type = TYPE_USHORT; + else + type = TYPE_UINT; + break; + case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': + case 'a': case 'A': + if (flags >= 16 || (flags & 4)) + type = TYPE_LONGDOUBLE; + else + type = TYPE_DOUBLE; + break; + case 'c': + if (flags >= 8) #if HAVE_WINT_T - type = TYPE_WIDE_CHAR; + type = TYPE_WIDE_CHAR; #else - goto error; + goto error; #endif - else - type = TYPE_CHAR; - break; + else + type = TYPE_CHAR; + break; #if HAVE_WINT_T - case 'C': - type = TYPE_WIDE_CHAR; - c = 'c'; - break; + case 'C': + type = TYPE_WIDE_CHAR; + c = 'c'; + break; #endif - case 's': - if (flags >= 8) + case 's': + if (flags >= 8) #if HAVE_WCHAR_T - type = TYPE_WIDE_STRING; + type = TYPE_WIDE_STRING; #else - goto error; + goto error; #endif - else - type = TYPE_STRING; - break; + else + type = TYPE_STRING; + break; #if HAVE_WCHAR_T - case 'S': - type = TYPE_WIDE_STRING; - c = 's'; - break; + case 'S': + type = TYPE_WIDE_STRING; + c = 's'; + break; #endif - case 'p': - type = TYPE_POINTER; - break; - case 'n': + case 'p': + type = TYPE_POINTER; + break; + case 'n': #if HAVE_LONG_LONG_INT - /* If 'long long' exists and is larger than 'long': */ - if (flags >= 16 || (flags & 4)) - type = TYPE_COUNT_LONGLONGINT_POINTER; - else + /* If 'long long' exists and is larger than 'long': */ + if (flags >= 16 || (flags & 4)) + type = TYPE_COUNT_LONGLONGINT_POINTER; + else #endif - /* If 'long long' exists and is the same as 'long', we parse - "lln" into TYPE_COUNT_LONGINT_POINTER. */ - if (flags >= 8) - type = TYPE_COUNT_LONGINT_POINTER; - else if (flags & 2) - type = TYPE_COUNT_SCHAR_POINTER; - else if (flags & 1) - type = TYPE_COUNT_SHORT_POINTER; - else - type = TYPE_COUNT_INT_POINTER; - break; + /* If 'long long' exists and is the same as 'long', we parse + "lln" into TYPE_COUNT_LONGINT_POINTER. */ + if (flags >= 8) + type = TYPE_COUNT_LONGINT_POINTER; + else if (flags & 2) + type = TYPE_COUNT_SCHAR_POINTER; + else if (flags & 1) + type = TYPE_COUNT_SHORT_POINTER; + else + type = TYPE_COUNT_INT_POINTER; + break; #if ENABLE_UNISTDIO - /* The unistdio extensions. */ - case 'U': - if (flags >= 16) - type = TYPE_U32_STRING; - else if (flags >= 8) - type = TYPE_U16_STRING; - else - type = TYPE_U8_STRING; - break; + /* The unistdio extensions. */ + case 'U': + if (flags >= 16) + type = TYPE_U32_STRING; + else if (flags >= 8) + type = TYPE_U16_STRING; + else + type = TYPE_U8_STRING; + break; #endif - case '%': - type = TYPE_NONE; - break; - default: - /* Unknown conversion character. */ - goto error; - } - } + case '%': + type = TYPE_NONE; + break; + default: + /* Unknown conversion character. */ + goto error; + } + } - if (type != TYPE_NONE) - { - dp->arg_index = arg_index; - if (dp->arg_index == ARG_NONE) - { - dp->arg_index = arg_posn++; - if (dp->arg_index == ARG_NONE) - /* arg_posn wrapped around. */ - goto error; - } - REGISTER_ARG (dp->arg_index, type); - } - dp->conversion = c; - dp->dir_end = cp; - } + if (type != TYPE_NONE) + { + dp->arg_index = arg_index; + if (dp->arg_index == ARG_NONE) + { + dp->arg_index = arg_posn++; + if (dp->arg_index == ARG_NONE) + /* arg_posn wrapped around. */ + goto error; + } + REGISTER_ARG (dp->arg_index, type); + } + dp->conversion = c; + dp->dir_end = cp; + } - d->count++; - if (d->count >= d_allocated) - { - size_t memory_size; - DIRECTIVE *memory; + d->count++; + if (d->count >= d_allocated) + { + size_t memory_size; + DIRECTIVE *memory; - d_allocated = xtimes (d_allocated, 2); - memory_size = xtimes (d_allocated, sizeof (DIRECTIVE)); - if (size_overflow_p (memory_size)) - /* Overflow, would lead to out of memory. */ - goto out_of_memory; - memory = (DIRECTIVE *) realloc (d->dir, memory_size); - if (memory == NULL) - /* Out of memory. */ - goto out_of_memory; - d->dir = memory; - } - } + d_allocated = xtimes (d_allocated, 2); + memory_size = xtimes (d_allocated, sizeof (DIRECTIVE)); + if (size_overflow_p (memory_size)) + /* Overflow, would lead to out of memory. */ + goto out_of_memory; + memory = (DIRECTIVE *) realloc (d->dir, memory_size); + if (memory == NULL) + /* Out of memory. */ + goto out_of_memory; + d->dir = memory; + } + } #if CHAR_T_ONLY_ASCII else if (!c_isascii (c)) - { - /* Non-ASCII character. Not supported. */ - goto error; - } + { + /* Non-ASCII character. Not supported. */ + goto error; + } #endif } d->dir[d->count].dir_start = cp; diff --git a/src/bin/coreutils/lib/printf-parse.h b/src/bin/coreutils/lib/printf-parse.h index 82b189ca2c..10c69c00d5 100644 --- a/src/bin/coreutils/lib/printf-parse.h +++ b/src/bin/coreutils/lib/printf-parse.h @@ -2,7 +2,8 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Parse printf format string. - Copyright (C) 1999, 2002-2003, 2005, 2007 Free Software Foundation, Inc. + Copyright (C) 1999, 2002-2003, 2005, 2007, 2009-2010 Free Software + Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,15 +30,15 @@ /* Flags */ -#define FLAG_GROUP 1 /* ' flag */ -#define FLAG_LEFT 2 /* - flag */ -#define FLAG_SHOWSIGN 4 /* + flag */ -#define FLAG_SPACE 8 /* space flag */ -#define FLAG_ALT 16 /* # flag */ -#define FLAG_ZERO 32 +#define FLAG_GROUP 1 /* ' flag */ +#define FLAG_LEFT 2 /* - flag */ +#define FLAG_SHOWSIGN 4 /* + flag */ +#define FLAG_SPACE 8 /* space flag */ +#define FLAG_ALT 16 /* # flag */ +#define FLAG_ZERO 32 /* arg_index value indicating that no argument is consumed. */ -#define ARG_NONE (~(size_t)0) +#define ARG_NONE (~(size_t)0) /* xxx_directive: A parsed directive. xxx_directives: A parsed format string. */ @@ -166,10 +167,10 @@ extern int u8_printf_parse (const uint8_t *format, u8_directives *d, arguments *a); extern int u16_printf_parse (const uint16_t *format, u16_directives *d, - arguments *a); + arguments *a); extern int u32_printf_parse (const uint32_t *format, u32_directives *d, - arguments *a); + arguments *a); #else # ifdef STATIC STATIC diff --git a/src/bin/coreutils/lib/priv-set.c b/src/bin/coreutils/lib/priv-set.c index 0051ce6708..911c28000f 100644 --- a/src/bin/coreutils/lib/priv-set.c +++ b/src/bin/coreutils/lib/priv-set.c @@ -1,6 +1,6 @@ /* Query, remove, or restore a Solaris privilege. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -41,21 +41,21 @@ priv_set_initialize (void) { eff_set = priv_allocset (); if (!eff_set) - { - return -1; - } + { + return -1; + } rem_set = priv_allocset (); if (!rem_set) - { - priv_freeset (eff_set); - return -1; - } + { + priv_freeset (eff_set); + return -1; + } if (getppriv (PRIV_EFFECTIVE, eff_set) != 0) - { - priv_freeset (eff_set); - priv_freeset (rem_set); - return -1; - } + { + priv_freeset (eff_set); + priv_freeset (rem_set); + return -1; + } priv_emptyset (rem_set); initialized = true; } @@ -89,13 +89,13 @@ priv_set_remove (const char *priv) if (priv_ismember (eff_set, priv)) { /* priv_addset/priv_delset can only fail if priv is invalid, which is - checked above by the priv_ismember call. */ + checked above by the priv_ismember call. */ priv_delset (eff_set, priv); if (setppriv (PRIV_SET, PRIV_EFFECTIVE, eff_set) != 0) - { - priv_addset (eff_set, priv); - return -1; - } + { + priv_addset (eff_set, priv); + return -1; + } priv_addset (rem_set, priv); } else @@ -122,13 +122,13 @@ priv_set_restore (const char *priv) if (priv_ismember (rem_set, priv)) { /* priv_addset/priv_delset can only fail if priv is invalid, which is - checked above by the priv_ismember call. */ + checked above by the priv_ismember call. */ priv_addset (eff_set, priv); if (setppriv (PRIV_SET, PRIV_EFFECTIVE, eff_set) != 0) - { - priv_delset (eff_set, priv); - return -1; - } + { + priv_delset (eff_set, priv); + return -1; + } priv_delset (rem_set, priv); } else diff --git a/src/bin/coreutils/lib/priv-set.h b/src/bin/coreutils/lib/priv-set.h index c461c42723..b8f8b72723 100644 --- a/src/bin/coreutils/lib/priv-set.h +++ b/src/bin/coreutils/lib/priv-set.h @@ -1,6 +1,6 @@ /* Query, remove, or restore a Solaris privilege. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/progname.c b/src/bin/coreutils/lib/progname.c index 19df10ad71..1415e6a55f 100644 --- a/src/bin/coreutils/lib/progname.c +++ b/src/bin/coreutils/lib/progname.c @@ -1,6 +1,6 @@ /* Program name management. - Copyright (C) 2001-2003, 2005-2009 Free Software Foundation, Inc. - Written by Bruno Haible , 2001. + Copyright (C) 2001-2003, 2005-2010 Free Software Foundation, Inc. + Written by Bruno Haible , 2001. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,6 +23,8 @@ #include "progname.h" #include /* get program_invocation_name declaration */ +#include +#include #include @@ -30,7 +32,9 @@ To be initialized by main(). */ const char *program_name = NULL; -/* Set program_name, based on argv[0]. */ +/* Set program_name, based on argv[0]. + argv0 must be a string allocated with indefinite extent, and must not be + modified after this call. */ void set_program_name (const char *argv0) { @@ -42,13 +46,30 @@ set_program_name (const char *argv0) const char *slash; const char *base; + /* Sanity check. POSIX requires the invoking process to pass a non-NULL + argv[0]. */ + if (argv0 == NULL) + { + /* It's a bug in the invoking program. Help diagnosing it. */ + fputs ("A NULL argv[0] was passed through an exec system call.\n", + stderr); + abort (); + } + slash = strrchr (argv0, '/'); base = (slash != NULL ? slash + 1 : argv0); if (base - argv0 >= 7 && strncmp (base - 7, "/.libs/", 7) == 0) { argv0 = base; if (strncmp (base, "lt-", 3) == 0) - argv0 = base + 3; + { + argv0 = base + 3; + /* On glibc systems, remove the "lt-" prefix from the variable + program_invocation_short_name. */ +#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME + program_invocation_short_name = (char *) argv0; +#endif + } } /* But don't strip off a leading / in general, because when the user @@ -62,9 +83,9 @@ set_program_name (const char *argv0) program_name = argv0; - /* On glibc systems, when the gnulib module 'error' is not used, the error() - function comes from libc and uses the variable program_invocation_name, - not program_name. So set this variable as well. */ + /* On glibc systems, the error() function comes from libc and uses the + variable program_invocation_name, not program_name. So set this variable + as well. */ #if HAVE_DECL_PROGRAM_INVOCATION_NAME program_invocation_name = (char *) argv0; #endif diff --git a/src/bin/coreutils/lib/progname.h b/src/bin/coreutils/lib/progname.h index 82615c6bc0..5ba303bd07 100644 --- a/src/bin/coreutils/lib/progname.h +++ b/src/bin/coreutils/lib/progname.h @@ -1,6 +1,6 @@ /* Program name management. - Copyright (C) 2001-2004, 2006 Free Software Foundation, Inc. - Written by Bruno Haible , 2001. + Copyright (C) 2001-2004, 2006, 2009-2010 Free Software Foundation, Inc. + Written by Bruno Haible , 2001. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,7 +31,9 @@ extern "C" { /* String containing name the program is called with. */ extern const char *program_name; -/* Set program_name, based on argv[0]. */ +/* Set program_name, based on argv[0]. + argv0 must be a string allocated with indefinite extent, and must not be + modified after this call. */ extern void set_program_name (const char *argv0); #if ENABLE_RELOCATABLE @@ -39,8 +41,8 @@ extern void set_program_name (const char *argv0); /* Set program_name, based on argv[0], and original installation prefix and directory, for relocatability. */ extern void set_program_name_and_installdir (const char *argv0, - const char *orig_installprefix, - const char *orig_installdir); + const char *orig_installprefix, + const char *orig_installdir); #undef set_program_name #define set_program_name(ARG0) \ set_program_name_and_installdir (ARG0, INSTALLPREFIX, INSTALLDIR) diff --git a/src/bin/coreutils/lib/propername.c b/src/bin/coreutils/lib/propername.c index 381a7a72cb..3971f3f7a5 100644 --- a/src/bin/coreutils/lib/propername.c +++ b/src/bin/coreutils/lib/propername.c @@ -1,5 +1,5 @@ /* Localization of proper names. - Copyright (C) 2006-2009 Free Software Foundation, Inc. + Copyright (C) 2006-2010 Free Software Foundation, Inc. Written by Bruno Haible , 2006. This program is free software: you can redistribute it and/or modify @@ -55,92 +55,92 @@ mbsstr_trimmed_wordbounded (const char *string, const char *sub) { const char *tsub_in_string = mbsstr (string, tsub); if (tsub_in_string == NULL) - break; + break; else - { - if (MB_CUR_MAX > 1) - { - mbui_iterator_t string_iter; - bool word_boundary_before; - bool word_boundary_after; + { + if (MB_CUR_MAX > 1) + { + mbui_iterator_t string_iter; + bool word_boundary_before; + bool word_boundary_after; - mbui_init (string_iter, string); - word_boundary_before = true; - if (mbui_cur_ptr (string_iter) < tsub_in_string) - { - mbchar_t last_char_before_tsub; - do - { - if (!mbui_avail (string_iter)) - abort (); - last_char_before_tsub = mbui_cur (string_iter); - mbui_advance (string_iter); - } - while (mbui_cur_ptr (string_iter) < tsub_in_string); - if (mb_isalnum (last_char_before_tsub)) - word_boundary_before = false; - } + mbui_init (string_iter, string); + word_boundary_before = true; + if (mbui_cur_ptr (string_iter) < tsub_in_string) + { + mbchar_t last_char_before_tsub; + do + { + if (!mbui_avail (string_iter)) + abort (); + last_char_before_tsub = mbui_cur (string_iter); + mbui_advance (string_iter); + } + while (mbui_cur_ptr (string_iter) < tsub_in_string); + if (mb_isalnum (last_char_before_tsub)) + word_boundary_before = false; + } - mbui_init (string_iter, tsub_in_string); - { - mbui_iterator_t tsub_iter; + mbui_init (string_iter, tsub_in_string); + { + mbui_iterator_t tsub_iter; - for (mbui_init (tsub_iter, tsub); - mbui_avail (tsub_iter); - mbui_advance (tsub_iter)) - { - if (!mbui_avail (string_iter)) - abort (); - mbui_advance (string_iter); - } - } - word_boundary_after = true; - if (mbui_avail (string_iter)) - { - mbchar_t first_char_after_tsub = mbui_cur (string_iter); - if (mb_isalnum (first_char_after_tsub)) - word_boundary_after = false; - } + for (mbui_init (tsub_iter, tsub); + mbui_avail (tsub_iter); + mbui_advance (tsub_iter)) + { + if (!mbui_avail (string_iter)) + abort (); + mbui_advance (string_iter); + } + } + word_boundary_after = true; + if (mbui_avail (string_iter)) + { + mbchar_t first_char_after_tsub = mbui_cur (string_iter); + if (mb_isalnum (first_char_after_tsub)) + word_boundary_after = false; + } - if (word_boundary_before && word_boundary_after) - { - found = true; - break; - } + if (word_boundary_before && word_boundary_after) + { + found = true; + break; + } - mbui_init (string_iter, tsub_in_string); - if (!mbui_avail (string_iter)) - break; - string = tsub_in_string + mb_len (mbui_cur (string_iter)); - } - else - { - bool word_boundary_before; - const char *p; - bool word_boundary_after; + mbui_init (string_iter, tsub_in_string); + if (!mbui_avail (string_iter)) + break; + string = tsub_in_string + mb_len (mbui_cur (string_iter)); + } + else + { + bool word_boundary_before; + const char *p; + bool word_boundary_after; - word_boundary_before = true; - if (string < tsub_in_string) - if (isalnum ((unsigned char) tsub_in_string[-1])) - word_boundary_before = false; + word_boundary_before = true; + if (string < tsub_in_string) + if (isalnum ((unsigned char) tsub_in_string[-1])) + word_boundary_before = false; - p = tsub_in_string + strlen (tsub); - word_boundary_after = true; - if (*p != '\0') - if (isalnum ((unsigned char) *p)) - word_boundary_after = false; + p = tsub_in_string + strlen (tsub); + word_boundary_after = true; + if (*p != '\0') + if (isalnum ((unsigned char) *p)) + word_boundary_after = false; - if (word_boundary_before && word_boundary_after) - { - found = true; - break; - } + if (word_boundary_before && word_boundary_after) + { + found = true; + break; + } - if (*tsub_in_string == '\0') - break; - string = tsub_in_string + 1; - } - } + if (*tsub_in_string == '\0') + break; + string = tsub_in_string + 1; + } + } } free (tsub); return found; @@ -158,16 +158,16 @@ proper_name (const char *name) { /* See whether the translation contains the original name. */ if (mbsstr_trimmed_wordbounded (translation, name)) - return translation; + return translation; else - { - /* Return "TRANSLATION (NAME)". */ - char *result = - XNMALLOC (strlen (translation) + 2 + strlen (name) + 1 + 1, char); + { + /* Return "TRANSLATION (NAME)". */ + char *result = + XNMALLOC (strlen (translation) + 2 + strlen (name) + 1 + 1, char); - sprintf (result, "%s (%s)", translation, name); - return result; - } + sprintf (result, "%s (%s)", translation, name); + return result; + } } else return name; @@ -196,37 +196,37 @@ proper_name_utf8 (const char *name_ascii, const char *name_utf8) { #if HAVE_ICONV name_converted = alloc_name_converted = - xstr_iconv (name_utf8, "UTF-8", locale_code); + xstr_iconv (name_utf8, "UTF-8", locale_code); # if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2 \ || _LIBICONV_VERSION >= 0x0105 { - char *converted_translit; + char *converted_translit; - size_t len = strlen (locale_code); - char *locale_code_translit = XNMALLOC (len + 10 + 1, char); - memcpy (locale_code_translit, locale_code, len); - memcpy (locale_code_translit + len, "//TRANSLIT", 10 + 1); + size_t len = strlen (locale_code); + char *locale_code_translit = XNMALLOC (len + 10 + 1, char); + memcpy (locale_code_translit, locale_code, len); + memcpy (locale_code_translit + len, "//TRANSLIT", 10 + 1); - converted_translit = - xstr_iconv (name_utf8, "UTF-8", locale_code_translit); + converted_translit = + xstr_iconv (name_utf8, "UTF-8", locale_code_translit); - free (locale_code_translit); + free (locale_code_translit); - if (converted_translit != NULL) - { + if (converted_translit != NULL) + { # if !_LIBICONV_VERSION - /* Don't use the transliteration if it added question marks. - glibc's transliteration falls back to question marks; libiconv's - transliteration does not. - mbschr is equivalent to strchr in this case. */ - if (strchr (converted_translit, '?') != NULL) - free (converted_translit); - else + /* Don't use the transliteration if it added question marks. + glibc's transliteration falls back to question marks; libiconv's + transliteration does not. + mbschr is equivalent to strchr in this case. */ + if (strchr (converted_translit, '?') != NULL) + free (converted_translit); + else # endif - name_converted_translit = alloc_name_converted_translit = - converted_translit; - } + name_converted_translit = alloc_name_converted_translit = + converted_translit; + } } # endif #endif @@ -239,8 +239,8 @@ proper_name_utf8 (const char *name_ascii, const char *name_utf8) /* The name in locale encoding. */ name = (name_converted != NULL ? name_converted : - name_converted_translit != NULL ? name_converted_translit : - name_ascii); + name_converted_translit != NULL ? name_converted_translit : + name_ascii); /* See whether we have a translation. Some translators have not understood that they should use the UTF-8 form of the name, if possible. So if the @@ -249,39 +249,39 @@ proper_name_utf8 (const char *name_ascii, const char *name_utf8) { /* See whether the translation contains the original name. */ if (mbsstr_trimmed_wordbounded (translation, name_ascii) - || (name_converted != NULL - && mbsstr_trimmed_wordbounded (translation, name_converted)) - || (name_converted_translit != NULL - && mbsstr_trimmed_wordbounded (translation, name_converted_translit))) - { - if (alloc_name_converted != NULL) - free (alloc_name_converted); - if (alloc_name_converted_translit != NULL) - free (alloc_name_converted_translit); - return translation; - } + || (name_converted != NULL + && mbsstr_trimmed_wordbounded (translation, name_converted)) + || (name_converted_translit != NULL + && mbsstr_trimmed_wordbounded (translation, name_converted_translit))) + { + if (alloc_name_converted != NULL) + free (alloc_name_converted); + if (alloc_name_converted_translit != NULL) + free (alloc_name_converted_translit); + return translation; + } else - { - /* Return "TRANSLATION (NAME)". */ - char *result = - XNMALLOC (strlen (translation) + 2 + strlen (name) + 1 + 1, char); + { + /* Return "TRANSLATION (NAME)". */ + char *result = + XNMALLOC (strlen (translation) + 2 + strlen (name) + 1 + 1, char); - sprintf (result, "%s (%s)", translation, name); + sprintf (result, "%s (%s)", translation, name); - if (alloc_name_converted != NULL) - free (alloc_name_converted); - if (alloc_name_converted_translit != NULL) - free (alloc_name_converted_translit); - return result; - } + if (alloc_name_converted != NULL) + free (alloc_name_converted); + if (alloc_name_converted_translit != NULL) + free (alloc_name_converted_translit); + return result; + } } else { if (alloc_name_converted != NULL && alloc_name_converted != name) - free (alloc_name_converted); + free (alloc_name_converted); if (alloc_name_converted_translit != NULL - && alloc_name_converted_translit != name) - free (alloc_name_converted_translit); + && alloc_name_converted_translit != name) + free (alloc_name_converted_translit); return name; } } diff --git a/src/bin/coreutils/lib/propername.h b/src/bin/coreutils/lib/propername.h index d603b1ae08..eba56f696a 100644 --- a/src/bin/coreutils/lib/propername.h +++ b/src/bin/coreutils/lib/propername.h @@ -1,5 +1,5 @@ /* Localization of proper names. - Copyright (C) 2006, 2008 Free Software Foundation, Inc. + Copyright (C) 2006, 2008, 2009, 2010 Free Software Foundation, Inc. Written by Bruno Haible , 2006. This program is free software: you can redistribute it and/or modify @@ -96,7 +96,7 @@ extern const char * proper_name (const char *name); escape sequences. NAME_ASCII is a fallback written only with ASCII characters. */ extern const char * proper_name_utf8 (const char *name_ascii, - const char *name_utf8); + const char *name_utf8); #ifdef __cplusplus } diff --git a/src/bin/coreutils/lib/putenv.c b/src/bin/coreutils/lib/putenv.c index cc14b93895..030f5675ba 100644 --- a/src/bin/coreutils/lib/putenv.c +++ b/src/bin/coreutils/lib/putenv.c @@ -1,5 +1,5 @@ -/* Copyright (C) 1991, 1994, 1997-1998, 2000, 2003-2008 - Free Software Foundation, Inc. +/* Copyright (C) 1991, 1994, 1997-1998, 2000, 2003-2010 Free Software + Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. @@ -44,8 +44,8 @@ extern char **environ; /* This lock protects against simultaneous modifications of `environ'. */ # include __libc_lock_define_initialized (static, envlock) -# define LOCK __libc_lock_lock (envlock) -# define UNLOCK __libc_lock_unlock (envlock) +# define LOCK __libc_lock_lock (envlock) +# define UNLOCK __libc_lock_unlock (envlock) #else # define LOCK # define UNLOCK @@ -71,13 +71,13 @@ _unsetenv (const char *name) while (*ep != NULL) if (!strncmp (*ep, name, len) && (*ep)[len] == '=') { - /* Found it. Remove this pointer by moving later ones back. */ - char **dp = ep; + /* Found it. Remove this pointer by moving later ones back. */ + char **dp = ep; - do - dp[0] = dp[1]; - while (*dp++); - /* Continue the loop in case NAME appears again. */ + do + dp[0] = dp[1]; + while (*dp++); + /* Continue the loop in case NAME appears again. */ } else ++ep; @@ -106,7 +106,7 @@ putenv (char *string) size = 0; for (ep = environ; *ep != NULL; ++ep) if (!strncmp (*ep, string, name_end - string) && - (*ep)[name_end - string] == '=') + (*ep)[name_end - string] == '=') break; else ++size; @@ -116,9 +116,9 @@ putenv (char *string) static char **last_environ = NULL; char **new_environ = (char **) malloc ((size + 2) * sizeof (char *)); if (new_environ == NULL) - return -1; + return -1; (void) memcpy ((void *) new_environ, (void *) environ, - size * sizeof (char *)); + size * sizeof (char *)); new_environ[size] = (char *) string; new_environ[size + 1] = NULL; free (last_environ); diff --git a/src/bin/coreutils/lib/quote.c b/src/bin/coreutils/lib/quote.c index 5e8b764711..1f64f44c38 100644 --- a/src/bin/coreutils/lib/quote.c +++ b/src/bin/coreutils/lib/quote.c @@ -1,6 +1,6 @@ /* quote.c - quote arguments for output - Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005, 2006 Free + Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005, 2006, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/src/bin/coreutils/lib/quote.h b/src/bin/coreutils/lib/quote.h index c3660b1963..a986956ab1 100644 --- a/src/bin/coreutils/lib/quote.h +++ b/src/bin/coreutils/lib/quote.h @@ -1,6 +1,6 @@ /* quote.h - prototypes for quote.c - Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software + Copyright (C) 1998, 1999, 2000, 2001, 2003, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/src/bin/coreutils/lib/quotearg.c b/src/bin/coreutils/lib/quotearg.c index 8380e9de6c..5418f512bc 100644 --- a/src/bin/coreutils/lib/quotearg.c +++ b/src/bin/coreutils/lib/quotearg.c @@ -1,7 +1,7 @@ /* quotearg.c - quote arguments for output - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, - 2008 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008, + 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -100,7 +100,7 @@ clone_quoting_options (struct quoting_options *o) { int e = errno; struct quoting_options *p = xmemdup (o ? o : &default_quoting_options, - sizeof *o); + sizeof *o); errno = e; return p; } @@ -202,11 +202,11 @@ gettext_quote (char const *msgid, enum quoting_style s) static size_t quotearg_buffer_restyled (char *buffer, size_t buffersize, - char const *arg, size_t argsize, - enum quoting_style quoting_style, int flags, - unsigned int const *quote_these_too, - char const *left_quote, - char const *right_quote) + char const *arg, size_t argsize, + enum quoting_style quoting_style, int flags, + unsigned int const *quote_these_too, + char const *left_quote, + char const *right_quote) { size_t i; size_t len = 0; @@ -219,9 +219,9 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, #define STORE(c) \ do \ { \ - if (len < buffersize) \ - buffer[len] = (c); \ - len++; \ + if (len < buffersize) \ + buffer[len] = (c); \ + len++; \ } \ while (0) @@ -233,7 +233,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, /* Fall through. */ case c_quoting_style: if (!elide_outer_quotes) - STORE ('"'); + STORE ('"'); backslash_escapes = true; quote_string = "\""; quote_string_len = 1; @@ -248,36 +248,36 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, case clocale_quoting_style: case custom_quoting_style: { - if (quoting_style != custom_quoting_style) - { - /* TRANSLATORS: - Get translations for open and closing quotation marks. + if (quoting_style != custom_quoting_style) + { + /* TRANSLATORS: + Get translations for open and closing quotation marks. - The message catalog should translate "`" to a left - quotation mark suitable for the locale, and similarly for - "'". If the catalog has no translation, - locale_quoting_style quotes `like this', and - clocale_quoting_style quotes "like this". + The message catalog should translate "`" to a left + quotation mark suitable for the locale, and similarly for + "'". If the catalog has no translation, + locale_quoting_style quotes `like this', and + clocale_quoting_style quotes "like this". - For example, an American English Unicode locale should - translate "`" to U+201C (LEFT DOUBLE QUOTATION MARK), and - should translate "'" to U+201D (RIGHT DOUBLE QUOTATION - MARK). A British English Unicode locale should instead - translate these to U+2018 (LEFT SINGLE QUOTATION MARK) - and U+2019 (RIGHT SINGLE QUOTATION MARK), respectively. + For example, an American English Unicode locale should + translate "`" to U+201C (LEFT DOUBLE QUOTATION MARK), and + should translate "'" to U+201D (RIGHT DOUBLE QUOTATION + MARK). A British English Unicode locale should instead + translate these to U+2018 (LEFT SINGLE QUOTATION MARK) + and U+2019 (RIGHT SINGLE QUOTATION MARK), respectively. - If you don't know what to put here, please see - - and use glyphs suitable for your language. */ - left_quote = gettext_quote (N_("`"), quoting_style); - right_quote = gettext_quote (N_("'"), quoting_style); - } - if (!elide_outer_quotes) - for (quote_string = left_quote; *quote_string; quote_string++) - STORE (*quote_string); - backslash_escapes = true; - quote_string = right_quote; - quote_string_len = strlen (quote_string); + If you don't know what to put here, please see + + and use glyphs suitable for your language. */ + left_quote = gettext_quote (N_("`"), quoting_style); + right_quote = gettext_quote (N_("'"), quoting_style); + } + if (!elide_outer_quotes) + for (quote_string = left_quote; *quote_string; quote_string++) + STORE (*quote_string); + backslash_escapes = true; + quote_string = right_quote; + quote_string_len = strlen (quote_string); } break; @@ -287,7 +287,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, /* Fall through. */ case shell_always_quoting_style: if (!elide_outer_quotes) - STORE ('\''); + STORE ('\''); quote_string = "'"; quote_string_len = 1; break; @@ -307,287 +307,287 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, bool is_right_quote = false; if (backslash_escapes - && quote_string_len - && i + quote_string_len <= argsize - && memcmp (arg + i, quote_string, quote_string_len) == 0) - { - if (elide_outer_quotes) - goto force_outer_quoting_style; - is_right_quote = true; - } + && quote_string_len + && i + quote_string_len <= argsize + && memcmp (arg + i, quote_string, quote_string_len) == 0) + { + if (elide_outer_quotes) + goto force_outer_quoting_style; + is_right_quote = true; + } c = arg[i]; switch (c) - { - case '\0': - if (backslash_escapes) - { - if (elide_outer_quotes) - goto force_outer_quoting_style; - STORE ('\\'); - /* If quote_string were to begin with digits, we'd need to - test for the end of the arg as well. However, it's - hard to imagine any locale that would use digits in - quotes, and set_custom_quoting is documented not to - accept them. */ - if (i + 1 < argsize && '0' <= arg[i + 1] && arg[i + 1] <= '9') - { - STORE ('0'); - STORE ('0'); - } - c = '0'; - /* We don't have to worry that this last '0' will be - backslash-escaped because, again, quote_string should - not start with it and because quote_these_too is - documented as not accepting it. */ - } - else if (flags & QA_ELIDE_NULL_BYTES) - continue; - break; + { + case '\0': + if (backslash_escapes) + { + if (elide_outer_quotes) + goto force_outer_quoting_style; + STORE ('\\'); + /* If quote_string were to begin with digits, we'd need to + test for the end of the arg as well. However, it's + hard to imagine any locale that would use digits in + quotes, and set_custom_quoting is documented not to + accept them. */ + if (i + 1 < argsize && '0' <= arg[i + 1] && arg[i + 1] <= '9') + { + STORE ('0'); + STORE ('0'); + } + c = '0'; + /* We don't have to worry that this last '0' will be + backslash-escaped because, again, quote_string should + not start with it and because quote_these_too is + documented as not accepting it. */ + } + else if (flags & QA_ELIDE_NULL_BYTES) + continue; + break; - case '?': - switch (quoting_style) - { - case shell_always_quoting_style: - if (elide_outer_quotes) - goto force_outer_quoting_style; - break; + case '?': + switch (quoting_style) + { + case shell_always_quoting_style: + if (elide_outer_quotes) + goto force_outer_quoting_style; + break; - case c_quoting_style: - if ((flags & QA_SPLIT_TRIGRAPHS) - && i + 2 < argsize && arg[i + 1] == '?') - switch (arg[i + 2]) - { - case '!': case '\'': - case '(': case ')': case '-': case '/': - case '<': case '=': case '>': - /* Escape the second '?' in what would otherwise be - a trigraph. */ - if (elide_outer_quotes) - goto force_outer_quoting_style; - c = arg[i + 2]; - i += 2; - STORE ('?'); - STORE ('"'); - STORE ('"'); - STORE ('?'); - break; + case c_quoting_style: + if ((flags & QA_SPLIT_TRIGRAPHS) + && i + 2 < argsize && arg[i + 1] == '?') + switch (arg[i + 2]) + { + case '!': case '\'': + case '(': case ')': case '-': case '/': + case '<': case '=': case '>': + /* Escape the second '?' in what would otherwise be + a trigraph. */ + if (elide_outer_quotes) + goto force_outer_quoting_style; + c = arg[i + 2]; + i += 2; + STORE ('?'); + STORE ('"'); + STORE ('"'); + STORE ('?'); + break; - default: - break; - } - break; + default: + break; + } + break; - default: - break; - } - break; + default: + break; + } + break; - case '\a': esc = 'a'; goto c_escape; - case '\b': esc = 'b'; goto c_escape; - case '\f': esc = 'f'; goto c_escape; - case '\n': esc = 'n'; goto c_and_shell_escape; - case '\r': esc = 'r'; goto c_and_shell_escape; - case '\t': esc = 't'; goto c_and_shell_escape; - case '\v': esc = 'v'; goto c_escape; - case '\\': esc = c; - /* No need to escape the escape if we are trying to elide - outer quotes and nothing else is problematic. */ - if (backslash_escapes && elide_outer_quotes && quote_string_len) - goto store_c; + case '\a': esc = 'a'; goto c_escape; + case '\b': esc = 'b'; goto c_escape; + case '\f': esc = 'f'; goto c_escape; + case '\n': esc = 'n'; goto c_and_shell_escape; + case '\r': esc = 'r'; goto c_and_shell_escape; + case '\t': esc = 't'; goto c_and_shell_escape; + case '\v': esc = 'v'; goto c_escape; + case '\\': esc = c; + /* No need to escape the escape if we are trying to elide + outer quotes and nothing else is problematic. */ + if (backslash_escapes && elide_outer_quotes && quote_string_len) + goto store_c; - c_and_shell_escape: - if (quoting_style == shell_always_quoting_style - && elide_outer_quotes) - goto force_outer_quoting_style; - /* Fall through. */ - c_escape: - if (backslash_escapes) - { - c = esc; - goto store_escape; - } - break; + c_and_shell_escape: + if (quoting_style == shell_always_quoting_style + && elide_outer_quotes) + goto force_outer_quoting_style; + /* Fall through. */ + c_escape: + if (backslash_escapes) + { + c = esc; + goto store_escape; + } + break; - case '{': case '}': /* sometimes special if isolated */ - if (! (argsize == SIZE_MAX ? arg[1] == '\0' : argsize == 1)) - break; - /* Fall through. */ - case '#': case '~': - if (i != 0) - break; - /* Fall through. */ - case ' ': - case '!': /* special in bash */ - case '"': case '$': case '&': - case '(': case ')': case '*': case ';': - case '<': - case '=': /* sometimes special in 0th or (with "set -k") later args */ - case '>': case '[': - case '^': /* special in old /bin/sh, e.g. SunOS 4.1.4 */ - case '`': case '|': - /* A shell special character. In theory, '$' and '`' could - be the first bytes of multibyte characters, which means - we should check them with mbrtowc, but in practice this - doesn't happen so it's not worth worrying about. */ - if (quoting_style == shell_always_quoting_style - && elide_outer_quotes) - goto force_outer_quoting_style; - break; + case '{': case '}': /* sometimes special if isolated */ + if (! (argsize == SIZE_MAX ? arg[1] == '\0' : argsize == 1)) + break; + /* Fall through. */ + case '#': case '~': + if (i != 0) + break; + /* Fall through. */ + case ' ': + case '!': /* special in bash */ + case '"': case '$': case '&': + case '(': case ')': case '*': case ';': + case '<': + case '=': /* sometimes special in 0th or (with "set -k") later args */ + case '>': case '[': + case '^': /* special in old /bin/sh, e.g. SunOS 4.1.4 */ + case '`': case '|': + /* A shell special character. In theory, '$' and '`' could + be the first bytes of multibyte characters, which means + we should check them with mbrtowc, but in practice this + doesn't happen so it's not worth worrying about. */ + if (quoting_style == shell_always_quoting_style + && elide_outer_quotes) + goto force_outer_quoting_style; + break; - case '\'': - if (quoting_style == shell_always_quoting_style) - { - if (elide_outer_quotes) - goto force_outer_quoting_style; - STORE ('\''); - STORE ('\\'); - STORE ('\''); - } - break; + case '\'': + if (quoting_style == shell_always_quoting_style) + { + if (elide_outer_quotes) + goto force_outer_quoting_style; + STORE ('\''); + STORE ('\\'); + STORE ('\''); + } + break; - case '%': case '+': case ',': case '-': case '.': case '/': - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': case ':': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': case ']': case '_': case 'a': case 'b': - case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': - case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': - case 'o': case 'p': case 'q': case 'r': case 's': case 't': - case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': - /* These characters don't cause problems, no matter what the - quoting style is. They cannot start multibyte sequences. - A digit or a special letter would cause trouble if it - appeared at the beginning of quote_string because we'd then - escape by prepending a backslash. However, it's hard to - imagine any locale that would use digits or letters as - quotes, and set_custom_quoting is documented not to accept - them. Also, a digit or a special letter would cause - trouble if it appeared in quote_these_too, but that's also - documented as not accepting them. */ - break; + case '%': case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': case '5': + case '6': case '7': case '8': case '9': case ':': + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': + case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': + case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': + case 'Y': case 'Z': case ']': case '_': case 'a': case 'b': + case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': + case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': + case 'o': case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': + /* These characters don't cause problems, no matter what the + quoting style is. They cannot start multibyte sequences. + A digit or a special letter would cause trouble if it + appeared at the beginning of quote_string because we'd then + escape by prepending a backslash. However, it's hard to + imagine any locale that would use digits or letters as + quotes, and set_custom_quoting is documented not to accept + them. Also, a digit or a special letter would cause + trouble if it appeared in quote_these_too, but that's also + documented as not accepting them. */ + break; - default: - /* If we have a multibyte sequence, copy it until we reach - its end, find an error, or come back to the initial shift - state. For C-like styles, if the sequence has - unprintable characters, escape the whole sequence, since - we can't easily escape single characters within it. */ - { - /* Length of multibyte sequence found so far. */ - size_t m; + default: + /* If we have a multibyte sequence, copy it until we reach + its end, find an error, or come back to the initial shift + state. For C-like styles, if the sequence has + unprintable characters, escape the whole sequence, since + we can't easily escape single characters within it. */ + { + /* Length of multibyte sequence found so far. */ + size_t m; - bool printable; + bool printable; - if (unibyte_locale) - { - m = 1; - printable = isprint (c) != 0; - } - else - { - mbstate_t mbstate; - memset (&mbstate, 0, sizeof mbstate); + if (unibyte_locale) + { + m = 1; + printable = isprint (c) != 0; + } + else + { + mbstate_t mbstate; + memset (&mbstate, 0, sizeof mbstate); - m = 0; - printable = true; - if (argsize == SIZE_MAX) - argsize = strlen (arg); + m = 0; + printable = true; + if (argsize == SIZE_MAX) + argsize = strlen (arg); - do - { - wchar_t w; - size_t bytes = mbrtowc (&w, &arg[i + m], - argsize - (i + m), &mbstate); - if (bytes == 0) - break; - else if (bytes == (size_t) -1) - { - printable = false; - break; - } - else if (bytes == (size_t) -2) - { - printable = false; - while (i + m < argsize && arg[i + m]) - m++; - break; - } - else - { - /* Work around a bug with older shells that "see" a '\' - that is really the 2nd byte of a multibyte character. - In practice the problem is limited to ASCII - chars >= '@' that are shell special chars. */ - if ('[' == 0x5b && elide_outer_quotes - && quoting_style == shell_always_quoting_style) - { - size_t j; - for (j = 1; j < bytes; j++) - switch (arg[i + m + j]) - { - case '[': case '\\': case '^': - case '`': case '|': - goto force_outer_quoting_style; + do + { + wchar_t w; + size_t bytes = mbrtowc (&w, &arg[i + m], + argsize - (i + m), &mbstate); + if (bytes == 0) + break; + else if (bytes == (size_t) -1) + { + printable = false; + break; + } + else if (bytes == (size_t) -2) + { + printable = false; + while (i + m < argsize && arg[i + m]) + m++; + break; + } + else + { + /* Work around a bug with older shells that "see" a '\' + that is really the 2nd byte of a multibyte character. + In practice the problem is limited to ASCII + chars >= '@' that are shell special chars. */ + if ('[' == 0x5b && elide_outer_quotes + && quoting_style == shell_always_quoting_style) + { + size_t j; + for (j = 1; j < bytes; j++) + switch (arg[i + m + j]) + { + case '[': case '\\': case '^': + case '`': case '|': + goto force_outer_quoting_style; - default: - break; - } - } + default: + break; + } + } - if (! iswprint (w)) - printable = false; - m += bytes; - } - } - while (! mbsinit (&mbstate)); - } + if (! iswprint (w)) + printable = false; + m += bytes; + } + } + while (! mbsinit (&mbstate)); + } - if (1 < m || (backslash_escapes && ! printable)) - { - /* Output a multibyte sequence, or an escaped - unprintable unibyte character. */ - size_t ilim = i + m; + if (1 < m || (backslash_escapes && ! printable)) + { + /* Output a multibyte sequence, or an escaped + unprintable unibyte character. */ + size_t ilim = i + m; - for (;;) - { - if (backslash_escapes && ! printable) - { - if (elide_outer_quotes) - goto force_outer_quoting_style; - STORE ('\\'); - STORE ('0' + (c >> 6)); - STORE ('0' + ((c >> 3) & 7)); - c = '0' + (c & 7); - } - else if (is_right_quote) - { - STORE ('\\'); - is_right_quote = false; - } - if (ilim <= i + 1) - break; - STORE (c); - c = arg[++i]; - } + for (;;) + { + if (backslash_escapes && ! printable) + { + if (elide_outer_quotes) + goto force_outer_quoting_style; + STORE ('\\'); + STORE ('0' + (c >> 6)); + STORE ('0' + ((c >> 3) & 7)); + c = '0' + (c & 7); + } + else if (is_right_quote) + { + STORE ('\\'); + is_right_quote = false; + } + if (ilim <= i + 1) + break; + STORE (c); + c = arg[++i]; + } - goto store_c; - } - } - } + goto store_c; + } + } + } if (! ((backslash_escapes || elide_outer_quotes) - && quote_these_too - && quote_these_too[c / INT_BITS] & (1 << (c % INT_BITS))) - && !is_right_quote) - goto store_c; + && quote_these_too + && quote_these_too[c / INT_BITS] & (1 << (c % INT_BITS))) + && !is_right_quote) + goto store_c; store_escape: if (elide_outer_quotes) - goto force_outer_quoting_style; + goto force_outer_quoting_style; STORE ('\\'); store_c: @@ -610,9 +610,9 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, /* Don't reuse quote_these_too, since the addition of outer quotes sufficiently quotes the specified characters. */ return quotearg_buffer_restyled (buffer, buffersize, arg, argsize, - quoting_style, - flags & ~QA_ELIDE_OUTER_QUOTES, NULL, - left_quote, right_quote); + quoting_style, + flags & ~QA_ELIDE_OUTER_QUOTES, NULL, + left_quote, right_quote); } /* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of @@ -626,14 +626,14 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, ARGSIZE. */ size_t quotearg_buffer (char *buffer, size_t buffersize, - char const *arg, size_t argsize, - struct quoting_options const *o) + char const *arg, size_t argsize, + struct quoting_options const *o) { struct quoting_options const *p = o ? o : &default_quoting_options; int e = errno; size_t r = quotearg_buffer_restyled (buffer, buffersize, arg, argsize, - p->style, p->flags, p->quote_these_too, - p->left_quote, p->right_quote); + p->style, p->flags, p->quote_these_too, + p->left_quote, p->right_quote); errno = e; return r; } @@ -641,7 +641,7 @@ quotearg_buffer (char *buffer, size_t buffersize, /* Equivalent to quotearg_alloc (ARG, ARGSIZE, NULL, O). */ char * quotearg_alloc (char const *arg, size_t argsize, - struct quoting_options const *o) + struct quoting_options const *o) { return quotearg_alloc_mem (arg, argsize, NULL, o); } @@ -654,20 +654,20 @@ quotearg_alloc (char const *arg, size_t argsize, flag. */ char * quotearg_alloc_mem (char const *arg, size_t argsize, size_t *size, - struct quoting_options const *o) + struct quoting_options const *o) { struct quoting_options const *p = o ? o : &default_quoting_options; int e = errno; /* Elide embedded null bytes if we can't return a size. */ int flags = p->flags | (size ? 0 : QA_ELIDE_NULL_BYTES); size_t bufsize = quotearg_buffer_restyled (0, 0, arg, argsize, p->style, - flags, p->quote_these_too, - p->left_quote, - p->right_quote) + 1; + flags, p->quote_these_too, + p->left_quote, + p->right_quote) + 1; char *buf = xcharalloc (bufsize); quotearg_buffer_restyled (buf, bufsize, arg, argsize, p->style, flags, - p->quote_these_too, - p->left_quote, p->right_quote); + p->quote_these_too, + p->left_quote, p->right_quote); errno = e; if (size) *size = bufsize - 1; @@ -719,7 +719,7 @@ quotearg_free (void) to allow for future extensions (using negative values). */ static char * quotearg_n_options (int n, char const *arg, size_t argsize, - struct quoting_options const *options) + struct quoting_options const *options) { int e = errno; @@ -732,19 +732,19 @@ quotearg_n_options (int n, char const *arg, size_t argsize, if (nslots <= n0) { /* FIXME: technically, the type of n1 should be `unsigned int', - but that evokes an unsuppressible warning from gcc-4.0.1 and - older. If gcc ever provides an option to suppress that warning, - revert to the original type, so that the test in xalloc_oversized - is once again performed only at compile time. */ + but that evokes an unsuppressible warning from gcc-4.0.1 and + older. If gcc ever provides an option to suppress that warning, + revert to the original type, so that the test in xalloc_oversized + is once again performed only at compile time. */ size_t n1 = n0 + 1; bool preallocated = (sv == &slotvec0); if (xalloc_oversized (n1, sizeof *sv)) - xalloc_die (); + xalloc_die (); slotvec = sv = xrealloc (preallocated ? NULL : sv, n1 * sizeof *sv); if (preallocated) - *sv = slotvec0; + *sv = slotvec0; memset (sv + nslots, 0, (n1 - nslots) * sizeof *sv); nslots = n1; } @@ -755,21 +755,21 @@ quotearg_n_options (int n, char const *arg, size_t argsize, /* Elide embedded null bytes since we don't return a size. */ int flags = options->flags | QA_ELIDE_NULL_BYTES; size_t qsize = quotearg_buffer_restyled (val, size, arg, argsize, - options->style, flags, - options->quote_these_too, - options->left_quote, - options->right_quote); + options->style, flags, + options->quote_these_too, + options->left_quote, + options->right_quote); if (size <= qsize) { - sv[n].size = size = qsize + 1; - if (val != slot0) - free (val); - sv[n].val = val = xcharalloc (size); - quotearg_buffer_restyled (val, size, arg, argsize, options->style, - flags, options->quote_these_too, - options->left_quote, - options->right_quote); + sv[n].size = size = qsize + 1; + if (val != slot0) + free (val); + sv[n].val = val = xcharalloc (size); + quotearg_buffer_restyled (val, size, arg, argsize, options->style, + flags, options->quote_these_too, + options->left_quote, + options->right_quote); } errno = e; @@ -810,7 +810,7 @@ quotearg_n_style (int n, enum quoting_style s, char const *arg) char * quotearg_n_style_mem (int n, enum quoting_style s, - char const *arg, size_t argsize) + char const *arg, size_t argsize) { struct quoting_options const o = quoting_options_from_style (s); return quotearg_n_options (n, arg, argsize, &o); @@ -857,16 +857,16 @@ quotearg_colon_mem (char const *arg, size_t argsize) char * quotearg_n_custom (int n, char const *left_quote, - char const *right_quote, char const *arg) + char const *right_quote, char const *arg) { return quotearg_n_custom_mem (n, left_quote, right_quote, arg, - SIZE_MAX); + SIZE_MAX); } char * quotearg_n_custom_mem (int n, char const *left_quote, - char const *right_quote, - char const *arg, size_t argsize) + char const *right_quote, + char const *arg, size_t argsize) { struct quoting_options o = default_quoting_options; set_custom_quoting (&o, left_quote, right_quote); @@ -875,15 +875,15 @@ quotearg_n_custom_mem (int n, char const *left_quote, char * quotearg_custom (char const *left_quote, char const *right_quote, - char const *arg) + char const *arg) { return quotearg_n_custom (0, left_quote, right_quote, arg); } char * quotearg_custom_mem (char const *left_quote, char const *right_quote, - char const *arg, size_t argsize) + char const *arg, size_t argsize) { return quotearg_n_custom_mem (0, left_quote, right_quote, arg, - argsize); + argsize); } diff --git a/src/bin/coreutils/lib/quotearg.h b/src/bin/coreutils/lib/quotearg.h index 63c47f13cc..084cd1b2de 100644 --- a/src/bin/coreutils/lib/quotearg.h +++ b/src/bin/coreutils/lib/quotearg.h @@ -1,7 +1,7 @@ /* quotearg.h - quote arguments for output - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2006, 2008 Free - Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2006, 2008, 2009, 2010 + Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -276,8 +276,8 @@ int set_quoting_flags (struct quoting_options *o, int i); that has special meaning after a backslash (for example, "\t" for tab). */ void set_custom_quoting (struct quoting_options *o, - char const *left_quote, - char const *right_quote); + char const *left_quote, + char const *right_quote); /* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of argument ARG (of size ARGSIZE), using O to control quoting. @@ -291,14 +291,14 @@ void set_custom_quoting (struct quoting_options *o, not -1, the style of O does not use backslash escapes, and the flags of O do not request elision of null bytes.*/ size_t quotearg_buffer (char *buffer, size_t buffersize, - char const *arg, size_t argsize, - struct quoting_options const *o); + char const *arg, size_t argsize, + struct quoting_options const *o); /* Like quotearg_buffer, except return the result in a newly allocated buffer. It is the caller's responsibility to free the result. The result will not contain embedded null bytes. */ char *quotearg_alloc (char const *arg, size_t argsize, - struct quoting_options const *o); + struct quoting_options const *o); /* Like quotearg_alloc, except that the length of the result, excluding the terminating null byte, is stored into SIZE if it is @@ -307,7 +307,7 @@ char *quotearg_alloc (char const *arg, size_t argsize, backslash escapes, and the flags of O do not request elision of null bytes.*/ char *quotearg_alloc_mem (char const *arg, size_t argsize, - size_t *size, struct quoting_options const *o); + size_t *size, struct quoting_options const *o); /* Use storage slot N to return a quoted version of the string ARG. Use the default quoting options. @@ -338,14 +338,14 @@ char *quotearg_n_style (int n, enum quoting_style s, char const *arg); argument ARG of size ARGSIZE. This is like quotearg_n_style (N, S, ARG), except it can quote null bytes. */ char *quotearg_n_style_mem (int n, enum quoting_style s, - char const *arg, size_t argsize); + char const *arg, size_t argsize); /* Equivalent to quotearg_n_style (0, S, ARG). */ char *quotearg_style (enum quoting_style s, char const *arg); /* Equivalent to quotearg_n_style_mem (0, S, ARG, ARGSIZE). */ char *quotearg_style_mem (enum quoting_style s, - char const *arg, size_t argsize); + char const *arg, size_t argsize); /* Like quotearg (ARG), except also quote any instances of CH. See set_char_quoting for a description of acceptable CH values. */ @@ -365,23 +365,23 @@ char *quotearg_colon_mem (char const *arg, size_t argsize); set_custom_quoting for a description of acceptable LEFT_QUOTE and RIGHT_QUOTE values. */ char *quotearg_n_custom (int n, char const *left_quote, - char const *right_quote, char const *arg); + char const *right_quote, char const *arg); /* Like quotearg_n_custom (N, LEFT_QUOTE, RIGHT_QUOTE, ARG) except it can quote null bytes. */ char *quotearg_n_custom_mem (int n, char const *left_quote, - char const *right_quote, - char const *arg, size_t argsize); + char const *right_quote, + char const *arg, size_t argsize); /* Equivalent to quotearg_n_custom (0, LEFT_QUOTE, RIGHT_QUOTE, ARG). */ char *quotearg_custom (char const *left_quote, char const *right_quote, - char const *arg); + char const *arg); /* Equivalent to quotearg_n_custom_mem (0, LEFT_QUOTE, RIGHT_QUOTE, ARG, - ARGSIZE). */ + ARGSIZE). */ char *quotearg_custom_mem (char const *left_quote, - char const *right_quote, - char const *arg, size_t argsize); + char const *right_quote, + char const *arg, size_t argsize); /* Free any dynamically allocated memory. */ void quotearg_free (void); diff --git a/src/bin/coreutils/lib/raise.c b/src/bin/coreutils/lib/raise.c index 3064889be8..1924fe86b2 100644 --- a/src/bin/coreutils/lib/raise.c +++ b/src/bin/coreutils/lib/raise.c @@ -1,6 +1,6 @@ /* Provide a non-threads replacement for the POSIX raise function. - Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2002-2003, 2005-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/rand-isaac.c b/src/bin/coreutils/lib/rand-isaac.c index a1edf4785f..52d53a393c 100644 --- a/src/bin/coreutils/lib/rand-isaac.c +++ b/src/bin/coreutils/lib/rand-isaac.c @@ -1,6 +1,6 @@ /* Bob Jenkins's cryptographic random number generator, ISAAC. - Copyright (C) 1999-2006, 2009 Free Software Foundation, Inc. + Copyright (C) 1999-2006, 2009-2010 Free Software Foundation, Inc. Copyright (C) 1997, 1998, 1999 Colin Plumb. This program is free software: you can redistribute it and/or modify diff --git a/src/bin/coreutils/lib/rand-isaac.h b/src/bin/coreutils/lib/rand-isaac.h index 7735a0aa75..6559dc8fea 100644 --- a/src/bin/coreutils/lib/rand-isaac.h +++ b/src/bin/coreutils/lib/rand-isaac.h @@ -1,6 +1,6 @@ /* Bob Jenkins's cryptographic random number generator, ISAAC. - Copyright (C) 1999-2005, 2009 Free Software Foundation, Inc. + Copyright (C) 1999-2005, 2009-2010 Free Software Foundation, Inc. Copyright (C) 1997, 1998, 1999 Colin Plumb. This program is free software: you can redistribute it and/or modify diff --git a/src/bin/coreutils/lib/randint.c b/src/bin/coreutils/lib/randint.c index cfa6e232bb..cb39221b4c 100644 --- a/src/bin/coreutils/lib/randint.c +++ b/src/bin/coreutils/lib/randint.c @@ -1,6 +1,6 @@ /* Generate random integers. - Copyright (C) 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/randint.h b/src/bin/coreutils/lib/randint.h index 91ba3586c0..92d35db6b5 100644 --- a/src/bin/coreutils/lib/randint.h +++ b/src/bin/coreutils/lib/randint.h @@ -1,6 +1,6 @@ /* Generate random integers. - Copyright (C) 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/randperm.c b/src/bin/coreutils/lib/randperm.c index a03c5b87f6..fb829ac25c 100644 --- a/src/bin/coreutils/lib/randperm.c +++ b/src/bin/coreutils/lib/randperm.c @@ -1,6 +1,6 @@ /* Generate random permutations. - Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 2006-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/randread.c b/src/bin/coreutils/lib/randread.c index 72475017e1..65e9d63695 100644 --- a/src/bin/coreutils/lib/randread.c +++ b/src/bin/coreutils/lib/randread.c @@ -1,6 +1,6 @@ /* Generate buffers of random data. - Copyright (C) 2006, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2006, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/randread.h b/src/bin/coreutils/lib/randread.h index 95043135ca..3fad3f0c67 100644 --- a/src/bin/coreutils/lib/randread.h +++ b/src/bin/coreutils/lib/randread.h @@ -1,6 +1,6 @@ /* Generate buffers of random data. - Copyright (C) 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/readlink.c b/src/bin/coreutils/lib/readlink.c index 5cccdc962a..1d9b3d3b07 100644 --- a/src/bin/coreutils/lib/readlink.c +++ b/src/bin/coreutils/lib/readlink.c @@ -1,5 +1,5 @@ /* Stub for readlink(). - Copyright (C) 2003-2007 Free Software Foundation, Inc. + Copyright (C) 2003-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,30 +20,55 @@ #include #include -#include +#include #include -#include #if !HAVE_READLINK /* readlink() substitute for systems that don't have a readlink() function, such as DJGPP 2.03 and mingw32. */ -/* The official POSIX return type of readlink() is ssize_t, but since here - we have no declaration in a public header file, we use 'int' as return - type. */ - -int -readlink (const char *path, char *buf, size_t bufsize) +ssize_t +readlink (const char *name, char *buf _GL_UNUSED, + size_t bufsize _GL_UNUSED) { struct stat statbuf; /* In general we should use lstat() here, not stat(). But on platforms - without symbolic links lstat() - if it exists - would be equivalent to + without symbolic links, lstat() - if it exists - would be equivalent to stat(), therefore we can use stat(). This saves us a configure check. */ - if (stat (path, &statbuf) >= 0) + if (stat (name, &statbuf) >= 0) errno = EINVAL; return -1; } -#endif +#else /* HAVE_READLINK */ + +# undef readlink + +/* readlink() wrapper that uses correct types, for systems like cygwin + 1.5.x where readlink returns int, and which rejects trailing slash, + for Solaris 9. */ + +ssize_t +rpl_readlink (const char *name, char *buf, size_t bufsize) +{ +# if READLINK_TRAILING_SLASH_BUG + size_t len = strlen (name); + if (len && name[len - 1] == '/') + { + /* Even if name without the slash is a symlink to a directory, + both lstat() and stat() must resolve the trailing slash to + the directory rather than the symlink. We can therefore + safely use stat() to distinguish between EINVAL and + ENOTDIR/ENOENT, avoiding extra overhead of rpl_lstat(). */ + struct stat st; + if (stat (name, &st) == 0) + errno = EINVAL; + return -1; + } +# endif /* READLINK_TRAILING_SLASH_BUG */ + return readlink (name, buf, bufsize); +} + +#endif /* HAVE_READLINK */ diff --git a/src/bin/coreutils/lib/readtokens.c b/src/bin/coreutils/lib/readtokens.c index 01750989cc..e29f20e69a 100644 --- a/src/bin/coreutils/lib/readtokens.c +++ b/src/bin/coreutils/lib/readtokens.c @@ -1,6 +1,7 @@ /* readtokens.c -- Functions for reading tokens from an input stream. - Copyright (C) 1990-1991, 1999-2004, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 1990-1991, 1999-2004, 2006, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -60,9 +61,9 @@ init_tokenbuffer (token_buffer *tokenbuffer) size_t readtoken (FILE *stream, - const char *delim, - size_t n_delim, - token_buffer *tokenbuffer) + const char *delim, + size_t n_delim, + token_buffer *tokenbuffer) { char *p; int c; @@ -79,13 +80,13 @@ readtoken (FILE *stream, { same_delimiters = true; for (i = 0; i < n_delim; i++) - { - if (delim[i] != saved_delim[i]) - { - same_delimiters = false; - break; - } - } + { + if (delim[i] != saved_delim[i]) + { + same_delimiters = false; + break; + } + } } if (!same_delimiters) @@ -94,10 +95,10 @@ readtoken (FILE *stream, saved_delim = delim; memset (isdelim, 0, sizeof isdelim); for (j = 0; j < n_delim; j++) - { - unsigned char ch = delim[j]; - isdelim[ch] = 1; - } + { + unsigned char ch = delim[j]; + isdelim[ch] = 1; + } } /* FIXME: don't fool with this caching. Use strchr instead. */ @@ -113,21 +114,21 @@ readtoken (FILE *stream, for (;;) { if (c < 0 && i == 0) - return -1; + return -1; if (i == n) - p = x2nrealloc (p, &n, sizeof *p); + p = x2nrealloc (p, &n, sizeof *p); if (c < 0) - { - p[i] = 0; - break; - } + { + p[i] = 0; + break; + } if (isdelim[c]) - { - p[i] = 0; - break; - } + { + p[i] = 0; + break; + } p[i++] = c; c = getc (stream); } @@ -146,11 +147,11 @@ readtoken (FILE *stream, size_t readtokens (FILE *stream, - size_t projected_n_tokens, - const char *delim, - size_t n_delim, - char ***tokens_out, - size_t **token_lengths) + size_t projected_n_tokens, + const char *delim, + size_t n_delim, + char ***tokens_out, + size_t **token_lengths) { token_buffer tb, *token = &tb; char **tokens; @@ -161,7 +162,7 @@ readtokens (FILE *stream, if (projected_n_tokens == 0) projected_n_tokens = 64; else - projected_n_tokens++; /* add one for trailing NULL pointer */ + projected_n_tokens++; /* add one for trailing NULL pointer */ sz = projected_n_tokens; tokens = xnmalloc (sz, sizeof *tokens); @@ -174,18 +175,18 @@ readtokens (FILE *stream, char *tmp; size_t token_length = readtoken (stream, delim, n_delim, token); if (n_tokens >= sz) - { - tokens = x2nrealloc (tokens, &sz, sizeof *tokens); - lengths = xnrealloc (lengths, sz, sizeof *lengths); - } + { + tokens = x2nrealloc (tokens, &sz, sizeof *tokens); + lengths = xnrealloc (lengths, sz, sizeof *lengths); + } if (token_length == (size_t) -1) - { - /* don't increment n_tokens for NULL entry */ - tokens[n_tokens] = NULL; - lengths[n_tokens] = 0; - break; - } + { + /* don't increment n_tokens for NULL entry */ + tokens[n_tokens] = NULL; + lengths[n_tokens] = 0; + break; + } tmp = xnmalloc (token_length + 1, sizeof *tmp); lengths[n_tokens] = token_length; tokens[n_tokens] = memcpy (tmp, token->buffer, token_length + 1); diff --git a/src/bin/coreutils/lib/readtokens.h b/src/bin/coreutils/lib/readtokens.h index 1c3cafeb1e..41632cc20b 100644 --- a/src/bin/coreutils/lib/readtokens.h +++ b/src/bin/coreutils/lib/readtokens.h @@ -1,6 +1,7 @@ /* readtokens.h -- Functions for reading tokens from an input stream. - Copyright (C) 1990, 1991, 1999, 2001-2004 Free Software Foundation, Inc. + Copyright (C) 1990-1991, 1999, 2001-2004, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,10 +34,10 @@ void init_tokenbuffer (token_buffer *tokenbuffer); size_t readtoken (FILE *stream, const char *delim, size_t n_delim, - token_buffer *tokenbuffer); + token_buffer *tokenbuffer); size_t readtokens (FILE *stream, size_t projected_n_tokens, - const char *delim, size_t n_delim, - char ***tokens_out, size_t **token_lengths); + const char *delim, size_t n_delim, + char ***tokens_out, size_t **token_lengths); #endif /* not READTOKENS_H */ diff --git a/src/bin/coreutils/lib/readtokens0.c b/src/bin/coreutils/lib/readtokens0.c index ccd2860c07..147dd0dfde 100644 --- a/src/bin/coreutils/lib/readtokens0.c +++ b/src/bin/coreutils/lib/readtokens0.c @@ -1,6 +1,6 @@ /* readtokens0.c -- Read NUL-separated tokens from an input stream. - Copyright (C) 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2004, 2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -70,23 +70,23 @@ readtokens0 (FILE *in, struct Tokens *t) { int c = fgetc (in); if (c == EOF) - { - size_t len = obstack_object_size (&t->o_data); - /* If the current object has nonzero length, then there - was no NUL byte at EOF -- or maybe there was an error, - in which case, we need to append a NUL byte to our buffer. */ - if (len) - { - obstack_1grow (&t->o_data, '\0'); - save_token (t); - } + { + size_t len = obstack_object_size (&t->o_data); + /* If the current object has nonzero length, then there + was no NUL byte at EOF -- or maybe there was an error, + in which case, we need to append a NUL byte to our buffer. */ + if (len) + { + obstack_1grow (&t->o_data, '\0'); + save_token (t); + } - break; - } + break; + } obstack_1grow (&t->o_data, c); if (c == '\0') - save_token (t); + save_token (t); } /* Add a NULL pointer at the end, in case the caller (like du) diff --git a/src/bin/coreutils/lib/readtokens0.h b/src/bin/coreutils/lib/readtokens0.h index 4f04b68643..9a21a66480 100644 --- a/src/bin/coreutils/lib/readtokens0.h +++ b/src/bin/coreutils/lib/readtokens0.h @@ -1,6 +1,6 @@ /* readtokens0.h -- read NUL-separated tokens from an input stream. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/readutmp.c b/src/bin/coreutils/lib/readutmp.c index aeec205723..40c5a9ae29 100644 --- a/src/bin/coreutils/lib/readutmp.c +++ b/src/bin/coreutils/lib/readutmp.c @@ -1,7 +1,6 @@ /* GNU's read utmp module. - Copyright (C) 1992-2001, 2003, 2004, 2005, 2006 Free Software - Foundation, Inc. + Copyright (C) 1992-2001, 2003-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -71,7 +70,7 @@ desirable_utmp_entry (STRUCT_UTMP const *u, int options) if ((options & READ_UTMP_CHECK_PIDS) && user_proc && (UT_PID (u) <= 0 - || (kill (UT_PID (u), 0) < 0 && errno == ESRCH))) + || (kill (UT_PID (u), 0) < 0 && errno == ESRCH))) return false; return true; } @@ -87,7 +86,7 @@ desirable_utmp_entry (STRUCT_UTMP const *u, int options) int read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf, - int options) + int options) { size_t n_read = 0; size_t n_alloc = 0; @@ -105,10 +104,10 @@ read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf, while ((u = GET_UTMP_ENT ()) != NULL) if (desirable_utmp_entry (u, options)) { - if (n_read == n_alloc) - utmp = x2nrealloc (utmp, &n_alloc, sizeof *utmp); + if (n_read == n_alloc) + utmp = x2nrealloc (utmp, &n_alloc, sizeof *utmp); - utmp[n_read++] = *u; + utmp[n_read++] = *u; } END_UTMP_ENT (); @@ -123,7 +122,7 @@ read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf, int read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf, - int options) + int options) { size_t n_read = 0; size_t n_alloc = 0; @@ -137,9 +136,9 @@ read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf, for (;;) { if (n_read == n_alloc) - utmp = x2nrealloc (utmp, &n_alloc, sizeof *utmp); + utmp = x2nrealloc (utmp, &n_alloc, sizeof *utmp); if (fread (&utmp[n_read], sizeof utmp[n_read], 1, f) == 0) - break; + break; n_read += desirable_utmp_entry (&utmp[n_read], options); } diff --git a/src/bin/coreutils/lib/readutmp.h b/src/bin/coreutils/lib/readutmp.h index 1e43a31e84..38acf4500a 100644 --- a/src/bin/coreutils/lib/readutmp.h +++ b/src/bin/coreutils/lib/readutmp.h @@ -1,6 +1,6 @@ /* Declarations for GNU's read utmp module. - Copyright (C) 1992-2007 Free Software Foundation, Inc. + Copyright (C) 1992-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -197,9 +197,9 @@ enum { UT_USER_SIZE = sizeof UT_USER ((STRUCT_UTMP *) 0) }; # define UT_TYPE_USER_PROCESS(U) 0 # endif -# define IS_USER_PROCESS(U) \ - (UT_USER (U)[0] \ - && (UT_TYPE_USER_PROCESS (U) \ +# define IS_USER_PROCESS(U) \ + (UT_USER (U)[0] \ + && (UT_TYPE_USER_PROCESS (U) \ || (UT_TYPE_NOT_DEFINED && UT_TIME_MEMBER (U) != 0))) /* Options for read_utmp. */ @@ -211,6 +211,6 @@ enum char *extract_trimmed_name (const STRUCT_UTMP *ut); int read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf, - int options); + int options); #endif /* __READUTMP_H__ */ diff --git a/src/bin/coreutils/lib/realloc.c b/src/bin/coreutils/lib/realloc.c index b61c2ca829..36aeecc41b 100644 --- a/src/bin/coreutils/lib/realloc.c +++ b/src/bin/coreutils/lib/realloc.c @@ -1,6 +1,7 @@ /* realloc() function that is glibc compatible. - Copyright (C) 1997, 2003, 2004, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -71,7 +72,7 @@ rpl_realloc (void *p, size_t n) { #if GNULIB_REALLOC_GNU && !NEED_REALLOC_GNU && !SYSTEM_MALLOC_GLIBC_COMPATIBLE if (n == 0) - n = 1; + n = 1; #endif result = malloc (n); } diff --git a/src/bin/coreutils/lib/ref-add.sin b/src/bin/coreutils/lib/ref-add.sin index 222d752951..dbb61df3dc 100644 --- a/src/bin/coreutils/lib/ref-add.sin +++ b/src/bin/coreutils/lib/ref-add.sin @@ -1,6 +1,6 @@ # Add this package to a list of references stored in a text file. # -# Copyright (C) 2000 Free Software Foundation, Inc. +# Copyright (C) 2000, 2009, 2010 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/ref-del.sin b/src/bin/coreutils/lib/ref-del.sin index 1bf073e15e..4c31a6eafd 100644 --- a/src/bin/coreutils/lib/ref-del.sin +++ b/src/bin/coreutils/lib/ref-del.sin @@ -1,6 +1,6 @@ # Remove this package from a list of references stored in a text file. # -# Copyright (C) 2000 Free Software Foundation, Inc. +# Copyright (C) 2000, 2009, 2010 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/regcomp.c b/src/bin/coreutils/lib/regcomp.c index 20904f094e..18db275790 100644 --- a/src/bin/coreutils/lib/regcomp.c +++ b/src/bin/coreutils/lib/regcomp.c @@ -2,8 +2,8 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Extended regular expression matching and search library. - Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 - Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free + Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa . @@ -21,6 +21,8 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "intprops.h" +#include "verify.h" static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern, size_t length, reg_syntax_t syntax); static void re_compile_fastmap_iter (regex_t *bufp, @@ -386,7 +388,7 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state, applies to multibyte character sets; for single byte character sets, the SIMPLE_BRACKET again suffices. */ if (dfa->mb_cur_max > 1 - && (cset->nchar_classes || cset->non_match + && (cset->nchar_classes || cset->non_match || cset->nranges # ifdef _LIBC || cset->nequiv_classes # endif /* _LIBC */ @@ -544,7 +546,7 @@ regerror (errcode, preg, errbuf, errbuf_size) size_t errbuf_size; #else /* size_t might promote */ size_t -regerror (int errcode, const regex_t *_Restrict_ preg, +regerror (int errcode, const regex_t *_Restrict_ preg _UNUSED_PARAMETER_, char *_Restrict_ errbuf, size_t errbuf_size) #endif { @@ -853,6 +855,9 @@ static reg_errcode_t init_dfa (re_dfa_t *dfa, size_t pat_len) { __re_size_t table_size; +#ifndef _LIBC + char *codeset_name; +#endif #ifdef RE_ENABLE_I18N size_t max_i18n_object_size = MAX (sizeof (wchar_t), sizeof (wctype_t)); #else @@ -896,7 +901,9 @@ init_dfa (re_dfa_t *dfa, size_t pat_len) dfa->map_notascii = (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_TO_NONASCII) != 0); #else - if (strcmp (locale_charset (), "UTF-8") == 0) + codeset_name = nl_langinfo (CODESET); + if (strcasecmp (codeset_name, "UTF-8") == 0 + || strcasecmp (codeset_name, "UTF8") == 0) dfa->is_utf8 = 1; /* We check exhaustively in the loop below if this charset is a @@ -1378,7 +1385,7 @@ calc_first (void *extra, bin_tree_t *node) /* Pass 2: compute NEXT on the tree. Preorder visit. */ static reg_errcode_t -calc_next (void *extra, bin_tree_t *node) +calc_next (void *extra _UNUSED_PARAMETER_, bin_tree_t *node) { switch (node->token.type) { @@ -1501,7 +1508,6 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node, destination. */ org_dest = dfa->edests[org_node].elems[0]; re_node_set_empty (dfa->edests + clone_node); - clone_dest = search_duplicated_node (dfa, org_dest, constraint); /* If the node is root_node itself, it means the epsilon closure has a loop. Then tie it to the destination of the root_node. */ if (org_node == root_node && clone_node != org_node) @@ -1545,7 +1551,7 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node, } else { - /* There is a duplicated node which satisfy the constraint, + /* There is a duplicated node which satisfies the constraint, use it to avoid infinite loop. */ ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); if (BE (! ok, 0)) @@ -2518,7 +2524,8 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa, return elem; } - if (BE (end != REG_MISSING && start > end, 0)) + if (BE ((end != REG_MISSING && start > end) + || token->type != OP_CLOSE_DUP_NUM, 0)) { /* First number greater than second. */ *err = REG_BADBR; @@ -2574,7 +2581,8 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa, /* This loop is actually executed only when end != REG_MISSING, to rewrite {0,n} as ((...?)?)?... We have already created the start+1-th copy. */ - if ((Idx) -1 < 0 || end != REG_MISSING) + verify (! TYPE_SIGNED (Idx)); + if (end != REG_MISSING) for (i = start + 2; i <= end; ++i) { elem = duplicate_tree (elem, dfa); @@ -2734,7 +2742,8 @@ static reg_errcode_t internal_function build_collating_symbol (bitset_t sbcset, # ifdef RE_ENABLE_I18N - re_charset_t *mbcset, Idx *coll_sym_alloc, + re_charset_t *mbcset _UNUSED_PARAMETER_, + Idx *coll_sym_alloc _UNUSED_PARAMETER_, # endif const unsigned char *name) { @@ -2802,7 +2811,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, return elem; } - /* Local function for parse_bracket_exp used in _LIBC environement. + /* Local function for parse_bracket_exp used in _LIBC environment. Look up the collation sequence value of BR_ELEM. Return the value if succeeded, UINT_MAX otherwise. */ @@ -2826,7 +2835,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, } else if (br_elem->type == MB_CHAR) { - return __collseq_table_lookup (collseqwc, br_elem->opr.wch); + if (nrules != 0) + return __collseq_table_lookup (collseqwc, br_elem->opr.wch); } else if (br_elem->type == COLL_SYM) { @@ -3312,7 +3322,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, static reg_errcode_t parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp, - re_token_t *token, int token_len, re_dfa_t *dfa, + re_token_t *token, int token_len, + re_dfa_t *dfa _UNUSED_PARAMETER_, reg_syntax_t syntax, bool accept_hyphen) { #ifdef RE_ENABLE_I18N @@ -3399,8 +3410,9 @@ parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp, static reg_errcode_t #ifdef RE_ENABLE_I18N -build_equiv_class (bitset_t sbcset, re_charset_t *mbcset, - Idx *equiv_class_alloc, const unsigned char *name) +build_equiv_class (bitset_t sbcset, re_charset_t *mbcset _UNUSED_PARAMETER_, + Idx *equiv_class_alloc _UNUSED_PARAMETER_, + const unsigned char *name) #else /* not RE_ENABLE_I18N */ build_equiv_class (bitset_t sbcset, const unsigned char *name) #endif /* not RE_ENABLE_I18N */ @@ -3433,7 +3445,7 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name) /* Build single byte matcing table for this equivalence class. */ char_buf[1] = (unsigned char) '\0'; - len = weights[idx1]; + len = weights[idx1 & 0xffffff]; for (ch = 0; ch < SBC_MAX; ++ch) { char_buf[0] = ch; @@ -3445,11 +3457,15 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name) if (idx2 == 0) /* This isn't a valid character. */ continue; - if (len == weights[idx2]) + /* Compare only if the length matches and the collation rule + index is the same. */ + if (len == weights[idx2 & 0xffffff] && (idx1 >> 24) == (idx2 >> 24)) { int cnt = 0; + while (cnt <= len && - weights[idx1 + 1 + cnt] == weights[idx2 + 1 + cnt]) + weights[(idx1 & 0xffffff) + 1 + cnt] + == weights[(idx2 & 0xffffff) + 1 + cnt]) ++cnt; if (cnt > len) @@ -3801,7 +3817,7 @@ free_token (re_token_t *node) and its children. */ static reg_errcode_t -free_tree (void *extra, bin_tree_t *node) +free_tree (void *extra _UNUSED_PARAMETER_, bin_tree_t *node) { free_token (&node->token); return REG_NOERROR; diff --git a/src/bin/coreutils/lib/regex.c b/src/bin/coreutils/lib/regex.c index 822b925338..b0e5d0bdf1 100644 --- a/src/bin/coreutils/lib/regex.c +++ b/src/bin/coreutils/lib/regex.c @@ -2,7 +2,8 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Extended regular expression matching and search library. - Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2005, 2006, 2009, 2010 Free Software Foundation, + Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa . diff --git a/src/bin/coreutils/lib/regex.h b/src/bin/coreutils/lib/regex.h index 40de1ff40a..aa144d5a1a 100644 --- a/src/bin/coreutils/lib/regex.h +++ b/src/bin/coreutils/lib/regex.h @@ -3,8 +3,9 @@ #line 1 /* Definitions for data structures and routines for the regular expression library. - Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005,2006 - Free Software Foundation, Inc. + Copyright (C) 1985, 1989, 1990, 1991, 1992, 1993, 1995, 1996, 1997, 1998, + 2000, 2001, 2002, 2003, 2005, 2006, 2009, 2010 Free Software Foundation, + Inc. This file is part of the GNU C Library. This program is free software; you can redistribute it and/or modify diff --git a/src/bin/coreutils/lib/regex_internal.c b/src/bin/coreutils/lib/regex_internal.c index 5b96537168..088ecf67a9 100644 --- a/src/bin/coreutils/lib/regex_internal.c +++ b/src/bin/coreutils/lib/regex_internal.c @@ -2,8 +2,8 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Extended regular expression matching and search library. - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 - Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free + Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa . @@ -21,6 +21,8 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "verify.h" +#include "intprops.h" static void re_string_construct_common (const char *str, Idx len, re_string_t *pstr, RE_TRANSLATE_TYPE trans, bool icase, @@ -1393,7 +1395,10 @@ static void internal_function re_node_set_remove_at (re_node_set *set, Idx idx) { - if (idx < 0 || idx >= set->nelem) + verify (! TYPE_SIGNED (Idx)); + /* if (idx < 0) + return; */ + if (idx >= set->nelem) return; --set->nelem; for (; idx < set->nelem; idx++) diff --git a/src/bin/coreutils/lib/regex_internal.h b/src/bin/coreutils/lib/regex_internal.h index 397f4e4fbf..3dd1d61249 100644 --- a/src/bin/coreutils/lib/regex_internal.h +++ b/src/bin/coreutils/lib/regex_internal.h @@ -2,8 +2,8 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Extended regular expression matching and search library. - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 - Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free + Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa . @@ -31,9 +31,8 @@ #include #include -#ifdef _LIBC -# include -#else +#include +#ifndef _LIBC # include "localcharset.h" #endif #if defined HAVE_LOCALE_H || defined _LIBC @@ -829,7 +828,8 @@ re_string_wchar_at (const re_string_t *pstr, Idx idx) static int internal_function __attribute ((pure)) -re_string_elem_size_at (const re_string_t *pstr, Idx idx) +re_string_elem_size_at (const re_string_t *pstr _UNUSED_PARAMETER_, + Idx idx _UNUSED_PARAMETER_) { # ifdef _LIBC const unsigned char *p, *extra; diff --git a/src/bin/coreutils/lib/regexec.c b/src/bin/coreutils/lib/regexec.c index bc11bab41f..0392d5a1fa 100644 --- a/src/bin/coreutils/lib/regexec.c +++ b/src/bin/coreutils/lib/regexec.c @@ -2,8 +2,8 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Extended regular expression matching and search library. - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 - Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free + Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa . @@ -21,6 +21,8 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "verify.h" +#include "intprops.h" static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags, Idx n) internal_function; static void match_ctx_clean (re_match_context_t *mctx) internal_function; @@ -381,8 +383,11 @@ re_search_2_stub (struct re_pattern_buffer *bufp, Idx len = length1 + length2; char *s = NULL; - if (BE (length1 < 0 || length2 < 0 || stop < 0 || len < length1, 0)) - return -2; + verify (! TYPE_SIGNED (Idx)); + if (BE (len < length1, 0)) + return -2; + /* if (BE (length1 < 0 || length2 < 0 || stop < 0, 0)) + return -2; */ /* Concatenate the strings. */ if (length2 > 0) @@ -434,11 +439,14 @@ re_search_stub (struct re_pattern_buffer *bufp, Idx last_start = start + range; /* Check for out-of-range. */ - if (BE (start < 0 || start > length, 0)) - return -1; + verify (! TYPE_SIGNED (Idx)); + /* if (BE (start < 0, 0)) + return -1; */ + if (BE (start > length, 0)) + return -1; if (BE (length < last_start || (0 <= range && last_start < start), 0)) last_start = length; - else if (BE (last_start < 0 || (range < 0 && start <= last_start), 0)) + else if (BE (/* last_start < 0 || */ (range < 0 && start <= last_start), 0)) last_start = 0; __libc_lock_lock (dfa->lock); @@ -3952,15 +3960,20 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx, _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB); indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB); - idx = findidx (&cp); + int32_t idx = findidx (&cp); if (idx > 0) for (i = 0; i < cset->nequiv_classes; ++i) { int32_t equiv_class_idx = cset->equiv_classes[i]; - size_t weight_len = weights[idx]; - if (weight_len == weights[equiv_class_idx]) + size_t weight_len = weights[idx & 0xffffff]; + if (weight_len == weights[equiv_class_idx & 0xffffff] + && (idx >> 24) == (equiv_class_idx >> 24)) { Idx cnt = 0; + + idx &= 0xffffff; + equiv_class_idx &= 0xffffff; + while (cnt <= weight_len && (weights[equiv_class_idx + 1 + cnt] == weights[idx + 1 + cnt])) diff --git a/src/bin/coreutils/lib/remove.c b/src/bin/coreutils/lib/remove.c new file mode 100644 index 0000000000..62e92da900 --- /dev/null +++ b/src/bin/coreutils/lib/remove.c @@ -0,0 +1,43 @@ +/* Remove a file or directory. + Copyright (C) 2009, 2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* written by Eric Blake */ + +#include + +#include + +#include +#include + +#undef remove + +/* Remove NAME from the file system. This works around C89 platforms + that don't handle directories like POSIX requires; it also works + around Solaris 9 bugs with trailing slash. */ +int +rpl_remove (char const *name) +{ + /* It is faster to just try rmdir, and fall back on unlink, than it + is to use lstat to see what we are about to remove. Technically, + it is more likely that we want unlink, not rmdir, but we cannot + guarantee the safety of unlink on directories. Trailing slash + bugs are handled by our rmdir and unlink wrappers. */ + int result = rmdir (name); + if (result && errno == ENOTDIR) + result = unlink (name); + return result; +} diff --git a/src/bin/coreutils/lib/rename-dest-slash.c b/src/bin/coreutils/lib/rename-dest-slash.c deleted file mode 100644 index 80660768a1..0000000000 --- a/src/bin/coreutils/lib/rename-dest-slash.c +++ /dev/null @@ -1,87 +0,0 @@ -/* A rename wrapper to make tools like mv -- that would normally rely - on the underlying rename syscall -- work more consistently. - On at least NetBSD 1.6, `rename ("dir", "B/")' fails when B doesn't - exist, whereas it succeeds on Linux-2.6.x and Solaris 10. This wrapper - provides an interface for systems like the former so that the tools - (namely mv) relying on the rename syscall have more consistent - semantics. - - Copyright (C) 2006 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* written by Jim Meyering */ - -#include -#undef rename - -#include -#include -#include - -#include -#include -#include - -#include "dirname.h" -#include "xalloc.h" - -static bool -has_trailing_slash (char const *file) -{ - /* Don't count "/", "//", etc., as having a trailing slash. */ - bool has_non_slash = false; - bool ends_in_slash = false; - - for (file += FILE_SYSTEM_PREFIX_LEN (file); *file; file++) - { - ends_in_slash = ISSLASH (*file); - has_non_slash |= ~ ends_in_slash; - } - - return has_non_slash & ends_in_slash; -} - -/* This is a rename wrapper for systems where the rename syscall - works differently than desired when SRC is a directory and DST does - not exist but is specified with a trailing slash. On NetBSD 6.1, - rename fails in that case. On Linux and Solaris systems, it succeeds. - This wrapper makes it succeed on NetBSD by running the originally - requested rename, and if it fails due to the above scenario, calling - it again with DST's trailing slashes removed. */ -int -rpl_rename_dest_slash (char const *src, char const *dst) -{ - int ret_val = rename (src, dst); - - if (ret_val != 0 && errno == ENOENT && has_trailing_slash (dst)) - { - int rename_errno = ENOENT; - - /* Fail now, unless SRC is a directory. */ - struct stat sb; - if (lstat (src, &sb) == 0 && S_ISDIR (sb.st_mode)) - { - char *dst_temp = xstrdup (dst); - strip_trailing_slashes (dst_temp); - ret_val = rename (src, dst_temp); - rename_errno = errno; - free (dst_temp); - } - - errno = rename_errno; - } - - return ret_val; -} diff --git a/src/bin/coreutils/lib/rename.c b/src/bin/coreutils/lib/rename.c index 5cd4dee9b0..ca3a6696c8 100644 --- a/src/bin/coreutils/lib/rename.c +++ b/src/bin/coreutils/lib/rename.c @@ -1,10 +1,6 @@ -/* Work around rename bugs in some systems. On SunOS 4.1.1_U1 - and mips-dec-ultrix4.4, rename fails when the source file has - a trailing slash. On mingw, rename fails when the destination - exists. +/* Work around rename bugs in some systems. - Copyright (C) 2001, 2002, 2003, 2005, 2006, 2009 Free Software - Foundation, Inc. + Copyright (C) 2001-2003, 2005-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -/* written by Volker Borchert */ +/* Written by Volker Borchert, Eric Blake. */ #include @@ -33,10 +29,16 @@ existing files. */ # include +# include +# include +# include +# include # define WIN32_LEAN_AND_MEAN # include +# include "dirname.h" + /* Rename the file SRC to DST. This replacement is necessary on Windows, on which the system rename function will not replace an existing DST. */ @@ -44,15 +46,140 @@ int rpl_rename (char const *src, char const *dst) { int error; + size_t src_len = strlen (src); + size_t dst_len = strlen (dst); + char *src_base = last_component (src); + char *dst_base = last_component (dst); + bool src_slash; + bool dst_slash; + bool dst_exists; + struct stat src_st; + struct stat dst_st; - /* MoveFileEx works if SRC is a directory without any flags, - but fails with MOVEFILE_REPLACE_EXISTING, so try without - flags first. */ + /* Filter out dot as last component. */ + if (!src_len || !dst_len) + { + errno = ENOENT; + return -1; + } + if (*src_base == '.') + { + size_t len = base_len (src_base); + if (len == 1 || (len == 2 && src_base[1] == '.')) + { + errno = EINVAL; + return -1; + } + } + if (*dst_base == '.') + { + size_t len = base_len (dst_base); + if (len == 1 || (len == 2 && dst_base[1] == '.')) + { + errno = EINVAL; + return -1; + } + } + + /* Presence of a trailing slash requires directory semantics. If + the source does not exist, or if the destination cannot be turned + into a directory, give up now. Otherwise, strip trailing slashes + before calling rename. There are no symlinks on mingw, so stat + works instead of lstat. */ + src_slash = ISSLASH (src[src_len - 1]); + dst_slash = ISSLASH (dst[dst_len - 1]); + if (stat (src, &src_st)) + return -1; + if (stat (dst, &dst_st)) + { + if (errno != ENOENT || (!S_ISDIR (src_st.st_mode) && dst_slash)) + return -1; + dst_exists = false; + } + else + { + if (S_ISDIR (dst_st.st_mode) != S_ISDIR (src_st.st_mode)) + { + errno = S_ISDIR (dst_st.st_mode) ? EISDIR : ENOTDIR; + return -1; + } + dst_exists = true; + } + + /* There are no symlinks, so if a file existed with a trailing + slash, it must be a directory, and we don't have to worry about + stripping strip trailing slash. However, mingw refuses to + replace an existing empty directory, so we have to help it out. + And canonicalize_file_name is not yet ported to mingw; however, + for directories, getcwd works as a viable alternative. Ensure + that we can get back to where we started before using it; later + attempts to return are fatal. Note that we can end up losing a + directory if rename then fails, but it was empty, so not much + damage was done. */ + if (dst_exists && S_ISDIR (dst_st.st_mode)) + { + char *cwd = getcwd (NULL, 0); + char *src_temp; + char *dst_temp; + if (!cwd || chdir (cwd)) + return -1; + if (IS_ABSOLUTE_FILE_NAME (src)) + { + dst_temp = chdir (dst) ? NULL : getcwd (NULL, 0); + src_temp = chdir (src) ? NULL : getcwd (NULL, 0); + } + else + { + src_temp = chdir (src) ? NULL : getcwd (NULL, 0); + if (!IS_ABSOLUTE_FILE_NAME (dst) && chdir (cwd)) + abort (); + dst_temp = chdir (dst) ? NULL : getcwd (NULL, 0); + } + if (chdir (cwd)) + abort (); + free (cwd); + if (!src_temp || !dst_temp) + { + free (src_temp); + free (dst_temp); + errno = ENOMEM; + return -1; + } + src_len = strlen (src_temp); + if (strncmp (src_temp, dst_temp, src_len) == 0 + && (ISSLASH (dst_temp[src_len]) || dst_temp[src_len] == '\0')) + { + error = dst_temp[src_len]; + free (src_temp); + free (dst_temp); + if (error) + { + errno = EINVAL; + return -1; + } + return 0; + } + if (rmdir (dst)) + { + error = errno; + free (src_temp); + free (dst_temp); + errno = error; + return -1; + } + free (src_temp); + free (dst_temp); + } + + /* MoveFileEx works if SRC is a directory without any flags, but + fails with MOVEFILE_REPLACE_EXISTING, so try without flags first. + Thankfully, MoveFileEx handles hard links correctly, even though + rename() does not. */ if (MoveFileEx (src, dst, 0)) return 0; /* Retry with MOVEFILE_REPLACE_EXISTING if the move failed - * due to the destination already existing. */ + due to the destination already existing. */ error = GetLastError (); if (error == ERROR_FILE_EXISTS || error == ERROR_ALREADY_EXISTS) { @@ -120,7 +247,7 @@ rpl_rename (char const *src, char const *dst) break; # ifndef ERROR_FILE_TOO_LARGE -/* This value is documented but not defined in all versions of windows.h. */ +/* This value is documented but not defined in all versions of windows.h. */ # define ERROR_FILE_TOO_LARGE 223 # endif case ERROR_FILE_TOO_LARGE: @@ -137,40 +264,210 @@ rpl_rename (char const *src, char const *dst) #else /* ! W32 platform */ -# if RENAME_DEST_EXISTS_BUG -# error Please report your platform and this message to bug-gnulib@gnu.org. -# elif RENAME_TRAILING_SLASH_BUG -# include -# include -# include +# include +# include +# include +# include +# include +# include -# include "dirname.h" -# include "xalloc.h" +# include "dirname.h" +# include "same-inode.h" -/* Rename the file SRC to DST, removing any trailing - slashes from SRC. Needed for SunOS 4.1.1_U1. */ +/* Rename the file SRC to DST, fixing any trailing slash bugs. */ int rpl_rename (char const *src, char const *dst) { - char *src_temp; - int ret_val; - size_t s_len = strlen (src); + size_t src_len = strlen (src); + size_t dst_len = strlen (dst); + char *src_temp = (char *) src; + char *dst_temp = (char *) dst; + bool src_slash; + bool dst_slash; + bool dst_exists; + int ret_val = -1; + int rename_errno = ENOTDIR; + struct stat src_st; + struct stat dst_st; - if (s_len && src[s_len - 1] == '/') + if (!src_len || !dst_len) + return rename (src, dst); /* Let strace see the ENOENT failure. */ + +# if RENAME_DEST_EXISTS_BUG + { + char *src_base = last_component (src); + char *dst_base = last_component (dst); + if (*src_base == '.') + { + size_t len = base_len (src_base); + if (len == 1 || (len == 2 && src_base[1] == '.')) + { + errno = EINVAL; + return -1; + } + } + if (*dst_base == '.') + { + size_t len = base_len (dst_base); + if (len == 1 || (len == 2 && dst_base[1] == '.')) + { + errno = EINVAL; + return -1; + } + } + } +# endif /* RENAME_DEST_EXISTS_BUG */ + + src_slash = src[src_len - 1] == '/'; + dst_slash = dst[dst_len - 1] == '/'; + +# if !RENAME_HARD_LINK_BUG && !RENAME_DEST_EXISTS_BUG + /* If there are no trailing slashes, then trust the native + implementation unless we also suspect issues with hard link + detection or file/directory conflicts. */ + if (!src_slash && !dst_slash) + return rename (src, dst); +# endif /* !RENAME_HARD_LINK_BUG && !RENAME_DEST_EXISTS_BUG */ + + /* Presence of a trailing slash requires directory semantics. If + the source does not exist, or if the destination cannot be turned + into a directory, give up now. Otherwise, strip trailing slashes + before calling rename. */ + if (lstat (src, &src_st)) + return -1; + if (lstat (dst, &dst_st)) { - src_temp = xstrdup (src); - strip_trailing_slashes (src_temp); + if (errno != ENOENT || (!S_ISDIR (src_st.st_mode) && dst_slash)) + return -1; + dst_exists = false; } else - src_temp = (char *) src; + { + if (S_ISDIR (dst_st.st_mode) != S_ISDIR (src_st.st_mode)) + { + errno = S_ISDIR (dst_st.st_mode) ? EISDIR : ENOTDIR; + return -1; + } +# if RENAME_HARD_LINK_BUG + if (SAME_INODE (src_st, dst_st)) + return 0; +# endif /* RENAME_HARD_LINK_BUG */ + dst_exists = true; + } - ret_val = rename (src_temp, dst); +# if (RENAME_TRAILING_SLASH_SOURCE_BUG || RENAME_DEST_EXISTS_BUG \ + || RENAME_HARD_LINK_BUG) + /* If the only bug was that a trailing slash was allowed on a + non-existing file destination, as in Solaris 10, then we've + already covered that situation. But if there is any problem with + a trailing slash on an existing source or destination, as in + Solaris 9, or if a directory can overwrite a symlink, as on + Cygwin 1.5, or if directories cannot be created with trailing + slash, as on NetBSD 1.6, then we must strip the offending slash + and check that we have not encountered a symlink instead of a + directory. + Stripping a trailing slash interferes with POSIX semantics, where + rename behavior on a symlink with a trailing slash operates on + the corresponding target directory. We prefer the GNU semantics + of rejecting any use of a symlink with trailing slash, but do not + enforce them, since Solaris 10 is able to obey POSIX semantics + and there might be clients expecting it, as counter-intuitive as + those semantics are. + + Technically, we could also follow the POSIX behavior by chasing a + readlink trail, but that is harder to implement. */ + if (src_slash) + { + src_temp = strdup (src); + if (!src_temp) + { + /* Rather than rely on strdup-posix, we set errno ourselves. */ + rename_errno = ENOMEM; + goto out; + } + strip_trailing_slashes (src_temp); + if (lstat (src_temp, &src_st)) + { + rename_errno = errno; + goto out; + } + if (S_ISLNK (src_st.st_mode)) + goto out; + } + if (dst_slash) + { + dst_temp = strdup (dst); + if (!dst_temp) + { + rename_errno = ENOMEM; + goto out; + } + strip_trailing_slashes (dst_temp); + if (lstat (dst_temp, &dst_st)) + { + if (errno != ENOENT) + { + rename_errno = errno; + goto out; + } + } + else if (S_ISLNK (dst_st.st_mode)) + goto out; + } +# endif /* RENAME_TRAILING_SLASH_SOURCE_BUG || RENAME_DEST_EXISTS_BUG + || RENAME_HARD_LINK_BUG */ + +# if RENAME_DEST_EXISTS_BUG + /* Cygwin 1.5 sometimes behaves oddly when moving a non-empty + directory on top of an empty one (the old directory name can + reappear if the new directory tree is removed). Work around this + by removing the target first, but don't remove the target if it + is a subdirectory of the source. Note that we can end up losing + a directory if rename then fails, but it was empty, so not much + damage was done. */ + if (dst_exists && S_ISDIR (dst_st.st_mode)) + { + if (src_st.st_dev != dst_st.st_dev) + { + rename_errno = EXDEV; + goto out; + } + if (src_temp != src) + free (src_temp); + src_temp = canonicalize_file_name (src); + if (dst_temp != dst) + free (dst_temp); + dst_temp = canonicalize_file_name (dst); + if (!src_temp || !dst_temp) + { + rename_errno = ENOMEM; + goto out; + } + src_len = strlen (src_temp); + if (strncmp (src_temp, dst_temp, src_len) == 0 + && dst_temp[src_len] == '/') + { + rename_errno = EINVAL; + goto out; + } + if (rmdir (dst)) + { + rename_errno = errno; + goto out; + } + } +# endif /* RENAME_DEST_EXISTS_BUG */ + + ret_val = rename (src_temp, dst_temp); + rename_errno = errno; + out: if (src_temp != src) free (src_temp); - + if (dst_temp != dst) + free (dst_temp); + errno = rename_errno; return ret_val; } -# endif /* RENAME_TRAILING_SLASH_BUG */ #endif /* ! W32 platform */ diff --git a/src/bin/coreutils/lib/rmdir.c b/src/bin/coreutils/lib/rmdir.c index 113d13c714..36a61180d4 100644 --- a/src/bin/coreutils/lib/rmdir.c +++ b/src/bin/coreutils/lib/rmdir.c @@ -1,7 +1,7 @@ -/* BSD compatible remove directory function for System V +/* Work around rmdir bugs. - Copyright (C) 1988, 1990, 1999, 2003, 2004, 2005, 2006 Free - Software Foundation, Inc. + Copyright (C) 1988, 1990, 1999, 2003-2006, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,24 +18,49 @@ #include -#include -#include -#include +#include -/* rmdir adapted from GNU tar. */ +#include +#include +#include +#include + +#undef rmdir /* Remove directory DIR. Return 0 if successful, -1 if not. */ int -rmdir (char const *dir) +rpl_rmdir (char const *dir) { +#if HAVE_RMDIR + /* Work around cygwin 1.5.x bug where rmdir("dir/./") succeeds. */ + size_t len = strlen (dir); + int result; + while (len && ISSLASH (dir[len - 1])) + len--; + if (len && dir[len - 1] == '.' && (1 == len || ISSLASH (dir[len - 2]))) + { + errno = EINVAL; + return -1; + } + result = rmdir (dir); + /* Work around mingw bug, where rmdir("file/") fails with EINVAL + instead of ENOTDIR. We've already filtered out trailing ., the + only reason allowed by POSIX for EINVAL. */ + if (result == -1 && errno == EINVAL) + errno = ENOTDIR; + return result; + +#else /* !HAVE_RMDIR */ + /* rmdir adapted from GNU tar. FIXME: Delete this implementation in + 2010 if no one reports a system with missing rmdir. */ pid_t cpid; int status; struct stat statbuf; if (stat (dir, &statbuf) != 0) - return -1; /* errno already set */ + return -1; /* errno already set */ if (!S_ISDIR (statbuf.st_mode)) { @@ -46,28 +71,29 @@ rmdir (char const *dir) cpid = fork (); switch (cpid) { - case -1: /* cannot fork */ - return -1; /* errno already set */ + case -1: /* cannot fork */ + return -1; /* errno already set */ - case 0: /* child process */ + case 0: /* child process */ execl ("/bin/rmdir", "rmdir", dir, (char *) 0); _exit (1); - default: /* parent process */ + default: /* parent process */ /* Wait for kid to finish. */ while (wait (&status) != cpid) - /* Do nothing. */ ; + /* Do nothing. */ ; if (status) - { + { - /* /bin/rmdir failed. */ + /* /bin/rmdir failed. */ - errno = EIO; - return -1; - } + errno = EIO; + return -1; + } return 0; } +#endif /* !HAVE_RMDIR */ } diff --git a/src/bin/coreutils/lib/root-dev-ino.c b/src/bin/coreutils/lib/root-dev-ino.c index eb50cf8de1..7483336b13 100644 --- a/src/bin/coreutils/lib/root-dev-ino.c +++ b/src/bin/coreutils/lib/root-dev-ino.c @@ -1,5 +1,5 @@ /* root-dev-ino.c -- get the device and inode numbers for `/'. - Copyright (C) 2003, 2005, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2003, 2005-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/root-dev-ino.h b/src/bin/coreutils/lib/root-dev-ino.h index bec27f0aeb..3c4b45864d 100644 --- a/src/bin/coreutils/lib/root-dev-ino.h +++ b/src/bin/coreutils/lib/root-dev-ino.h @@ -1,6 +1,6 @@ /* Root device and inode number checking. - Copyright (C) 2003, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2003, 2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/rpmatch.c b/src/bin/coreutils/lib/rpmatch.c index 217e1710a2..e6a1fc76b5 100644 --- a/src/bin/coreutils/lib/rpmatch.c +++ b/src/bin/coreutils/lib/rpmatch.c @@ -1,7 +1,7 @@ /* Determine whether string value is affirmation or negative response according to current locale's data. - Copyright (C) 1996, 1998, 2000, 2002, 2003, 2006-2008 Free Software + Copyright (C) 1996, 1998, 2000, 2002-2003, 2006-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -43,7 +43,7 @@ The resulting string may only be used until the next nl_langinfo call. */ static const char * localized_pattern (const char *english_pattern, nl_item nl_index, - bool posixly_correct) + bool posixly_correct) { const char *translated_pattern; @@ -65,7 +65,7 @@ localized_pattern (const char *english_pattern, nl_item nl_index, translated_pattern = nl_langinfo (nl_index); /* Check against a broken system return value. */ if (translated_pattern != NULL && translated_pattern[0] != '\0') - return translated_pattern; + return translated_pattern; } /* Look in the gnulib message catalog. */ @@ -73,11 +73,11 @@ localized_pattern (const char *english_pattern, nl_item nl_index, if (translated_pattern == english_pattern) { /* The gnulib message catalog provides no translation. - Try the system's message catalog. */ + Try the system's message catalog. */ translated_pattern = nl_langinfo (nl_index); /* Check against a broken system return value. */ if (translated_pattern != NULL && translated_pattern[0] != '\0') - return translated_pattern; + return translated_pattern; /* Fall back to English. */ translated_pattern = english_pattern; } @@ -97,20 +97,20 @@ try (const char *response, const char *pattern, char **lastp, regex_t *re) /* The pattern has changed. */ if (*lastp != NULL) - { - /* Free the old compiled pattern. */ - regfree (re); - free (*lastp); - *lastp = NULL; - } + { + /* Free the old compiled pattern. */ + regfree (re); + free (*lastp); + *lastp = NULL; + } /* Put the PATTERN into safe memory before calling regcomp. - (regcomp may call nl_langinfo, overwriting PATTERN's storage. */ + (regcomp may call nl_langinfo, overwriting PATTERN's storage. */ safe_pattern = strdup (pattern); if (safe_pattern == NULL) - return -1; + return -1; /* Compile the pattern and cache it for future runs. */ if (regcomp (re, safe_pattern, REG_EXTENDED) != 0) - return -1; + return -1; *lastp = safe_pattern; } @@ -168,6 +168,6 @@ rpmatch (const char *response) #else /* Test against "^[yY]" and "^[nN]", hardcoded to avoid requiring regex */ return (*response == 'y' || *response == 'Y' ? 1 - : *response == 'n' || *response == 'N' ? 0 : -1); + : *response == 'n' || *response == 'N' ? 0 : -1); #endif } diff --git a/src/bin/coreutils/lib/safe-read.c b/src/bin/coreutils/lib/safe-read.c index 0cb1edee8b..855be677aa 100644 --- a/src/bin/coreutils/lib/safe-read.c +++ b/src/bin/coreutils/lib/safe-read.c @@ -1,7 +1,7 @@ /* An interface to read and write that retries after interrupts. - Copyright (C) 1993, 1994, 1998, 2002, 2003, 2004, 2005, 2006 Free - Software Foundation, Inc. + Copyright (C) 1993-1994, 1998, 2002-2006, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -66,12 +66,12 @@ safe_rw (int fd, void const *buf, size_t count) ssize_t result = rw (fd, buf, count); if (0 <= result) - return result; + return result; else if (IS_EINTR (errno)) - continue; + continue; else if (errno == EINVAL && BUGGY_READ_MAXIMUM < count) - count = BUGGY_READ_MAXIMUM; + count = BUGGY_READ_MAXIMUM; else - return result; + return result; } } diff --git a/src/bin/coreutils/lib/safe-read.h b/src/bin/coreutils/lib/safe-read.h index ba191713b6..1f15b01826 100644 --- a/src/bin/coreutils/lib/safe-read.h +++ b/src/bin/coreutils/lib/safe-read.h @@ -1,5 +1,5 @@ /* An interface to read() that retries after interrupts. - Copyright (C) 2002, 2006 Free Software Foundation, Inc. + Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/safe-write.c b/src/bin/coreutils/lib/safe-write.c index b644f7cff3..a2c3b4df1d 100644 --- a/src/bin/coreutils/lib/safe-write.c +++ b/src/bin/coreutils/lib/safe-write.c @@ -1,5 +1,5 @@ /* An interface to write that retries after interrupts. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/safe-write.h b/src/bin/coreutils/lib/safe-write.h index da036a97a1..185f660301 100644 --- a/src/bin/coreutils/lib/safe-write.h +++ b/src/bin/coreutils/lib/safe-write.h @@ -1,5 +1,5 @@ /* An interface to write() that retries after interrupts. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/same-inode.h b/src/bin/coreutils/lib/same-inode.h index 063271174c..e978abbe30 100644 --- a/src/bin/coreutils/lib/same-inode.h +++ b/src/bin/coreutils/lib/same-inode.h @@ -1,6 +1,6 @@ /* Determine whether two stat buffers refer to the same file. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/same.c b/src/bin/coreutils/lib/same.c index af3a95efb7..1abc55c880 100644 --- a/src/bin/coreutils/lib/same.c +++ b/src/bin/coreutils/lib/same.c @@ -1,7 +1,6 @@ /* Determine whether two file names refer to the same file. - Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006 Free - Software Foundation, Inc. + Copyright (C) 1997-2000, 2002-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -40,7 +39,6 @@ #include "dirname.h" #include "error.h" #include "same-inode.h" -#include "xalloc.h" #ifndef MIN # define MIN(a, b) ((a) < (b) ? (a) : (b)) @@ -85,36 +83,36 @@ same_name (const char *source, const char *dest) dest_dirname = dir_name (dest); if (stat (source_dirname, &source_dir_stats)) - { - /* Shouldn't happen. */ - error (1, errno, "%s", source_dirname); - } + { + /* Shouldn't happen. */ + error (1, errno, "%s", source_dirname); + } if (stat (dest_dirname, &dest_dir_stats)) - { - /* Shouldn't happen. */ - error (1, errno, "%s", dest_dirname); - } + { + /* Shouldn't happen. */ + error (1, errno, "%s", dest_dirname); + } same = SAME_INODE (source_dir_stats, dest_dir_stats); #if ! _POSIX_NO_TRUNC && HAVE_PATHCONF && defined _PC_NAME_MAX if (same && ! identical_basenames) - { - long name_max = (errno = 0, pathconf (dest_dirname, _PC_NAME_MAX)); - if (name_max < 0) - { - if (errno) - { - /* Shouldn't happen. */ - error (1, errno, "%s", dest_dirname); - } - same = false; - } - else - same = (name_max <= min_baselen - && memcmp (source_basename, dest_basename, name_max) == 0); - } + { + long name_max = (errno = 0, pathconf (dest_dirname, _PC_NAME_MAX)); + if (name_max < 0) + { + if (errno) + { + /* Shouldn't happen. */ + error (1, errno, "%s", dest_dirname); + } + same = false; + } + else + same = (name_max <= min_baselen + && memcmp (source_basename, dest_basename, name_max) == 0); + } #endif free (source_dirname); diff --git a/src/bin/coreutils/lib/same.h b/src/bin/coreutils/lib/same.h index 56e51cffc1..39d708cd15 100644 --- a/src/bin/coreutils/lib/same.h +++ b/src/bin/coreutils/lib/same.h @@ -1,7 +1,6 @@ /* Determine whether two file names refer to the same file. - Copyright (C) 1997, 1998, 1999, 2000, 2003, 2004 Free Software - Foundation, Inc. + Copyright (C) 1997-2000, 2003-2004, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/save-cwd.c b/src/bin/coreutils/lib/save-cwd.c index e158e8b6b2..7394d50acc 100644 --- a/src/bin/coreutils/lib/save-cwd.c +++ b/src/bin/coreutils/lib/save-cwd.c @@ -1,7 +1,7 @@ /* save-cwd.c -- Save and restore current working directory. - Copyright (C) 1995, 1997, 1998, 2003, 2004, 2005, 2006 Free - Software Foundation, Inc. + Copyright (C) 1995, 1997-1998, 2003-2006, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,15 +23,21 @@ #include "save-cwd.h" #include +#include #include #include #include -#include #include "chdir-long.h" -#include "fcntl--.h" +#include "unistd--.h" #include "xgetcwd.h" +#if GNULIB_FCNTL_SAFER +# include "fcntl--.h" +#else +# define GNULIB_FCNTL_SAFER 0 +#endif + /* On systems without the fchdir function (WOE), pretend that open always returns -1 so that save_cwd resorts to using xgetcwd. Since chdir_long requires fchdir, use chdir instead. */ @@ -70,6 +76,8 @@ save_cwd (struct saved_cwd *cwd) cwd->name = NULL; cwd->desc = open (".", O_RDONLY); + if (!GNULIB_FCNTL_SAFER) + cwd->desc = fd_safer (cwd->desc); if (cwd->desc < 0) { cwd->name = xgetcwd (); diff --git a/src/bin/coreutils/lib/save-cwd.h b/src/bin/coreutils/lib/save-cwd.h index e23eb725fd..955f846e61 100644 --- a/src/bin/coreutils/lib/save-cwd.h +++ b/src/bin/coreutils/lib/save-cwd.h @@ -1,6 +1,7 @@ /* Save and restore current working directory. - Copyright (C) 1995, 1997, 1998, 2003 Free Software Foundation, Inc. + Copyright (C) 1995, 1997-1998, 2003, 2009-2010 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/savedir.c b/src/bin/coreutils/lib/savedir.c index 5e69d386f3..538f397cb6 100644 --- a/src/bin/coreutils/lib/savedir.c +++ b/src/bin/coreutils/lib/savedir.c @@ -1,7 +1,7 @@ /* savedir.c -- save the list of files in a directory in a string - Copyright (C) 1990, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, - 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 1990, 1997-2001, 2003-2006, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,7 +28,7 @@ #include "dirent--.h" #ifndef _D_EXACT_NAMLEN -# define _D_EXACT_NAMLEN(dp) strlen ((dp)->d_name) +# define _D_EXACT_NAMLEN(dp) strlen ((dp)->d_name) #endif #include @@ -68,31 +68,31 @@ savedirstream (DIR *dirp) errno = 0; dp = readdir (dirp); if (! dp) - break; + break; /* Skip "", ".", and "..". "" is returned by at least one buggy implementation: Solaris 2.4 readdir on NFS file systems. */ entry = dp->d_name; if (entry[entry[0] != '.' ? 0 : entry[1] != '.' ? 1 : 2] != '\0') - { - size_t entry_size = _D_EXACT_NAMLEN (dp) + 1; - if (used + entry_size < used) - xalloc_die (); - if (allocated <= used + entry_size) - { - do - { - if (2 * allocated < allocated) - xalloc_die (); - allocated *= 2; - } - while (allocated <= used + entry_size); + { + size_t entry_size = _D_EXACT_NAMLEN (dp) + 1; + if (used + entry_size < used) + xalloc_die (); + if (allocated <= used + entry_size) + { + do + { + if (2 * allocated < allocated) + xalloc_die (); + allocated *= 2; + } + while (allocated <= used + entry_size); - name_space = xrealloc (name_space, allocated); - } - memcpy (name_space + used, entry, entry_size); - used += entry_size; - } + name_space = xrealloc (name_space, allocated); + } + memcpy (name_space + used, entry, entry_size); + used += entry_size; + } } name_space[used] = '\0'; save_errno = errno; diff --git a/src/bin/coreutils/lib/savedir.h b/src/bin/coreutils/lib/savedir.h index 0c696415b8..fb11f90b14 100644 --- a/src/bin/coreutils/lib/savedir.h +++ b/src/bin/coreutils/lib/savedir.h @@ -1,6 +1,7 @@ /* Save the list of files in a directory in a string. - Copyright (C) 1997, 1999, 2001, 2003, 2005 Free Software Foundation, Inc. + Copyright (C) 1997, 1999, 2001, 2003, 2005, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/savewd.c b/src/bin/coreutils/lib/savewd.c index f593f94677..e111207ba9 100644 --- a/src/bin/coreutils/lib/savewd.c +++ b/src/bin/coreutils/lib/savewd.c @@ -1,6 +1,6 @@ /* Save and restore the working directory, possibly using a child process. - Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 2006-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -45,38 +45,38 @@ savewd_save (struct savewd *wd) case INITIAL_STATE: /* Save the working directory, or prepare to fall back if possible. */ { - int fd = open_safer (".", O_RDONLY); - if (0 <= fd) - { - wd->state = FD_STATE; - wd->val.fd = fd; - break; - } - if (errno != EACCES && errno != ESTALE) - { - wd->state = ERROR_STATE; - wd->val.errnum = errno; - break; - } + int fd = open_safer (".", O_RDONLY); + if (0 <= fd) + { + wd->state = FD_STATE; + wd->val.fd = fd; + break; + } + if (errno != EACCES && errno != ESTALE) + { + wd->state = ERROR_STATE; + wd->val.errnum = errno; + break; + } } wd->state = FORKING_STATE; wd->val.child = -1; /* Fall through. */ case FORKING_STATE: if (wd->val.child < 0) - { - /* "Save" the initial working directory by forking a new - subprocess that will attempt all the work from the chdir - until until the next savewd_restore. */ - wd->val.child = fork (); - if (wd->val.child != 0) - { - if (0 < wd->val.child) - return true; - wd->state = ERROR_STATE; - wd->val.errnum = errno; - } - } + { + /* "Save" the initial working directory by forking a new + subprocess that will attempt all the work from the chdir + until until the next savewd_restore. */ + wd->val.child = fork (); + if (wd->val.child != 0) + { + if (0 < wd->val.child) + return true; + wd->state = ERROR_STATE; + wd->val.errnum = errno; + } + } break; case FD_STATE: @@ -94,7 +94,7 @@ savewd_save (struct savewd *wd) int savewd_chdir (struct savewd *wd, char const *dir, int options, - int open_result[2]) + int open_result[2]) { int fd = -1; int result = 0; @@ -105,50 +105,50 @@ savewd_chdir (struct savewd *wd, char const *dir, int options, || (options & (HAVE_WORKING_O_NOFOLLOW ? SAVEWD_CHDIR_NOFOLLOW : 0))) { fd = open (dir, - (O_RDONLY | O_DIRECTORY | O_NOCTTY | O_NONBLOCK - | (options & SAVEWD_CHDIR_NOFOLLOW ? O_NOFOLLOW : 0))); + (O_RDONLY | O_DIRECTORY | O_NOCTTY | O_NONBLOCK + | (options & SAVEWD_CHDIR_NOFOLLOW ? O_NOFOLLOW : 0))); if (open_result) - { - open_result[0] = fd; - open_result[1] = errno; - } + { + open_result[0] = fd; + open_result[1] = errno; + } if (fd < 0 && (errno != EACCES || (options & SAVEWD_CHDIR_READABLE))) - result = -1; + result = -1; } if (result == 0 && ! (0 <= fd && options & SAVEWD_CHDIR_SKIP_READABLE)) { if (savewd_save (wd)) - { - open_result = NULL; - result = -2; - } + { + open_result = NULL; + result = -2; + } else - { - result = (fd < 0 ? chdir (dir) : fchdir (fd)); + { + result = (fd < 0 ? chdir (dir) : fchdir (fd)); - if (result == 0) - switch (wd->state) - { - case FD_STATE: - wd->state = FD_POST_CHDIR_STATE; - break; + if (result == 0) + switch (wd->state) + { + case FD_STATE: + wd->state = FD_POST_CHDIR_STATE; + break; - case ERROR_STATE: - case FD_POST_CHDIR_STATE: - case FINAL_STATE: - break; + case ERROR_STATE: + case FD_POST_CHDIR_STATE: + case FINAL_STATE: + break; - case FORKING_STATE: - assert (wd->val.child == 0); - break; + case FORKING_STATE: + assert (wd->val.child == 0); + break; - default: - assert (false); - } - } + default: + assert (false); + } + } } if (0 <= fd && ! open_result) @@ -169,23 +169,23 @@ savewd_restore (struct savewd *wd, int status) case INITIAL_STATE: case FD_STATE: /* The working directory is the desired directory, so there's no - work to do. */ + work to do. */ break; case FD_POST_CHDIR_STATE: /* Restore the working directory using fchdir. */ if (fchdir (wd->val.fd) == 0) - { - wd->state = FD_STATE; - break; - } + { + wd->state = FD_STATE; + break; + } else - { - int chdir_errno = errno; - close (wd->val.fd); - wd->state = ERROR_STATE; - wd->val.errnum = chdir_errno; - } + { + int chdir_errno = errno; + close (wd->val.fd); + wd->state = ERROR_STATE; + wd->val.errnum = chdir_errno; + } /* Fall through. */ case ERROR_STATE: /* Report an error if asked to restore the working directory. */ @@ -194,21 +194,21 @@ savewd_restore (struct savewd *wd, int status) case FORKING_STATE: /* "Restore" the working directory by waiting for the subprocess - to finish. */ + to finish. */ { - pid_t child = wd->val.child; - if (child == 0) - _exit (status); - if (0 < child) - { - int child_status; - while (waitpid (child, &child_status, 0) < 0) - assert (errno == EINTR); - wd->val.child = -1; - if (! WIFEXITED (child_status)) - raise (WTERMSIG (child_status)); - return WEXITSTATUS (child_status); - } + pid_t child = wd->val.child; + if (child == 0) + _exit (status); + if (0 < child) + { + int child_status; + while (waitpid (child, &child_status, 0) < 0) + assert (errno == EINTR); + wd->val.child = -1; + if (! WIFEXITED (child_status)) + raise (WTERMSIG (child_status)); + return WEXITSTATUS (child_status); + } } break; @@ -262,8 +262,8 @@ savewd_delegating (struct savewd const *wd) int savewd_process_files (int n_files, char **file, - int (*act) (char *, struct savewd *, void *), - void *options) + int (*act) (char *, struct savewd *, void *), + void *options) { int i = 0; int last_relative; @@ -278,18 +278,18 @@ savewd_process_files (int n_files, char **file, for (; i < last_relative; i++) { if (! savewd_delegating (&wd)) - { - int s = act (file[i], &wd, options); - if (exit_status < s) - exit_status = s; - } + { + int s = act (file[i], &wd, options); + if (exit_status < s) + exit_status = s; + } if (! IS_ABSOLUTE_FILE_NAME (file[i + 1])) - { - int r = savewd_restore (&wd, exit_status); - if (exit_status < r) - exit_status = r; - } + { + int r = savewd_restore (&wd, exit_status); + if (exit_status < r) + exit_status = r; + } } savewd_finish (&wd); @@ -298,7 +298,7 @@ savewd_process_files (int n_files, char **file, { int s = act (file[i], &wd, options); if (exit_status < s) - exit_status = s; + exit_status = s; } return exit_status; diff --git a/src/bin/coreutils/lib/savewd.h b/src/bin/coreutils/lib/savewd.h index 0d293c941e..5ec703dbc5 100644 --- a/src/bin/coreutils/lib/savewd.h +++ b/src/bin/coreutils/lib/savewd.h @@ -1,6 +1,6 @@ /* Save and restore the working directory, possibly using a subprocess. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,29 +31,29 @@ struct savewd enum { /* This object has been created but does not yet represent - the working directory. */ + the working directory. */ INITIAL_STATE, /* val.fd is the original working directory's file descriptor. - It is still the working directory. */ + It is still the working directory. */ FD_STATE, /* Like FD_STATE, but the working directory has changed, so - restoring it will require a fchdir. */ + restoring it will require a fchdir. */ FD_POST_CHDIR_STATE, /* Fork and let the subprocess do the work. val.child is 0 in a - child, negative in a childless parent, and the child process - ID in a parent with a child. */ + child, negative in a childless parent, and the child process + ID in a parent with a child. */ FORKING_STATE, /* A serious problem argues against further efforts. val.errnum - contains the error number (e.g., EIO). */ + contains the error number (e.g., EIO). */ ERROR_STATE, /* savewd_finish has been called, so the application no longer - cares whether the working directory is saved, and there is no - more work to do. */ + cares whether the working directory is saved, and there is no + more work to do. */ FINAL_STATE } state; @@ -106,7 +106,7 @@ enum Return -2 if a subprocess was spun off to do the real work, -1 (setting errno) if unsuccessful, 0 if successful. */ int savewd_chdir (struct savewd *wd, char const *dir, int options, - int open_result[2]); + int open_result[2]); /* Restore the working directory from *WD. STATUS indicates the exit status corresponding to the work done since the last save; this is @@ -142,7 +142,7 @@ void savewd_finish (struct savewd *wd); Return the maximum exit status that any call to ACT returned, or EXIT_SUCCESS (i.e., 0) if no calls were made. */ int savewd_process_files (int n_files, char **file, - int (*act) (char *, struct savewd *, void *), - void *options); + int (*act) (char *, struct savewd *, void *), + void *options); #endif diff --git a/src/bin/coreutils/lib/se-context.in.h b/src/bin/coreutils/lib/se-context.in.h index 5eb95af22c..cb7419a568 100644 --- a/src/bin/coreutils/lib/se-context.in.h +++ b/src/bin/coreutils/lib/se-context.in.h @@ -3,24 +3,26 @@ # include -typedef int context_t; -static inline context_t context_new (char const *s _UNUSED_PARAMETER_) - { errno = ENOTSUP; return 0; } -static inline char *context_str (context_t con _UNUSED_PARAMETER_) - { errno = ENOTSUP; return (void *) 0; } -static inline void context_free (context_t c _UNUSED_PARAMETER_) {} +/* The definition of _GL_UNUSED_PARAMETER is copied here. */ -static inline int context_user_set (context_t sc _UNUSED_PARAMETER_, - char const *s _UNUSED_PARAMETER_) +typedef int context_t; +static inline context_t context_new (char const *s _GL_UNUSED_PARAMETER) + { errno = ENOTSUP; return 0; } +static inline char *context_str (context_t con _GL_UNUSED_PARAMETER) + { errno = ENOTSUP; return (void *) 0; } +static inline void context_free (context_t c _GL_UNUSED_PARAMETER) {} + +static inline int context_user_set (context_t sc _GL_UNUSED_PARAMETER, + char const *s _GL_UNUSED_PARAMETER) { errno = ENOTSUP; return -1; } -static inline int context_role_set (context_t sc _UNUSED_PARAMETER_, - char const *s _UNUSED_PARAMETER_) +static inline int context_role_set (context_t sc _GL_UNUSED_PARAMETER, + char const *s _GL_UNUSED_PARAMETER) { errno = ENOTSUP; return -1; } -static inline int context_range_set (context_t sc _UNUSED_PARAMETER_, - char const *s _UNUSED_PARAMETER_) +static inline int context_range_set (context_t sc _GL_UNUSED_PARAMETER, + char const *s _GL_UNUSED_PARAMETER) { errno = ENOTSUP; return -1; } -static inline int context_type_set (context_t sc _UNUSED_PARAMETER_, - char const *s _UNUSED_PARAMETER_) +static inline int context_type_set (context_t sc _GL_UNUSED_PARAMETER, + char const *s _GL_UNUSED_PARAMETER) { errno = ENOTSUP; return -1; } #endif diff --git a/src/bin/coreutils/lib/se-selinux.in.h b/src/bin/coreutils/lib/se-selinux.in.h index 25cbaaef7f..76f7c1bff5 100644 --- a/src/bin/coreutils/lib/se-selinux.in.h +++ b/src/bin/coreutils/lib/se-selinux.in.h @@ -1,58 +1,75 @@ -#ifndef SELINUX_SELINUX_H -# define SELINUX_SELINUX_H +#ifndef _GL_SELINUX_SELINUX_H +# define _GL_SELINUX_SELINUX_H -# include -# include +# if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +# endif + +# if HAVE_SELINUX_SELINUX_H + +#@INCLUDE_NEXT@ @NEXT_SELINUX_SELINUX_H@ + +# else + +# include +# include + +/* The definition of _GL_UNUSED_PARAMETER is copied here. */ typedef unsigned short security_class_t; -# define security_context_t char* -# define is_selinux_enabled() 0 +# define security_context_t char* +# define is_selinux_enabled() 0 -static inline int getcon (security_context_t *con _UNUSED_PARAMETER_) +static inline int getcon (security_context_t *con _GL_UNUSED_PARAMETER) { errno = ENOTSUP; return -1; } -static inline void freecon (security_context_t con _UNUSED_PARAMETER_) {} +static inline void freecon (security_context_t con _GL_UNUSED_PARAMETER) {} -static inline int getfscreatecon (security_context_t *con _UNUSED_PARAMETER_) +static inline int getfscreatecon (security_context_t *con _GL_UNUSED_PARAMETER) { errno = ENOTSUP; return -1; } -static inline int setfscreatecon (security_context_t con _UNUSED_PARAMETER_) +static inline int setfscreatecon (security_context_t con _GL_UNUSED_PARAMETER) { errno = ENOTSUP; return -1; } -static inline int matchpathcon (char const *s _UNUSED_PARAMETER_, - mode_t m _UNUSED_PARAMETER_, - security_context_t *con _UNUSED_PARAMETER_) +static inline int matchpathcon (char const *file _GL_UNUSED_PARAMETER, + mode_t m _GL_UNUSED_PARAMETER, + security_context_t *con _GL_UNUSED_PARAMETER) { errno = ENOTSUP; return -1; } -static inline int getfilecon (char const *s _UNUSED_PARAMETER_, - security_context_t *con _UNUSED_PARAMETER_) +static inline int getfilecon (char const *file _GL_UNUSED_PARAMETER, + security_context_t *con _GL_UNUSED_PARAMETER) { errno = ENOTSUP; return -1; } -static inline int lgetfilecon (char const *s _UNUSED_PARAMETER_, - security_context_t *con _UNUSED_PARAMETER_) +static inline int lgetfilecon (char const *file _GL_UNUSED_PARAMETER, + security_context_t *con _GL_UNUSED_PARAMETER) { errno = ENOTSUP; return -1; } -static inline int setfilecon (char const *s _UNUSED_PARAMETER_, - security_context_t con _UNUSED_PARAMETER_) +static inline int fgetfilecon (int fd, + security_context_t *con _GL_UNUSED_PARAMETER) { errno = ENOTSUP; return -1; } -static inline int lsetfilecon (char const *s _UNUSED_PARAMETER_, - security_context_t con _UNUSED_PARAMETER_) +static inline int setfilecon (char const *file _GL_UNUSED_PARAMETER, + security_context_t con _GL_UNUSED_PARAMETER) { errno = ENOTSUP; return -1; } -static inline int fsetfilecon (int fd _UNUSED_PARAMETER_, - security_context_t con _UNUSED_PARAMETER_) +static inline int lsetfilecon (char const *file _GL_UNUSED_PARAMETER, + security_context_t con _GL_UNUSED_PARAMETER) + { errno = ENOTSUP; return -1; } +static inline int fsetfilecon (int fd _GL_UNUSED_PARAMETER, + security_context_t con _GL_UNUSED_PARAMETER) { errno = ENOTSUP; return -1; } static inline int security_check_context - (security_context_t con _UNUSED_PARAMETER_) + (security_context_t con _GL_UNUSED_PARAMETER) { errno = ENOTSUP; return -1; } static inline int security_check_context_raw - (security_context_t con _UNUSED_PARAMETER_) + (security_context_t con _GL_UNUSED_PARAMETER) { errno = ENOTSUP; return -1; } -static inline int setexeccon (security_context_t con _UNUSED_PARAMETER_) +static inline int setexeccon (security_context_t con _GL_UNUSED_PARAMETER) { errno = ENOTSUP; return -1; } static inline int security_compute_create - (security_context_t scon _UNUSED_PARAMETER_, - security_context_t tcon _UNUSED_PARAMETER_, - security_class_t tclass _UNUSED_PARAMETER_, - security_context_t *newcon _UNUSED_PARAMETER_) + (security_context_t scon _GL_UNUSED_PARAMETER, + security_context_t tcon _GL_UNUSED_PARAMETER, + security_class_t tclass _GL_UNUSED_PARAMETER, + security_context_t *newcon _GL_UNUSED_PARAMETER) { errno = ENOTSUP; return -1; } static inline int matchpathcon_init_prefix - (char const *path _UNUSED_PARAMETER_, - char const *prefix _UNUSED_PARAMETER_) + (char const *path _GL_UNUSED_PARAMETER, + char const *prefix _GL_UNUSED_PARAMETER) { errno = ENOTSUP; return -1; } -#endif + +# endif +#endif /* _GL_SELINUX_SELINUX_H */ diff --git a/src/bin/coreutils/lib/select.c b/src/bin/coreutils/lib/select.c index 41bb35ba08..d398dc1bd3 100644 --- a/src/bin/coreutils/lib/select.c +++ b/src/bin/coreutils/lib/select.c @@ -4,7 +4,7 @@ /* Emulation for select(2) Contributed by Paolo Bonzini. - Copyright 2008-2009 Free Software Foundation, Inc. + Copyright 2008-2010 Free Software Foundation, Inc. This file is part of gnulib. @@ -74,10 +74,10 @@ typedef enum _FILE_INFORMATION_CLASS { } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS; typedef DWORD (WINAPI *PNtQueryInformationFile) - (HANDLE, IO_STATUS_BLOCK *, VOID *, ULONG, FILE_INFORMATION_CLASS); + (HANDLE, IO_STATUS_BLOCK *, VOID *, ULONG, FILE_INFORMATION_CLASS); #ifndef PIPE_BUF -#define PIPE_BUF 512 +#define PIPE_BUF 512 #endif #define IsConsoleHandle(h) (((long) (h) & 3) == 3) @@ -101,7 +101,7 @@ IsSocketHandle(HANDLE h) static int win32_poll_handle (HANDLE h, int fd, struct bitset *rbits, struct bitset *wbits, - struct bitset *xbits) + struct bitset *xbits) { BOOL read, write, except; int i, ret; @@ -123,78 +123,78 @@ win32_poll_handle (HANDLE h, int fd, struct bitset *rbits, struct bitset *wbits, case FILE_TYPE_PIPE: if (!once_only) - { - NtQueryInformationFile = (PNtQueryInformationFile) - GetProcAddress (GetModuleHandle ("ntdll.dll"), - "NtQueryInformationFile"); - once_only = TRUE; - } + { + NtQueryInformationFile = (PNtQueryInformationFile) + GetProcAddress (GetModuleHandle ("ntdll.dll"), + "NtQueryInformationFile"); + once_only = TRUE; + } if (PeekNamedPipe (h, NULL, 0, NULL, &avail, NULL) != 0) - { - if (avail) - read = TRUE; - } + { + if (avail) + read = TRUE; + } else - { - /* It was the write-end of the pipe. Check if it is writable. - If NtQueryInformationFile fails, optimistically assume the pipe is - writable. This could happen on Win9x, where NtQueryInformationFile - is not available, or if we inherit a pipe that doesn't permit - FILE_READ_ATTRIBUTES access on the write end (I think this should - not happen since WinXP SP2; WINE seems fine too). Otherwise, - ensure that enough space is available for atomic writes. */ + { + /* It was the write-end of the pipe. Check if it is writable. + If NtQueryInformationFile fails, optimistically assume the pipe is + writable. This could happen on Win9x, where NtQueryInformationFile + is not available, or if we inherit a pipe that doesn't permit + FILE_READ_ATTRIBUTES access on the write end (I think this should + not happen since WinXP SP2; WINE seems fine too). Otherwise, + ensure that enough space is available for atomic writes. */ memset (&iosb, 0, sizeof (iosb)); memset (&fpli, 0, sizeof (fpli)); if (!NtQueryInformationFile || NtQueryInformationFile (h, &iosb, &fpli, sizeof (fpli), - FilePipeLocalInformation) - || fpli.WriteQuotaAvailable >= PIPE_BUF - || (fpli.OutboundQuota < PIPE_BUF && - fpli.WriteQuotaAvailable == fpli.OutboundQuota)) - write = TRUE; - } + FilePipeLocalInformation) + || fpli.WriteQuotaAvailable >= PIPE_BUF + || (fpli.OutboundQuota < PIPE_BUF && + fpli.WriteQuotaAvailable == fpli.OutboundQuota)) + write = TRUE; + } break; case FILE_TYPE_CHAR: write = TRUE; if (!(rbits->in[fd / CHAR_BIT] & (1 << (fd & (CHAR_BIT - 1))))) - break; + break; ret = WaitForSingleObject (h, 0); if (ret == WAIT_OBJECT_0) { - if (!IsConsoleHandle (h)) - { - read = TRUE; - break; - } + if (!IsConsoleHandle (h)) + { + read = TRUE; + break; + } - nbuffer = avail = 0; - bRet = GetNumberOfConsoleInputEvents (h, &nbuffer); + nbuffer = avail = 0; + bRet = GetNumberOfConsoleInputEvents (h, &nbuffer); - /* Screen buffers handles are filtered earlier. */ - assert (bRet); - if (nbuffer == 0) - { - except = TRUE; - break; - } + /* Screen buffers handles are filtered earlier. */ + assert (bRet); + if (nbuffer == 0) + { + except = TRUE; + break; + } - irbuffer = (INPUT_RECORD *) alloca (nbuffer * sizeof (INPUT_RECORD)); - bRet = PeekConsoleInput (h, irbuffer, nbuffer, &avail); - if (!bRet || avail == 0) - { - except = TRUE; - break; - } + irbuffer = (INPUT_RECORD *) alloca (nbuffer * sizeof (INPUT_RECORD)); + bRet = PeekConsoleInput (h, irbuffer, nbuffer, &avail); + if (!bRet || avail == 0) + { + except = TRUE; + break; + } - for (i = 0; i < avail; i++) - if (irbuffer[i].EventType == KEY_EVENT) - read = TRUE; - } + for (i = 0; i < avail; i++) + if (irbuffer[i].EventType == KEY_EVENT) + read = TRUE; + } break; default: @@ -278,10 +278,10 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds, for (i = 0; i < rfds->fd_count; i++) { fd = rfds->fd_array[i]; - h = (HANDLE) _get_osfhandle (fd); - if (IsConsoleHandle (h) - && !GetNumberOfConsoleInputEvents (h, &nbuffer)) - continue; + h = (HANDLE) _get_osfhandle (fd); + if (IsConsoleHandle (h) + && !GetNumberOfConsoleInputEvents (h, &nbuffer)) + continue; rbits.in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1)); anyfds_in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1)); @@ -293,10 +293,10 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds, for (i = 0; i < wfds->fd_count; i++) { fd = wfds->fd_array[i]; - h = (HANDLE) _get_osfhandle (fd); - if (IsConsoleHandle (h) - && GetNumberOfConsoleInputEvents (h, &nbuffer)) - continue; + h = (HANDLE) _get_osfhandle (fd); + if (IsConsoleHandle (h) + && GetNumberOfConsoleInputEvents (h, &nbuffer)) + continue; wbits.in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1)); anyfds_in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1)); @@ -325,16 +325,14 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds, /* Classify handles. Create fd sets for sockets, poll the others. */ for (i = 0; i < nfds; i++) { - WSANETWORKEVENTS ev; - if ((anyfds_in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) == 0) - continue; + continue; h = (HANDLE) _get_osfhandle (i); if (!h) { - errno = EBADF; - return -1; + errno = EBADF; + return -1; } if (IsSocketHandle (h)) @@ -342,37 +340,37 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds, int requested = FD_CLOSE; /* See above; socket handles are mapped onto select, but we - need to map descriptors to handles. */ + need to map descriptors to handles. */ if (rbits.in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) - { + { requested |= FD_READ | FD_ACCEPT; - FD_SET ((SOCKET) h, rfds); - FD_SET ((SOCKET) h, &handle_rfds); - } + FD_SET ((SOCKET) h, rfds); + FD_SET ((SOCKET) h, &handle_rfds); + } if (wbits.in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) - { + { requested |= FD_WRITE | FD_CONNECT; - FD_SET ((SOCKET) h, wfds); - FD_SET ((SOCKET) h, &handle_wfds); - } + FD_SET ((SOCKET) h, wfds); + FD_SET ((SOCKET) h, &handle_wfds); + } if (xbits.in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) - { + { requested |= FD_OOB; - FD_SET ((SOCKET) h, xfds); - FD_SET ((SOCKET) h, &handle_xfds); - } + FD_SET ((SOCKET) h, xfds); + FD_SET ((SOCKET) h, &handle_xfds); + } WSAEventSelect ((SOCKET) h, hEvent, requested); - nsock++; + nsock++; } else { handle_array[nhandles++] = h; - /* Poll now. If we get an event, do not wait below. */ + /* Poll now. If we get an event, do not wait below. */ if (wait_timeout != 0 - && win32_poll_handle (h, i, &rbits, &wbits, &xbits)) - wait_timeout = 0; + && win32_poll_handle (h, i, &rbits, &wbits, &xbits)) + wait_timeout = 0; } } @@ -385,12 +383,12 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds, no need to call select again. */ rc = select (0, &handle_rfds, &handle_wfds, &handle_xfds, &tv0); if (rc == 0) - { - /* Restore the fd_sets for the other select we do below. */ + { + /* Restore the fd_sets for the other select we do below. */ memcpy (&handle_rfds, rfds, sizeof (fd_set)); memcpy (&handle_wfds, wfds, sizeof (fd_set)); memcpy (&handle_xfds, xfds, sizeof (fd_set)); - } + } else wait_timeout = 0; } @@ -398,20 +396,20 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds, for (;;) { ret = MsgWaitForMultipleObjects (nhandles, handle_array, FALSE, - wait_timeout, QS_ALLINPUT); + wait_timeout, QS_ALLINPUT); if (ret == WAIT_OBJECT_0 + nhandles) - { + { /* new input of some other kind */ - BOOL bRet; + BOOL bRet; while ((bRet = PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) != 0) { TranslateMessage (&msg); DispatchMessage (&msg); } - } + } else - break; + break; } /* If we haven't done it yet, check the status of the sockets. */ @@ -429,13 +427,13 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds, for (i = 0; i < nfds; i++) { if ((anyfds_in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) == 0) - continue; + continue; h = (HANDLE) _get_osfhandle (i); if (h != handle_array[nhandles]) - { - /* Perform handle->descriptor mapping. Don't update rc, as these - results are counted in the return value of Winsock's select. */ + { + /* Perform handle->descriptor mapping. Don't update rc, as these + results are counted in the return value of Winsock's select. */ WSAEventSelect ((SOCKET) h, NULL, 0); if (FD_ISSET (h, &handle_rfds)) FD_SET (i, rfds); @@ -443,7 +441,7 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds, FD_SET (i, wfds); if (FD_ISSET (h, &handle_xfds)) FD_SET (i, xfds); - } + } else { /* Not a socket. */ @@ -451,19 +449,19 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds, win32_poll_handle (h, i, &rbits, &wbits, &xbits); if (rbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) { - rc++; - FD_SET (i, rfds); - } + rc++; + FD_SET (i, rfds); + } if (wbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) { - rc++; - FD_SET (i, wfds); - } + rc++; + FD_SET (i, wfds); + } if (xbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) { - rc++; - FD_SET (i, xfds); - } + rc++; + FD_SET (i, xfds); + } } } diff --git a/src/bin/coreutils/lib/selinux-at.c b/src/bin/coreutils/lib/selinux-at.c index 65f938b412..beac4b08a2 100644 --- a/src/bin/coreutils/lib/selinux-at.c +++ b/src/bin/coreutils/lib/selinux-at.c @@ -1,5 +1,5 @@ /* openat-style fd-relative functions for SE Linux - Copyright (C) 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/selinux-at.h b/src/bin/coreutils/lib/selinux-at.h index 1d84c197ac..9931680e56 100644 --- a/src/bin/coreutils/lib/selinux-at.h +++ b/src/bin/coreutils/lib/selinux-at.h @@ -1,5 +1,5 @@ /* Prototypes for openat-style fd-relative SELinux functions - Copyright (C) 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/set-mode-acl.c b/src/bin/coreutils/lib/set-mode-acl.c index 34076db202..c5b4726e23 100644 --- a/src/bin/coreutils/lib/set-mode-acl.c +++ b/src/bin/coreutils/lib/set-mode-acl.c @@ -1,6 +1,6 @@ /* set-mode-acl.c - set access control list equivalent to a mode - Copyright (C) 2002-2003, 2005-2009 Free Software Foundation, Inc. + Copyright (C) 2002-2003, 2005-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -79,15 +79,15 @@ qset_acl (char const *name, int desc, mode_t mode) { acl = acl_from_mode (mode); if (!acl) - return -1; + return -1; } else /* FreeBSD, IRIX, Tru64 */ { /* If we were to create the ACL using the functions acl_init(), - acl_create_entry(), acl_set_tag_type(), acl_set_qualifier(), - acl_get_permset(), acl_clear_perm[s](), acl_add_perm(), we - would need to create a qualifier. I don't know how to do this. - So create it using acl_from_text(). */ + acl_create_entry(), acl_set_tag_type(), acl_set_qualifier(), + acl_get_permset(), acl_clear_perm[s](), acl_add_perm(), we + would need to create a qualifier. I don't know how to do this. + So create it using acl_from_text(). */ # if HAVE_ACL_FREE_TEXT /* Tru64 */ char acl_text[] = "u::---,g::---,o::---,"; @@ -107,7 +107,7 @@ qset_acl (char const *name, int desc, mode_t mode) acl = acl_from_text (acl_text); if (!acl) - return -1; + return -1; } if (HAVE_ACL_SET_FD && desc != -1) ret = acl_set_fd (desc, acl); @@ -119,12 +119,12 @@ qset_acl (char const *name, int desc, mode_t mode) acl_free (acl); if (ACL_NOT_WELL_SUPPORTED (errno)) - return chmod_or_fchmod (name, desc, mode); + return chmod_or_fchmod (name, desc, mode); else - { - errno = saved_errno; - return -1; - } + { + errno = saved_errno; + return -1; + } } else acl_free (acl); @@ -135,7 +135,7 @@ qset_acl (char const *name, int desc, mode_t mode) if (mode & (S_ISUID | S_ISGID | S_ISVTX)) { /* We did not call chmod so far, so the special bits have not yet - been set. */ + been set. */ return chmod_or_fchmod (name, desc, mode); } return 0; @@ -150,14 +150,14 @@ qset_acl (char const *name, int desc, mode_t mode) /* On MacOS X, acl_get_file (name, ACL_TYPE_ACCESS) and acl_get_file (name, ACL_TYPE_DEFAULT) always return NULL / EINVAL. You have to use - acl_get_file (name, ACL_TYPE_EXTENDED) + acl_get_file (name, ACL_TYPE_EXTENDED) or acl_get_fd (open (name, ...)) to retrieve an ACL. On the other hand, - acl_set_file (name, ACL_TYPE_ACCESS, acl) + acl_set_file (name, ACL_TYPE_ACCESS, acl) and acl_set_file (name, ACL_TYPE_DEFAULT, acl) have the same effect as - acl_set_file (name, ACL_TYPE_EXTENDED, acl): + acl_set_file (name, ACL_TYPE_EXTENDED, acl): Each of these calls sets the file's ACL. */ acl_t acl; @@ -174,27 +174,27 @@ qset_acl (char const *name, int desc, mode_t mode) acl = acl_init (0); if (acl) - { - if (HAVE_ACL_SET_FD && desc != -1) - ret = acl_set_fd (desc, acl); - else - ret = acl_set_file (name, ACL_TYPE_EXTENDED, acl); - if (ret != 0) - { - int saved_errno = errno; + { + if (HAVE_ACL_SET_FD && desc != -1) + ret = acl_set_fd (desc, acl); + else + ret = acl_set_file (name, ACL_TYPE_EXTENDED, acl); + if (ret != 0) + { + int saved_errno = errno; - acl_free (acl); + acl_free (acl); - if (ACL_NOT_WELL_SUPPORTED (saved_errno)) - return chmod_or_fchmod (name, desc, mode); - else - { - errno = saved_errno; - return -1; - } - } - acl_free (acl); - } + if (ACL_NOT_WELL_SUPPORTED (saved_errno)) + return chmod_or_fchmod (name, desc, mode); + else + { + errno = saved_errno; + return -1; + } + } + acl_free (acl); + } } /* Since !MODE_INSIDE_ACL, we have to call chmod explicitly. */ @@ -235,7 +235,7 @@ qset_acl (char const *name, int desc, mode_t mode) if (ret < 0) { if (saved_errno == ENOSYS || saved_errno == EOPNOTSUPP) - return chmod_or_fchmod (name, desc, mode); + return chmod_or_fchmod (name, desc, mode); errno = saved_errno; return -1; } @@ -243,7 +243,7 @@ qset_acl (char const *name, int desc, mode_t mode) if (mode & (S_ISUID | S_ISGID | S_ISVTX)) { /* We did not call chmod so far, so the special bits have not yet - been set. */ + been set. */ return chmod_or_fchmod (name, desc, mode); } return 0; @@ -268,41 +268,41 @@ qset_acl (char const *name, int desc, mode_t mode) for (;;) { - if (desc != -1) - count = facl (desc, ACE_GETACLCNT, 0, NULL); - else - count = acl (name, ACE_GETACLCNT, 0, NULL); - if (count <= 0) - { - convention = -1; - break; - } - entries = (ace_t *) malloc (count * sizeof (ace_t)); - if (entries == NULL) - { - errno = ENOMEM; - return -1; - } - if ((desc != -1 - ? facl (desc, ACE_GETACL, count, entries) - : acl (name, ACE_GETACL, count, entries)) - == count) - { - int i; + if (desc != -1) + count = facl (desc, ACE_GETACLCNT, 0, NULL); + else + count = acl (name, ACE_GETACLCNT, 0, NULL); + if (count <= 0) + { + convention = -1; + break; + } + entries = (ace_t *) malloc (count * sizeof (ace_t)); + if (entries == NULL) + { + errno = ENOMEM; + return -1; + } + if ((desc != -1 + ? facl (desc, ACE_GETACL, count, entries) + : acl (name, ACE_GETACL, count, entries)) + == count) + { + int i; - convention = 0; - for (i = 0; i < count; i++) - if (entries[i].a_flags & (ACE_OWNER | ACE_GROUP | ACE_OTHER)) - { - convention = 1; - break; - } - free (entries); - break; - } - /* Huh? The number of ACL entries changed since the last call. - Repeat. */ - free (entries); + convention = 0; + for (i = 0; i < count; i++) + if (entries[i].a_flags & (ACE_OWNER | ACE_GROUP | ACE_OTHER)) + { + convention = 1; + break; + } + free (entries); + break; + } + /* Huh? The number of ACL entries changed since the last call. + Repeat. */ + free (entries); } } @@ -312,58 +312,58 @@ qset_acl (char const *name, int desc, mode_t mode) int ret; if (convention) - { - /* Running on Solaris 10. */ - entries[0].a_type = ALLOW; - entries[0].a_flags = ACE_OWNER; - entries[0].a_who = 0; /* irrelevant */ - entries[0].a_access_mask = (mode >> 6) & 7; - entries[1].a_type = ALLOW; - entries[1].a_flags = ACE_GROUP; - entries[1].a_who = 0; /* irrelevant */ - entries[1].a_access_mask = (mode >> 3) & 7; - entries[2].a_type = ALLOW; - entries[2].a_flags = ACE_OTHER; - entries[2].a_who = 0; - entries[2].a_access_mask = mode & 7; - } + { + /* Running on Solaris 10. */ + entries[0].a_type = ALLOW; + entries[0].a_flags = ACE_OWNER; + entries[0].a_who = 0; /* irrelevant */ + entries[0].a_access_mask = (mode >> 6) & 7; + entries[1].a_type = ALLOW; + entries[1].a_flags = ACE_GROUP; + entries[1].a_who = 0; /* irrelevant */ + entries[1].a_access_mask = (mode >> 3) & 7; + entries[2].a_type = ALLOW; + entries[2].a_flags = ACE_OTHER; + entries[2].a_who = 0; + entries[2].a_access_mask = mode & 7; + } else - { - /* Running on Solaris 10 (newer version) or Solaris 11. */ - entries[0].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE; - entries[0].a_flags = NEW_ACE_OWNER; - entries[0].a_who = 0; /* irrelevant */ - entries[0].a_access_mask = - (mode & 0400 ? NEW_ACE_READ_DATA : 0) - | (mode & 0200 ? NEW_ACE_WRITE_DATA : 0) - | (mode & 0100 ? NEW_ACE_EXECUTE : 0); - entries[1].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE; - entries[1].a_flags = NEW_ACE_GROUP | NEW_ACE_IDENTIFIER_GROUP; - entries[1].a_who = 0; /* irrelevant */ - entries[1].a_access_mask = - (mode & 0040 ? NEW_ACE_READ_DATA : 0) - | (mode & 0020 ? NEW_ACE_WRITE_DATA : 0) - | (mode & 0010 ? NEW_ACE_EXECUTE : 0); - entries[2].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE; - entries[2].a_flags = ACE_EVERYONE; - entries[2].a_who = 0; - entries[2].a_access_mask = - (mode & 0004 ? NEW_ACE_READ_DATA : 0) - | (mode & 0002 ? NEW_ACE_WRITE_DATA : 0) - | (mode & 0001 ? NEW_ACE_EXECUTE : 0); - } + { + /* Running on Solaris 10 (newer version) or Solaris 11. */ + entries[0].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE; + entries[0].a_flags = NEW_ACE_OWNER; + entries[0].a_who = 0; /* irrelevant */ + entries[0].a_access_mask = + (mode & 0400 ? NEW_ACE_READ_DATA : 0) + | (mode & 0200 ? NEW_ACE_WRITE_DATA : 0) + | (mode & 0100 ? NEW_ACE_EXECUTE : 0); + entries[1].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE; + entries[1].a_flags = NEW_ACE_GROUP | NEW_ACE_IDENTIFIER_GROUP; + entries[1].a_who = 0; /* irrelevant */ + entries[1].a_access_mask = + (mode & 0040 ? NEW_ACE_READ_DATA : 0) + | (mode & 0020 ? NEW_ACE_WRITE_DATA : 0) + | (mode & 0010 ? NEW_ACE_EXECUTE : 0); + entries[2].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE; + entries[2].a_flags = ACE_EVERYONE; + entries[2].a_who = 0; + entries[2].a_access_mask = + (mode & 0004 ? NEW_ACE_READ_DATA : 0) + | (mode & 0002 ? NEW_ACE_WRITE_DATA : 0) + | (mode & 0001 ? NEW_ACE_EXECUTE : 0); + } if (desc != -1) - ret = facl (desc, ACE_SETACL, - sizeof (entries) / sizeof (ace_t), entries); + ret = facl (desc, ACE_SETACL, + sizeof (entries) / sizeof (ace_t), entries); else - ret = acl (name, ACE_SETACL, - sizeof (entries) / sizeof (ace_t), entries); + ret = acl (name, ACE_SETACL, + sizeof (entries) / sizeof (ace_t), entries); if (ret < 0 && errno != EINVAL && errno != ENOTSUP) - { - if (errno == ENOSYS) - return chmod_or_fchmod (name, desc, mode); - return -1; - } + { + if (errno == ENOSYS) + return chmod_or_fchmod (name, desc, mode); + return -1; + } } # endif @@ -387,16 +387,16 @@ qset_acl (char const *name, int desc, mode_t mode) ret = acl (name, SETACL, sizeof (entries) / sizeof (aclent_t), entries); if (ret < 0) { - if (errno == ENOSYS) - return chmod_or_fchmod (name, desc, mode); - return -1; + if (errno == ENOSYS) + return chmod_or_fchmod (name, desc, mode); + return -1; } } if (!MODE_INSIDE_ACL || (mode & (S_ISUID | S_ISGID | S_ISVTX))) { /* We did not call chmod so far, so the special bits have not yet - been set. */ + been set. */ return chmod_or_fchmod (name, desc, mode); } return 0; @@ -433,21 +433,124 @@ qset_acl (char const *name, int desc, mode_t mode) if (ret < 0) { if (errno == ENOSYS || errno == EOPNOTSUPP) - return chmod_or_fchmod (name, desc, mode); + return chmod_or_fchmod (name, desc, mode); return -1; } if (mode & (S_ISUID | S_ISGID | S_ISVTX)) { /* We did not call chmod so far, so the special bits have not yet - been set. */ + been set. */ return chmod_or_fchmod (name, desc, mode); } return 0; -# elif HAVE_ACLX_GET && 0 /* AIX */ +# elif HAVE_ACLX_GET && defined ACL_AIX_WIP /* AIX */ - /* TODO: use aclx_fput or aclx_put, respectively */ + acl_type_list_t types; + size_t types_size = sizeof (types); + acl_type_t type; + + if (aclx_gettypes (name, &types, &types_size) < 0 + || types.num_entries == 0) + return chmod_or_fchmod (name, desc, mode); + + /* XXX Do we need to clear all types of ACLs for the given file, or is it + sufficient to clear the first one? */ + type = types.entries[0]; + if (type.u64 == ACL_AIXC) + { + union { struct acl a; char room[128]; } u; + int ret; + + u.a.acl_len = (char *) &u.a.acl_ext[0] - (char *) &u.a; /* no entries */ + u.a.acl_mode = mode & ~(S_IXACL | 0777); + u.a.u_access = (mode >> 6) & 7; + u.a.g_access = (mode >> 3) & 7; + u.a.o_access = mode & 7; + + if (desc != -1) + ret = aclx_fput (desc, SET_ACL | SET_MODE_S_BITS, + type, &u.a, u.a.acl_len, mode); + else + ret = aclx_put (name, SET_ACL | SET_MODE_S_BITS, + type, &u.a, u.a.acl_len, mode); + if (!(ret < 0 && errno == ENOSYS)) + return ret; + } + else if (type.u64 == ACL_NFS4) + { + union { nfs4_acl_int_t a; char room[128]; } u; + nfs4_ace_int_t *ace; + int ret; + + u.a.aclVersion = NFS4_ACL_INT_STRUCT_VERSION; + u.a.aclEntryN = 0; + ace = &u.a.aclEntry[0]; + { + ace->flags = ACE4_ID_SPECIAL; + ace->aceWho.special_whoid = ACE4_WHO_OWNER; + ace->aceType = ACE4_ACCESS_ALLOWED_ACE_TYPE; + ace->aceFlags = 0; + ace->aceMask = + (mode & 0400 ? ACE4_READ_DATA | ACE4_LIST_DIRECTORY : 0) + | (mode & 0200 + ? ACE4_WRITE_DATA | ACE4_ADD_FILE | ACE4_APPEND_DATA + | ACE4_ADD_SUBDIRECTORY + : 0) + | (mode & 0100 ? ACE4_EXECUTE : 0); + ace->aceWhoString[0] = '\0'; + ace->entryLen = (char *) &ace->aceWhoString[4] - (char *) ace; + ace = (nfs4_ace_int_t *) (char *) &ace->aceWhoString[4]; + u.a.aclEntryN++; + } + { + ace->flags = ACE4_ID_SPECIAL; + ace->aceWho.special_whoid = ACE4_WHO_GROUP; + ace->aceType = ACE4_ACCESS_ALLOWED_ACE_TYPE; + ace->aceFlags = 0; + ace->aceMask = + (mode & 0040 ? ACE4_READ_DATA | ACE4_LIST_DIRECTORY : 0) + | (mode & 0020 + ? ACE4_WRITE_DATA | ACE4_ADD_FILE | ACE4_APPEND_DATA + | ACE4_ADD_SUBDIRECTORY + : 0) + | (mode & 0010 ? ACE4_EXECUTE : 0); + ace->aceWhoString[0] = '\0'; + ace->entryLen = (char *) &ace->aceWhoString[4] - (char *) ace; + ace = (nfs4_ace_int_t *) (char *) &ace->aceWhoString[4]; + u.a.aclEntryN++; + } + { + ace->flags = ACE4_ID_SPECIAL; + ace->aceWho.special_whoid = ACE4_WHO_EVERYONE; + ace->aceType = ACE4_ACCESS_ALLOWED_ACE_TYPE; + ace->aceFlags = 0; + ace->aceMask = + (mode & 0004 ? ACE4_READ_DATA | ACE4_LIST_DIRECTORY : 0) + | (mode & 0002 + ? ACE4_WRITE_DATA | ACE4_ADD_FILE | ACE4_APPEND_DATA + | ACE4_ADD_SUBDIRECTORY + : 0) + | (mode & 0001 ? ACE4_EXECUTE : 0); + ace->aceWhoString[0] = '\0'; + ace->entryLen = (char *) &ace->aceWhoString[4] - (char *) ace; + ace = (nfs4_ace_int_t *) (char *) &ace->aceWhoString[4]; + u.a.aclEntryN++; + } + u.a.aclLength = (char *) ace - (char *) &u.a; + + if (desc != -1) + ret = aclx_fput (desc, SET_ACL | SET_MODE_S_BITS, + type, &u.a, u.a.aclLength, mode); + else + ret = aclx_put (name, SET_ACL | SET_MODE_S_BITS, + type, &u.a, u.a.aclLength, mode); + if (!(ret < 0 && errno == ENOSYS)) + return ret; + } + + return chmod_or_fchmod (name, desc, mode); # elif HAVE_STATACL /* older AIX */ diff --git a/src/bin/coreutils/lib/setenv.c b/src/bin/coreutils/lib/setenv.c index 83b52b88b9..b4c5532290 100644 --- a/src/bin/coreutils/lib/setenv.c +++ b/src/bin/coreutils/lib/setenv.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992,1995-1999,2000-2003,2005-2008 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1995-2003, 2005-2010 Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software: you can redistribute it and/or modify @@ -17,6 +17,11 @@ #if !_LIBC # include #endif + +/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc + optimizes away the name == NULL test below. */ +#define _GL_ARG_NONNULL(params) + #include /* Specification. */ @@ -32,22 +37,22 @@ # include #endif -#if _LIBC || !HAVE_SETENV - #if !_LIBC # include "malloca.h" #endif +#if _LIBC || !HAVE_SETENV + #if !_LIBC -# define __environ environ +# define __environ environ #endif #if _LIBC /* This lock protects against simultaneous modifications of `environ'. */ # include __libc_lock_define_initialized (static, envlock) -# define LOCK __libc_lock_lock (envlock) -# define UNLOCK __libc_lock_unlock (envlock) +# define LOCK __libc_lock_lock (envlock) +# define UNLOCK __libc_lock_unlock (envlock) #else # define LOCK # define UNLOCK @@ -66,8 +71,8 @@ __libc_lock_define_initialized (static, envlock) values are from a small set. Outside glibc this will eat up all memory after a while. */ #if defined _LIBC || (defined HAVE_SEARCH_H && defined HAVE_TSEARCH \ - && defined __GNUC__) -# define USE_TSEARCH 1 + && defined __GNUC__) +# define USE_TSEARCH 1 # include typedef int (*compar_fn_t) (const void *, const void *); @@ -76,9 +81,9 @@ typedef int (*compar_fn_t) (const void *, const void *); static void *known_values; # define KNOWN_VALUE(Str) \ - ({ \ - void *value = tfind (Str, &known_values, (compar_fn_t) strcmp); \ - value != NULL ? *(char **) value : NULL; \ + ({ \ + void *value = tfind (Str, &known_values, (compar_fn_t) strcmp); \ + value != NULL ? *(char **) value : NULL; \ }) # define STORE_VALUE(Str) \ tsearch (Str, &known_values, (compar_fn_t) strcmp) @@ -105,7 +110,7 @@ static char **last_environ; free the strings. */ int __add_to_environ (const char *name, const char *value, const char *combined, - int replace) + int replace) { register char **ep; register size_t size; @@ -122,10 +127,10 @@ __add_to_environ (const char *name, const char *value, const char *combined, if (ep != NULL) { for (; *ep != NULL; ++ep) - if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=') - break; - else - ++size; + if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=') + break; + else + ++size; } if (ep == NULL || *ep == NULL) @@ -137,76 +142,76 @@ __add_to_environ (const char *name, const char *value, const char *combined, /* We allocated this space; we can extend it. */ new_environ = - (char **) (last_environ == NULL - ? malloc ((size + 2) * sizeof (char *)) - : realloc (last_environ, (size + 2) * sizeof (char *))); + (char **) (last_environ == NULL + ? malloc ((size + 2) * sizeof (char *)) + : realloc (last_environ, (size + 2) * sizeof (char *))); if (new_environ == NULL) - { - UNLOCK; - return -1; - } + { + UNLOCK; + return -1; + } /* If the whole entry is given add it. */ if (combined != NULL) - /* We must not add the string to the search tree since it belongs - to the user. */ - new_environ[size] = (char *) combined; + /* We must not add the string to the search tree since it belongs + to the user. */ + new_environ[size] = (char *) combined; else - { - /* See whether the value is already known. */ + { + /* See whether the value is already known. */ #ifdef USE_TSEARCH # ifdef _LIBC - new_value = (char *) alloca (namelen + 1 + vallen); - __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1), - value, vallen); + new_value = (char *) alloca (namelen + 1 + vallen); + __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1), + value, vallen); # else - new_value = (char *) malloca (namelen + 1 + vallen); - if (new_value == NULL) - { - __set_errno (ENOMEM); - UNLOCK; - return -1; - } - memcpy (new_value, name, namelen); - new_value[namelen] = '='; - memcpy (&new_value[namelen + 1], value, vallen); + new_value = (char *) malloca (namelen + 1 + vallen); + if (new_value == NULL) + { + __set_errno (ENOMEM); + UNLOCK; + return -1; + } + memcpy (new_value, name, namelen); + new_value[namelen] = '='; + memcpy (&new_value[namelen + 1], value, vallen); # endif - new_environ[size] = KNOWN_VALUE (new_value); - if (new_environ[size] == NULL) + new_environ[size] = KNOWN_VALUE (new_value); + if (new_environ[size] == NULL) #endif - { - new_environ[size] = (char *) malloc (namelen + 1 + vallen); - if (new_environ[size] == NULL) - { + { + new_environ[size] = (char *) malloc (namelen + 1 + vallen); + if (new_environ[size] == NULL) + { #if defined USE_TSEARCH && !defined _LIBC - freea (new_value); + freea (new_value); #endif - __set_errno (ENOMEM); - UNLOCK; - return -1; - } + __set_errno (ENOMEM); + UNLOCK; + return -1; + } #ifdef USE_TSEARCH - memcpy (new_environ[size], new_value, namelen + 1 + vallen); + memcpy (new_environ[size], new_value, namelen + 1 + vallen); #else - memcpy (new_environ[size], name, namelen); - new_environ[size][namelen] = '='; - memcpy (&new_environ[size][namelen + 1], value, vallen); + memcpy (new_environ[size], name, namelen); + new_environ[size][namelen] = '='; + memcpy (&new_environ[size][namelen + 1], value, vallen); #endif - /* And save the value now. We cannot do this when we remove - the string since then we cannot decide whether it is a - user string or not. */ - STORE_VALUE (new_environ[size]); - } + /* And save the value now. We cannot do this when we remove + the string since then we cannot decide whether it is a + user string or not. */ + STORE_VALUE (new_environ[size]); + } #if defined USE_TSEARCH && !defined _LIBC - freea (new_value); + freea (new_value); #endif - } + } if (__environ != last_environ) - memcpy ((char *) new_environ, (char *) __environ, - size * sizeof (char *)); + memcpy ((char *) new_environ, (char *) __environ, + size * sizeof (char *)); new_environ[size + 1] = NULL; @@ -218,57 +223,57 @@ __add_to_environ (const char *name, const char *value, const char *combined, /* Use the user string if given. */ if (combined != NULL) - np = (char *) combined; + np = (char *) combined; else - { + { #ifdef USE_TSEARCH - char *new_value; + char *new_value; # ifdef _LIBC - new_value = alloca (namelen + 1 + vallen); - __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1), - value, vallen); + new_value = alloca (namelen + 1 + vallen); + __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1), + value, vallen); # else - new_value = malloca (namelen + 1 + vallen); - if (new_value == NULL) - { - __set_errno (ENOMEM); - UNLOCK; - return -1; - } - memcpy (new_value, name, namelen); - new_value[namelen] = '='; - memcpy (&new_value[namelen + 1], value, vallen); + new_value = malloca (namelen + 1 + vallen); + if (new_value == NULL) + { + __set_errno (ENOMEM); + UNLOCK; + return -1; + } + memcpy (new_value, name, namelen); + new_value[namelen] = '='; + memcpy (&new_value[namelen + 1], value, vallen); # endif - np = KNOWN_VALUE (new_value); - if (np == NULL) + np = KNOWN_VALUE (new_value); + if (np == NULL) #endif - { - np = malloc (namelen + 1 + vallen); - if (np == NULL) - { + { + np = malloc (namelen + 1 + vallen); + if (np == NULL) + { #if defined USE_TSEARCH && !defined _LIBC - freea (new_value); + freea (new_value); #endif - __set_errno (ENOMEM); - UNLOCK; - return -1; - } + __set_errno (ENOMEM); + UNLOCK; + return -1; + } #ifdef USE_TSEARCH - memcpy (np, new_value, namelen + 1 + vallen); + memcpy (np, new_value, namelen + 1 + vallen); #else - memcpy (np, name, namelen); - np[namelen] = '='; - memcpy (&np[namelen + 1], value, vallen); + memcpy (np, name, namelen); + np[namelen] = '='; + memcpy (&np[namelen + 1], value, vallen); #endif - /* And remember the value. */ - STORE_VALUE (np); - } + /* And remember the value. */ + STORE_VALUE (np); + } #if defined USE_TSEARCH && !defined _LIBC - freea (new_value); + freea (new_value); #endif - } + } *ep = np; } @@ -281,6 +286,12 @@ __add_to_environ (const char *name, const char *value, const char *combined, int setenv (const char *name, const char *value, int replace) { + if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) + { + __set_errno (EINVAL); + return -1; + } + return __add_to_environ (name, value, NULL, replace); } @@ -328,3 +339,45 @@ weak_alias (__clearenv, clearenv) #endif #endif /* _LIBC || !HAVE_SETENV */ + +/* The rest of this file is called into use when replacing an existing + but buggy setenv. Known bugs include failure to diagnose invalid + name, and consuming a leading '=' from value. */ +#if HAVE_SETENV + +# undef setenv +# define STREQ(a, b) (strcmp (a, b) == 0) + +int +rpl_setenv (const char *name, const char *value, int replace) +{ + int result; + if (!name || !*name || strchr (name, '=')) + { + errno = EINVAL; + return -1; + } + /* Call the real setenv even if replace is 0, in case implementation + has underlying data to update, such as when environ changes. */ + result = setenv (name, value, replace); + if (result == 0 && replace && *value == '=') + { + char *tmp = getenv (name); + if (!STREQ (tmp, value)) + { + int saved_errno; + size_t len = strlen (value); + tmp = malloca (len + 2); + /* Since leading '=' is eaten, double it up. */ + *tmp = '='; + memcpy (tmp + 1, value, len + 1); + result = setenv (name, tmp, replace); + saved_errno = errno; + freea (tmp); + errno = saved_errno; + } + } + return result; +} + +#endif /* HAVE_SETENV */ diff --git a/src/bin/coreutils/lib/settime.c b/src/bin/coreutils/lib/settime.c index 366a298d04..cb91e8b8f3 100644 --- a/src/bin/coreutils/lib/settime.c +++ b/src/bin/coreutils/lib/settime.c @@ -1,7 +1,6 @@ /* settime -- set the system clock - Copyright (C) 2002, 2004, 2005, 2006, 2007, 2009 Free Software - Foundation, Inc. + Copyright (C) 2002, 2004-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/sha1.c b/src/bin/coreutils/lib/sha1.c index b3368cd9ca..30d09b1008 100644 --- a/src/bin/coreutils/lib/sha1.c +++ b/src/bin/coreutils/lib/sha1.c @@ -4,8 +4,8 @@ /* sha1.c - Functions to compute SHA1 message digest of files or memory blocks according to the NIST specification FIPS-180-1. - Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2008 Free Software - Foundation, Inc. + Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2008, 2009, 2010 Free + Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -31,6 +31,7 @@ #include "sha1.h" #include +#include #include #if USE_UNLOCKED_IO @@ -44,7 +45,7 @@ (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24)) #endif -#define BLOCKSIZE 4096 +#define BLOCKSIZE 32768 #if BLOCKSIZE % 64 != 0 # error "invalid BLOCKSIZE" #endif @@ -127,9 +128,12 @@ int sha1_stream (FILE *stream, void *resblock) { struct sha1_ctx ctx; - char buffer[BLOCKSIZE + 72]; size_t sum; + char *buffer = malloc (BLOCKSIZE + 72); + if (!buffer) + return 1; + /* Initialize the computation context. */ sha1_init_ctx (&ctx); @@ -137,40 +141,43 @@ sha1_stream (FILE *stream, void *resblock) while (1) { /* We read the file in blocks of BLOCKSIZE bytes. One call of the - computation function processes the whole buffer so that with the - next round of the loop another block can be read. */ + computation function processes the whole buffer so that with the + next round of the loop another block can be read. */ size_t n; sum = 0; /* Read block. Take care for partial reads. */ while (1) - { - n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); + { + n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); - sum += n; + sum += n; - if (sum == BLOCKSIZE) - break; + if (sum == BLOCKSIZE) + break; - if (n == 0) - { - /* Check for the error flag IFF N == 0, so that we don't - exit the loop after a partial read due to e.g., EAGAIN - or EWOULDBLOCK. */ - if (ferror (stream)) - return 1; - goto process_partial_block; - } + if (n == 0) + { + /* Check for the error flag IFF N == 0, so that we don't + exit the loop after a partial read due to e.g., EAGAIN + or EWOULDBLOCK. */ + if (ferror (stream)) + { + free (buffer); + return 1; + } + goto process_partial_block; + } - /* We've read at least one byte, so ignore errors. But always - check for EOF, since feof may be true even though N > 0. - Otherwise, we could end up calling fread after EOF. */ - if (feof (stream)) - goto process_partial_block; - } + /* We've read at least one byte, so ignore errors. But always + check for EOF, since feof may be true even though N > 0. + Otherwise, we could end up calling fread after EOF. */ + if (feof (stream)) + goto process_partial_block; + } /* Process buffer with BLOCKSIZE bytes. Note that - BLOCKSIZE % 64 == 0 + BLOCKSIZE % 64 == 0 */ sha1_process_block (buffer, BLOCKSIZE, &ctx); } @@ -183,6 +190,7 @@ sha1_stream (FILE *stream, void *resblock) /* Construct result in desired memory. */ sha1_finish_ctx (&ctx, resblock); + free (buffer); return 0; } @@ -219,15 +227,15 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx) ctx->buflen += add; if (ctx->buflen > 64) - { - sha1_process_block (ctx->buffer, ctx->buflen & ~63, ctx); + { + sha1_process_block (ctx->buffer, ctx->buflen & ~63, ctx); - ctx->buflen &= 63; - /* The regions in the following copy operation cannot overlap. */ - memcpy (ctx->buffer, - &((char *) ctx->buffer)[(left_over + add) & ~63], - ctx->buflen); - } + ctx->buflen &= 63; + /* The regions in the following copy operation cannot overlap. */ + memcpy (ctx->buffer, + &((char *) ctx->buffer)[(left_over + add) & ~63], + ctx->buflen); + } buffer = (const char *) buffer + add; len -= add; @@ -240,19 +248,19 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx) # define alignof(type) offsetof (struct { char c; type x; }, x) # define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) if (UNALIGNED_P (buffer)) - while (len > 64) - { - sha1_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); - buffer = (const char *) buffer + 64; - len -= 64; - } + while (len > 64) + { + sha1_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); + buffer = (const char *) buffer + 64; + len -= 64; + } else #endif - { - sha1_process_block (buffer, len & ~63, ctx); - buffer = (const char *) buffer + (len & ~63); - len &= 63; - } + { + sha1_process_block (buffer, len & ~63, ctx); + buffer = (const char *) buffer + (len & ~63); + len &= 63; + } } /* Move remaining bytes in internal buffer. */ @@ -263,11 +271,11 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx) memcpy (&((char *) ctx->buffer)[left_over], buffer, len); left_over += len; if (left_over >= 64) - { - sha1_process_block (ctx->buffer, 64, ctx); - left_over -= 64; - memcpy (ctx->buffer, &ctx->buffer[16], left_over); - } + { + sha1_process_block (ctx->buffer, 64, ctx); + left_over -= 64; + memcpy (ctx->buffer, &ctx->buffer[16], left_over); + } ctx->buflen = left_over; } } @@ -313,25 +321,25 @@ sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx) #define rol(x, n) (((x) << (n)) | ((uint32_t) (x) >> (32 - (n)))) #define M(I) ( tm = x[I&0x0f] ^ x[(I-14)&0x0f] \ - ^ x[(I-8)&0x0f] ^ x[(I-3)&0x0f] \ - , (x[I&0x0f] = rol(tm, 1)) ) + ^ x[(I-8)&0x0f] ^ x[(I-3)&0x0f] \ + , (x[I&0x0f] = rol(tm, 1)) ) #define R(A,B,C,D,E,F,K,M) do { E += rol( A, 5 ) \ - + F( B, C, D ) \ - + K \ - + M; \ - B = rol( B, 30 ); \ - } while(0) + + F( B, C, D ) \ + + K \ + + M; \ + B = rol( B, 30 ); \ + } while(0) while (words < endp) { uint32_t tm; int t; for (t = 0; t < 16; t++) - { - x[t] = SWAP (*words); - words++; - } + { + x[t] = SWAP (*words); + words++; + } R( a, b, c, d, e, F1, K1, x[ 0] ); R( e, a, b, c, d, F1, K1, x[ 1] ); diff --git a/src/bin/coreutils/lib/sha1.h b/src/bin/coreutils/lib/sha1.h index 4a81a9315f..ab7b04493e 100644 --- a/src/bin/coreutils/lib/sha1.h +++ b/src/bin/coreutils/lib/sha1.h @@ -3,8 +3,8 @@ #line 1 /* Declarations of functions and data types used for SHA1 sum library functions. - Copyright (C) 2000, 2001, 2003, 2005, 2006, 2008, 2009 - Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2003, 2005, 2006, 2008, 2009, 2010 Free Software + Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -55,14 +55,14 @@ extern void sha1_init_ctx (struct sha1_ctx *ctx); starting at BUFFER. It is necessary that LEN is a multiple of 64!!! */ extern void sha1_process_block (const void *buffer, size_t len, - struct sha1_ctx *ctx); + struct sha1_ctx *ctx); /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is NOT required that LEN is a multiple of 64. */ extern void sha1_process_bytes (const void *buffer, size_t len, - struct sha1_ctx *ctx); + struct sha1_ctx *ctx); /* Process the remaining bytes in the buffer and put result from CTX in first 20 bytes following RESBUF. The result is always in little diff --git a/src/bin/coreutils/lib/sha256.c b/src/bin/coreutils/lib/sha256.c index 0ad9444351..6eb4b44aeb 100644 --- a/src/bin/coreutils/lib/sha256.c +++ b/src/bin/coreutils/lib/sha256.c @@ -1,7 +1,7 @@ /* sha256.c - Functions to compute SHA256 and SHA224 message digest of files or memory blocks according to the NIST specification FIPS-180-2. - Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 2008, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,6 +25,7 @@ #include "sha256.h" #include +#include #include #if USE_UNLOCKED_IO @@ -38,7 +39,7 @@ (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24)) #endif -#define BLOCKSIZE 4096 +#define BLOCKSIZE 32768 #if BLOCKSIZE % 64 != 0 # error "invalid BLOCKSIZE" #endif @@ -138,9 +139,9 @@ sha256_conclude_ctx (struct sha256_ctx *ctx) Use set_uint32 rather than a simple assignment, to avoid risk of unaligned access. */ set_uint32 ((char *) &ctx->buffer[size - 2], - SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29))); + SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29))); set_uint32 ((char *) &ctx->buffer[size - 1], - SWAP (ctx->total[0] << 3)); + SWAP (ctx->total[0] << 3)); memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes); @@ -169,9 +170,12 @@ int sha256_stream (FILE *stream, void *resblock) { struct sha256_ctx ctx; - char buffer[BLOCKSIZE + 72]; size_t sum; + char *buffer = malloc (BLOCKSIZE + 72); + if (!buffer) + return 1; + /* Initialize the computation context. */ sha256_init_ctx (&ctx); @@ -179,40 +183,43 @@ sha256_stream (FILE *stream, void *resblock) while (1) { /* We read the file in blocks of BLOCKSIZE bytes. One call of the - computation function processes the whole buffer so that with the - next round of the loop another block can be read. */ + computation function processes the whole buffer so that with the + next round of the loop another block can be read. */ size_t n; sum = 0; /* Read block. Take care for partial reads. */ while (1) - { - n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); + { + n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); - sum += n; + sum += n; - if (sum == BLOCKSIZE) - break; + if (sum == BLOCKSIZE) + break; - if (n == 0) - { - /* Check for the error flag IFF N == 0, so that we don't - exit the loop after a partial read due to e.g., EAGAIN - or EWOULDBLOCK. */ - if (ferror (stream)) - return 1; - goto process_partial_block; - } + if (n == 0) + { + /* Check for the error flag IFF N == 0, so that we don't + exit the loop after a partial read due to e.g., EAGAIN + or EWOULDBLOCK. */ + if (ferror (stream)) + { + free (buffer); + return 1; + } + goto process_partial_block; + } - /* We've read at least one byte, so ignore errors. But always - check for EOF, since feof may be true even though N > 0. - Otherwise, we could end up calling fread after EOF. */ - if (feof (stream)) - goto process_partial_block; - } + /* We've read at least one byte, so ignore errors. But always + check for EOF, since feof may be true even though N > 0. + Otherwise, we could end up calling fread after EOF. */ + if (feof (stream)) + goto process_partial_block; + } /* Process buffer with BLOCKSIZE bytes. Note that - BLOCKSIZE % 64 == 0 + BLOCKSIZE % 64 == 0 */ sha256_process_block (buffer, BLOCKSIZE, &ctx); } @@ -225,6 +232,7 @@ sha256_stream (FILE *stream, void *resblock) /* Construct result in desired memory. */ sha256_finish_ctx (&ctx, resblock); + free (buffer); return 0; } @@ -233,9 +241,12 @@ int sha224_stream (FILE *stream, void *resblock) { struct sha256_ctx ctx; - char buffer[BLOCKSIZE + 72]; size_t sum; + char *buffer = malloc (BLOCKSIZE + 72); + if (!buffer) + return 1; + /* Initialize the computation context. */ sha224_init_ctx (&ctx); @@ -243,40 +254,43 @@ sha224_stream (FILE *stream, void *resblock) while (1) { /* We read the file in blocks of BLOCKSIZE bytes. One call of the - computation function processes the whole buffer so that with the - next round of the loop another block can be read. */ + computation function processes the whole buffer so that with the + next round of the loop another block can be read. */ size_t n; sum = 0; /* Read block. Take care for partial reads. */ while (1) - { - n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); + { + n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); - sum += n; + sum += n; - if (sum == BLOCKSIZE) - break; + if (sum == BLOCKSIZE) + break; - if (n == 0) - { - /* Check for the error flag IFF N == 0, so that we don't - exit the loop after a partial read due to e.g., EAGAIN - or EWOULDBLOCK. */ - if (ferror (stream)) - return 1; - goto process_partial_block; - } + if (n == 0) + { + /* Check for the error flag IFF N == 0, so that we don't + exit the loop after a partial read due to e.g., EAGAIN + or EWOULDBLOCK. */ + if (ferror (stream)) + { + free (buffer); + return 1; + } + goto process_partial_block; + } - /* We've read at least one byte, so ignore errors. But always - check for EOF, since feof may be true even though N > 0. - Otherwise, we could end up calling fread after EOF. */ - if (feof (stream)) - goto process_partial_block; - } + /* We've read at least one byte, so ignore errors. But always + check for EOF, since feof may be true even though N > 0. + Otherwise, we could end up calling fread after EOF. */ + if (feof (stream)) + goto process_partial_block; + } /* Process buffer with BLOCKSIZE bytes. Note that - BLOCKSIZE % 64 == 0 + BLOCKSIZE % 64 == 0 */ sha256_process_block (buffer, BLOCKSIZE, &ctx); } @@ -289,6 +303,7 @@ sha224_stream (FILE *stream, void *resblock) /* Construct result in desired memory. */ sha224_finish_ctx (&ctx, resblock); + free (buffer); return 0; } @@ -340,15 +355,15 @@ sha256_process_bytes (const void *buffer, size_t len, struct sha256_ctx *ctx) ctx->buflen += add; if (ctx->buflen > 64) - { - sha256_process_block (ctx->buffer, ctx->buflen & ~63, ctx); + { + sha256_process_block (ctx->buffer, ctx->buflen & ~63, ctx); - ctx->buflen &= 63; - /* The regions in the following copy operation cannot overlap. */ - memcpy (ctx->buffer, - &((char *) ctx->buffer)[(left_over + add) & ~63], - ctx->buflen); - } + ctx->buflen &= 63; + /* The regions in the following copy operation cannot overlap. */ + memcpy (ctx->buffer, + &((char *) ctx->buffer)[(left_over + add) & ~63], + ctx->buflen); + } buffer = (const char *) buffer + add; len -= add; @@ -361,19 +376,19 @@ sha256_process_bytes (const void *buffer, size_t len, struct sha256_ctx *ctx) # define alignof(type) offsetof (struct { char c; type x; }, x) # define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) if (UNALIGNED_P (buffer)) - while (len > 64) - { - sha256_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); - buffer = (const char *) buffer + 64; - len -= 64; - } + while (len > 64) + { + sha256_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); + buffer = (const char *) buffer + 64; + len -= 64; + } else #endif - { - sha256_process_block (buffer, len & ~63, ctx); - buffer = (const char *) buffer + (len & ~63); - len &= 63; - } + { + sha256_process_block (buffer, len & ~63, ctx); + buffer = (const char *) buffer + (len & ~63); + len &= 63; + } } /* Move remaining bytes in internal buffer. */ @@ -384,11 +399,11 @@ sha256_process_bytes (const void *buffer, size_t len, struct sha256_ctx *ctx) memcpy (&((char *) ctx->buffer)[left_over], buffer, len); left_over += len; if (left_over >= 64) - { - sha256_process_block (ctx->buffer, 64, ctx); - left_over -= 64; - memcpy (ctx->buffer, &ctx->buffer[16], left_over); - } + { + sha256_process_block (ctx->buffer, 64, ctx); + left_over -= 64; + memcpy (ctx->buffer, &ctx->buffer[16], left_over); + } ctx->buflen = left_over; } } @@ -454,16 +469,16 @@ sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx) #define SS1(x) (rol(x,26)^rol(x,21)^rol(x,7)) #define M(I) ( tm = S1(x[(I-2)&0x0f]) + x[(I-7)&0x0f] \ - + S0(x[(I-15)&0x0f]) + x[I&0x0f] \ - , x[I&0x0f] = tm ) + + S0(x[(I-15)&0x0f]) + x[I&0x0f] \ + , x[I&0x0f] = tm ) #define R(A,B,C,D,E,F,G,H,K,M) do { t0 = SS0(A) + F2(A,B,C); \ t1 = H + SS1(E) \ + F1(E,F,G) \ - + K \ - + M; \ - D += t1; H = t0 + t1; \ - } while(0) + + K \ + + M; \ + D += t1; H = t0 + t1; \ + } while(0) while (words < endp) { @@ -472,10 +487,10 @@ sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx) int t; /* FIXME: see sha1.c for a better implementation. */ for (t = 0; t < 16; t++) - { - x[t] = SWAP (*words); - words++; - } + { + x[t] = SWAP (*words); + words++; + } R( a, b, c, d, e, f, g, h, K( 0), x[ 0] ); R( h, a, b, c, d, e, f, g, K( 1), x[ 1] ); diff --git a/src/bin/coreutils/lib/sha256.h b/src/bin/coreutils/lib/sha256.h index 6a9aed41ad..59df6fc9ec 100644 --- a/src/bin/coreutils/lib/sha256.h +++ b/src/bin/coreutils/lib/sha256.h @@ -1,6 +1,6 @@ /* Declarations of functions and data types used for SHA256 and SHA224 sum library functions. - Copyright (C) 2005, 2006, 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 2008, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -47,14 +47,14 @@ extern void sha224_init_ctx (struct sha256_ctx *ctx); starting at BUFFER. It is necessary that LEN is a multiple of 64!!! */ extern void sha256_process_block (const void *buffer, size_t len, - struct sha256_ctx *ctx); + struct sha256_ctx *ctx); /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is NOT required that LEN is a multiple of 64. */ extern void sha256_process_bytes (const void *buffer, size_t len, - struct sha256_ctx *ctx); + struct sha256_ctx *ctx); /* Process the remaining bytes in the buffer and put result from CTX in first 32 (28) bytes following RESBUF. The result is always in little diff --git a/src/bin/coreutils/lib/sha512.c b/src/bin/coreutils/lib/sha512.c index 261a7bb02f..5c0b2ed181 100644 --- a/src/bin/coreutils/lib/sha512.c +++ b/src/bin/coreutils/lib/sha512.c @@ -1,7 +1,7 @@ /* sha512.c - Functions to compute SHA512 and SHA384 message digest of files or memory blocks according to the NIST specification FIPS-180-2. - Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 2008, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,6 +25,7 @@ #include "sha512.h" #include +#include #include #if USE_UNLOCKED_IO @@ -35,17 +36,17 @@ # define SWAP(n) (n) #else # define SWAP(n) \ - u64or (u64or (u64or (u64shl (n, 56), \ - u64shl (u64and (n, u64lo (0x0000ff00)), 40)), \ - u64or (u64shl (u64and (n, u64lo (0x00ff0000)), 24), \ - u64shl (u64and (n, u64lo (0xff000000)), 8))), \ - u64or (u64or (u64and (u64shr (n, 8), u64lo (0xff000000)), \ - u64and (u64shr (n, 24), u64lo (0x00ff0000))), \ - u64or (u64and (u64shr (n, 40), u64lo (0x0000ff00)), \ - u64shr (n, 56)))) + u64or (u64or (u64or (u64shl (n, 56), \ + u64shl (u64and (n, u64lo (0x0000ff00)), 40)), \ + u64or (u64shl (u64and (n, u64lo (0x00ff0000)), 24), \ + u64shl (u64and (n, u64lo (0xff000000)), 8))), \ + u64or (u64or (u64and (u64shr (n, 8), u64lo (0xff000000)), \ + u64and (u64shr (n, 24), u64lo (0x00ff0000))), \ + u64or (u64and (u64shr (n, 40), u64lo (0x0000ff00)), \ + u64shr (n, 56)))) #endif -#define BLOCKSIZE 4096 +#define BLOCKSIZE 32768 #if BLOCKSIZE % 128 != 0 # error "invalid BLOCKSIZE" #endif @@ -145,10 +146,10 @@ sha512_conclude_ctx (struct sha512_ctx *ctx) Use set_uint64 rather than a simple assignment, to avoid risk of unaligned access. */ set_uint64 ((char *) &ctx->buffer[size - 2], - SWAP (u64or (u64shl (ctx->total[1], 3), - u64shr (ctx->total[0], 61)))); + SWAP (u64or (u64shl (ctx->total[1], 3), + u64shr (ctx->total[0], 61)))); set_uint64 ((char *) &ctx->buffer[size - 1], - SWAP (u64shl (ctx->total[0], 3))); + SWAP (u64shl (ctx->total[0], 3))); memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 8 - bytes); @@ -177,9 +178,12 @@ int sha512_stream (FILE *stream, void *resblock) { struct sha512_ctx ctx; - char buffer[BLOCKSIZE + 72]; size_t sum; + char *buffer = malloc (BLOCKSIZE + 72); + if (!buffer) + return 1; + /* Initialize the computation context. */ sha512_init_ctx (&ctx); @@ -187,40 +191,43 @@ sha512_stream (FILE *stream, void *resblock) while (1) { /* We read the file in blocks of BLOCKSIZE bytes. One call of the - computation function processes the whole buffer so that with the - next round of the loop another block can be read. */ + computation function processes the whole buffer so that with the + next round of the loop another block can be read. */ size_t n; sum = 0; /* Read block. Take care for partial reads. */ while (1) - { - n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); + { + n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); - sum += n; + sum += n; - if (sum == BLOCKSIZE) - break; + if (sum == BLOCKSIZE) + break; - if (n == 0) - { - /* Check for the error flag IFF N == 0, so that we don't - exit the loop after a partial read due to e.g., EAGAIN - or EWOULDBLOCK. */ - if (ferror (stream)) - return 1; - goto process_partial_block; - } + if (n == 0) + { + /* Check for the error flag IFF N == 0, so that we don't + exit the loop after a partial read due to e.g., EAGAIN + or EWOULDBLOCK. */ + if (ferror (stream)) + { + free (buffer); + return 1; + } + goto process_partial_block; + } - /* We've read at least one byte, so ignore errors. But always - check for EOF, since feof may be true even though N > 0. - Otherwise, we could end up calling fread after EOF. */ - if (feof (stream)) - goto process_partial_block; - } + /* We've read at least one byte, so ignore errors. But always + check for EOF, since feof may be true even though N > 0. + Otherwise, we could end up calling fread after EOF. */ + if (feof (stream)) + goto process_partial_block; + } /* Process buffer with BLOCKSIZE bytes. Note that - BLOCKSIZE % 128 == 0 + BLOCKSIZE % 128 == 0 */ sha512_process_block (buffer, BLOCKSIZE, &ctx); } @@ -233,6 +240,7 @@ sha512_stream (FILE *stream, void *resblock) /* Construct result in desired memory. */ sha512_finish_ctx (&ctx, resblock); + free (buffer); return 0; } @@ -241,9 +249,12 @@ int sha384_stream (FILE *stream, void *resblock) { struct sha512_ctx ctx; - char buffer[BLOCKSIZE + 72]; size_t sum; + char *buffer = malloc (BLOCKSIZE + 72); + if (!buffer) + return 1; + /* Initialize the computation context. */ sha384_init_ctx (&ctx); @@ -251,40 +262,43 @@ sha384_stream (FILE *stream, void *resblock) while (1) { /* We read the file in blocks of BLOCKSIZE bytes. One call of the - computation function processes the whole buffer so that with the - next round of the loop another block can be read. */ + computation function processes the whole buffer so that with the + next round of the loop another block can be read. */ size_t n; sum = 0; /* Read block. Take care for partial reads. */ while (1) - { - n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); + { + n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); - sum += n; + sum += n; - if (sum == BLOCKSIZE) - break; + if (sum == BLOCKSIZE) + break; - if (n == 0) - { - /* Check for the error flag IFF N == 0, so that we don't - exit the loop after a partial read due to e.g., EAGAIN - or EWOULDBLOCK. */ - if (ferror (stream)) - return 1; - goto process_partial_block; - } + if (n == 0) + { + /* Check for the error flag IFF N == 0, so that we don't + exit the loop after a partial read due to e.g., EAGAIN + or EWOULDBLOCK. */ + if (ferror (stream)) + { + free (buffer); + return 1; + } + goto process_partial_block; + } - /* We've read at least one byte, so ignore errors. But always - check for EOF, since feof may be true even though N > 0. - Otherwise, we could end up calling fread after EOF. */ - if (feof (stream)) - goto process_partial_block; - } + /* We've read at least one byte, so ignore errors. But always + check for EOF, since feof may be true even though N > 0. + Otherwise, we could end up calling fread after EOF. */ + if (feof (stream)) + goto process_partial_block; + } /* Process buffer with BLOCKSIZE bytes. Note that - BLOCKSIZE % 128 == 0 + BLOCKSIZE % 128 == 0 */ sha512_process_block (buffer, BLOCKSIZE, &ctx); } @@ -297,6 +311,7 @@ sha384_stream (FILE *stream, void *resblock) /* Construct result in desired memory. */ sha384_finish_ctx (&ctx, resblock); + free (buffer); return 0; } @@ -348,15 +363,15 @@ sha512_process_bytes (const void *buffer, size_t len, struct sha512_ctx *ctx) ctx->buflen += add; if (ctx->buflen > 128) - { - sha512_process_block (ctx->buffer, ctx->buflen & ~127, ctx); + { + sha512_process_block (ctx->buffer, ctx->buflen & ~127, ctx); - ctx->buflen &= 127; - /* The regions in the following copy operation cannot overlap. */ - memcpy (ctx->buffer, - &((char *) ctx->buffer)[(left_over + add) & ~127], - ctx->buflen); - } + ctx->buflen &= 127; + /* The regions in the following copy operation cannot overlap. */ + memcpy (ctx->buffer, + &((char *) ctx->buffer)[(left_over + add) & ~127], + ctx->buflen); + } buffer = (const char *) buffer + add; len -= add; @@ -369,19 +384,19 @@ sha512_process_bytes (const void *buffer, size_t len, struct sha512_ctx *ctx) # define alignof(type) offsetof (struct { char c; type x; }, x) # define UNALIGNED_P(p) (((size_t) p) % alignof (u64) != 0) if (UNALIGNED_P (buffer)) - while (len > 128) - { - sha512_process_block (memcpy (ctx->buffer, buffer, 128), 128, ctx); - buffer = (const char *) buffer + 128; - len -= 128; - } + while (len > 128) + { + sha512_process_block (memcpy (ctx->buffer, buffer, 128), 128, ctx); + buffer = (const char *) buffer + 128; + len -= 128; + } else #endif - { - sha512_process_block (buffer, len & ~127, ctx); - buffer = (const char *) buffer + (len & ~127); - len &= 127; - } + { + sha512_process_block (buffer, len & ~127, ctx); + buffer = (const char *) buffer + (len & ~127); + len &= 127; + } } /* Move remaining bytes in internal buffer. */ @@ -392,11 +407,11 @@ sha512_process_bytes (const void *buffer, size_t len, struct sha512_ctx *ctx) memcpy (&((char *) ctx->buffer)[left_over], buffer, len); left_over += len; if (left_over >= 128) - { - sha512_process_block (ctx->buffer, 128, ctx); - left_over -= 128; - memcpy (ctx->buffer, &ctx->buffer[16], left_over); - } + { + sha512_process_block (ctx->buffer, 128, ctx); + left_over -= 128; + memcpy (ctx->buffer, &ctx->buffer[16], left_over); + } ctx->buflen = left_over; } } @@ -483,22 +498,22 @@ sha512_process_block (const void *buffer, size_t len, struct sha512_ctx *ctx) #define SS0(x) u64xor (u64rol (x, 36), u64xor (u64rol (x, 30), u64rol (x, 25))) #define SS1(x) u64xor (u64rol(x, 50), u64xor (u64rol (x, 46), u64rol (x, 23))) -#define M(I) (x[(I) & 15] \ - = u64plus (x[(I) & 15], \ - u64plus (S1 (x[((I) - 2) & 15]), \ - u64plus (x[((I) - 7) & 15], \ - S0 (x[((I) - 15) & 15]))))) +#define M(I) (x[(I) & 15] \ + = u64plus (x[(I) & 15], \ + u64plus (S1 (x[((I) - 2) & 15]), \ + u64plus (x[((I) - 7) & 15], \ + S0 (x[((I) - 15) & 15]))))) -#define R(A, B, C, D, E, F, G, H, K, M) \ - do \ - { \ - u64 t0 = u64plus (SS0 (A), F2 (A, B, C)); \ - u64 t1 = \ - u64plus (H, u64plus (SS1 (E), \ - u64plus (F1 (E, F, G), u64plus (K, M)))); \ - D = u64plus (D, t1); \ - H = u64plus (t0, t1); \ - } \ +#define R(A, B, C, D, E, F, G, H, K, M) \ + do \ + { \ + u64 t0 = u64plus (SS0 (A), F2 (A, B, C)); \ + u64 t1 = \ + u64plus (H, u64plus (SS1 (E), \ + u64plus (F1 (E, F, G), u64plus (K, M)))); \ + D = u64plus (D, t1); \ + H = u64plus (t0, t1); \ + } \ while (0) while (words < endp) @@ -506,10 +521,10 @@ sha512_process_block (const void *buffer, size_t len, struct sha512_ctx *ctx) int t; /* FIXME: see sha1.c for a better implementation. */ for (t = 0; t < 16; t++) - { - x[t] = SWAP (*words); - words++; - } + { + x[t] = SWAP (*words); + words++; + } R( a, b, c, d, e, f, g, h, K( 0), x[ 0] ); R( h, a, b, c, d, e, f, g, K( 1), x[ 1] ); diff --git a/src/bin/coreutils/lib/sha512.h b/src/bin/coreutils/lib/sha512.h index 11ac2706f0..ea85194fb5 100644 --- a/src/bin/coreutils/lib/sha512.h +++ b/src/bin/coreutils/lib/sha512.h @@ -1,6 +1,6 @@ /* Declarations of functions and data types used for SHA512 and SHA384 sum library functions. - Copyright (C) 2005, 2006, 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 2008, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -48,14 +48,14 @@ extern void sha384_init_ctx (struct sha512_ctx *ctx); starting at BUFFER. It is necessary that LEN is a multiple of 128!!! */ extern void sha512_process_block (const void *buffer, size_t len, - struct sha512_ctx *ctx); + struct sha512_ctx *ctx); /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is NOT required that LEN is a multiple of 128. */ extern void sha512_process_bytes (const void *buffer, size_t len, - struct sha512_ctx *ctx); + struct sha512_ctx *ctx); /* Process the remaining bytes in the buffer and put result from CTX in first 64 (48) bytes following RESBUF. The result is always in little diff --git a/src/bin/coreutils/lib/sig-handler.h b/src/bin/coreutils/lib/sig-handler.h index 969f679023..6a634c246a 100644 --- a/src/bin/coreutils/lib/sig-handler.h +++ b/src/bin/coreutils/lib/sig-handler.h @@ -1,6 +1,6 @@ /* Convenience declarations when working with . - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/sig2str.c b/src/bin/coreutils/lib/sig2str.c index 9252b28661..fce22c0d41 100644 --- a/src/bin/coreutils/lib/sig2str.c +++ b/src/bin/coreutils/lib/sig2str.c @@ -1,6 +1,6 @@ /* sig2str.c -- convert between signal names and numbers - Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -131,7 +131,7 @@ static struct numname { int num; char const name[8]; } numname_table[] = /* Unix Version 7. */ #ifdef SIGIOT - NUMNAME (IOT), /* Older name for ABRT. */ + NUMNAME (IOT), /* Older name for ABRT. */ #endif #ifdef SIGEMT NUMNAME (EMT), @@ -215,16 +215,16 @@ static struct numname { int num; char const name[8]; } numname_table[] = /* Older AIX versions. */ #ifdef SIGALRM1 - NUMNAME (ALRM1), /* unknown; taken from Bash 2.05 */ + NUMNAME (ALRM1), /* unknown; taken from Bash 2.05 */ #endif #ifdef SIGKAP - NUMNAME (KAP), /* Older name for SIGGRANT. */ + NUMNAME (KAP), /* Older name for SIGGRANT. */ #endif #ifdef SIGVIRT - NUMNAME (VIRT), /* unknown; taken from Bash 2.05 */ + NUMNAME (VIRT), /* unknown; taken from Bash 2.05 */ #endif #ifdef SIGWINDOW - NUMNAME (WINDOW), /* Older name for SIGWINCH. */ + NUMNAME (WINDOW), /* Older name for SIGWINCH. */ #endif /* BeOS */ @@ -263,32 +263,32 @@ str2signum (char const *signame) char *endp; long int n = strtol (signame, &endp, 10); if (! *endp && n <= SIGNUM_BOUND) - return n; + return n; } else { unsigned int i; for (i = 0; i < NUMNAME_ENTRIES; i++) - if (strcmp (numname_table[i].name, signame) == 0) - return numname_table[i].num; + if (strcmp (numname_table[i].name, signame) == 0) + return numname_table[i].num; { - char *endp; - int rtmin = SIGRTMIN; - int rtmax = SIGRTMAX; + char *endp; + int rtmin = SIGRTMIN; + int rtmax = SIGRTMAX; - if (0 < rtmin && strncmp (signame, "RTMIN", 5) == 0) - { - long int n = strtol (signame + 5, &endp, 10); - if (! *endp && 0 <= n && n <= rtmax - rtmin) - return rtmin + n; - } - else if (0 < rtmax && strncmp (signame, "RTMAX", 5) == 0) - { - long int n = strtol (signame + 5, &endp, 10); - if (! *endp && rtmin - rtmax <= n && n <= 0) - return rtmax + n; - } + if (0 < rtmin && strncmp (signame, "RTMIN", 5) == 0) + { + long int n = strtol (signame + 5, &endp, 10); + if (! *endp && 0 <= n && n <= rtmax - rtmin) + return rtmin + n; + } + else if (0 < rtmax && strncmp (signame, "RTMAX", 5) == 0) + { + long int n = strtol (signame + 5, &endp, 10); + if (! *endp && rtmin - rtmax <= n && n <= 0) + return rtmax + n; + } } } @@ -316,8 +316,8 @@ sig2str (int signum, char *signame) for (i = 0; i < NUMNAME_ENTRIES; i++) if (numname_table[i].num == signum) { - strcpy (signame, numname_table[i].name); - return 0; + strcpy (signame, numname_table[i].name); + return 0; } { @@ -329,13 +329,13 @@ sig2str (int signum, char *signame) if (signum <= rtmin + (rtmax - rtmin) / 2) { - int delta = signum - rtmin; - sprintf (signame, delta ? "RTMIN+%d" : "RTMIN", delta); + int delta = signum - rtmin; + sprintf (signame, delta ? "RTMIN+%d" : "RTMIN", delta); } else { - int delta = rtmax - signum; - sprintf (signame, delta ? "RTMAX-%d" : "RTMAX", delta); + int delta = rtmax - signum; + sprintf (signame, delta ? "RTMAX-%d" : "RTMAX", delta); } return 0; diff --git a/src/bin/coreutils/lib/sig2str.h b/src/bin/coreutils/lib/sig2str.h index 05a522f478..a9e7184860 100644 --- a/src/bin/coreutils/lib/sig2str.h +++ b/src/bin/coreutils/lib/sig2str.h @@ -1,6 +1,6 @@ /* sig2str.h -- convert between signal names and numbers - Copyright (C) 2002, 2005 Free Software Foundation, Inc. + Copyright (C) 2002, 2005, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/sigaction.c b/src/bin/coreutils/lib/sigaction.c index 5fcd3ed9ad..e14bd9647e 100644 --- a/src/bin/coreutils/lib/sigaction.c +++ b/src/bin/coreutils/lib/sigaction.c @@ -1,5 +1,5 @@ /* POSIX compatible signal blocking. - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. Written by Eric Blake , 2008. This program is free software: you can redistribute it and/or modify @@ -91,7 +91,7 @@ sigaction_handler (int sig) { /* Unexpected situation; be careful to avoid recursive abort. */ if (sig == SIGABRT) - signal (SIGABRT, SIG_DFL); + signal (SIGABRT, SIG_DFL); abort (); } diff --git a/src/bin/coreutils/lib/siglist.h b/src/bin/coreutils/lib/siglist.h new file mode 100644 index 0000000000..e372429a32 --- /dev/null +++ b/src/bin/coreutils/lib/siglist.h @@ -0,0 +1,130 @@ +/* Canonical list of all signal names. + Copyright (C) 1996, 1997, 1998, 1999, 2008, 2009, 2010 Free Software + Foundation, Inc. + This file is part of the GNU C Library. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* This file should be usable for any platform, since it just associates + the SIG* macros with text names and descriptions. The actual values + come from (via ). For any signal macros do not + exist on every platform, we can use #ifdef tests here and still use + this single common file for all platforms. */ + +/* This file is included multiple times. */ + +/* Standard signals */ +#ifdef SIGHUP + init_sig (SIGHUP, "HUP", N_("Hangup")) +#endif +#ifdef SIGINT + init_sig (SIGINT, "INT", N_("Interrupt")) +#endif +#ifdef SIGQUIT + init_sig (SIGQUIT, "QUIT", N_("Quit")) +#endif +#ifdef SIGILL + init_sig (SIGILL, "ILL", N_("Illegal instruction")) +#endif +#ifdef SIGTRAP + init_sig (SIGTRAP, "TRAP", N_("Trace/breakpoint trap")) +#endif +#ifdef SIGABRT + init_sig (SIGABRT, "ABRT", N_("Aborted")) +#endif +#ifdef SIGFPE + init_sig (SIGFPE, "FPE", N_("Floating point exception")) +#endif +#ifdef SIGKILL + init_sig (SIGKILL, "KILL", N_("Killed")) +#endif +#ifdef SIGBUS + init_sig (SIGBUS, "BUS", N_("Bus error")) +#endif +#ifdef SIGSEGV + init_sig (SIGSEGV, "SEGV", N_("Segmentation fault")) +#endif +#ifdef SIGPIPE + init_sig (SIGPIPE, "PIPE", N_("Broken pipe")) +#endif +#ifdef SIGALRM + init_sig (SIGALRM, "ALRM", N_("Alarm clock")) +#endif +#ifdef SIGTERM + init_sig (SIGTERM, "TERM", N_("Terminated")) +#endif +#ifdef SIGURG + init_sig (SIGURG, "URG", N_("Urgent I/O condition")) +#endif +#ifdef SIGSTOP + init_sig (SIGSTOP, "STOP", N_("Stopped (signal)")) +#endif +#ifdef SIGTSTP + init_sig (SIGTSTP, "TSTP", N_("Stopped")) +#endif +#ifdef SIGCONT + init_sig (SIGCONT, "CONT", N_("Continued")) +#endif +#ifdef SIGCHLD + init_sig (SIGCHLD, "CHLD", N_("Child exited")) +#endif +#ifdef SIGTTIN + init_sig (SIGTTIN, "TTIN", N_("Stopped (tty input)")) +#endif +#ifdef SIGTTOU + init_sig (SIGTTOU, "TTOU", N_("Stopped (tty output)")) +#endif +#ifdef SIGIO + init_sig (SIGIO, "IO", N_("I/O possible")) +#endif +#ifdef SIGXCPU + init_sig (SIGXCPU, "XCPU", N_("CPU time limit exceeded")) +#endif +#ifdef SIGXFSZ + init_sig (SIGXFSZ, "XFSZ", N_("File size limit exceeded")) +#endif +#ifdef SIGVTALRM + init_sig (SIGVTALRM, "VTALRM", N_("Virtual timer expired")) +#endif +#ifdef SIGPROF + init_sig (SIGPROF, "PROF", N_("Profiling timer expired")) +#endif +#ifdef SIGWINCH + init_sig (SIGWINCH, "WINCH", N_("Window changed")) +#endif +#ifdef SIGUSR1 + init_sig (SIGUSR1, "USR1", N_("User defined signal 1")) +#endif +#ifdef SIGUSR2 + init_sig (SIGUSR2, "USR2", N_("User defined signal 2")) +#endif + +/* Variations */ +#ifdef SIGEMT + init_sig (SIGEMT, "EMT", N_("EMT trap")) +#endif +#ifdef SIGSYS + init_sig (SIGSYS, "SYS", N_("Bad system call")) +#endif +#ifdef SIGSTKFLT + init_sig (SIGSTKFLT, "STKFLT", N_("Stack fault")) +#endif +#ifdef SIGINFO + init_sig (SIGINFO, "INFO", N_("Information request")) +#elif defined(SIGPWR) && (!defined(SIGLOST) || (SIGPWR != SIGLOST)) + init_sig (SIGPWR, "PWR", N_("Power failure")) +#endif +#ifdef SIGLOST + init_sig (SIGLOST, "LOST", N_("Resource lost")) +#endif diff --git a/src/bin/coreutils/lib/signal.h b/src/bin/coreutils/lib/signal.h new file mode 100644 index 0000000000..c4517aa7b7 --- /dev/null +++ b/src/bin/coreutils/lib/signal.h @@ -0,0 +1,288 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* A GNU-like . + + Copyright (C) 2006-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#if __GNUC__ >= 3 +#pragma GCC system_header +#endif + +#if defined __need_sig_atomic_t || defined __need_sigset_t +/* Special invocation convention inside glibc header files. */ + +# include_next + +#else +/* Normal invocation convention. */ + +#ifndef _GL_SIGNAL_H + +/* The include_next requires a split double-inclusion guard. */ +#include_next + +#ifndef _GL_SIGNAL_H +#define _GL_SIGNAL_H + +/* The definition of GL_LINK_WARNING is copied here. */ +/* GL_LINK_WARNING("literal string") arranges to emit the literal string as + a linker warning on most glibc systems. + We use a linker warning rather than a preprocessor warning, because + #warning cannot be used inside macros. */ +#ifndef GL_LINK_WARNING + /* This works on platforms with GNU ld and ELF object format. + Testing __GLIBC__ is sufficient for asserting that GNU ld is in use. + Testing __ELF__ guarantees the ELF object format. + Testing __GNUC__ is necessary for the compound expression syntax. */ +# if defined __GLIBC__ && defined __ELF__ && defined __GNUC__ +# define GL_LINK_WARNING(message) \ + GL_LINK_WARNING1 (__FILE__, __LINE__, message) +# define GL_LINK_WARNING1(file, line, message) \ + GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */ +# define GL_LINK_WARNING2(file, line, message) \ + GL_LINK_WARNING3 (file ":" #line ": warning: " message) +# define GL_LINK_WARNING3(message) \ + ({ static const char warning[sizeof (message)] \ + __attribute__ ((__unused__, \ + __section__ (".gnu.warning"), \ + __aligned__ (1))) \ + = message "\n"; \ + (void)0; \ + }) +# else +# define GL_LINK_WARNING(message) ((void) 0) +# endif +#endif + +/* The definition of _GL_ARG_NONNULL is copied here. */ +/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools + that the values passed as arguments n, ..., m must be non-NULL pointers. + n = 1 stands for the first argument, n = 2 for the second argument etc. */ +#ifndef _GL_ARG_NONNULL +# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 +# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) +# else +# define _GL_ARG_NONNULL(params) +# endif +#endif + +/* Define pid_t, uid_t. + Also, mingw defines sigset_t not in , but in . */ +#include + +/* On AIX, sig_atomic_t already includes volatile. C99 requires that + 'volatile sig_atomic_t' ignore the extra modifier, but C89 did not. + Hence, redefine this to a non-volatile type as needed. */ +#if ! 1 +typedef int rpl_sig_atomic_t; +# undef sig_atomic_t +# define sig_atomic_t rpl_sig_atomic_t +#endif + +/* A set or mask of signals. */ +#if !1 +typedef unsigned int sigset_t; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + +#if 0 +# ifndef SIGPIPE +/* Define SIGPIPE to a value that does not overlap with other signals. */ +# define SIGPIPE 13 +# define GNULIB_defined_SIGPIPE 1 +/* To actually use SIGPIPE, you also need the gnulib modules 'sigprocmask', + 'write', 'stdio'. */ +# endif +#endif + + +#if 1 +# if !1 + +/* Maximum signal number + 1. */ +# ifndef NSIG +# define NSIG 32 +# endif + +/* This code supports only 32 signals. */ +typedef int verify_NSIG_constraint[2 * (NSIG <= 32) - 1]; + +/* Test whether a given signal is contained in a signal set. */ +extern int sigismember (const sigset_t *set, int sig) _GL_ARG_NONNULL ((1)); + +/* Initialize a signal set to the empty set. */ +extern int sigemptyset (sigset_t *set) _GL_ARG_NONNULL ((1)); + +/* Add a signal to a signal set. */ +extern int sigaddset (sigset_t *set, int sig) _GL_ARG_NONNULL ((1)); + +/* Remove a signal from a signal set. */ +extern int sigdelset (sigset_t *set, int sig) _GL_ARG_NONNULL ((1)); + +/* Fill a signal set with all possible signals. */ +extern int sigfillset (sigset_t *set) _GL_ARG_NONNULL ((1)); + +/* Return the set of those blocked signals that are pending. */ +extern int sigpending (sigset_t *set) _GL_ARG_NONNULL ((1)); + +/* If OLD_SET is not NULL, put the current set of blocked signals in *OLD_SET. + Then, if SET is not NULL, affect the current set of blocked signals by + combining it with *SET as indicated in OPERATION. + In this implementation, you are not allowed to change a signal handler + while the signal is blocked. */ +# define SIG_BLOCK 0 /* blocked_set = blocked_set | *set; */ +# define SIG_SETMASK 1 /* blocked_set = *set; */ +# define SIG_UNBLOCK 2 /* blocked_set = blocked_set & ~*set; */ +extern int sigprocmask (int operation, const sigset_t *set, sigset_t *old_set); + +# define signal rpl_signal +/* Install the handler FUNC for signal SIG, and return the previous + handler. */ +extern void (*signal (int sig, void (*func) (int))) (int); + +# if GNULIB_defined_SIGPIPE + +/* Raise signal SIG. */ +# undef raise +# define raise rpl_raise +extern int raise (int sig); + +# endif + +# endif /* !1 */ +#elif defined GNULIB_POSIXCHECK +# undef sigaddset +# define sigaddset(s,n) \ + (GL_LINK_WARNING ("sigaddset is unportable - " \ + "use gnulib module sigprocmask for portability"), \ + sigaddset (s, n)) +# undef sigdelset +# define sigdelset(s,n) \ + (GL_LINK_WARNING ("sigdelset is unportable - " \ + "use gnulib module sigprocmask for portability"), \ + sigdelset (s, n)) +# undef sigemptyset +# define sigemptyset(s) \ + (GL_LINK_WARNING ("sigemptyset is unportable - " \ + "use gnulib module sigprocmask for portability"), \ + sigemptyset (s)) +# undef sigfillset +# define sigfillset(s) \ + (GL_LINK_WARNING ("sigfillset is unportable - " \ + "use gnulib module sigprocmask for portability"), \ + sigfillset (s)) +# undef sigismember +# define sigismember(s,n) \ + (GL_LINK_WARNING ("sigismember is unportable - " \ + "use gnulib module sigprocmask for portability"), \ + sigismember (s, n)) +# undef sigpending +# define sigpending(s) \ + (GL_LINK_WARNING ("sigpending is unportable - " \ + "use gnulib module sigprocmask for portability"), \ + sigpending (s)) +# undef sigprocmask +# define sigprocmask(h,s,o) \ + (GL_LINK_WARNING ("sigprocmask is unportable - " \ + "use gnulib module sigprocmask for portability"), \ + sigprocmask (h, s, o)) +#endif /* 1 */ + + +#if 1 +# if !1 + +# if !1 +/* Present to allow compilation, but unsupported by gnulib. */ +union sigval +{ + int sival_int; + void *sival_ptr; +}; + +/* Present to allow compilation, but unsupported by gnulib. */ +struct siginfo_t +{ + int si_signo; + int si_code; + int si_errno; + pid_t si_pid; + uid_t si_uid; + void *si_addr; + int si_status; + long si_band; + union sigval si_value; +}; +typedef struct siginfo_t siginfo_t; +# endif /* !1 */ + +/* We assume that platforms which lack the sigaction() function also lack + the 'struct sigaction' type, and vice versa. */ + +struct sigaction +{ + union + { + void (*_sa_handler) (int); + /* Present to allow compilation, but unsupported by gnulib. POSIX + says that implementations may, but not must, make sa_sigaction + overlap with sa_handler, but we know of no implementation where + they do not overlap. */ + void (*_sa_sigaction) (int, siginfo_t *, void *); + } _sa_func; + sigset_t sa_mask; + /* Not all POSIX flags are supported. */ + int sa_flags; +}; +# define sa_handler _sa_func._sa_handler +# define sa_sigaction _sa_func._sa_sigaction +/* Unsupported flags are not present. */ +# define SA_RESETHAND 1 +# define SA_NODEFER 2 +# define SA_RESTART 4 + +extern int sigaction (int, const struct sigaction *restrict, + struct sigaction *restrict); + +# elif !0 + +# define sa_sigaction sa_handler + +# endif /* !1, !0 */ +#elif defined GNULIB_POSIXCHECK +# undef sigaction +# define sigaction(s,a,o) \ + (GL_LINK_WARNING ("sigaction is unportable - " \ + "use gnulib module sigaction for portability"), \ + sigaction (s, a, o)) +#endif + +/* Some systems don't have SA_NODEFER. */ +#ifndef SA_NODEFER +# define SA_NODEFER 0 +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* _GL_SIGNAL_H */ +#endif /* _GL_SIGNAL_H */ +#endif diff --git a/src/bin/coreutils/lib/signal.in.h b/src/bin/coreutils/lib/signal.in.h index 5c42fe9e26..ebfba747eb 100644 --- a/src/bin/coreutils/lib/signal.in.h +++ b/src/bin/coreutils/lib/signal.in.h @@ -1,6 +1,6 @@ /* A GNU-like . - Copyright (C) 2006-2009 Free Software Foundation, Inc. + Copyright (C) 2006-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,6 +37,8 @@ /* The definition of GL_LINK_WARNING is copied here. */ +/* The definition of _GL_ARG_NONNULL is copied here. */ + /* Define pid_t, uid_t. Also, mingw defines sigset_t not in , but in . */ #include @@ -50,6 +52,11 @@ typedef int rpl_sig_atomic_t; # define sig_atomic_t rpl_sig_atomic_t #endif +/* A set or mask of signals. */ +#if !@HAVE_SIGSET_T@ +typedef unsigned int sigset_t; +#endif + #ifdef __cplusplus extern "C" { #endif @@ -66,69 +73,103 @@ extern "C" { #endif -#if !@HAVE_POSIX_SIGNALBLOCKING@ +#if @GNULIB_SIGPROCMASK@ +# if !@HAVE_POSIX_SIGNALBLOCKING@ /* Maximum signal number + 1. */ -# ifndef NSIG -# define NSIG 32 -# endif +# ifndef NSIG +# define NSIG 32 +# endif /* This code supports only 32 signals. */ typedef int verify_NSIG_constraint[2 * (NSIG <= 32) - 1]; -/* A set or mask of signals. */ -# if !@HAVE_SIGSET_T@ -typedef unsigned int sigset_t; -# endif - /* Test whether a given signal is contained in a signal set. */ -extern int sigismember (const sigset_t *set, int sig); +extern int sigismember (const sigset_t *set, int sig) _GL_ARG_NONNULL ((1)); /* Initialize a signal set to the empty set. */ -extern int sigemptyset (sigset_t *set); +extern int sigemptyset (sigset_t *set) _GL_ARG_NONNULL ((1)); /* Add a signal to a signal set. */ -extern int sigaddset (sigset_t *set, int sig); +extern int sigaddset (sigset_t *set, int sig) _GL_ARG_NONNULL ((1)); /* Remove a signal from a signal set. */ -extern int sigdelset (sigset_t *set, int sig); +extern int sigdelset (sigset_t *set, int sig) _GL_ARG_NONNULL ((1)); /* Fill a signal set with all possible signals. */ -extern int sigfillset (sigset_t *set); +extern int sigfillset (sigset_t *set) _GL_ARG_NONNULL ((1)); /* Return the set of those blocked signals that are pending. */ -extern int sigpending (sigset_t *set); +extern int sigpending (sigset_t *set) _GL_ARG_NONNULL ((1)); /* If OLD_SET is not NULL, put the current set of blocked signals in *OLD_SET. Then, if SET is not NULL, affect the current set of blocked signals by combining it with *SET as indicated in OPERATION. In this implementation, you are not allowed to change a signal handler while the signal is blocked. */ -# define SIG_BLOCK 0 /* blocked_set = blocked_set | *set; */ -# define SIG_SETMASK 1 /* blocked_set = *set; */ -# define SIG_UNBLOCK 2 /* blocked_set = blocked_set & ~*set; */ +# define SIG_BLOCK 0 /* blocked_set = blocked_set | *set; */ +# define SIG_SETMASK 1 /* blocked_set = *set; */ +# define SIG_UNBLOCK 2 /* blocked_set = blocked_set & ~*set; */ extern int sigprocmask (int operation, const sigset_t *set, sigset_t *old_set); -# define signal rpl_signal +# define signal rpl_signal /* Install the handler FUNC for signal SIG, and return the previous handler. */ extern void (*signal (int sig, void (*func) (int))) (int); -# if GNULIB_defined_SIGPIPE +# if GNULIB_defined_SIGPIPE /* Raise signal SIG. */ -# undef raise -# define raise rpl_raise +# undef raise +# define raise rpl_raise extern int raise (int sig); -# endif +# endif -#endif /* !@HAVE_POSIX_SIGNALBLOCKING@ */ +# endif /* !@HAVE_POSIX_SIGNALBLOCKING@ */ +#elif defined GNULIB_POSIXCHECK +# undef sigaddset +# define sigaddset(s,n) \ + (GL_LINK_WARNING ("sigaddset is unportable - " \ + "use gnulib module sigprocmask for portability"), \ + sigaddset (s, n)) +# undef sigdelset +# define sigdelset(s,n) \ + (GL_LINK_WARNING ("sigdelset is unportable - " \ + "use gnulib module sigprocmask for portability"), \ + sigdelset (s, n)) +# undef sigemptyset +# define sigemptyset(s) \ + (GL_LINK_WARNING ("sigemptyset is unportable - " \ + "use gnulib module sigprocmask for portability"), \ + sigemptyset (s)) +# undef sigfillset +# define sigfillset(s) \ + (GL_LINK_WARNING ("sigfillset is unportable - " \ + "use gnulib module sigprocmask for portability"), \ + sigfillset (s)) +# undef sigismember +# define sigismember(s,n) \ + (GL_LINK_WARNING ("sigismember is unportable - " \ + "use gnulib module sigprocmask for portability"), \ + sigismember (s, n)) +# undef sigpending +# define sigpending(s) \ + (GL_LINK_WARNING ("sigpending is unportable - " \ + "use gnulib module sigprocmask for portability"), \ + sigpending (s)) +# undef sigprocmask +# define sigprocmask(h,s,o) \ + (GL_LINK_WARNING ("sigprocmask is unportable - " \ + "use gnulib module sigprocmask for portability"), \ + sigprocmask (h, s, o)) +#endif /* @GNULIB_SIGPROCMASK@ */ -#if !@HAVE_SIGACTION@ +#if @GNULIB_SIGACTION@ +# if !@HAVE_SIGACTION@ -# if !@HAVE_SIGINFO_T@ +# if !@HAVE_SIGINFO_T@ /* Present to allow compilation, but unsupported by gnulib. */ union sigval { @@ -150,7 +191,7 @@ struct siginfo_t union sigval si_value; }; typedef struct siginfo_t siginfo_t; -# endif /* !@HAVE_SIGINFO_T@ */ +# endif /* !@HAVE_SIGINFO_T@ */ /* We assume that platforms which lack the sigaction() function also lack the 'struct sigaction' type, and vice versa. */ @@ -170,22 +211,28 @@ struct sigaction /* Not all POSIX flags are supported. */ int sa_flags; }; -# define sa_handler _sa_func._sa_handler -# define sa_sigaction _sa_func._sa_sigaction +# define sa_handler _sa_func._sa_handler +# define sa_sigaction _sa_func._sa_sigaction /* Unsupported flags are not present. */ -# define SA_RESETHAND 1 -# define SA_NODEFER 2 -# define SA_RESTART 4 +# define SA_RESETHAND 1 +# define SA_NODEFER 2 +# define SA_RESTART 4 extern int sigaction (int, const struct sigaction *restrict, struct sigaction *restrict); -#elif !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@ +# elif !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@ -# define sa_sigaction sa_handler - -#endif /* !@HAVE_SIGACTION@, !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@ */ +# define sa_sigaction sa_handler +# endif /* !@HAVE_SIGACTION@, !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@ */ +#elif defined GNULIB_POSIXCHECK +# undef sigaction +# define sigaction(s,a,o) \ + (GL_LINK_WARNING ("sigaction is unportable - " \ + "use gnulib module sigaction for portability"), \ + sigaction (s, a, o)) +#endif /* Some systems don't have SA_NODEFER. */ #ifndef SA_NODEFER diff --git a/src/bin/coreutils/lib/signbitd.c b/src/bin/coreutils/lib/signbitd.c index 30f7e14709..3645615ea9 100644 --- a/src/bin/coreutils/lib/signbitd.c +++ b/src/bin/coreutils/lib/signbitd.c @@ -1,5 +1,5 @@ /* signbit() macro: Determine the sign bit of a floating-point number. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/signbitf.c b/src/bin/coreutils/lib/signbitf.c index c3d5545234..becc7e0c4e 100644 --- a/src/bin/coreutils/lib/signbitf.c +++ b/src/bin/coreutils/lib/signbitf.c @@ -1,5 +1,5 @@ /* signbit() macro: Determine the sign bit of a floating-point number. - Copyright (C) 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/signbitl.c b/src/bin/coreutils/lib/signbitl.c index 84d6493d8d..c0dd49fa8a 100644 --- a/src/bin/coreutils/lib/signbitl.c +++ b/src/bin/coreutils/lib/signbitl.c @@ -1,5 +1,5 @@ /* signbit() macro: Determine the sign bit of a floating-point number. - Copyright (C) 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/sigprocmask.c b/src/bin/coreutils/lib/sigprocmask.c index 7b486a2b04..016325ecfa 100644 --- a/src/bin/coreutils/lib/sigprocmask.c +++ b/src/bin/coreutils/lib/sigprocmask.c @@ -1,5 +1,5 @@ /* POSIX compatible signal blocking. - Copyright (C) 2006-2008 Free Software Foundation, Inc. + Copyright (C) 2006-2010 Free Software Foundation, Inc. Written by Bruno Haible , 2006. This program is free software: you can redistribute it and/or modify @@ -72,9 +72,9 @@ ext_signal (int sig, handler_t handler) { case SIGPIPE: { - handler_t old_handler = SIGPIPE_handler; - SIGPIPE_handler = handler; - return old_handler; + handler_t old_handler = SIGPIPE_handler; + SIGPIPE_handler = handler; + return old_handler; } default: /* System defined signal */ return signal (sig, handler); @@ -90,7 +90,7 @@ sigismember (const sigset_t *set, int sig) { #ifdef SIGABRT_COMPAT if (sig == SIGABRT_COMPAT) - sig = SIGABRT; + sig = SIGABRT; #endif return (*set >> sig) & 1; @@ -113,7 +113,7 @@ sigaddset (sigset_t *set, int sig) { #ifdef SIGABRT_COMPAT if (sig == SIGABRT_COMPAT) - sig = SIGABRT; + sig = SIGABRT; #endif *set |= 1U << sig; @@ -133,7 +133,7 @@ sigdelset (sigset_t *set, int sig) { #ifdef SIGABRT_COMPAT if (sig == SIGABRT_COMPAT) - sig = SIGABRT; + sig = SIGABRT; #endif *set &= ~(1U << sig); @@ -204,60 +204,60 @@ sigprocmask (int operation, const sigset_t *set, sigset_t *old_set) sigset_t to_block; switch (operation) - { - case SIG_BLOCK: - new_blocked_set = blocked_set | *set; - break; - case SIG_SETMASK: - new_blocked_set = *set; - break; - case SIG_UNBLOCK: - new_blocked_set = blocked_set & ~*set; - break; - default: - errno = EINVAL; - return -1; - } + { + case SIG_BLOCK: + new_blocked_set = blocked_set | *set; + break; + case SIG_SETMASK: + new_blocked_set = *set; + break; + case SIG_UNBLOCK: + new_blocked_set = blocked_set & ~*set; + break; + default: + errno = EINVAL; + return -1; + } to_unblock = blocked_set & ~new_blocked_set; to_block = new_blocked_set & ~blocked_set; if (to_block != 0) - { - int sig; + { + int sig; - for (sig = 0; sig < NSIG; sig++) - if ((to_block >> sig) & 1) - { - pending_array[sig] = 0; - if ((old_handlers[sig] = signal (sig, blocked_handler)) != SIG_ERR) - blocked_set |= 1U << sig; - } - } + for (sig = 0; sig < NSIG; sig++) + if ((to_block >> sig) & 1) + { + pending_array[sig] = 0; + if ((old_handlers[sig] = signal (sig, blocked_handler)) != SIG_ERR) + blocked_set |= 1U << sig; + } + } if (to_unblock != 0) - { - sig_atomic_t received[NSIG]; - int sig; + { + sig_atomic_t received[NSIG]; + int sig; - for (sig = 0; sig < NSIG; sig++) - if ((to_unblock >> sig) & 1) - { - if (signal (sig, old_handlers[sig]) != blocked_handler) - /* The application changed a signal handler while the signal - was blocked, bypassing our rpl_signal replacement. - We don't support this. */ - abort (); - received[sig] = pending_array[sig]; - blocked_set &= ~(1U << sig); - pending_array[sig] = 0; - } - else - received[sig] = 0; + for (sig = 0; sig < NSIG; sig++) + if ((to_unblock >> sig) & 1) + { + if (signal (sig, old_handlers[sig]) != blocked_handler) + /* The application changed a signal handler while the signal + was blocked, bypassing our rpl_signal replacement. + We don't support this. */ + abort (); + received[sig] = pending_array[sig]; + blocked_set &= ~(1U << sig); + pending_array[sig] = 0; + } + else + received[sig] = 0; - for (sig = 0; sig < NSIG; sig++) - if (received[sig]) - raise (sig); - } + for (sig = 0; sig < NSIG; sig++) + if (received[sig]) + raise (sig); + } } return 0; } @@ -274,26 +274,26 @@ rpl_signal (int sig, handler_t handler) { #ifdef SIGABRT_COMPAT if (sig == SIGABRT_COMPAT) - sig = SIGABRT; + sig = SIGABRT; #endif if (blocked_set & (1U << sig)) - { - /* POSIX states that sigprocmask and signal are both - async-signal-safe. This is not true of our - implementation - there is a slight data race where an - asynchronous interrupt on signal A can occur after we - install blocked_handler but before we have updated - old_handlers for signal B, such that handler A can see - stale information if it calls signal(B). Oh well - - signal handlers really shouldn't try to manipulate the - installed handlers of unrelated signals. */ - handler_t result = old_handlers[sig]; - old_handlers[sig] = handler; - return result; - } + { + /* POSIX states that sigprocmask and signal are both + async-signal-safe. This is not true of our + implementation - there is a slight data race where an + asynchronous interrupt on signal A can occur after we + install blocked_handler but before we have updated + old_handlers for signal B, such that handler A can see + stale information if it calls signal(B). Oh well - + signal handlers really shouldn't try to manipulate the + installed handlers of unrelated signals. */ + handler_t result = old_handlers[sig]; + old_handlers[sig] = handler; + return result; + } else - return signal (sig, handler); + return signal (sig, handler); } else { @@ -312,15 +312,15 @@ rpl_raise (int sig) { case SIGPIPE: if (blocked_set & (1U << sig)) - pending_array[sig] = 1; + pending_array[sig] = 1; else - { - handler_t handler = SIGPIPE_handler; - if (handler == SIG_DFL) - exit (128 + SIGPIPE); - else if (handler != SIG_IGN) - (*handler) (sig); - } + { + handler_t handler = SIGPIPE_handler; + if (handler == SIG_DFL) + exit (128 + SIGPIPE); + else if (handler != SIG_IGN) + (*handler) (sig); + } return 0; default: /* System defined signal */ return raise (sig); diff --git a/src/bin/coreutils/lib/size_max.h b/src/bin/coreutils/lib/size_max.h index bdb3fff662..c1aa7e4869 100644 --- a/src/bin/coreutils/lib/size_max.h +++ b/src/bin/coreutils/lib/size_max.h @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* size_max.h -- declare SIZE_MAX through system headers - Copyright (C) 2005-2006 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc. Written by Simon Josefsson. This program is free software; you can redistribute it and/or modify diff --git a/src/bin/coreutils/lib/snprintf.c b/src/bin/coreutils/lib/snprintf.c index b74323682e..62396578ff 100644 --- a/src/bin/coreutils/lib/snprintf.c +++ b/src/bin/coreutils/lib/snprintf.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Formatted output to strings. - Copyright (C) 2004, 2006-2008 Free Software Foundation, Inc. + Copyright (C) 2004, 2006-2010 Free Software Foundation, Inc. Written by Simon Josefsson and Paul Eggert. This program is free software; you can redistribute it and/or modify @@ -56,11 +56,11 @@ snprintf (char *str, size_t size, const char *format, ...) if (output != str) { if (size) - { - size_t pruned_len = (len < size ? len : size - 1); - memcpy (str, output, pruned_len); - str[pruned_len] = '\0'; - } + { + size_t pruned_len = (len < size ? len : size - 1); + memcpy (str, output, pruned_len); + str[pruned_len] = '\0'; + } free (output); } diff --git a/src/bin/coreutils/lib/sockets.c b/src/bin/coreutils/lib/sockets.c index 7cb9981d12..b946c7e63d 100644 --- a/src/bin/coreutils/lib/sockets.c +++ b/src/bin/coreutils/lib/sockets.c @@ -1,6 +1,6 @@ /* sockets.c --- wrappers for Windows socket functions - Copyright (C) 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,12 +25,12 @@ #if WINDOWS_SOCKETS /* This includes winsock2.h on MinGW. */ -#include +# include -#include "close-hook.h" +# include "close-hook.h" /* Get set_winsock_errno, FD_TO_SOCKET etc. */ -#include "w32sock.h" +# include "w32sock.h" static int close_fd_maybe_socket (int fd, const struct close_hook *remaining_list) @@ -46,21 +46,21 @@ close_fd_maybe_socket (int fd, const struct close_hook *remaining_list) { /* fd refers to a socket. */ /* FIXME: other applications, like squid, use an undocumented - _free_osfhnd free function. But this is not enough: The 'osfile' - flags for fd also needs to be cleared, but it is hard to access it. - Instead, here we just close twice the file descriptor. */ + _free_osfhnd free function. But this is not enough: The 'osfile' + flags for fd also needs to be cleared, but it is hard to access it. + Instead, here we just close twice the file descriptor. */ if (closesocket (sock)) - { - set_winsock_errno (); - return -1; - } + { + set_winsock_errno (); + return -1; + } else - { - /* This call frees the file descriptor and does a - CloseHandle ((HANDLE) _get_osfhandle (fd)), which fails. */ - _close (fd); - return 0; - } + { + /* This call frees the file descriptor and does a + CloseHandle ((HANDLE) _get_osfhandle (fd)), which fails. */ + _close (fd); + return 0; + } } else /* Some other type of file descriptor. */ @@ -71,10 +71,10 @@ static struct close_hook close_sockets_hook; static int initialized_sockets_version /* = 0 */; -#endif +#endif /* WINDOWS_SOCKETS */ int -gl_sockets_startup (int version) +gl_sockets_startup (int version _GL_UNUSED) { #if WINDOWS_SOCKETS if (version > initialized_sockets_version) @@ -84,13 +84,13 @@ gl_sockets_startup (int version) err = WSAStartup (version, &data); if (err != 0) - return 1; + return 1; if (data.wVersion < version) - return 2; + return 2; if (initialized_sockets_version == 0) - register_close_hook (close_fd_maybe_socket, &close_sockets_hook); + register_close_hook (close_fd_maybe_socket, &close_sockets_hook); initialized_sockets_version = version; } diff --git a/src/bin/coreutils/lib/sockets.h b/src/bin/coreutils/lib/sockets.h index b42e368d21..921bf6f793 100644 --- a/src/bin/coreutils/lib/sockets.h +++ b/src/bin/coreutils/lib/sockets.h @@ -1,6 +1,6 @@ /* sockets.h - wrappers for Windows socket functions - Copyright (C) 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/stat-time.h b/src/bin/coreutils/lib/stat-time.h index 8957ab4608..16300485f3 100644 --- a/src/bin/coreutils/lib/stat-time.h +++ b/src/bin/coreutils/lib/stat-time.h @@ -1,6 +1,6 @@ /* stat-related time functions. - Copyright (C) 2005, 2007 Free Software Foundation, Inc. + Copyright (C) 2005, 2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/stat.c b/src/bin/coreutils/lib/stat.c new file mode 100644 index 0000000000..875317bf52 --- /dev/null +++ b/src/bin/coreutils/lib/stat.c @@ -0,0 +1,104 @@ +/* Work around platform bugs in stat. + Copyright (C) 2009, 2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* written by Eric Blake */ + +#include + +/* Get the original definition of stat. It might be defined as a macro. */ +#define __need_system_sys_stat_h +#include +#include +#undef __need_system_sys_stat_h + +static inline int +orig_stat (const char *filename, struct stat *buf) +{ + return stat (filename, buf); +} + +/* Specification. */ +#include + +#include +#include +#include +#include + +/* Store information about NAME into ST. Work around bugs with + trailing slashes. Mingw has other bugs (such as st_ino always + being 0 on success) which this wrapper does not work around. But + at least this implementation provides the ability to emulate fchdir + correctly. */ + +int +rpl_stat (char const *name, struct stat *st) +{ + int result = orig_stat (name, st); +#if REPLACE_FUNC_STAT_FILE + /* Solaris 9 mistakenly succeeds when given a non-directory with a + trailing slash. */ + if (result == 0 && !S_ISDIR (st->st_mode)) + { + size_t len = strlen (name); + if (ISSLASH (name[len - 1])) + { + errno = ENOTDIR; + return -1; + } + } +#endif /* REPLACE_FUNC_STAT_FILE */ +#if REPLACE_FUNC_STAT_DIR + if (result == -1 && errno == ENOENT) + { + /* Due to mingw's oddities, there are some directories (like + c:\) where stat() only succeeds with a trailing slash, and + other directories (like c:\windows) where stat() only + succeeds without a trailing slash. But we want the two to be + synonymous, since chdir() manages either style. Likewise, Mingw also + reports ENOENT for names longer than PATH_MAX, when we want + ENAMETOOLONG, and for stat("file/"), when we want ENOTDIR. + Fortunately, mingw PATH_MAX is small enough for stack + allocation. */ + char fixed_name[PATH_MAX + 1] = {0}; + size_t len = strlen (name); + bool check_dir = false; + if (PATH_MAX <= len) + errno = ENAMETOOLONG; + else if (len) + { + strcpy (fixed_name, name); + if (ISSLASH (fixed_name[len - 1])) + { + check_dir = true; + while (len && ISSLASH (fixed_name[len - 1])) + fixed_name[--len] = '\0'; + if (!len) + fixed_name[0] = '/'; + } + else + fixed_name[len++] = '/'; + result = orig_stat (fixed_name, st); + if (result == 0 && check_dir && !S_ISDIR (st->st_mode)) + { + result = -1; + errno = ENOTDIR; + } + } + } +#endif /* REPLACE_FUNC_STAT_DIR */ + return result; +} diff --git a/src/bin/coreutils/lib/stdarg.in.h b/src/bin/coreutils/lib/stdarg.in.h index 947f076c96..7f3254daf2 100644 --- a/src/bin/coreutils/lib/stdarg.in.h +++ b/src/bin/coreutils/lib/stdarg.in.h @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Substitute for and wrapper around . - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/stdbool.h b/src/bin/coreutils/lib/stdbool.h new file mode 100644 index 0000000000..88ec021ff7 --- /dev/null +++ b/src/bin/coreutils/lib/stdbool.h @@ -0,0 +1,123 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +#line 1 +/* Copyright (C) 2001-2003, 2006-2010 Free Software Foundation, Inc. + Written by Bruno Haible , 2001. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef _GL_STDBOOL_H +#define _GL_STDBOOL_H + +/* ISO C 99 for platforms that lack it. */ + +/* Usage suggestions: + + Programs that use should be aware of some limitations + and standards compliance issues. + + Standards compliance: + + - must be #included before 'bool', 'false', 'true' + can be used. + + - You cannot assume that sizeof (bool) == 1. + + - Programs should not undefine the macros bool, true, and false, + as C99 lists that as an "obsolescent feature". + + Limitations of this substitute, when used in a C89 environment: + + - must be #included before the '_Bool' type can be used. + + - You cannot assume that _Bool is a typedef; it might be a macro. + + - Bit-fields of type 'bool' are not supported. Portable code + should use 'unsigned int foo : 1;' rather than 'bool foo : 1;'. + + - In C99, casts and automatic conversions to '_Bool' or 'bool' are + performed in such a way that every nonzero value gets converted + to 'true', and zero gets converted to 'false'. This doesn't work + with this substitute. With this substitute, only the values 0 and 1 + give the expected result when converted to _Bool' or 'bool'. + + Also, it is suggested that programs use 'bool' rather than '_Bool'; + this isn't required, but 'bool' is more common. */ + + +/* 7.16. Boolean type and values */ + +/* BeOS already #defines false 0, true 1. We use the same + definitions below, but temporarily we have to #undef them. */ +#if defined __BEOS__ && !defined __HAIKU__ +# include /* defines bool but not _Bool */ +# undef false +# undef true +#endif + +/* For the sake of symbolic names in gdb, we define true and false as + enum constants, not only as macros. + It is tempting to write + typedef enum { false = 0, true = 1 } _Bool; + so that gdb prints values of type 'bool' symbolically. But if we do + this, values of type '_Bool' may promote to 'int' or 'unsigned int' + (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int' + (see ISO C 99 6.3.1.1.(2)). So we add a negative value to the + enum; this ensures that '_Bool' promotes to 'int'. */ +#if defined __cplusplus || (defined __BEOS__ && !defined __HAIKU__) + /* A compiler known to have 'bool'. */ + /* If the compiler already has both 'bool' and '_Bool', we can assume they + are the same types. */ +# if !0 +typedef bool _Bool; +# endif +#else +# if !defined __GNUC__ + /* If 0: + Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when + the built-in _Bool type is used. See + http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html + http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html + http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html + Similar bugs are likely with other compilers as well; this file + wouldn't be used if was working. + So we override the _Bool type. + If !0: + Need to define _Bool ourselves. As 'signed char' or as an enum type? + Use of a typedef, with SunPRO C, leads to a stupid + "warning: _Bool is a keyword in ISO C99". + Use of an enum type, with IRIX cc, leads to a stupid + "warning(1185): enumerated type mixed with another type". + Even the existence of an enum type, without a typedef, + "Invalid enumerator. (badenum)" with HP-UX cc on Tru64. + The only benefit of the enum, debuggability, is not important + with these compilers. So use 'signed char' and no enum. */ +# define _Bool signed char +# else + /* With this compiler, trust the _Bool type if the compiler has it. */ +# if !0 +typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool; +# endif +# endif +#endif +#define bool _Bool + +/* The other macros must be usable in preprocessor directives. */ +#define false 0 +#define true 1 +#define __bool_true_false_are_defined 1 + +#endif /* _GL_STDBOOL_H */ diff --git a/src/bin/coreutils/lib/stdbool.in.h b/src/bin/coreutils/lib/stdbool.in.h index 72681fc2fc..b1e59d043a 100644 --- a/src/bin/coreutils/lib/stdbool.in.h +++ b/src/bin/coreutils/lib/stdbool.in.h @@ -1,7 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 -/* Copyright (C) 2001-2003, 2006-2008 Free Software Foundation, Inc. +/* Copyright (C) 2001-2003, 2006-2010 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify diff --git a/src/bin/coreutils/lib/stddef.in.h b/src/bin/coreutils/lib/stddef.in.h index c60c26eb32..d635b26fbe 100644 --- a/src/bin/coreutils/lib/stddef.in.h +++ b/src/bin/coreutils/lib/stddef.in.h @@ -3,7 +3,7 @@ #line 1 /* A substitute for POSIX 2008 , for platforms that have issues. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009, 2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/stdint.h b/src/bin/coreutils/lib/stdint.h index 3987ca17f0..c8802b1c35 100644 --- a/src/bin/coreutils/lib/stdint.h +++ b/src/bin/coreutils/lib/stdint.h @@ -1,11 +1,14 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ -/* Copyright (C) 2001-2002, 2004-2006 Free Software Foundation, Inc. +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +#line 1 +/* Copyright (C) 2001-2002, 2004-2010 Free Software Foundation, Inc. Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood. This file is part of gnulib. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) + the Free Software Foundation; either version 3, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -17,14 +20,19 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef _GL_STDINT_H -#define _GL_STDINT_H - /* * ISO C 99 for platforms that lack it. * */ +#ifndef _GL_STDINT_H + +/* When including a system file that in turn includes , + use the system , not our substitute. This avoids + problems with (for example) VMS, whose includes + . */ +#define _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H + /* Get those types that are already defined in other system include files, so that we can "#define int8_t signed char" below without worrying about a later system include file containing a "typedef @@ -43,16 +51,23 @@ /* Other systems may have an incomplete or buggy . Include it before , since any "#include " in would reinclude us, skipping our contents because - _GL_STDINT_H is defined. */ -# include_next "stdint.h" + _GL_STDINT_H is defined. + The include_next requires a split double-inclusion guard. */ +# if __GNUC__ >= 3 +#pragma GCC system_header +# endif +# include_next #endif +#if ! defined _GL_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H +#define _GL_STDINT_H + /* defines some of the stdint.h types as well, on glibc, IRIX 6.5, and OpenBSD 3.8 (via ). AIX 5.2 isn't needed and causes troubles. MacOS X 10.4.6 includes (which is us), but relies on the system definitions, so include - after "///boot/home/svnhaiku/trunk/headers/posix/stdint.h". */ + after . */ #if 1 && ! defined _AIX # include #endif @@ -64,9 +79,7 @@ /* In OpenBSD 3.8, includes , which defines int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__. also defines intptr_t and uintptr_t. */ -# define _GL_JUST_INCLUDE_ABSOLUTE_INTTYPES_H # include -# undef _GL_JUST_INCLUDE_ABSOLUTE_INTTYPES_H #elif 0 /* Solaris 7 has the types except the *_fast*_t types, and the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. */ @@ -80,18 +93,7 @@ # include #endif -#if ! defined __cplusplus || defined __STDC_CONSTANT_MACROS - -/* Get WCHAR_MIN, WCHAR_MAX. */ -# if 1 && ! (defined WCHAR_MIN && defined WCHAR_MAX) - /* BSD/OS 4.1 has a bug: and must be included before - . */ -# include -# include -# include -# endif - -#endif +#undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H /* Minimum and maximum values for a integer type under the usual assumption. Return an unspecified value if BITS == 0, adding a check to pacify @@ -103,7 +105,10 @@ #define _STDINT_MAX(signed, bits, zero) \ ((signed) \ ? ~ _STDINT_MIN (signed, bits, zero) \ - : ((((zero) + 1) << ((bits) ? (bits) - 1 : 0)) - 1) * 2 + 1) + : /* The expression for the unsigned case. The subtraction of (signed) \ + is a nop in the unsigned case and avoids "signed integer overflow" \ + warnings in the signed case. */ \ + ((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1) /* 7.18.1.1. Exact-width integer types */ @@ -112,35 +117,59 @@ #undef int8_t #undef uint8_t -#define int8_t signed char -#define uint8_t unsigned char +typedef signed char gl_int8_t; +typedef unsigned char gl_uint8_t; +#define int8_t gl_int8_t +#define uint8_t gl_uint8_t #undef int16_t #undef uint16_t -#define int16_t short int -#define uint16_t unsigned short int +typedef short int gl_int16_t; +typedef unsigned short int gl_uint16_t; +#define int16_t gl_int16_t +#define uint16_t gl_uint16_t #undef int32_t #undef uint32_t -#define int32_t int -#define uint32_t unsigned int +typedef int gl_int32_t; +typedef unsigned int gl_uint32_t; +#define int32_t gl_int32_t +#define uint32_t gl_uint32_t -#undef int64_t +/* Do not undefine int64_t if gnulib is not being used with 64-bit + types, since otherwise it breaks platforms like Tandem/NSK. */ #if LONG_MAX >> 31 >> 31 == 1 -# define int64_t long int +# undef int64_t +typedef long int gl_int64_t; +# define int64_t gl_int64_t +# define GL_INT64_T #elif defined _MSC_VER -# define int64_t __int64 +# undef int64_t +typedef __int64 gl_int64_t; +# define int64_t gl_int64_t +# define GL_INT64_T #elif 1 -# define int64_t long long int +# undef int64_t +typedef long long int gl_int64_t; +# define int64_t gl_int64_t +# define GL_INT64_T #endif -#undef uint64_t #if ULONG_MAX >> 31 >> 31 >> 1 == 1 -# define uint64_t unsigned long int +# undef uint64_t +typedef unsigned long int gl_uint64_t; +# define uint64_t gl_uint64_t +# define GL_UINT64_T #elif defined _MSC_VER -# define uint64_t unsigned __int64 +# undef uint64_t +typedef unsigned __int64 gl_uint64_t; +# define uint64_t gl_uint64_t +# define GL_UINT64_T #elif 1 -# define uint64_t unsigned long long int +# undef uint64_t +typedef unsigned long long int gl_uint64_t; +# define uint64_t gl_uint64_t +# define GL_UINT64_T #endif /* Avoid collision with Solaris 2.5.1 etc. */ @@ -169,10 +198,10 @@ #define uint_least16_t uint16_t #define int_least32_t int32_t #define uint_least32_t uint32_t -#ifdef int64_t +#ifdef GL_INT64_T # define int_least64_t int64_t #endif -#ifdef uint64_t +#ifdef GL_UINT64_T # define uint_least64_t uint64_t #endif @@ -194,16 +223,22 @@ #undef uint_fast32_t #undef int_fast64_t #undef uint_fast64_t -#define int_fast8_t long int -#define uint_fast8_t unsigned int_fast8_t -#define int_fast16_t long int -#define uint_fast16_t unsigned int_fast16_t -#define int_fast32_t long int -#define uint_fast32_t unsigned int_fast32_t -#ifdef int64_t +typedef long int gl_int_fast8_t; +typedef unsigned long int gl_uint_fast8_t; +typedef long int gl_int_fast16_t; +typedef unsigned long int gl_uint_fast16_t; +typedef long int gl_int_fast32_t; +typedef unsigned long int gl_uint_fast32_t; +#define int_fast8_t gl_int_fast8_t +#define uint_fast8_t gl_uint_fast8_t +#define int_fast16_t gl_int_fast16_t +#define uint_fast16_t gl_uint_fast16_t +#define int_fast32_t gl_int_fast32_t +#define uint_fast32_t gl_uint_fast32_t +#ifdef GL_INT64_T # define int_fast64_t int64_t #endif -#ifdef uint64_t +#ifdef GL_UINT64_T # define uint_fast64_t uint64_t #endif @@ -211,8 +246,10 @@ #undef intptr_t #undef uintptr_t -#define intptr_t long int -#define uintptr_t unsigned long int +typedef long int gl_intptr_t; +typedef unsigned long int gl_uintptr_t; +#define intptr_t gl_intptr_t +#define uintptr_t gl_uintptr_t /* 7.18.1.5. Greatest-width integer types */ @@ -221,22 +258,31 @@ #undef intmax_t #if 1 && LONG_MAX >> 30 == 1 -# define intmax_t long long int -#elif defined int64_t +typedef long long int gl_intmax_t; +# define intmax_t gl_intmax_t +#elif defined GL_INT64_T # define intmax_t int64_t #else -# define intmax_t long int +typedef long int gl_intmax_t; +# define intmax_t gl_intmax_t #endif #undef uintmax_t #if 1 && ULONG_MAX >> 31 == 1 -# define uintmax_t unsigned long long int -#elif defined uint64_t +typedef unsigned long long int gl_uintmax_t; +# define uintmax_t gl_uintmax_t +#elif defined GL_UINT64_T # define uintmax_t uint64_t #else -# define uintmax_t unsigned long int +typedef unsigned long int gl_uintmax_t; +# define uintmax_t gl_uintmax_t #endif +/* Verify that intmax_t and uintmax_t have the same size. Too much code + breaks if this is not the case. If this check fails, the reason is likely + to be found in the autoconf macros. */ +typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) - 1]; + /* 7.18.2. Limits of specified-width integer types */ #if ! defined __cplusplus || defined __STDC_LIMIT_MACROS @@ -269,13 +315,15 @@ #undef INT64_MIN #undef INT64_MAX -#ifdef int64_t -# define INT64_MIN (~ INT64_MAX) +#ifdef GL_INT64_T +/* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0 + evaluates the latter incorrectly in preprocessor expressions. */ +# define INT64_MIN (- INTMAX_C (1) << 63) # define INT64_MAX INTMAX_C (9223372036854775807) #endif #undef UINT64_MAX -#ifdef uint64_t +#ifdef GL_UINT64_T # define UINT64_MAX UINTMAX_C (18446744073709551615) #endif @@ -308,13 +356,13 @@ #undef INT_LEAST64_MIN #undef INT_LEAST64_MAX -#ifdef int64_t +#ifdef GL_INT64_T # define INT_LEAST64_MIN INT64_MIN # define INT_LEAST64_MAX INT64_MAX #endif #undef UINT_LEAST64_MAX -#ifdef uint64_t +#ifdef GL_UINT64_T # define UINT_LEAST64_MAX UINT64_MAX #endif @@ -347,13 +395,13 @@ #undef INT_FAST64_MIN #undef INT_FAST64_MAX -#ifdef int64_t +#ifdef GL_INT64_T # define INT_FAST64_MIN INT64_MIN # define INT_FAST64_MAX INT64_MAX #endif #undef UINT_FAST64_MAX -#ifdef uint64_t +#ifdef GL_UINT64_T # define UINT_FAST64_MAX UINT64_MAX #endif @@ -370,10 +418,11 @@ #undef INTMAX_MIN #undef INTMAX_MAX -#define INTMAX_MIN (~ INTMAX_MAX) #ifdef INT64_MAX +# define INTMAX_MIN INT64_MIN # define INTMAX_MAX INT64_MAX #else +# define INTMAX_MIN INT32_MIN # define INTMAX_MAX INT32_MAX #endif @@ -389,33 +438,60 @@ /* ptrdiff_t limits */ #undef PTRDIFF_MIN #undef PTRDIFF_MAX -#define PTRDIFF_MIN \ - _STDINT_MIN (1, 32, 0l) -#define PTRDIFF_MAX \ - _STDINT_MAX (1, 32, 0l) +#if 0 +# ifdef _LP64 +# define PTRDIFF_MIN _STDINT_MIN (1, 64, 0l) +# define PTRDIFF_MAX _STDINT_MAX (1, 64, 0l) +# else +# define PTRDIFF_MIN _STDINT_MIN (1, 32, 0) +# define PTRDIFF_MAX _STDINT_MAX (1, 32, 0) +# endif +#else +# define PTRDIFF_MIN \ + _STDINT_MIN (1, 32, 0l) +# define PTRDIFF_MAX \ + _STDINT_MAX (1, 32, 0l) +#endif /* sig_atomic_t limits */ #undef SIG_ATOMIC_MIN #undef SIG_ATOMIC_MAX #define SIG_ATOMIC_MIN \ _STDINT_MIN (1, 32, \ - 0) + 0) #define SIG_ATOMIC_MAX \ _STDINT_MAX (1, 32, \ - 0) + 0) /* size_t limit */ #undef SIZE_MAX -#define SIZE_MAX _STDINT_MAX (0, 32, 0ul) +#if 0 +# ifdef _LP64 +# define SIZE_MAX _STDINT_MAX (0, 64, 0ul) +# else +# define SIZE_MAX _STDINT_MAX (0, 32, 0ul) +# endif +#else +# define SIZE_MAX _STDINT_MAX (0, 32, 0ul) +#endif /* wchar_t limits */ +/* Get WCHAR_MIN, WCHAR_MAX. + This include is not on the top, above, because on OSF/1 4.0 we have a sequence of nested + includes -> -> -> , and the latter includes + and assumes its types are already defined. */ +#if ! (defined WCHAR_MIN && defined WCHAR_MAX) +# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H +# include +# undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H +#endif #undef WCHAR_MIN #undef WCHAR_MAX #define WCHAR_MIN \ - _STDINT_MIN (0, 16, 0) + _STDINT_MIN (1, 32, 0) #define WCHAR_MAX \ - _STDINT_MAX (0, 16, 0) + _STDINT_MAX (1, 32, 0) /* wint_t limits */ #undef WINT_MIN @@ -474,7 +550,7 @@ #undef INTMAX_C #if 1 && LONG_MAX >> 30 == 1 # define INTMAX_C(x) x##LL -#elif defined int64_t +#elif defined GL_INT64_T # define INTMAX_C(x) INT64_C(x) #else # define INTMAX_C(x) x##L @@ -483,7 +559,7 @@ #undef UINTMAX_C #if 1 && ULONG_MAX >> 31 == 1 # define UINTMAX_C(x) x##ULL -#elif defined uint64_t +#elif defined GL_UINT64_T # define UINTMAX_C(x) UINT64_C(x) #else # define UINTMAX_C(x) x##UL @@ -492,3 +568,4 @@ #endif /* !defined __cplusplus || defined __STDC_CONSTANT_MACROS */ #endif /* _GL_STDINT_H */ +#endif /* !defined _GL_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */ diff --git a/src/bin/coreutils/lib/stdint.in.h b/src/bin/coreutils/lib/stdint.in.h index 710600eaf0..81f78ea18d 100644 --- a/src/bin/coreutils/lib/stdint.in.h +++ b/src/bin/coreutils/lib/stdint.in.h @@ -1,7 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 -/* Copyright (C) 2001-2002, 2004-2009 Free Software Foundation, Inc. +/* Copyright (C) 2001-2002, 2004-2010 Free Software Foundation, Inc. Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood. This file is part of gnulib. @@ -105,8 +105,8 @@ ((signed) \ ? ~ _STDINT_MIN (signed, bits, zero) \ : /* The expression for the unsigned case. The subtraction of (signed) \ - is a nop in the unsigned case and avoids "signed integer overflow" \ - warnings in the signed case. */ \ + is a nop in the unsigned case and avoids "signed integer overflow" \ + warnings in the signed case. */ \ ((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1) /* 7.18.1.1. Exact-width integer types */ @@ -457,10 +457,10 @@ typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) - #undef SIG_ATOMIC_MAX #define SIG_ATOMIC_MIN \ _STDINT_MIN (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ - 0@SIG_ATOMIC_T_SUFFIX@) + 0@SIG_ATOMIC_T_SUFFIX@) #define SIG_ATOMIC_MAX \ _STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ - 0@SIG_ATOMIC_T_SUFFIX@) + 0@SIG_ATOMIC_T_SUFFIX@) /* size_t limit */ diff --git a/src/bin/coreutils/lib/stdio--.h b/src/bin/coreutils/lib/stdio--.h index ed90dda5a5..b832308963 100644 --- a/src/bin/coreutils/lib/stdio--.h +++ b/src/bin/coreutils/lib/stdio--.h @@ -1,6 +1,6 @@ /* Like stdio.h, but redefine some names to avoid glitches. - Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,6 +25,11 @@ # define fopen fopen_safer #endif +#if GNULIB_FREOPEN_SAFER +# undef freopen +# define freopen freopen_safer +#endif + #if GNULIB_TMPFILE_SAFER # undef tmpfile # define tmpfile tmpfile_safer diff --git a/src/bin/coreutils/lib/stdio-impl.h b/src/bin/coreutils/lib/stdio-impl.h index c803e88c97..7d719efe1b 100644 --- a/src/bin/coreutils/lib/stdio-impl.h +++ b/src/bin/coreutils/lib/stdio-impl.h @@ -1,5 +1,5 @@ /* Implementation details of FILE streams. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,21 +26,21 @@ # if defined __DragonFly__ /* DragonFly */ /* See . */ # define fp_ ((struct { struct __FILE_public pub; \ - struct { unsigned char *_base; int _size; } _bf; \ - void *cookie; \ - void *_close; \ - void *_read; \ - void *_seek; \ - void *_write; \ - struct { unsigned char *_base; int _size; } _ub; \ - int _ur; \ - unsigned char _ubuf[3]; \ - unsigned char _nbuf[1]; \ - struct { unsigned char *_base; int _size; } _lb; \ - int _blksize; \ - fpos_t _offset; \ - /* More fields, not relevant here. */ \ - } *) fp) + struct { unsigned char *_base; int _size; } _bf; \ + void *cookie; \ + void *_close; \ + void *_read; \ + void *_seek; \ + void *_write; \ + struct { unsigned char *_base; int _size; } _ub; \ + int _ur; \ + unsigned char _ubuf[3]; \ + unsigned char _nbuf[1]; \ + struct { unsigned char *_base; int _size; } _lb; \ + int _blksize; \ + fpos_t _offset; \ + /* More fields, not relevant here. */ \ + } *) fp) /* See . */ # define _p pub._p # define _flags pub._flags @@ -74,12 +74,12 @@ # if defined __sun && defined _LP64 /* Solaris/{SPARC,AMD64} 64-bit */ # define fp_ ((struct { unsigned char *_ptr; \ - unsigned char *_base; \ - unsigned char *_end; \ - long _cnt; \ - int _file; \ - unsigned int _flag; \ - } *) fp) + unsigned char *_base; \ + unsigned char *_end; \ + long _cnt; \ + int _file; \ + unsigned int _flag; \ + } *) fp) # else # define fp_ fp # endif diff --git a/src/bin/coreutils/lib/stdio-safer.h b/src/bin/coreutils/lib/stdio-safer.h index dde22f1045..9a7c4da5aa 100644 --- a/src/bin/coreutils/lib/stdio-safer.h +++ b/src/bin/coreutils/lib/stdio-safer.h @@ -1,6 +1,6 @@ /* Invoke stdio functions, but avoid some glitches. - Copyright (C) 2001, 2003, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2001, 2003, 2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,6 +19,18 @@ #include +#if GNULIB_FOPEN_SAFER FILE *fopen_safer (char const *, char const *); +#endif + +#if GNULIB_FREOPEN_SAFER +FILE *freopen_safer (char const *, char const *, FILE *); +#endif + +#if GNULIB_POPEN_SAFER FILE *popen_safer (char const *, char const *); +#endif + +#if GNULIB_TMPFILE_SAFER FILE *tmpfile_safer (void); +#endif diff --git a/src/bin/coreutils/lib/stdio-write.c b/src/bin/coreutils/lib/stdio-write.c index 15cc5ed742..f7da9e420b 100644 --- a/src/bin/coreutils/lib/stdio-write.c +++ b/src/bin/coreutils/lib/stdio-write.c @@ -1,5 +1,5 @@ /* POSIX compatible FILE stream write function. - Copyright (C) 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. Written by Bruno Haible , 2008. This program is free software: you can redistribute it and/or modify @@ -39,27 +39,27 @@ # include # define CALL_WITH_SIGPIPE_EMULATION(RETTYPE, EXPRESSION, FAILED) \ - if (ferror (stream)) \ - return (EXPRESSION); \ - else \ - { \ - RETTYPE ret; \ - SetLastError (0); \ - ret = (EXPRESSION); \ + if (ferror (stream)) \ + return (EXPRESSION); \ + else \ + { \ + RETTYPE ret; \ + SetLastError (0); \ + ret = (EXPRESSION); \ if (FAILED && GetLastError () == ERROR_NO_DATA && ferror (stream)) \ - { \ - int fd = fileno (stream); \ - if (fd >= 0 \ - && GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE)\ - { \ - /* Try to raise signal SIGPIPE. */ \ - raise (SIGPIPE); \ - /* If it is currently blocked or ignored, change errno from \ - EINVAL to EPIPE. */ \ - errno = EPIPE; \ - } \ - } \ - return ret; \ + { \ + int fd = fileno (stream); \ + if (fd >= 0 \ + && GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE)\ + { \ + /* Try to raise signal SIGPIPE. */ \ + raise (SIGPIPE); \ + /* If it is currently blocked or ignored, change errno from \ + EINVAL to EPIPE. */ \ + errno = EPIPE; \ + } \ + } \ + return ret; \ } # if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */ diff --git a/src/bin/coreutils/lib/stdio.in.h b/src/bin/coreutils/lib/stdio.in.h index 14067da9db..414d332c8d 100644 --- a/src/bin/coreutils/lib/stdio.in.h +++ b/src/bin/coreutils/lib/stdio.in.h @@ -3,7 +3,7 @@ #line 1 /* A GNU-like . - Copyright (C) 2004, 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2004, 2007-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -39,16 +39,13 @@ #ifndef _GL_STDIO_H #define _GL_STDIO_H +/* Get va_list. Needed on many systems, including glibc 2.8. */ #include + #include -#if (@GNULIB_FSEEKO@ && @REPLACE_FSEEKO@) \ - || (@GNULIB_FTELLO@ && @REPLACE_FTELLO@) \ - || (@GNULIB_GETDELIM@ && !@HAVE_DECL_GETDELIM@) \ - || (@GNULIB_GETLINE@ && (!@HAVE_DECL_GETLINE@ || @REPLACE_GETLINE@)) -/* Get off_t and ssize_t. */ -# include -#endif +/* Get off_t and ssize_t. Needed on many systems, including glibc 2.8. */ +#include #ifndef __attribute__ /* This feature is available in gcc versions 2.5 and later. */ @@ -66,6 +63,10 @@ /* The definition of GL_LINK_WARNING is copied here. */ +/* The definition of _GL_ARG_NONNULL is copied here. */ + +/* The definition of _GL_WARN_ON_USE is copied here. */ + #ifdef __cplusplus extern "C" { @@ -77,21 +78,21 @@ extern "C" { # endif # if @REPLACE_DPRINTF@ || !@HAVE_DPRINTF@ extern int dprintf (int fd, const char *format, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); + __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((2)); # endif #elif defined GNULIB_POSIXCHECK # undef dprintf -# define dprintf(d,f,a) \ +# define dprintf \ (GL_LINK_WARNING ("dprintf is unportable - " \ "use gnulib module dprintf for portability"), \ - dprintf (d, f, a)) + dprintf) #endif #if @GNULIB_FCLOSE@ # if @REPLACE_FCLOSE@ # define fclose rpl_fclose /* Close STREAM and its underlying file descriptor. */ -extern int fclose (FILE *stream); +extern int fclose (FILE *stream) _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef fclose @@ -122,11 +123,18 @@ extern int fclose (FILE *stream); fflush (f)) #endif +/* It is very rare that the developer ever has full control of stdin, + so any use of gets warrants an unconditional warning. Assume it is + always declared, since it is required by C89. */ +#undef gets +_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); + #if @GNULIB_FOPEN@ # if @REPLACE_FOPEN@ # undef fopen # define fopen rpl_fopen -extern FILE * fopen (const char *filename, const char *mode); +extern FILE * fopen (const char *filename, const char *mode) + _GL_ARG_NONNULL ((1, 2)); # endif #elif defined GNULIB_POSIXCHECK # undef fopen @@ -140,12 +148,14 @@ extern FILE * fopen (const char *filename, const char *mode); # if @REPLACE_FPRINTF@ # define fprintf rpl_fprintf extern int fprintf (FILE *fp, const char *format, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); + __attribute__ ((__format__ (__printf__, 2, 3))) + _GL_ARG_NONNULL ((1, 2)); # endif #elif @GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ # define fprintf rpl_fprintf extern int fprintf (FILE *fp, const char *format, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); + __attribute__ ((__format__ (__printf__, 2, 3))) + _GL_ARG_NONNULL ((1, 2)); #elif defined GNULIB_POSIXCHECK # undef fprintf # define fprintf \ @@ -166,7 +176,7 @@ extern int fprintf (FILE *fp, const char *format, ...) was before the write calls. When discarding pending input, the file position is advanced to match the end of the previously read input. Return 0 if successful. Upon error, return -1 and set errno. */ - extern int fpurge (FILE *gl_stream); + extern int fpurge (FILE *gl_stream) _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef fpurge @@ -179,20 +189,21 @@ extern int fprintf (FILE *fp, const char *format, ...) #if @GNULIB_FPUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ # undef fputc # define fputc rpl_fputc -extern int fputc (int c, FILE *stream); +extern int fputc (int c, FILE *stream) _GL_ARG_NONNULL ((2)); #endif #if @GNULIB_FPUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ # undef fputs # define fputs rpl_fputs -extern int fputs (const char *string, FILE *stream); +extern int fputs (const char *string, FILE *stream) _GL_ARG_NONNULL ((1, 2)); #endif #if @GNULIB_FREOPEN@ # if @REPLACE_FREOPEN@ # undef freopen # define freopen rpl_freopen -extern FILE * freopen (const char *filename, const char *mode, FILE *stream); +extern FILE * freopen (const char *filename, const char *mode, FILE *stream) + _GL_ARG_NONNULL ((2, 3)); # endif #elif defined GNULIB_POSIXCHECK # undef freopen @@ -202,84 +213,143 @@ extern FILE * freopen (const char *filename, const char *mode, FILE *stream); freopen (f, m, s)) #endif -#if @GNULIB_FSEEK@ && @REPLACE_FSEEK@ -extern int rpl_fseek (FILE *fp, long offset, int whence); -# undef fseek -# if defined GNULIB_POSIXCHECK -# define fseek(f,o,w) \ - (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \ - "on 32-bit platforms - " \ - "use fseeko function for handling of large files"), \ - rpl_fseek (f, o, w)) -# else -# define fseek rpl_fseek +/* Set up the following warnings, based on which modules are in use. + GNU Coding Standards discourage the use of fseek, since it imposes + an arbitrary limitation on some 32-bit hosts. Remember that the + fseek module depends on the fseeko module, so we only have three + cases to consider: + + 1. The developer is not using either module. Issue a warning under + GNULIB_POSIXCHECK for both functions, to remind them that both + functions have bugs on some systems. _GL_NO_LARGE_FILES has no + impact on this warning. + + 2. The developer is using both modules. They may be unaware of the + arbitrary limitations of fseek, so issue a warning under + GNULIB_POSIXCHECK. On the other hand, they may be using both + modules intentionally, so the developer can define + _GL_NO_LARGE_FILES in the compilation units where the use of fseek + is safe, to silence the warning. + + 3. The developer is using the fseeko module, but not fseek. Gnulib + guarantees that fseek will still work around platform bugs in that + case, but we presume that the developer is aware of the pitfalls of + fseek and was trying to avoid it, so issue a warning even when + GNULIB_POSIXCHECK is undefined. Again, _GL_NO_LARGE_FILES can be + defined to silence the warning in particular compilation units. + + Most gnulib clients that perform stream operations should fall into + category three. */ + +#if @GNULIB_FSEEK@ +# if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES +# define _GL_FSEEK_WARN /* Category 2, above. */ +# undef fseek # endif -#elif defined GNULIB_POSIXCHECK -# ifndef fseek -# define fseek(f,o,w) \ - (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \ - "on 32-bit platforms - " \ - "use fseeko function for handling of large files"), \ - fseek (f, o, w)) +# if @REPLACE_FSEEK@ +# undef fseek +# define fseek rpl_fseek +extern int fseek (FILE *fp, long offset, int whence) _GL_ARG_NONNULL ((1)); # endif #endif #if @GNULIB_FSEEKO@ +# if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES +# define _GL_FSEEK_WARN /* Category 3, above. */ +# undef fseek +# endif # if @REPLACE_FSEEKO@ /* Provide fseek, fseeko functions that are aware of a preceding fflush(), and which detect pipes. */ +# undef fseeko # define fseeko rpl_fseeko -extern int fseeko (FILE *fp, off_t offset, int whence); -# define fseek(fp, offset, whence) fseeko (fp, (off_t)(offset), whence) +extern int fseeko (FILE *fp, off_t offset, int whence) _GL_ARG_NONNULL ((1)); +# if !@GNULIB_FSEEK@ +# undef fseek +# define fseek rpl_fseek +static inline int _GL_ARG_NONNULL ((1)) +rpl_fseek (FILE *fp, long offset, int whence) +{ + return fseeko (fp, offset, whence); +} +# endif # endif #elif defined GNULIB_POSIXCHECK +# define _GL_FSEEK_WARN /* Category 1, above. */ +# undef fseek # undef fseeko -# define fseeko(f,o,w) \ - (GL_LINK_WARNING ("fseeko is unportable - " \ - "use gnulib module fseeko for portability"), \ - fseeko (f, o, w)) +# if HAVE_RAW_DECL_FSEEKO +_GL_WARN_ON_USE (fseeko, "fseeko is unportable - " + "use gnulib module fseeko for portability"); +# endif #endif -#if @GNULIB_FTELL@ && @REPLACE_FTELL@ -extern long rpl_ftell (FILE *fp); -# undef ftell -# if GNULIB_POSIXCHECK -# define ftell(f) \ - (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \ - "on 32-bit platforms - " \ - "use ftello function for handling of large files"), \ - rpl_ftell (f)) -# else -# define ftell rpl_ftell +#ifdef _GL_FSEEK_WARN +# undef _GL_FSEEK_WARN +/* Here, either fseek is undefined (but C89 guarantees that it is + declared), or it is defined as rpl_fseek (declared above). */ +_GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB " + "on 32-bit platforms - " + "use fseeko function for handling of large files"); +#endif + +/* See the comments on fseek/fseeko. */ + +#if @GNULIB_FTELL@ +# if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES +# define _GL_FTELL_WARN /* Category 2, above. */ +# undef ftell # endif -#elif defined GNULIB_POSIXCHECK -# ifndef ftell -# define ftell(f) \ - (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \ - "on 32-bit platforms - " \ - "use ftello function for handling of large files"), \ - ftell (f)) +# if && @REPLACE_FTELL@ +# undef ftell +# define ftell rpl_ftell +extern long ftell (FILE *fp) _GL_ARG_NONNULL ((1)); # endif #endif #if @GNULIB_FTELLO@ +# if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES +# define _GL_FTELL_WARN /* Category 3, above. */ +# undef ftell +# endif # if @REPLACE_FTELLO@ +# undef ftello # define ftello rpl_ftello -extern off_t ftello (FILE *fp); -# define ftell(fp) ftello (fp) +extern off_t ftello (FILE *fp) _GL_ARG_NONNULL ((1)); +# if !@GNULIB_FTELL@ +# undef ftell +# define ftell rpl_ftell +static inline long _GL_ARG_NONNULL ((1)) +rpl_ftell (FILE *f) +{ + return ftello (f); +} +# endif # endif #elif defined GNULIB_POSIXCHECK +# define _GL_FTELL_WARN /* Category 1, above. */ +# undef ftell # undef ftello -# define ftello(f) \ - (GL_LINK_WARNING ("ftello is unportable - " \ - "use gnulib module ftello for portability"), \ - ftello (f)) +# if HAVE_RAW_DECL_FTELLO +_GL_WARN_ON_USE (ftello, "ftello is unportable - " + "use gnulib module ftello for portability"); +# endif +#endif + +#ifdef _GL_FTELL_WARN +# undef _GL_FTELL_WARN +/* Here, either ftell is undefined (but C89 guarantees that it is + declared), or it is defined as rpl_ftell (declared above). */ +_GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB " + "on 32-bit platforms - " + "use ftello function for handling of large files"); #endif #if @GNULIB_FWRITE@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ # undef fwrite # define fwrite rpl_fwrite -extern size_t fwrite (const void *ptr, size_t s, size_t n, FILE *stream); +extern size_t fwrite (const void *ptr, size_t s, size_t n, FILE *stream) + _GL_ARG_NONNULL ((1, 4)); #endif #if @GNULIB_GETDELIM@ @@ -291,13 +361,14 @@ extern size_t fwrite (const void *ptr, size_t s, size_t n, FILE *stream); Return the number of bytes read and stored at *LINEPTR (not including the NUL terminator), or -1 on error or EOF. */ extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter, - FILE *stream); + FILE *stream) + _GL_ARG_NONNULL ((1, 2, 4)); # endif #elif defined GNULIB_POSIXCHECK # undef getdelim -# define getdelim(l, s, d, f) \ - (GL_LINK_WARNING ("getdelim is unportable - " \ - "use gnulib module getdelim for portability"), \ +# define getdelim(l, s, d, f) \ + (GL_LINK_WARNING ("getdelim is unportable - " \ + "use gnulib module getdelim for portability"), \ getdelim (l, s, d, f)) #endif @@ -313,13 +384,14 @@ extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter, bytes of space. It is realloc'd as necessary. Return the number of bytes read and stored at *LINEPTR (not including the NUL terminator), or -1 on error or EOF. */ -extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream); +extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream) + _GL_ARG_NONNULL ((1, 2, 3)); # endif #elif defined GNULIB_POSIXCHECK # undef getline -# define getline(l, s, f) \ - (GL_LINK_WARNING ("getline is unportable - " \ - "use gnulib module getline for portability"), \ +# define getline(l, s, f) \ + (GL_LINK_WARNING ("getline is unportable - " \ + "use gnulib module getline for portability"), \ getline (l, s, f)) #endif @@ -336,10 +408,10 @@ extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream); memory allocation error, call obstack_alloc_failed_handler. Upon other error, return -1. */ extern int obstack_printf (struct obstack *obs, const char *format, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); + __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((1, 2)); extern int obstack_vprintf (struct obstack *obs, const char *format, - va_list args) - __attribute__ ((__format__ (__printf__, 2, 0))); + va_list args) + __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((1, 2)); # endif #endif @@ -363,7 +435,8 @@ extern void perror (const char *string); # if @REPLACE_POPEN@ # undef popen # define popen rpl_popen -extern FILE *popen (const char *cmd, const char *mode); +extern FILE *popen (const char *cmd, const char *mode) + _GL_ARG_NONNULL ((1, 2)); # endif #elif defined GNULIB_POSIXCHECK # undef popen @@ -378,13 +451,13 @@ extern FILE *popen (const char *cmd, const char *mode); /* Don't break __attribute__((format(printf,M,N))). */ # define printf __printf__ extern int printf (const char *format, ...) - __attribute__ ((__format__ (__printf__, 1, 2))); + __attribute__ ((__format__ (__printf__, 1, 2))) _GL_ARG_NONNULL ((1)); # endif #elif @GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ /* Don't break __attribute__((format(printf,M,N))). */ # define printf __printf__ extern int printf (const char *format, ...) - __attribute__ ((__format__ (__printf__, 1, 2))); + __attribute__ ((__format__ (__printf__, 1, 2))) _GL_ARG_NONNULL ((1)); #elif defined GNULIB_POSIXCHECK # undef printf # define printf \ @@ -404,7 +477,7 @@ extern int printf (const char *format, ...) #if @GNULIB_PUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ # undef putc # define putc rpl_fputc -extern int putc (int c, FILE *stream); +extern int putc (int c, FILE *stream) _GL_ARG_NONNULL ((2)); #endif #if @GNULIB_PUTCHAR@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ @@ -416,30 +489,63 @@ extern int putchar (int c); #if @GNULIB_PUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ # undef puts # define puts rpl_puts -extern int puts (const char *string); +extern int puts (const char *string) _GL_ARG_NONNULL ((1)); +#endif + +#if @GNULIB_REMOVE@ +# if @REPLACE_REMOVE@ +# undef remove +# define remove rpl_remove +extern int remove (const char *name) _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef remove +# define remove(n) \ + (GL_LINK_WARNING ("remove cannot handle directories on some platforms - " \ + "use gnulib module remove for more portability"), \ + remove (n)) #endif #if @GNULIB_RENAME@ # if @REPLACE_RENAME@ # undef rename # define rename rpl_rename -extern int rename (const char *old, const char *new); +extern int rename (const char *old_filename, const char *new_filename) + _GL_ARG_NONNULL ((1, 2)); # endif #elif defined GNULIB_POSIXCHECK # undef rename -# define rename(o,n) \ +# define rename(o,n) \ (GL_LINK_WARNING ("rename is buggy on some platforms - " \ "use gnulib module rename for more portability"), \ rename (o, n)) #endif +#if @GNULIB_RENAMEAT@ +# if @REPLACE_RENAMEAT@ +# undef renameat +# define renameat rpl_renameat +# endif +# if !@HAVE_RENAMEAT@ || @REPLACE_RENAMEAT@ +extern int renameat (int fd1, char const *file1, int fd2, char const *file2) + _GL_ARG_NONNULL ((2, 4)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef renameat +# define renameat(d1,f1,d2,f2) \ + (GL_LINK_WARNING ("renameat is not portable - " \ + "use gnulib module renameat for portability"), \ + renameat (d1, f1, d2, f2)) +#endif + #if @GNULIB_SNPRINTF@ # if @REPLACE_SNPRINTF@ # define snprintf rpl_snprintf # endif # if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@ extern int snprintf (char *str, size_t size, const char *format, ...) - __attribute__ ((__format__ (__printf__, 3, 4))); + __attribute__ ((__format__ (__printf__, 3, 4))) + _GL_ARG_NONNULL ((3)); # endif #elif defined GNULIB_POSIXCHECK # undef snprintf @@ -449,11 +555,21 @@ extern int snprintf (char *str, size_t size, const char *format, ...) snprintf) #endif +/* Some people would argue that sprintf should be handled like gets + (for example, OpenBSD issues a link warning for both functions), + since both can cause security holes due to buffer overruns. + However, we believe that sprintf can be used safely, and is more + efficient than snprintf in those safe cases; and as proof of our + belief, we use sprintf in several gnulib modules. So this header + intentionally avoids adding a warning to sprintf except when + GNULIB_POSIXCHECK is defined. */ + #if @GNULIB_SPRINTF_POSIX@ # if @REPLACE_SPRINTF@ # define sprintf rpl_sprintf extern int sprintf (char *str, const char *format, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); + __attribute__ ((__format__ (__printf__, 2, 3))) + _GL_ARG_NONNULL ((1, 2)); # endif #elif defined GNULIB_POSIXCHECK # undef sprintf @@ -475,9 +591,9 @@ extern int sprintf (char *str, const char *format, ...) *RESULT and return the number of resulting bytes, excluding the trailing NUL. Upon memory allocation error, or some other error, return -1. */ extern int asprintf (char **result, const char *format, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); + __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((1, 2)); extern int vasprintf (char **result, const char *format, va_list args) - __attribute__ ((__format__ (__printf__, 2, 0))); + __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((1, 2)); # endif #endif @@ -487,7 +603,7 @@ extern int sprintf (char *str, const char *format, ...) # endif # if @REPLACE_VDPRINTF@ || !@HAVE_VDPRINTF@ extern int vdprintf (int fd, const char *format, va_list args) - __attribute__ ((__format__ (__printf__, 2, 0))); + __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((2)); # endif #elif defined GNULIB_POSIXCHECK # undef vdprintf @@ -501,12 +617,14 @@ extern int vdprintf (int fd, const char *format, va_list args) # if @REPLACE_VFPRINTF@ # define vfprintf rpl_vfprintf extern int vfprintf (FILE *fp, const char *format, va_list args) - __attribute__ ((__format__ (__printf__, 2, 0))); + __attribute__ ((__format__ (__printf__, 2, 0))) + _GL_ARG_NONNULL ((1, 2)); # endif #elif @GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ # define vfprintf rpl_vfprintf extern int vfprintf (FILE *fp, const char *format, va_list args) - __attribute__ ((__format__ (__printf__, 2, 0))); + __attribute__ ((__format__ (__printf__, 2, 0))) + _GL_ARG_NONNULL ((1, 2)); #elif defined GNULIB_POSIXCHECK # undef vfprintf # define vfprintf(s,f,a) \ @@ -520,12 +638,12 @@ extern int vfprintf (FILE *fp, const char *format, va_list args) # if @REPLACE_VPRINTF@ # define vprintf rpl_vprintf extern int vprintf (const char *format, va_list args) - __attribute__ ((__format__ (__printf__, 1, 0))); + __attribute__ ((__format__ (__printf__, 1, 0))) _GL_ARG_NONNULL ((1)); # endif #elif @GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ # define vprintf rpl_vprintf extern int vprintf (const char *format, va_list args) - __attribute__ ((__format__ (__printf__, 1, 0))); + __attribute__ ((__format__ (__printf__, 1, 0))) _GL_ARG_NONNULL ((1)); #elif defined GNULIB_POSIXCHECK # undef vprintf # define vprintf(f,a) \ @@ -541,7 +659,8 @@ extern int vprintf (const char *format, va_list args) # endif # if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@ extern int vsnprintf (char *str, size_t size, const char *format, va_list args) - __attribute__ ((__format__ (__printf__, 3, 0))); + __attribute__ ((__format__ (__printf__, 3, 0))) + _GL_ARG_NONNULL ((3)); # endif #elif defined GNULIB_POSIXCHECK # undef vsnprintf @@ -555,7 +674,8 @@ extern int vsnprintf (char *str, size_t size, const char *format, va_list args) # if @REPLACE_VSPRINTF@ # define vsprintf rpl_vsprintf extern int vsprintf (char *str, const char *format, va_list args) - __attribute__ ((__format__ (__printf__, 2, 0))); + __attribute__ ((__format__ (__printf__, 2, 0))) + _GL_ARG_NONNULL ((1, 2)); # endif #elif defined GNULIB_POSIXCHECK # undef vsprintf diff --git a/src/bin/coreutils/lib/stdlib--.h b/src/bin/coreutils/lib/stdlib--.h index 495d0eb8f5..368eb56a1f 100644 --- a/src/bin/coreutils/lib/stdlib--.h +++ b/src/bin/coreutils/lib/stdlib--.h @@ -1,6 +1,6 @@ /* Like stdlib.h, but redefine some names to avoid glitches. - Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2005-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,3 +22,15 @@ #undef mkstemp #define mkstemp mkstemp_safer + +#if GNULIB_MKOSTEMP +# define mkostemp mkostemp_safer +#endif + +#if GNULIB_MKOSTEMPS +# define mkostemps mkostemps_safer +#endif + +#if GNULIB_MKSTEMPS +# define mkstemps mkstemps_safer +#endif diff --git a/src/bin/coreutils/lib/stdlib-safer.h b/src/bin/coreutils/lib/stdlib-safer.h index a014372962..ff0cadc059 100644 --- a/src/bin/coreutils/lib/stdlib-safer.h +++ b/src/bin/coreutils/lib/stdlib-safer.h @@ -1,6 +1,6 @@ /* Invoke stdlib.h functions, but avoid some glitches. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,3 +18,15 @@ /* Written by Paul Eggert. */ int mkstemp_safer (char *); + +#if GNULIB_MKOSTEMP +int mkostemp_safer (char *, int); +#endif + +#if GNULIB_MKOSTEMPS +int mkostemps_safer (char *, int, int); +#endif + +#if GNULIB_MKSTEMPS +int mkstemps_safer (char *, int); +#endif diff --git a/src/bin/coreutils/lib/stdlib.in.h b/src/bin/coreutils/lib/stdlib.in.h index 9ac7199568..5f546ffa8e 100644 --- a/src/bin/coreutils/lib/stdlib.in.h +++ b/src/bin/coreutils/lib/stdlib.in.h @@ -1,6 +1,6 @@ /* A GNU-like . - Copyright (C) 1995, 2001-2004, 2006-2009 Free Software Foundation, Inc. + Copyright (C) 1995, 2001-2004, 2006-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -39,7 +39,7 @@ #include /* Solaris declares getloadavg() in . */ -#if @GNULIB_GETLOADAVG@ && @HAVE_SYS_LOADAVG_H@ +#if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@ # include #endif @@ -49,25 +49,35 @@ # include #endif -#if @GNULIB_RANDOM_R@ || !@HAVE_STRUCT_RANDOM_DATA@ +#if !@HAVE_STRUCT_RANDOM_DATA@ || (@GNULIB_RANDOM_R@ && !@HAVE_RANDOM_R@) \ + || defined GNULIB_POSIXCHECK # include #endif #if !@HAVE_STRUCT_RANDOM_DATA@ struct random_data { - int32_t *fptr; /* Front pointer. */ - int32_t *rptr; /* Rear pointer. */ - int32_t *state; /* Array of state values. */ - int rand_type; /* Type of random number generator. */ - int rand_deg; /* Degree of random number generator. */ - int rand_sep; /* Distance between front and rear. */ - int32_t *end_ptr; /* Pointer behind state table. */ + int32_t *fptr; /* Front pointer. */ + int32_t *rptr; /* Rear pointer. */ + int32_t *state; /* Array of state values. */ + int rand_type; /* Type of random number generator. */ + int rand_deg; /* Degree of random number generator. */ + int rand_sep; /* Distance between front and rear. */ + int32_t *end_ptr; /* Pointer behind state table. */ }; #endif +#if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ +/* On MacOS X 10.3, only declares mkstemp. */ +/* On Cygwin 1.7.1, only declares getsubopt. */ +/* But avoid namespace pollution on glibc systems. */ +# include +#endif + /* The definition of GL_LINK_WARNING is copied here. */ +/* The definition of _GL_ARG_NONNULL is copied here. */ + /* Some systems do not define EXIT_*, despite otherwise supporting C89. */ #ifndef EXIT_SUCCESS @@ -87,37 +97,20 @@ struct random_data extern "C" { #endif - -#if @GNULIB_MALLOC_POSIX@ -# if !@HAVE_MALLOC_POSIX@ -# undef malloc -# define malloc rpl_malloc -extern void * malloc (size_t size); +#if @GNULIB_ATOLL@ +# if !@HAVE_ATOLL@ +/* Parse a signed decimal integer. + Returns the value of the integer. Errors are not detected. */ +extern long long atoll (const char *string) _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK -# undef malloc -# define malloc(s) \ - (GL_LINK_WARNING ("malloc is not POSIX compliant everywhere - " \ - "use gnulib module malloc-posix for portability"), \ - malloc (s)) +# undef atoll +# define atoll(s) \ + (GL_LINK_WARNING ("atoll is unportable - " \ + "use gnulib module atoll for portability"), \ + atoll (s)) #endif - -#if @GNULIB_REALLOC_POSIX@ -# if !@HAVE_REALLOC_POSIX@ -# undef realloc -# define realloc rpl_realloc -extern void * realloc (void *ptr, size_t size); -# endif -#elif defined GNULIB_POSIXCHECK -# undef realloc -# define realloc(p,s) \ - (GL_LINK_WARNING ("realloc is not POSIX compliant everywhere - " \ - "use gnulib module realloc-posix for portability"), \ - realloc (p, s)) -#endif - - #if @GNULIB_CALLOC_POSIX@ # if !@HAVE_CALLOC_POSIX@ # undef calloc @@ -132,29 +125,28 @@ extern void * calloc (size_t nmemb, size_t size); calloc (n, s)) #endif - -#if @GNULIB_ATOLL@ -# if !@HAVE_ATOLL@ -/* Parse a signed decimal integer. - Returns the value of the integer. Errors are not detected. */ -extern long long atoll (const char *string); +#if @GNULIB_CANONICALIZE_FILE_NAME@ +# if @REPLACE_CANONICALIZE_FILE_NAME@ +# define canonicalize_file_name rpl_canonicalize_file_name +# endif +# if !@HAVE_CANONICALIZE_FILE_NAME@ || @REPLACE_CANONICALIZE_FILE_NAME@ +extern char *canonicalize_file_name (const char *name) _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK -# undef atoll -# define atoll(s) \ - (GL_LINK_WARNING ("atoll is unportable - " \ - "use gnulib module atoll for portability"), \ - atoll (s)) +# undef canonicalize_file_name +# define canonicalize_file_name(n) \ + (GL_LINK_WARNING ("canonicalize_file_name is unportable - " \ + "use gnulib module canonicalize-lgpl for portability"), \ + canonicalize_file_name (n)) #endif - #if @GNULIB_GETLOADAVG@ # if !@HAVE_DECL_GETLOADAVG@ /* Store max(NELEM,3) load average numbers in LOADAVG[]. The three numbers are the load average of the last 1 minute, the last 5 minutes, and the last 15 minutes, respectively. LOADAVG is an array of NELEM numbers. */ -extern int getloadavg (double loadavg[], int nelem); +extern int getloadavg (double loadavg[], int nelem) _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef getloadavg @@ -164,7 +156,6 @@ extern int getloadavg (double loadavg[], int nelem); getloadavg (l, n)) #endif - #if @GNULIB_GETSUBOPT@ /* Assuming *OPTIONP is a comma separated list of elements of the form "token" or "token=value", getsubopt parses the first of these elements. @@ -178,7 +169,8 @@ extern int getloadavg (double loadavg[], int nelem); For more details see the POSIX:2001 specification. http://www.opengroup.org/susv3xsh/getsubopt.html */ # if !@HAVE_GETSUBOPT@ -extern int getsubopt (char **optionp, char *const *tokens, char **valuep); +extern int getsubopt (char **optionp, char *const *tokens, char **valuep) + _GL_ARG_NONNULL ((1, 2, 3)); # endif #elif defined GNULIB_POSIXCHECK # undef getsubopt @@ -188,6 +180,19 @@ extern int getsubopt (char **optionp, char *const *tokens, char **valuep); getsubopt (o, t, v)) #endif +#if @GNULIB_MALLOC_POSIX@ +# if !@HAVE_MALLOC_POSIX@ +# undef malloc +# define malloc rpl_malloc +extern void * malloc (size_t size); +# endif +#elif defined GNULIB_POSIXCHECK +# undef malloc +# define malloc(s) \ + (GL_LINK_WARNING ("malloc is not POSIX compliant everywhere - " \ + "use gnulib module malloc-posix for portability"), \ + malloc (s)) +#endif #if @GNULIB_MKDTEMP@ # if !@HAVE_MKDTEMP@ @@ -196,7 +201,7 @@ extern int getsubopt (char **optionp, char *const *tokens, char **valuep); they are replaced with a string that makes the directory name unique. Returns TEMPLATE, or a null pointer if it cannot get a unique name. The directory is created mode 700. */ -extern char * mkdtemp (char * /*template*/); +extern char * mkdtemp (char * /*template*/) _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef mkdtemp @@ -206,7 +211,6 @@ extern char * mkdtemp (char * /*template*/); mkdtemp (t)) #endif - #if @GNULIB_MKOSTEMP@ # if !@HAVE_MKOSTEMP@ /* Create a unique temporary file from TEMPLATE. @@ -221,7 +225,7 @@ extern char * mkdtemp (char * /*template*/); implementation. Returns the open file descriptor if successful, otherwise -1 and errno set. */ -extern int mkostemp (char * /*template*/, int /*flags*/); +extern int mkostemp (char * /*template*/, int /*flags*/) _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef mkostemp @@ -231,6 +235,31 @@ extern int mkostemp (char * /*template*/, int /*flags*/); mkostemp (t, f)) #endif +#if @GNULIB_MKOSTEMPS@ +# if !@HAVE_MKOSTEMPS@ +/* Create a unique temporary file from TEMPLATE. + The last six characters of TEMPLATE before a suffix of length + SUFFIXLEN must be "XXXXXX"; + they are replaced with a string that makes the file name unique. + The flags are a bitmask, possibly including O_CLOEXEC (defined in ) + and O_TEXT, O_BINARY (defined in "binary-io.h"). + The file is then created, with the specified flags, ensuring it didn't exist + before. + The file is created read-write (mask at least 0600 & ~umask), but it may be + world-readable and world-writable (mask 0666 & ~umask), depending on the + implementation. + Returns the open file descriptor if successful, otherwise -1 and errno + set. */ +extern int mkostemps (char * /*template*/, int /*suffixlen*/, int /*flags*/) + _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mkostemps +# define mkostemps(t,s,f) \ + (GL_LINK_WARNING ("mkostemps is unportable - " \ + "use gnulib module mkostemps for portability"), \ + mkostemps (t, s, f)) +#endif #if @GNULIB_MKSTEMP@ # if @REPLACE_MKSTEMP@ @@ -244,10 +273,7 @@ extern int mkostemp (char * /*template*/, int /*flags*/); Returns the open file descriptor if successful, otherwise -1 and errno set. */ # define mkstemp rpl_mkstemp -extern int mkstemp (char * /*template*/); -# else -/* On MacOS X 10.3, only declares mkstemp. */ -# include +extern int mkstemp (char * /*template*/) _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef mkstemp @@ -257,16 +283,37 @@ extern int mkstemp (char * /*template*/); mkstemp (t)) #endif +#if @GNULIB_MKSTEMPS@ +# if !@HAVE_MKSTEMPS@ +/* Create a unique temporary file from TEMPLATE. + The last six characters of TEMPLATE prior to a suffix of length + SUFFIXLEN must be "XXXXXX"; + they are replaced with a string that makes the file name unique. + The file is then created, ensuring it didn't exist before. + The file is created read-write (mask at least 0600 & ~umask), but it may be + world-readable and world-writable (mask 0666 & ~umask), depending on the + implementation. + Returns the open file descriptor if successful, otherwise -1 and errno + set. */ +extern int mkstemps (char * /*template*/, int /*suffixlen*/) + _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mkstemps +# define mkstemps(t,s) \ + (GL_LINK_WARNING ("mkstemps is unportable - " \ + "use gnulib module mkstemps for portability"), \ + mkstemps (t, s)) +#endif #if @GNULIB_PUTENV@ # if @REPLACE_PUTENV@ # undef putenv # define putenv rpl_putenv -extern int putenv (char *string); +extern int putenv (char *string) _GL_ARG_NONNULL ((1)); # endif #endif - #if @GNULIB_RANDOM_R@ # if !@HAVE_RANDOM_R@ @@ -274,41 +321,73 @@ extern int putenv (char *string); # define RAND_MAX 2147483647 # endif -int srandom_r (unsigned int seed, struct random_data *rand_state); +int srandom_r (unsigned int seed, struct random_data *rand_state) + _GL_ARG_NONNULL ((2)); int initstate_r (unsigned int seed, char *buf, size_t buf_size, - struct random_data *rand_state); -int setstate_r (char *arg_state, struct random_data *rand_state); -int random_r (struct random_data *buf, int32_t *result); + struct random_data *rand_state) + _GL_ARG_NONNULL ((2, 4)); +int setstate_r (char *arg_state, struct random_data *rand_state) + _GL_ARG_NONNULL ((1, 2)); +int random_r (struct random_data *buf, int32_t *result) + _GL_ARG_NONNULL ((1, 2)); # endif #elif defined GNULIB_POSIXCHECK # undef random_r -# define random_r(b,r) \ +# define random_r(b,r) \ (GL_LINK_WARNING ("random_r is unportable - " \ "use gnulib module random_r for portability"), \ random_r (b,r)) # undef initstate_r -# define initstate_r(s,b,sz,r) \ +# define initstate_r(s,b,sz,r) \ (GL_LINK_WARNING ("initstate_r is unportable - " \ "use gnulib module random_r for portability"), \ initstate_r (s,b,sz,r)) # undef srandom_r -# define srandom_r(s,r) \ +# define srandom_r(s,r) \ (GL_LINK_WARNING ("srandom_r is unportable - " \ "use gnulib module random_r for portability"), \ srandom_r (s,r)) # undef setstate_r -# define setstate_r(a,r) \ +# define setstate_r(a,r) \ (GL_LINK_WARNING ("setstate_r is unportable - " \ "use gnulib module random_r for portability"), \ setstate_r (a,r)) #endif +#if @GNULIB_REALLOC_POSIX@ +# if !@HAVE_REALLOC_POSIX@ +# undef realloc +# define realloc rpl_realloc +extern void * realloc (void *ptr, size_t size); +# endif +#elif defined GNULIB_POSIXCHECK +# undef realloc +# define realloc(p,s) \ + (GL_LINK_WARNING ("realloc is not POSIX compliant everywhere - " \ + "use gnulib module realloc-posix for portability"), \ + realloc (p, s)) +#endif + +#if @GNULIB_REALPATH@ +# if @REPLACE_REALPATH@ +# define realpath rpl_realpath +# endif +# if !@HAVE_REALPATH@ || @REPLACE_REALPATH@ +extern char *realpath (const char *name, char *resolved) _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef realpath +# define realpath(n,r) \ + (GL_LINK_WARNING ("realpath is unportable - use gnulib module " \ + "canonicalize or canonicalize-lgpl for portability"), \ + realpath (n, r)) +#endif #if @GNULIB_RPMATCH@ # if !@HAVE_RPMATCH@ /* Test a user response to a question. Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */ -extern int rpmatch (const char *response); +extern int rpmatch (const char *response) _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef rpmatch @@ -318,37 +397,32 @@ extern int rpmatch (const char *response); rpmatch (r)) #endif - #if @GNULIB_SETENV@ -# if !@HAVE_SETENV@ +# if @REPLACE_SETENV@ +# undef setenv +# define setenv rpl_setenv +# endif +# if !@HAVE_SETENV@ || @REPLACE_SETENV@ /* Set NAME to VALUE in the environment. If REPLACE is nonzero, overwrite an existing value. */ -extern int setenv (const char *name, const char *value, int replace); +extern int setenv (const char *name, const char *value, int replace) + _GL_ARG_NONNULL ((1)); # endif +#elif defined GNULIB_POSIXCHECK +# undef setenv +# define setenv(n,v,o) \ + (GL_LINK_WARNING ("setenv is unportable - " \ + "use gnulib module setenv for portability"), \ + setenv (n, v, o)) #endif - -#if @GNULIB_UNSETENV@ -# if @HAVE_UNSETENV@ -# if @VOID_UNSETENV@ -/* On some systems, unsetenv() returns void. - This is the case for MacOS X 10.3, FreeBSD 4.8, NetBSD 1.6, OpenBSD 3.4. */ -# define unsetenv(name) ((unsetenv)(name), 0) -# endif -# else -/* Remove the variable NAME from the environment. */ -extern int unsetenv (const char *name); -# endif -#endif - - #if @GNULIB_STRTOD@ # if @REPLACE_STRTOD@ # define strtod rpl_strtod # endif # if !@HAVE_STRTOD@ || @REPLACE_STRTOD@ /* Parse a double from STRING, updating ENDP if appropriate. */ -extern double strtod (const char *str, char **endp); +extern double strtod (const char *str, char **endp) _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef strtod @@ -358,7 +432,6 @@ extern double strtod (const char *str, char **endp); strtod (s, e)) #endif - #if @GNULIB_STRTOLL@ # if !@HAVE_STRTOLL@ /* Parse a signed integer whose textual representation starts at STRING. @@ -369,7 +442,8 @@ extern double strtod (const char *str, char **endp); stored in *ENDPTR. Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set to ERANGE. */ -extern long long strtoll (const char *string, char **endptr, int base); +extern long long strtoll (const char *string, char **endptr, int base) + _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef strtoll @@ -379,7 +453,6 @@ extern long long strtoll (const char *string, char **endptr, int base); strtoll (s, e, b)) #endif - #if @GNULIB_STRTOULL@ # if !@HAVE_STRTOULL@ /* Parse an unsigned integer whose textual representation starts at STRING. @@ -390,7 +463,8 @@ extern long long strtoll (const char *string, char **endptr, int base); stored in *ENDPTR. Upon overflow, the return value is ULLONG_MAX, and errno is set to ERANGE. */ -extern unsigned long long strtoull (const char *string, char **endptr, int base); +extern unsigned long long strtoull (const char *string, char **endptr, int base) + _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef strtoull @@ -400,6 +474,22 @@ extern unsigned long long strtoull (const char *string, char **endptr, int base) strtoull (s, e, b)) #endif +#if @GNULIB_UNSETENV@ +# if @REPLACE_UNSETENV@ +# undef unsetenv +# define unsetenv rpl_unsetenv +# endif +# if !@HAVE_UNSETENV@ || @REPLACE_UNSETENV@ +/* Remove the variable NAME from the environment. */ +extern int unsetenv (const char *name) _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef unsetenv +# define unsetenv(n) \ + (GL_LINK_WARNING ("unsetenv is unportable - " \ + "use gnulib module unsetenv for portability"), \ + unsetenv (n)) +#endif #ifdef __cplusplus } diff --git a/src/bin/coreutils/lib/stpcpy.c b/src/bin/coreutils/lib/stpcpy.c index 1e70013382..196461f989 100644 --- a/src/bin/coreutils/lib/stpcpy.c +++ b/src/bin/coreutils/lib/stpcpy.c @@ -1,5 +1,6 @@ /* stpcpy.c -- copy a string and return pointer to end of new string - Copyright (C) 1992, 1995, 1997-1998, 2006 Free Software Foundation, Inc. + Copyright (C) 1992, 1995, 1997-1998, 2006, 2009-2010 Free Software + Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. diff --git a/src/bin/coreutils/lib/stpncpy.c b/src/bin/coreutils/lib/stpncpy.c index 7a64574609..ca53ebbd13 100644 --- a/src/bin/coreutils/lib/stpncpy.c +++ b/src/bin/coreutils/lib/stpncpy.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1993, 1995-1997, 2002-2003, 2005-2007 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1995-1997, 2002-2003, 2005-2007, 2009-2010 Free Software + * Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@gnu.org. @@ -40,26 +41,26 @@ __stpncpy (char *dest, const char *src, size_t n) size_t n4 = n >> 2; for (;;) - { - c = *src++; - *dest++ = c; - if (c == '\0') - break; - c = *src++; - *dest++ = c; - if (c == '\0') - break; - c = *src++; - *dest++ = c; - if (c == '\0') - break; - c = *src++; - *dest++ = c; - if (c == '\0') - break; - if (--n4 == 0) - goto last_chars; - } + { + c = *src++; + *dest++ = c; + if (c == '\0') + break; + c = *src++; + *dest++ = c; + if (c == '\0') + break; + c = *src++; + *dest++ = c; + if (c == '\0') + break; + c = *src++; + *dest++ = c; + if (c == '\0') + break; + if (--n4 == 0) + goto last_chars; + } n -= dest - s; goto zero_fill; } @@ -75,9 +76,9 @@ __stpncpy (char *dest, const char *src, size_t n) --n; *dest++ = c; if (c == '\0') - break; + break; if (n == 0) - return dest; + return dest; } zero_fill: diff --git a/src/bin/coreutils/lib/str-kmp.h b/src/bin/coreutils/lib/str-kmp.h index 4dbcf36856..a132e6aab8 100644 --- a/src/bin/coreutils/lib/str-kmp.h +++ b/src/bin/coreutils/lib/str-kmp.h @@ -3,7 +3,7 @@ #line 1 /* Substring search in a NUL terminated string of 'char' elements, using the Knuth-Morris-Pratt algorithm. - Copyright (C) 2005-2008 Free Software Foundation, Inc. + Copyright (C) 2005-2010 Free Software Foundation, Inc. Written by Bruno Haible , 2005. This program is free software; you can redistribute it and/or modify @@ -33,7 +33,7 @@ Return false if it was aborted because not enough memory was available. */ static bool knuth_morris_pratt_unibyte (const char *haystack, const char *needle, - const char **resultp) + const char **resultp) { size_t m = strlen (needle); @@ -65,46 +65,46 @@ knuth_morris_pratt_unibyte (const char *haystack, const char *needle, for (i = 2; i < m; i++) { - /* Here: j = i-1 - table[i-1]. - The inequality needle[x..i-1] != needle[0..i-1-x] is known to hold - for x < table[i-1], by induction. - Furthermore, if j>0: needle[i-1-j..i-2] = needle[0..j-1]. */ - unsigned char b = CANON_ELEMENT ((unsigned char) needle[i - 1]); + /* Here: j = i-1 - table[i-1]. + The inequality needle[x..i-1] != needle[0..i-1-x] is known to hold + for x < table[i-1], by induction. + Furthermore, if j>0: needle[i-1-j..i-2] = needle[0..j-1]. */ + unsigned char b = CANON_ELEMENT ((unsigned char) needle[i - 1]); - for (;;) - { - /* Invariants: The inequality needle[x..i-1] != needle[0..i-1-x] - is known to hold for x < i-1-j. - Furthermore, if j>0: needle[i-1-j..i-2] = needle[0..j-1]. */ - if (b == CANON_ELEMENT ((unsigned char) needle[j])) - { - /* Set table[i] := i-1-j. */ - table[i] = i - ++j; - break; - } - /* The inequality needle[x..i-1] != needle[0..i-1-x] also holds - for x = i-1-j, because - needle[i-1] != needle[j] = needle[i-1-x]. */ - if (j == 0) - { - /* The inequality holds for all possible x. */ - table[i] = i; - break; - } - /* The inequality needle[x..i-1] != needle[0..i-1-x] also holds - for i-1-j < x < i-1-j+table[j], because for these x: - needle[x..i-2] - = needle[x-(i-1-j)..j-1] - != needle[0..j-1-(x-(i-1-j))] (by definition of table[j]) - = needle[0..i-2-x], - hence needle[x..i-1] != needle[0..i-1-x]. - Furthermore - needle[i-1-j+table[j]..i-2] - = needle[table[j]..j-1] - = needle[0..j-1-table[j]] (by definition of table[j]). */ - j = j - table[j]; - } - /* Here: j = i - table[i]. */ + for (;;) + { + /* Invariants: The inequality needle[x..i-1] != needle[0..i-1-x] + is known to hold for x < i-1-j. + Furthermore, if j>0: needle[i-1-j..i-2] = needle[0..j-1]. */ + if (b == CANON_ELEMENT ((unsigned char) needle[j])) + { + /* Set table[i] := i-1-j. */ + table[i] = i - ++j; + break; + } + /* The inequality needle[x..i-1] != needle[0..i-1-x] also holds + for x = i-1-j, because + needle[i-1] != needle[j] = needle[i-1-x]. */ + if (j == 0) + { + /* The inequality holds for all possible x. */ + table[i] = i; + break; + } + /* The inequality needle[x..i-1] != needle[0..i-1-x] also holds + for i-1-j < x < i-1-j+table[j], because for these x: + needle[x..i-2] + = needle[x-(i-1-j)..j-1] + != needle[0..j-1-(x-(i-1-j))] (by definition of table[j]) + = needle[0..i-2-x], + hence needle[x..i-1] != needle[0..i-1-x]. + Furthermore + needle[i-1-j+table[j]..i-2] + = needle[table[j]..j-1] + = needle[0..j-1-table[j]] (by definition of table[j]). */ + j = j - table[j]; + } + /* Here: j = i - table[i]. */ } } @@ -121,29 +121,29 @@ knuth_morris_pratt_unibyte (const char *haystack, const char *needle, /* Invariant: phaystack = rhaystack + j. */ while (*phaystack != '\0') if (CANON_ELEMENT ((unsigned char) needle[j]) - == CANON_ELEMENT ((unsigned char) *phaystack)) - { - j++; - phaystack++; - if (j == m) - { - /* The entire needle has been found. */ - *resultp = rhaystack; - break; - } - } + == CANON_ELEMENT ((unsigned char) *phaystack)) + { + j++; + phaystack++; + if (j == m) + { + /* The entire needle has been found. */ + *resultp = rhaystack; + break; + } + } else if (j > 0) - { - /* Found a match of needle[0..j-1], mismatch at needle[j]. */ - rhaystack += table[j]; - j -= table[j]; - } + { + /* Found a match of needle[0..j-1], mismatch at needle[j]. */ + rhaystack += table[j]; + j -= table[j]; + } else - { - /* Found a mismatch at needle[0] already. */ - rhaystack++; - phaystack++; - } + { + /* Found a mismatch at needle[0] already. */ + rhaystack++; + phaystack++; + } } freea (table); diff --git a/src/bin/coreutils/lib/str-two-way.h b/src/bin/coreutils/lib/str-two-way.h index 72daaa017b..e0d8629f3b 100644 --- a/src/bin/coreutils/lib/str-two-way.h +++ b/src/bin/coreutils/lib/str-two-way.h @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Byte-wise substring search, using the Two-Way algorithm. - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Eric Blake , 2008. @@ -24,21 +24,21 @@ , and define: RESULT_TYPE A macro that expands to the return type. AVAILABLE(h, h_l, j, n_l) - A macro that returns nonzero if there are - at least N_L bytes left starting at H[J]. - H is 'unsigned char *', H_L, J, and N_L - are 'size_t'; H_L is an lvalue. For - NUL-terminated searches, H_L can be - modified each iteration to avoid having - to compute the end of H up front. + A macro that returns nonzero if there are + at least N_L bytes left starting at H[J]. + H is 'unsigned char *', H_L, J, and N_L + are 'size_t'; H_L is an lvalue. For + NUL-terminated searches, H_L can be + modified each iteration to avoid having + to compute the end of H up front. For case-insensitivity, you may optionally define: CMP_FUNC(p1, p2, l) A macro that returns 0 iff the first L - characters of P1 and P2 are equal. + characters of P1 and P2 are equal. CANON_ELEMENT(c) A macro that canonicalizes an element right after - it has been fetched from one of the two strings. - The argument is an 'unsigned char'; the result - must be an 'unsigned char' as well. + it has been fetched from one of the two strings. + The argument is an 'unsigned char'; the result + must be an 'unsigned char' as well. This file undefines the macros documented above, and defines LONG_NEEDLE_THRESHOLD. @@ -106,7 +106,7 @@ periodicity. */ static size_t critical_factorization (const unsigned char *needle, size_t needle_len, - size_t *period) + size_t *period) { /* Index of last byte of left half, or SIZE_MAX. */ size_t max_suffix, max_suffix_rev; @@ -133,29 +133,29 @@ critical_factorization (const unsigned char *needle, size_t needle_len, a = CANON_ELEMENT (needle[j + k]); b = CANON_ELEMENT (needle[max_suffix + k]); if (a < b) - { - /* Suffix is smaller, period is entire prefix so far. */ - j += k; - k = 1; - p = j - max_suffix; - } + { + /* Suffix is smaller, period is entire prefix so far. */ + j += k; + k = 1; + p = j - max_suffix; + } else if (a == b) - { - /* Advance through repetition of the current period. */ - if (k != p) - ++k; - else - { - j += p; - k = 1; - } - } + { + /* Advance through repetition of the current period. */ + if (k != p) + ++k; + else + { + j += p; + k = 1; + } + } else /* b < a */ - { - /* Suffix is larger, start over from current location. */ - max_suffix = j++; - k = p = 1; - } + { + /* Suffix is larger, start over from current location. */ + max_suffix = j++; + k = p = 1; + } } *period = p; @@ -168,29 +168,29 @@ critical_factorization (const unsigned char *needle, size_t needle_len, a = CANON_ELEMENT (needle[j + k]); b = CANON_ELEMENT (needle[max_suffix_rev + k]); if (b < a) - { - /* Suffix is smaller, period is entire prefix so far. */ - j += k; - k = 1; - p = j - max_suffix_rev; - } + { + /* Suffix is smaller, period is entire prefix so far. */ + j += k; + k = 1; + p = j - max_suffix_rev; + } else if (a == b) - { - /* Advance through repetition of the current period. */ - if (k != p) - ++k; - else - { - j += p; - k = 1; - } - } + { + /* Advance through repetition of the current period. */ + if (k != p) + ++k; + else + { + j += p; + k = 1; + } + } else /* a < b */ - { - /* Suffix is larger, start over from current location. */ - max_suffix_rev = j++; - k = p = 1; - } + { + /* Suffix is larger, start over from current location. */ + max_suffix_rev = j++; + k = p = 1; + } } /* Choose the longer suffix. Return the first byte of the right @@ -213,7 +213,7 @@ critical_factorization (const unsigned char *needle, size_t needle_len, HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. */ static RETURN_TYPE two_way_short_needle (const unsigned char *haystack, size_t haystack_len, - const unsigned char *needle, size_t needle_len) + const unsigned char *needle, size_t needle_len) { size_t i; /* Index into current byte of NEEDLE. */ size_t j; /* Index into current window of HAYSTACK. */ @@ -230,65 +230,65 @@ two_way_short_needle (const unsigned char *haystack, size_t haystack_len, if (CMP_FUNC (needle, needle + period, suffix) == 0) { /* Entire needle is periodic; a mismatch can only advance by the - period, so use memory to avoid rescanning known occurrences - of the period. */ + period, so use memory to avoid rescanning known occurrences + of the period. */ size_t memory = 0; j = 0; while (AVAILABLE (haystack, haystack_len, j, needle_len)) - { - /* Scan for matches in right half. */ - i = MAX (suffix, memory); - while (i < needle_len && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - ++i; - if (needle_len <= i) - { - /* Scan for matches in left half. */ - i = suffix - 1; - while (memory < i + 1 && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - --i; - if (i + 1 < memory + 1) - return (RETURN_TYPE) (haystack + j); - /* No match, so remember how many repetitions of period - on the right half were scanned. */ - j += period; - memory = needle_len - period; - } - else - { - j += i - suffix + 1; - memory = 0; - } - } + { + /* Scan for matches in right half. */ + i = MAX (suffix, memory); + while (i < needle_len && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + ++i; + if (needle_len <= i) + { + /* Scan for matches in left half. */ + i = suffix - 1; + while (memory < i + 1 && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + --i; + if (i + 1 < memory + 1) + return (RETURN_TYPE) (haystack + j); + /* No match, so remember how many repetitions of period + on the right half were scanned. */ + j += period; + memory = needle_len - period; + } + else + { + j += i - suffix + 1; + memory = 0; + } + } } else { /* The two halves of needle are distinct; no extra memory is - required, and any mismatch results in a maximal shift. */ + required, and any mismatch results in a maximal shift. */ period = MAX (suffix, needle_len - suffix) + 1; j = 0; while (AVAILABLE (haystack, haystack_len, j, needle_len)) - { - /* Scan for matches in right half. */ - i = suffix; - while (i < needle_len && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - ++i; - if (needle_len <= i) - { - /* Scan for matches in left half. */ - i = suffix - 1; - while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - --i; - if (i == SIZE_MAX) - return (RETURN_TYPE) (haystack + j); - j += period; - } - else - j += i - suffix + 1; - } + { + /* Scan for matches in right half. */ + i = suffix; + while (i < needle_len && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + ++i; + if (needle_len <= i) + { + /* Scan for matches in left half. */ + i = suffix - 1; + while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + --i; + if (i == SIZE_MAX) + return (RETURN_TYPE) (haystack + j); + j += period; + } + else + j += i - suffix + 1; + } } return NULL; } @@ -307,7 +307,7 @@ two_way_short_needle (const unsigned char *haystack, size_t haystack_len, sublinear performance is not possible. */ static RETURN_TYPE two_way_long_needle (const unsigned char *haystack, size_t haystack_len, - const unsigned char *needle, size_t needle_len) + const unsigned char *needle, size_t needle_len) { size_t i; /* Index into current byte of NEEDLE. */ size_t j; /* Index into current window of HAYSTACK. */ @@ -334,93 +334,93 @@ two_way_long_needle (const unsigned char *haystack, size_t haystack_len, if (CMP_FUNC (needle, needle + period, suffix) == 0) { /* Entire needle is periodic; a mismatch can only advance by the - period, so use memory to avoid rescanning known occurrences - of the period. */ + period, so use memory to avoid rescanning known occurrences + of the period. */ size_t memory = 0; size_t shift; j = 0; while (AVAILABLE (haystack, haystack_len, j, needle_len)) - { - /* Check the last byte first; if it does not match, then - shift to the next possible match location. */ - shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; - if (0 < shift) - { - if (memory && shift < period) - { - /* Since needle is periodic, but the last period has - a byte out of place, there can be no match until - after the mismatch. */ - shift = needle_len - period; - memory = 0; - } - j += shift; - continue; - } - /* Scan for matches in right half. The last byte has - already been matched, by virtue of the shift table. */ - i = MAX (suffix, memory); - while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - ++i; - if (needle_len - 1 <= i) - { - /* Scan for matches in left half. */ - i = suffix - 1; - while (memory < i + 1 && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - --i; - if (i + 1 < memory + 1) - return (RETURN_TYPE) (haystack + j); - /* No match, so remember how many repetitions of period - on the right half were scanned. */ - j += period; - memory = needle_len - period; - } - else - { - j += i - suffix + 1; - memory = 0; - } - } + { + /* Check the last byte first; if it does not match, then + shift to the next possible match location. */ + shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; + if (0 < shift) + { + if (memory && shift < period) + { + /* Since needle is periodic, but the last period has + a byte out of place, there can be no match until + after the mismatch. */ + shift = needle_len - period; + memory = 0; + } + j += shift; + continue; + } + /* Scan for matches in right half. The last byte has + already been matched, by virtue of the shift table. */ + i = MAX (suffix, memory); + while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + ++i; + if (needle_len - 1 <= i) + { + /* Scan for matches in left half. */ + i = suffix - 1; + while (memory < i + 1 && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + --i; + if (i + 1 < memory + 1) + return (RETURN_TYPE) (haystack + j); + /* No match, so remember how many repetitions of period + on the right half were scanned. */ + j += period; + memory = needle_len - period; + } + else + { + j += i - suffix + 1; + memory = 0; + } + } } else { /* The two halves of needle are distinct; no extra memory is - required, and any mismatch results in a maximal shift. */ + required, and any mismatch results in a maximal shift. */ size_t shift; period = MAX (suffix, needle_len - suffix) + 1; j = 0; while (AVAILABLE (haystack, haystack_len, j, needle_len)) - { - /* Check the last byte first; if it does not match, then - shift to the next possible match location. */ - shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; - if (0 < shift) - { - j += shift; - continue; - } - /* Scan for matches in right half. The last byte has - already been matched, by virtue of the shift table. */ - i = suffix; - while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - ++i; - if (needle_len - 1 <= i) - { - /* Scan for matches in left half. */ - i = suffix - 1; - while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - --i; - if (i == SIZE_MAX) - return (RETURN_TYPE) (haystack + j); - j += period; - } - else - j += i - suffix + 1; - } + { + /* Check the last byte first; if it does not match, then + shift to the next possible match location. */ + shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; + if (0 < shift) + { + j += shift; + continue; + } + /* Scan for matches in right half. The last byte has + already been matched, by virtue of the shift table. */ + i = suffix; + while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + ++i; + if (needle_len - 1 <= i) + { + /* Scan for matches in left half. */ + i = suffix - 1; + while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + --i; + if (i == SIZE_MAX) + return (RETURN_TYPE) (haystack + j); + j += period; + } + else + j += i - suffix + 1; + } } return NULL; } diff --git a/src/bin/coreutils/lib/strcspn.c b/src/bin/coreutils/lib/strcspn.c index 0eecb8dc15..a807a4909c 100644 --- a/src/bin/coreutils/lib/strcspn.c +++ b/src/bin/coreutils/lib/strcspn.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1991, 1994, 1996-1997, 2002-2003, 2005-2006 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1994, 1996-1997, 2002-2003, 2005-2006, 2009-2010 Free + * Software Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@gnu.org. diff --git a/src/bin/coreutils/lib/strdup.c b/src/bin/coreutils/lib/strdup.c index 635718e511..5618fb6758 100644 --- a/src/bin/coreutils/lib/strdup.c +++ b/src/bin/coreutils/lib/strdup.c @@ -1,8 +1,8 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 -/* Copyright (C) 1991, 1996, 1997, 1998, 2002, 2003, 2004, 2006, 2007 Free - Software Foundation, Inc. +/* Copyright (C) 1991, 1996, 1997, 1998, 2002, 2003, 2004, 2006, 2007, 2009, + 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. diff --git a/src/bin/coreutils/lib/streq.h b/src/bin/coreutils/lib/streq.h index ff3a9cb3ad..7aecea8f0b 100644 --- a/src/bin/coreutils/lib/streq.h +++ b/src/bin/coreutils/lib/streq.h @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Optimized string comparison. - Copyright (C) 2001-2002, 2007 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published diff --git a/src/bin/coreutils/lib/strerror.c b/src/bin/coreutils/lib/strerror.c index dfe6c25f2f..b0df778489 100644 --- a/src/bin/coreutils/lib/strerror.c +++ b/src/bin/coreutils/lib/strerror.c @@ -1,6 +1,6 @@ /* strerror.c --- POSIX compatible system error routine - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -334,10 +334,10 @@ rpl_strerror (int n) if (result == NULL || result[0] == '\0') { - static char const fmt[] = "Unknown error (%d)"; - static char msg_buf[sizeof fmt + INT_STRLEN_BOUND (n)]; - sprintf (msg_buf, fmt, n); - return msg_buf; + static char const fmt[] = "Unknown error (%d)"; + static char msg_buf[sizeof fmt + INT_STRLEN_BOUND (n)]; + sprintf (msg_buf, fmt, n); + return msg_buf; } return result; diff --git a/src/bin/coreutils/lib/strftime.c b/src/bin/coreutils/lib/strftime.c index fff5d38eae..01c0c5516d 100644 --- a/src/bin/coreutils/lib/strftime.c +++ b/src/bin/coreutils/lib/strftime.c @@ -1,5 +1,4 @@ -/* Copyright (C) 1991-1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2009 Free Software - Foundation, Inc. +/* Copyright (C) 1991-2001, 2003-2007, 2009-2010 Free Software Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. @@ -27,6 +26,7 @@ #else # include # if FPRINTFTIME +# include "ignore-value.h" # include "fprintftime.h" # else # include "strftime.h" @@ -96,9 +96,9 @@ extern char *tzname[]; implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift right in the usual way when A < 0, so SHR falls back on division if ordinary A >> B doesn't seem to be the usual signed shift. */ -#define SHR(a, b) \ - (-1 >> 1 == -1 \ - ? (a) >> (b) \ +#define SHR(a, b) \ + (-1 >> 1 == -1 \ + ? (a) >> (b) \ : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0)) /* Bound on length of the string representing an integer type or expression T. @@ -113,7 +113,7 @@ extern char *tzname[]; #ifndef __isleap /* Nonzero if YEAR is a leap year (every 4 years, except every 100th isn't, and every 400th is). */ -# define __isleap(year) \ +# define __isleap(year) \ ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) #endif @@ -166,27 +166,27 @@ extern char *tzname[]; # define advance(P, N) ((P) += (N)) #endif -#define add(n, f) \ - do \ - { \ - int _n = (n); \ - int _delta = width - _n; \ - int _incr = _n + (_delta > 0 ? _delta : 0); \ - if ((size_t) _incr >= maxsize - i) \ - return 0; \ - if (p) \ - { \ - if (digits == 0 && _delta > 0) \ - { \ - if (pad == L_('0')) \ - memset_zero (p, _delta); \ - else \ - memset_space (p, _delta); \ - } \ - f; \ - advance (p, _n); \ - } \ - i += _incr; \ +#define add(n, f) \ + do \ + { \ + int _n = (n); \ + int _delta = width - _n; \ + int _incr = _n + (_delta > 0 ? _delta : 0); \ + if ((size_t) _incr >= maxsize - i) \ + return 0; \ + if (p) \ + { \ + if (digits == 0 && _delta > 0) \ + { \ + if (pad == L_('0')) \ + memset_zero (p, _delta); \ + else \ + memset_space (p, _delta); \ + } \ + f; \ + advance (p, _n); \ + } \ + i += _incr; \ } while (0) #if FPRINTFTIME @@ -197,22 +197,35 @@ extern char *tzname[]; #if FPRINTFTIME # define cpy(n, s) \ - add ((n), \ - if (to_lowcase) \ - fwrite_lowcase (p, (s), _n); \ - else if (to_uppcase) \ - fwrite_uppcase (p, (s), _n); \ - else \ - fwrite ((s), _n, 1, p)) + add ((n), \ + do \ + { \ + if (to_lowcase) \ + fwrite_lowcase (p, (s), _n); \ + else if (to_uppcase) \ + fwrite_uppcase (p, (s), _n); \ + else \ + { \ + /* We are ignoring the value of fwrite here, in spite of the \ + fact that technically, that may not be valid: the fwrite \ + specification in POSIX 2008 defers to that of fputc, which \ + is intended to be consistent with the one from ISO C, \ + which permits failure due to ENOMEM *without* setting the \ + stream's error indicator. */ \ + ignore_value (fwrite ((s), _n, 1, p)); \ + } \ + } \ + while (0) \ + ) #else -# define cpy(n, s) \ - add ((n), \ - if (to_lowcase) \ - memcpy_lowcase (p, (s), _n LOCALE_ARG); \ - else if (to_uppcase) \ - memcpy_uppcase (p, (s), _n LOCALE_ARG); \ - else \ - MEMCPY ((void *) p, (void const *) (s), _n)) +# define cpy(n, s) \ + add ((n), \ + if (to_lowcase) \ + memcpy_lowcase (p, (s), _n LOCALE_ARG); \ + else if (to_uppcase) \ + memcpy_uppcase (p, (s), _n LOCALE_ARG); \ + else \ + MEMCPY ((void *) p, (void const *) (s), _n)) #endif #ifdef COMPILE_WIDE @@ -221,13 +234,13 @@ extern char *tzname[]; # define __mbsrtowcs_l(d, s, l, st, loc) __mbsrtowcs (d, s, l, st) # endif # define widen(os, ws, l) \ - { \ - mbstate_t __st; \ - const char *__s = os; \ - memset (&__st, '\0', sizeof (__st)); \ - l = __mbsrtowcs_l (NULL, &__s, 0, &__st, loc); \ - ws = (wchar_t *) alloca ((l + 1) * sizeof (wchar_t)); \ - (void) __mbsrtowcs_l (ws, &__s, l, &__st, loc); \ + { \ + mbstate_t __st; \ + const char *__s = os; \ + memset (&__st, '\0', sizeof (__st)); \ + l = __mbsrtowcs_l (NULL, &__s, 0, &__st, loc); \ + ws = (wchar_t *) alloca ((l + 1) * sizeof (wchar_t)); \ + (void) __mbsrtowcs_l (ws, &__s, l, &__st, loc); \ } #endif @@ -237,8 +250,8 @@ extern char *tzname[]; function gets as an additional argument the locale which has to be used. To access the values we have to redefine the _NL_CURRENT macro. */ -# define strftime __strftime_l -# define wcsftime __wcsftime_l +# define strftime __strftime_l +# define wcsftime __wcsftime_l # undef _NL_CURRENT # define _NL_CURRENT(category, item) \ (current->values[_NL_ITEM_INDEX (item)].string) @@ -301,7 +314,7 @@ fwrite_uppcase (FILE *fp, const CHAR_T *src, size_t len) #else static CHAR_T * memcpy_lowcase (CHAR_T *dest, const CHAR_T *src, - size_t len LOCALE_PARAM_PROTO) + size_t len LOCALE_PARAM_PROTO) { while (len-- > 0) dest[len] = TOLOWER ((UCHAR_T) src[len], loc); @@ -310,7 +323,7 @@ memcpy_lowcase (CHAR_T *dest, const CHAR_T *src, static CHAR_T * memcpy_uppcase (CHAR_T *dest, const CHAR_T *src, - size_t len LOCALE_PARAM_PROTO) + size_t len LOCALE_PARAM_PROTO) { while (len-- > 0) dest[len] = TOUPPER ((UCHAR_T) src[len], loc); @@ -338,10 +351,10 @@ tm_diff (const struct tm *a, const struct tm *b) int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); int years = a->tm_year - b->tm_year; int days = (365 * years + intervening_leap_days - + (a->tm_yday - b->tm_yday)); + + (a->tm_yday - b->tm_yday)); return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour)) - + (a->tm_min - b->tm_min)) - + (a->tm_sec - b->tm_sec)); + + (a->tm_min - b->tm_min)) + + (a->tm_sec - b->tm_sec)); } #endif /* ! HAVE_TM_GMTOFF */ @@ -363,8 +376,8 @@ iso_week_days (int yday, int wday) /* Add enough to the first operand of % to make it nonnegative. */ int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7; return (yday - - (yday - wday + ISO_WEEK1_WDAY + big_enough_multiple_of_7) % 7 - + ISO_WEEK1_WDAY - ISO_WEEK_START_WDAY); + - (yday - wday + ISO_WEEK1_WDAY + big_enough_multiple_of_7) % 7 + + ISO_WEEK1_WDAY - ISO_WEEK_START_WDAY); } @@ -405,9 +418,9 @@ iso_week_days (int yday, int wday) to indicate that the result should be converted to upper case. */ static size_t strftime_case_ (bool upcase, STREAM_OR_CHAR_T *s, - STRFTIME_ARG (size_t maxsize) - const CHAR_T *format, - const struct tm *tp extra_args_spec LOCALE_PARAM_PROTO) + STRFTIME_ARG (size_t maxsize) + const CHAR_T *format, + const struct tm *tp extra_args_spec LOCALE_PARAM_PROTO) { #if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL struct locale_data *const current = loc->__locales[LC_TIME]; @@ -433,8 +446,8 @@ strftime_case_ (bool upcase, STREAM_OR_CHAR_T *s, # define f_month \ ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(MON_1) + tp->tm_mon)) # define ampm \ - ((const CHAR_T *) _NL_CURRENT (LC_TIME, tp->tm_hour > 11 \ - ? NLW(PM_STR) : NLW(AM_STR))) + ((const CHAR_T *) _NL_CURRENT (LC_TIME, tp->tm_hour > 11 \ + ? NLW(PM_STR) : NLW(AM_STR))) # define aw_len STRLEN (a_wkday) # define am_len STRLEN (a_month) @@ -471,12 +484,12 @@ strftime_case_ (bool upcase, STREAM_OR_CHAR_T *s, if (ut) { if (! (zone && *zone)) - zone = "GMT"; + zone = "GMT"; } else { /* POSIX.1 requires that local time zone information be used as - though strftime called tzset. */ + though strftime called tzset. */ # if HAVE_TZSET tzset (); # endif @@ -491,22 +504,22 @@ strftime_case_ (bool upcase, STREAM_OR_CHAR_T *s, for (f = format; *f != '\0'; ++f) { - int pad = 0; /* Padding for number ('-', '_', or 0). */ - int modifier; /* Field modifier ('E', 'O', or 0). */ - int digits = 0; /* Max digits for numeric format. */ - int number_value; /* Numeric value to be printed. */ + int pad = 0; /* Padding for number ('-', '_', or 0). */ + int modifier; /* Field modifier ('E', 'O', or 0). */ + int digits = 0; /* Max digits for numeric format. */ + int number_value; /* Numeric value to be printed. */ unsigned int u_number_value; /* (unsigned int) number_value. */ - bool negative_number; /* The number is negative. */ + bool negative_number; /* The number is negative. */ bool always_output_a_sign; /* +/- should always be output. */ - int tz_colon_mask; /* Bitmask of where ':' should appear. */ + int tz_colon_mask; /* Bitmask of where ':' should appear. */ const CHAR_T *subfmt; CHAR_T sign_char; CHAR_T *bufp; CHAR_T buf[1 - + 2 /* for the two colons in a %::z or %:::z time zone */ - + (sizeof (int) < sizeof (time_t) - ? INT_STRLEN_BOUND (time_t) - : INT_STRLEN_BOUND (int))]; + + 2 /* for the two colons in a %::z or %:::z time zone */ + + (sizeof (int) < sizeof (time_t) + ? INT_STRLEN_BOUND (time_t) + : INT_STRLEN_BOUND (int))]; int width = -1; bool to_lowcase = false; bool to_uppcase = upcase; @@ -516,900 +529,900 @@ strftime_case_ (bool upcase, STREAM_OR_CHAR_T *s, #if DO_MULTIBYTE && !defined COMPILE_WIDE switch (*f) - { - case L_('%'): - break; + { + case L_('%'): + break; - case L_('\b'): case L_('\t'): case L_('\n'): - case L_('\v'): case L_('\f'): case L_('\r'): - case L_(' '): case L_('!'): case L_('"'): case L_('#'): case L_('&'): - case L_('\''): case L_('('): case L_(')'): case L_('*'): case L_('+'): - case L_(','): case L_('-'): case L_('.'): case L_('/'): case L_('0'): - case L_('1'): case L_('2'): case L_('3'): case L_('4'): case L_('5'): - case L_('6'): case L_('7'): case L_('8'): case L_('9'): case L_(':'): - case L_(';'): case L_('<'): case L_('='): case L_('>'): case L_('?'): - case L_('A'): case L_('B'): case L_('C'): case L_('D'): case L_('E'): - case L_('F'): case L_('G'): case L_('H'): case L_('I'): case L_('J'): - case L_('K'): case L_('L'): case L_('M'): case L_('N'): case L_('O'): - case L_('P'): case L_('Q'): case L_('R'): case L_('S'): case L_('T'): - case L_('U'): case L_('V'): case L_('W'): case L_('X'): case L_('Y'): - case L_('Z'): case L_('['): case L_('\\'): case L_(']'): case L_('^'): - case L_('_'): case L_('a'): case L_('b'): case L_('c'): case L_('d'): - case L_('e'): case L_('f'): case L_('g'): case L_('h'): case L_('i'): - case L_('j'): case L_('k'): case L_('l'): case L_('m'): case L_('n'): - case L_('o'): case L_('p'): case L_('q'): case L_('r'): case L_('s'): - case L_('t'): case L_('u'): case L_('v'): case L_('w'): case L_('x'): - case L_('y'): case L_('z'): case L_('{'): case L_('|'): case L_('}'): - case L_('~'): - /* The C Standard requires these 98 characters (plus '%') to - be in the basic execution character set. None of these - characters can start a multibyte sequence, so they need - not be analyzed further. */ - add1 (*f); - continue; + case L_('\b'): case L_('\t'): case L_('\n'): + case L_('\v'): case L_('\f'): case L_('\r'): + case L_(' '): case L_('!'): case L_('"'): case L_('#'): case L_('&'): + case L_('\''): case L_('('): case L_(')'): case L_('*'): case L_('+'): + case L_(','): case L_('-'): case L_('.'): case L_('/'): case L_('0'): + case L_('1'): case L_('2'): case L_('3'): case L_('4'): case L_('5'): + case L_('6'): case L_('7'): case L_('8'): case L_('9'): case L_(':'): + case L_(';'): case L_('<'): case L_('='): case L_('>'): case L_('?'): + case L_('A'): case L_('B'): case L_('C'): case L_('D'): case L_('E'): + case L_('F'): case L_('G'): case L_('H'): case L_('I'): case L_('J'): + case L_('K'): case L_('L'): case L_('M'): case L_('N'): case L_('O'): + case L_('P'): case L_('Q'): case L_('R'): case L_('S'): case L_('T'): + case L_('U'): case L_('V'): case L_('W'): case L_('X'): case L_('Y'): + case L_('Z'): case L_('['): case L_('\\'): case L_(']'): case L_('^'): + case L_('_'): case L_('a'): case L_('b'): case L_('c'): case L_('d'): + case L_('e'): case L_('f'): case L_('g'): case L_('h'): case L_('i'): + case L_('j'): case L_('k'): case L_('l'): case L_('m'): case L_('n'): + case L_('o'): case L_('p'): case L_('q'): case L_('r'): case L_('s'): + case L_('t'): case L_('u'): case L_('v'): case L_('w'): case L_('x'): + case L_('y'): case L_('z'): case L_('{'): case L_('|'): case L_('}'): + case L_('~'): + /* The C Standard requires these 98 characters (plus '%') to + be in the basic execution character set. None of these + characters can start a multibyte sequence, so they need + not be analyzed further. */ + add1 (*f); + continue; - default: - /* Copy this multibyte sequence until we reach its end, find - an error, or come back to the initial shift state. */ - { - mbstate_t mbstate = mbstate_zero; - size_t len = 0; - size_t fsize; + default: + /* Copy this multibyte sequence until we reach its end, find + an error, or come back to the initial shift state. */ + { + mbstate_t mbstate = mbstate_zero; + size_t len = 0; + size_t fsize; - if (! format_end) - format_end = f + strlen (f) + 1; - fsize = format_end - f; + if (! format_end) + format_end = f + strlen (f) + 1; + fsize = format_end - f; - do - { - size_t bytes = mbrlen (f + len, fsize - len, &mbstate); + do + { + size_t bytes = mbrlen (f + len, fsize - len, &mbstate); - if (bytes == 0) - break; + if (bytes == 0) + break; - if (bytes == (size_t) -2) - { - len += strlen (f + len); - break; - } + if (bytes == (size_t) -2) + { + len += strlen (f + len); + break; + } - if (bytes == (size_t) -1) - { - len++; - break; - } + if (bytes == (size_t) -1) + { + len++; + break; + } - len += bytes; - } - while (! mbsinit (&mbstate)); + len += bytes; + } + while (! mbsinit (&mbstate)); - cpy (len, f); - f += len - 1; - continue; - } - } + cpy (len, f); + f += len - 1; + continue; + } + } #else /* ! DO_MULTIBYTE */ /* Either multibyte encodings are not supported, they are - safe for formats, so any non-'%' byte can be copied through, - or this is the wide character version. */ + safe for formats, so any non-'%' byte can be copied through, + or this is the wide character version. */ if (*f != L_('%')) - { - add1 (*f); - continue; - } + { + add1 (*f); + continue; + } #endif /* ! DO_MULTIBYTE */ /* Check for flags that can modify a format. */ while (1) - { - switch (*++f) - { - /* This influences the number formats. */ - case L_('_'): - case L_('-'): - case L_('0'): - pad = *f; - continue; + { + switch (*++f) + { + /* This influences the number formats. */ + case L_('_'): + case L_('-'): + case L_('0'): + pad = *f; + continue; - /* This changes textual output. */ - case L_('^'): - to_uppcase = true; - continue; - case L_('#'): - change_case = true; - continue; + /* This changes textual output. */ + case L_('^'): + to_uppcase = true; + continue; + case L_('#'): + change_case = true; + continue; - default: - break; - } - break; - } + default: + break; + } + break; + } /* As a GNU extension we allow to specify the field width. */ if (ISDIGIT (*f)) - { - width = 0; - do - { - if (width > INT_MAX / 10 - || (width == INT_MAX / 10 && *f - L_('0') > INT_MAX % 10)) - /* Avoid overflow. */ - width = INT_MAX; - else - { - width *= 10; - width += *f - L_('0'); - } - ++f; - } - while (ISDIGIT (*f)); - } + { + width = 0; + do + { + if (width > INT_MAX / 10 + || (width == INT_MAX / 10 && *f - L_('0') > INT_MAX % 10)) + /* Avoid overflow. */ + width = INT_MAX; + else + { + width *= 10; + width += *f - L_('0'); + } + ++f; + } + while (ISDIGIT (*f)); + } /* Check for modifiers. */ switch (*f) - { - case L_('E'): - case L_('O'): - modifier = *f++; - break; + { + case L_('E'): + case L_('O'): + modifier = *f++; + break; - default: - modifier = 0; - break; - } + default: + modifier = 0; + break; + } /* Now do the specified format. */ format_char = *f; switch (format_char) - { + { #define DO_NUMBER(d, v) \ - digits = d; \ - number_value = v; goto do_number + digits = d; \ + number_value = v; goto do_number #define DO_SIGNED_NUMBER(d, negative, v) \ - digits = d; \ - negative_number = negative; \ - u_number_value = v; goto do_signed_number + digits = d; \ + negative_number = negative; \ + u_number_value = v; goto do_signed_number - /* The mask is not what you might think. - When the ordinal i'th bit is set, insert a colon - before the i'th digit of the time zone representation. */ + /* The mask is not what you might think. + When the ordinal i'th bit is set, insert a colon + before the i'th digit of the time zone representation. */ #define DO_TZ_OFFSET(d, negative, mask, v) \ - digits = d; \ - negative_number = negative; \ - tz_colon_mask = mask; \ - u_number_value = v; goto do_tz_offset + digits = d; \ + negative_number = negative; \ + tz_colon_mask = mask; \ + u_number_value = v; goto do_tz_offset #define DO_NUMBER_SPACEPAD(d, v) \ - digits = d; \ - number_value = v; goto do_number_spacepad + digits = d; \ + number_value = v; goto do_number_spacepad - case L_('%'): - if (modifier != 0) - goto bad_format; - add1 (*f); - break; + case L_('%'): + if (modifier != 0) + goto bad_format; + add1 (*f); + break; - case L_('a'): - if (modifier != 0) - goto bad_format; - if (change_case) - { - to_uppcase = true; - to_lowcase = false; - } + case L_('a'): + if (modifier != 0) + goto bad_format; + if (change_case) + { + to_uppcase = true; + to_lowcase = false; + } #ifdef _NL_CURRENT - cpy (aw_len, a_wkday); - break; + cpy (aw_len, a_wkday); + break; #else - goto underlying_strftime; + goto underlying_strftime; #endif - case 'A': - if (modifier != 0) - goto bad_format; - if (change_case) - { - to_uppcase = true; - to_lowcase = false; - } + case 'A': + if (modifier != 0) + goto bad_format; + if (change_case) + { + to_uppcase = true; + to_lowcase = false; + } #ifdef _NL_CURRENT - cpy (STRLEN (f_wkday), f_wkday); - break; + cpy (STRLEN (f_wkday), f_wkday); + break; #else - goto underlying_strftime; + goto underlying_strftime; #endif - case L_('b'): - case L_('h'): - if (change_case) - { - to_uppcase = true; - to_lowcase = false; - } - if (modifier != 0) - goto bad_format; + case L_('b'): + case L_('h'): + if (change_case) + { + to_uppcase = true; + to_lowcase = false; + } + if (modifier != 0) + goto bad_format; #ifdef _NL_CURRENT - cpy (am_len, a_month); - break; + cpy (am_len, a_month); + break; #else - goto underlying_strftime; + goto underlying_strftime; #endif - case L_('B'): - if (modifier != 0) - goto bad_format; - if (change_case) - { - to_uppcase = true; - to_lowcase = false; - } + case L_('B'): + if (modifier != 0) + goto bad_format; + if (change_case) + { + to_uppcase = true; + to_lowcase = false; + } #ifdef _NL_CURRENT - cpy (STRLEN (f_month), f_month); - break; + cpy (STRLEN (f_month), f_month); + break; #else - goto underlying_strftime; + goto underlying_strftime; #endif - case L_('c'): - if (modifier == L_('O')) - goto bad_format; + case L_('c'): + if (modifier == L_('O')) + goto bad_format; #ifdef _NL_CURRENT - if (! (modifier == 'E' - && (*(subfmt = - (const CHAR_T *) _NL_CURRENT (LC_TIME, - NLW(ERA_D_T_FMT))) - != '\0'))) - subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_T_FMT)); + if (! (modifier == 'E' + && (*(subfmt = + (const CHAR_T *) _NL_CURRENT (LC_TIME, + NLW(ERA_D_T_FMT))) + != '\0'))) + subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_T_FMT)); #else - goto underlying_strftime; + goto underlying_strftime; #endif - subformat: - { - size_t len = strftime_case_ (to_uppcase, - NULL, STRFTIME_ARG ((size_t) -1) - subfmt, - tp extra_args LOCALE_ARG); - add (len, strftime_case_ (to_uppcase, p, - STRFTIME_ARG (maxsize - i) - subfmt, - tp extra_args LOCALE_ARG)); - } - break; + subformat: + { + size_t len = strftime_case_ (to_uppcase, + NULL, STRFTIME_ARG ((size_t) -1) + subfmt, + tp extra_args LOCALE_ARG); + add (len, strftime_case_ (to_uppcase, p, + STRFTIME_ARG (maxsize - i) + subfmt, + tp extra_args LOCALE_ARG)); + } + break; #if !(defined _NL_CURRENT && HAVE_STRUCT_ERA_ENTRY) - underlying_strftime: - { - /* The relevant information is available only via the - underlying strftime implementation, so use that. */ - char ufmt[5]; - char *u = ufmt; - char ubuf[1024]; /* enough for any single format in practice */ - size_t len; - /* Make sure we're calling the actual underlying strftime. - In some cases, config.h contains something like - "#define strftime rpl_strftime". */ + underlying_strftime: + { + /* The relevant information is available only via the + underlying strftime implementation, so use that. */ + char ufmt[5]; + char *u = ufmt; + char ubuf[1024]; /* enough for any single format in practice */ + size_t len; + /* Make sure we're calling the actual underlying strftime. + In some cases, config.h contains something like + "#define strftime rpl_strftime". */ # ifdef strftime # undef strftime - size_t strftime (); + size_t strftime (); # endif - /* The space helps distinguish strftime failure from empty - output. */ - *u++ = ' '; - *u++ = '%'; - if (modifier != 0) - *u++ = modifier; - *u++ = format_char; - *u = '\0'; - len = strftime (ubuf, sizeof ubuf, ufmt, tp); - if (len != 0) - cpy (len - 1, ubuf + 1); - } - break; + /* The space helps distinguish strftime failure from empty + output. */ + *u++ = ' '; + *u++ = '%'; + if (modifier != 0) + *u++ = modifier; + *u++ = format_char; + *u = '\0'; + len = strftime (ubuf, sizeof ubuf, ufmt, tp); + if (len != 0) + cpy (len - 1, ubuf + 1); + } + break; #endif - case L_('C'): - if (modifier == L_('O')) - goto bad_format; - if (modifier == L_('E')) - { + case L_('C'): + if (modifier == L_('O')) + goto bad_format; + if (modifier == L_('E')) + { #if HAVE_STRUCT_ERA_ENTRY - struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); - if (era) - { + struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); + if (era) + { # ifdef COMPILE_WIDE - size_t len = __wcslen (era->era_wname); - cpy (len, era->era_wname); + size_t len = __wcslen (era->era_wname); + cpy (len, era->era_wname); # else - size_t len = strlen (era->era_name); - cpy (len, era->era_name); + size_t len = strlen (era->era_name); + cpy (len, era->era_name); # endif - break; - } + break; + } #else - goto underlying_strftime; + goto underlying_strftime; #endif - } + } - { - int century = tp->tm_year / 100 + TM_YEAR_BASE / 100; - century -= tp->tm_year % 100 < 0 && 0 < century; - DO_SIGNED_NUMBER (2, tp->tm_year < - TM_YEAR_BASE, century); - } + { + int century = tp->tm_year / 100 + TM_YEAR_BASE / 100; + century -= tp->tm_year % 100 < 0 && 0 < century; + DO_SIGNED_NUMBER (2, tp->tm_year < - TM_YEAR_BASE, century); + } - case L_('x'): - if (modifier == L_('O')) - goto bad_format; + case L_('x'): + if (modifier == L_('O')) + goto bad_format; #ifdef _NL_CURRENT - if (! (modifier == L_('E') - && (*(subfmt = - (const CHAR_T *)_NL_CURRENT (LC_TIME, NLW(ERA_D_FMT))) - != L_('\0')))) - subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_FMT)); - goto subformat; + if (! (modifier == L_('E') + && (*(subfmt = + (const CHAR_T *)_NL_CURRENT (LC_TIME, NLW(ERA_D_FMT))) + != L_('\0')))) + subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_FMT)); + goto subformat; #else - goto underlying_strftime; + goto underlying_strftime; #endif - case L_('D'): - if (modifier != 0) - goto bad_format; - subfmt = L_("%m/%d/%y"); - goto subformat; + case L_('D'): + if (modifier != 0) + goto bad_format; + subfmt = L_("%m/%d/%y"); + goto subformat; - case L_('d'): - if (modifier == L_('E')) - goto bad_format; + case L_('d'): + if (modifier == L_('E')) + goto bad_format; - DO_NUMBER (2, tp->tm_mday); + DO_NUMBER (2, tp->tm_mday); - case L_('e'): - if (modifier == L_('E')) - goto bad_format; + case L_('e'): + if (modifier == L_('E')) + goto bad_format; - DO_NUMBER_SPACEPAD (2, tp->tm_mday); + DO_NUMBER_SPACEPAD (2, tp->tm_mday); - /* All numeric formats set DIGITS and NUMBER_VALUE (or U_NUMBER_VALUE) - and then jump to one of these labels. */ + /* All numeric formats set DIGITS and NUMBER_VALUE (or U_NUMBER_VALUE) + and then jump to one of these labels. */ - do_tz_offset: - always_output_a_sign = true; - goto do_number_body; + do_tz_offset: + always_output_a_sign = true; + goto do_number_body; - do_number_spacepad: - /* Force `_' flag unless overridden by `0' or `-' flag. */ - if (pad != L_('0') && pad != L_('-')) - pad = L_('_'); + do_number_spacepad: + /* Force `_' flag unless overridden by `0' or `-' flag. */ + if (pad != L_('0') && pad != L_('-')) + pad = L_('_'); - do_number: - /* Format NUMBER_VALUE according to the MODIFIER flag. */ - negative_number = number_value < 0; - u_number_value = number_value; + do_number: + /* Format NUMBER_VALUE according to the MODIFIER flag. */ + negative_number = number_value < 0; + u_number_value = number_value; - do_signed_number: - always_output_a_sign = false; - tz_colon_mask = 0; + do_signed_number: + always_output_a_sign = false; + tz_colon_mask = 0; - do_number_body: - /* Format U_NUMBER_VALUE according to the MODIFIER flag. - NEGATIVE_NUMBER is nonzero if the original number was - negative; in this case it was converted directly to - unsigned int (i.e., modulo (UINT_MAX + 1)) without - negating it. */ - if (modifier == L_('O') && !negative_number) - { + do_number_body: + /* Format U_NUMBER_VALUE according to the MODIFIER flag. + NEGATIVE_NUMBER is nonzero if the original number was + negative; in this case it was converted directly to + unsigned int (i.e., modulo (UINT_MAX + 1)) without + negating it. */ + if (modifier == L_('O') && !negative_number) + { #ifdef _NL_CURRENT - /* Get the locale specific alternate representation of - the number. If none exist NULL is returned. */ - const CHAR_T *cp = nl_get_alt_digit (u_number_value - HELPER_LOCALE_ARG); + /* Get the locale specific alternate representation of + the number. If none exist NULL is returned. */ + const CHAR_T *cp = nl_get_alt_digit (u_number_value + HELPER_LOCALE_ARG); - if (cp != NULL) - { - size_t digitlen = STRLEN (cp); - if (digitlen != 0) - { - cpy (digitlen, cp); - break; - } - } + if (cp != NULL) + { + size_t digitlen = STRLEN (cp); + if (digitlen != 0) + { + cpy (digitlen, cp); + break; + } + } #else - goto underlying_strftime; + goto underlying_strftime; #endif - } + } - bufp = buf + sizeof (buf) / sizeof (buf[0]); + bufp = buf + sizeof (buf) / sizeof (buf[0]); - if (negative_number) - u_number_value = - u_number_value; + if (negative_number) + u_number_value = - u_number_value; - do - { - if (tz_colon_mask & 1) - *--bufp = ':'; - tz_colon_mask >>= 1; - *--bufp = u_number_value % 10 + L_('0'); - u_number_value /= 10; - } - while (u_number_value != 0 || tz_colon_mask != 0); + do + { + if (tz_colon_mask & 1) + *--bufp = ':'; + tz_colon_mask >>= 1; + *--bufp = u_number_value % 10 + L_('0'); + u_number_value /= 10; + } + while (u_number_value != 0 || tz_colon_mask != 0); - do_number_sign_and_padding: - if (digits < width) - digits = width; + do_number_sign_and_padding: + if (digits < width) + digits = width; - sign_char = (negative_number ? L_('-') - : always_output_a_sign ? L_('+') - : 0); + sign_char = (negative_number ? L_('-') + : always_output_a_sign ? L_('+') + : 0); - if (pad == L_('-')) - { - if (sign_char) - add1 (sign_char); - } - else - { - int padding = digits - (buf + (sizeof (buf) / sizeof (buf[0])) - - bufp) - !!sign_char; + if (pad == L_('-')) + { + if (sign_char) + add1 (sign_char); + } + else + { + int padding = digits - (buf + (sizeof (buf) / sizeof (buf[0])) + - bufp) - !!sign_char; - if (padding > 0) - { - if (pad == L_('_')) - { - if ((size_t) padding >= maxsize - i) - return 0; + if (padding > 0) + { + if (pad == L_('_')) + { + if ((size_t) padding >= maxsize - i) + return 0; - if (p) - memset_space (p, padding); - i += padding; - width = width > padding ? width - padding : 0; - if (sign_char) - add1 (sign_char); - } - else - { - if ((size_t) digits >= maxsize - i) - return 0; + if (p) + memset_space (p, padding); + i += padding; + width = width > padding ? width - padding : 0; + if (sign_char) + add1 (sign_char); + } + else + { + if ((size_t) digits >= maxsize - i) + return 0; - if (sign_char) - add1 (sign_char); + if (sign_char) + add1 (sign_char); - if (p) - memset_zero (p, padding); - i += padding; - width = 0; - } - } - else - { - if (sign_char) - add1 (sign_char); - } - } + if (p) + memset_zero (p, padding); + i += padding; + width = 0; + } + } + else + { + if (sign_char) + add1 (sign_char); + } + } - cpy (buf + sizeof (buf) / sizeof (buf[0]) - bufp, bufp); - break; + cpy (buf + sizeof (buf) / sizeof (buf[0]) - bufp, bufp); + break; - case L_('F'): - if (modifier != 0) - goto bad_format; - subfmt = L_("%Y-%m-%d"); - goto subformat; + case L_('F'): + if (modifier != 0) + goto bad_format; + subfmt = L_("%Y-%m-%d"); + goto subformat; - case L_('H'): - if (modifier == L_('E')) - goto bad_format; + case L_('H'): + if (modifier == L_('E')) + goto bad_format; - DO_NUMBER (2, tp->tm_hour); + DO_NUMBER (2, tp->tm_hour); - case L_('I'): - if (modifier == L_('E')) - goto bad_format; + case L_('I'): + if (modifier == L_('E')) + goto bad_format; - DO_NUMBER (2, hour12); + DO_NUMBER (2, hour12); - case L_('k'): /* GNU extension. */ - if (modifier == L_('E')) - goto bad_format; + case L_('k'): /* GNU extension. */ + if (modifier == L_('E')) + goto bad_format; - DO_NUMBER_SPACEPAD (2, tp->tm_hour); + DO_NUMBER_SPACEPAD (2, tp->tm_hour); - case L_('l'): /* GNU extension. */ - if (modifier == L_('E')) - goto bad_format; + case L_('l'): /* GNU extension. */ + if (modifier == L_('E')) + goto bad_format; - DO_NUMBER_SPACEPAD (2, hour12); + DO_NUMBER_SPACEPAD (2, hour12); - case L_('j'): - if (modifier == L_('E')) - goto bad_format; + case L_('j'): + if (modifier == L_('E')) + goto bad_format; - DO_SIGNED_NUMBER (3, tp->tm_yday < -1, tp->tm_yday + 1U); + DO_SIGNED_NUMBER (3, tp->tm_yday < -1, tp->tm_yday + 1U); - case L_('M'): - if (modifier == L_('E')) - goto bad_format; + case L_('M'): + if (modifier == L_('E')) + goto bad_format; - DO_NUMBER (2, tp->tm_min); + DO_NUMBER (2, tp->tm_min); - case L_('m'): - if (modifier == L_('E')) - goto bad_format; + case L_('m'): + if (modifier == L_('E')) + goto bad_format; - DO_SIGNED_NUMBER (2, tp->tm_mon < -1, tp->tm_mon + 1U); + DO_SIGNED_NUMBER (2, tp->tm_mon < -1, tp->tm_mon + 1U); #ifndef _LIBC - case L_('N'): /* GNU extension. */ - if (modifier == L_('E')) - goto bad_format; + case L_('N'): /* GNU extension. */ + if (modifier == L_('E')) + goto bad_format; - number_value = ns; - if (width == -1) - width = 9; - else - { - /* Take an explicit width less than 9 as a precision. */ - int j; - for (j = width; j < 9; j++) - number_value /= 10; - } + number_value = ns; + if (width == -1) + width = 9; + else + { + /* Take an explicit width less than 9 as a precision. */ + int j; + for (j = width; j < 9; j++) + number_value /= 10; + } - DO_NUMBER (width, number_value); + DO_NUMBER (width, number_value); #endif - case L_('n'): - add1 (L_('\n')); - break; + case L_('n'): + add1 (L_('\n')); + break; - case L_('P'): - to_lowcase = true; + case L_('P'): + to_lowcase = true; #ifndef _NL_CURRENT - format_char = L_('p'); + format_char = L_('p'); #endif - /* FALLTHROUGH */ + /* FALLTHROUGH */ - case L_('p'): - if (change_case) - { - to_uppcase = false; - to_lowcase = true; - } + case L_('p'): + if (change_case) + { + to_uppcase = false; + to_lowcase = true; + } #ifdef _NL_CURRENT - cpy (ap_len, ampm); - break; + cpy (ap_len, ampm); + break; #else - goto underlying_strftime; + goto underlying_strftime; #endif - case L_('R'): - subfmt = L_("%H:%M"); - goto subformat; + case L_('R'): + subfmt = L_("%H:%M"); + goto subformat; - case L_('r'): + case L_('r'): #ifdef _NL_CURRENT - if (*(subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, - NLW(T_FMT_AMPM))) - == L_('\0')) - subfmt = L_("%I:%M:%S %p"); - goto subformat; + if (*(subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, + NLW(T_FMT_AMPM))) + == L_('\0')) + subfmt = L_("%I:%M:%S %p"); + goto subformat; #else - goto underlying_strftime; + goto underlying_strftime; #endif - case L_('S'): - if (modifier == L_('E')) - goto bad_format; + case L_('S'): + if (modifier == L_('E')) + goto bad_format; - DO_NUMBER (2, tp->tm_sec); + DO_NUMBER (2, tp->tm_sec); - case L_('s'): /* GNU extension. */ - { - struct tm ltm; - time_t t; + case L_('s'): /* GNU extension. */ + { + struct tm ltm; + time_t t; - ltm = *tp; - t = mktime (<m); + ltm = *tp; + t = mktime (<m); - /* Generate string value for T using time_t arithmetic; - this works even if sizeof (long) < sizeof (time_t). */ + /* Generate string value for T using time_t arithmetic; + this works even if sizeof (long) < sizeof (time_t). */ - bufp = buf + sizeof (buf) / sizeof (buf[0]); - negative_number = t < 0; + bufp = buf + sizeof (buf) / sizeof (buf[0]); + negative_number = t < 0; - do - { - int d = t % 10; - t /= 10; - *--bufp = (negative_number ? -d : d) + L_('0'); - } - while (t != 0); + do + { + int d = t % 10; + t /= 10; + *--bufp = (negative_number ? -d : d) + L_('0'); + } + while (t != 0); - digits = 1; - always_output_a_sign = false; - goto do_number_sign_and_padding; - } + digits = 1; + always_output_a_sign = false; + goto do_number_sign_and_padding; + } - case L_('X'): - if (modifier == L_('O')) - goto bad_format; + case L_('X'): + if (modifier == L_('O')) + goto bad_format; #ifdef _NL_CURRENT - if (! (modifier == L_('E') - && (*(subfmt = - (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ERA_T_FMT))) - != L_('\0')))) - subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(T_FMT)); - goto subformat; + if (! (modifier == L_('E') + && (*(subfmt = + (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ERA_T_FMT))) + != L_('\0')))) + subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(T_FMT)); + goto subformat; #else - goto underlying_strftime; + goto underlying_strftime; #endif - case L_('T'): - subfmt = L_("%H:%M:%S"); - goto subformat; + case L_('T'): + subfmt = L_("%H:%M:%S"); + goto subformat; - case L_('t'): - add1 (L_('\t')); - break; + case L_('t'): + add1 (L_('\t')); + break; - case L_('u'): - DO_NUMBER (1, (tp->tm_wday - 1 + 7) % 7 + 1); + case L_('u'): + DO_NUMBER (1, (tp->tm_wday - 1 + 7) % 7 + 1); - case L_('U'): - if (modifier == L_('E')) - goto bad_format; + case L_('U'): + if (modifier == L_('E')) + goto bad_format; - DO_NUMBER (2, (tp->tm_yday - tp->tm_wday + 7) / 7); + DO_NUMBER (2, (tp->tm_yday - tp->tm_wday + 7) / 7); - case L_('V'): - case L_('g'): - case L_('G'): - if (modifier == L_('E')) - goto bad_format; - { - /* YEAR is a leap year if and only if (tp->tm_year + TM_YEAR_BASE) - is a leap year, except that YEAR and YEAR - 1 both work - correctly even when (tp->tm_year + TM_YEAR_BASE) would - overflow. */ - int year = (tp->tm_year - + (tp->tm_year < 0 - ? TM_YEAR_BASE % 400 - : TM_YEAR_BASE % 400 - 400)); - int year_adjust = 0; - int days = iso_week_days (tp->tm_yday, tp->tm_wday); + case L_('V'): + case L_('g'): + case L_('G'): + if (modifier == L_('E')) + goto bad_format; + { + /* YEAR is a leap year if and only if (tp->tm_year + TM_YEAR_BASE) + is a leap year, except that YEAR and YEAR - 1 both work + correctly even when (tp->tm_year + TM_YEAR_BASE) would + overflow. */ + int year = (tp->tm_year + + (tp->tm_year < 0 + ? TM_YEAR_BASE % 400 + : TM_YEAR_BASE % 400 - 400)); + int year_adjust = 0; + int days = iso_week_days (tp->tm_yday, tp->tm_wday); - if (days < 0) - { - /* This ISO week belongs to the previous year. */ - year_adjust = -1; - days = iso_week_days (tp->tm_yday + (365 + __isleap (year - 1)), - tp->tm_wday); - } - else - { - int d = iso_week_days (tp->tm_yday - (365 + __isleap (year)), - tp->tm_wday); - if (0 <= d) - { - /* This ISO week belongs to the next year. */ - year_adjust = 1; - days = d; - } - } + if (days < 0) + { + /* This ISO week belongs to the previous year. */ + year_adjust = -1; + days = iso_week_days (tp->tm_yday + (365 + __isleap (year - 1)), + tp->tm_wday); + } + else + { + int d = iso_week_days (tp->tm_yday - (365 + __isleap (year)), + tp->tm_wday); + if (0 <= d) + { + /* This ISO week belongs to the next year. */ + year_adjust = 1; + days = d; + } + } - switch (*f) - { - case L_('g'): - { - int yy = (tp->tm_year % 100 + year_adjust) % 100; - DO_NUMBER (2, (0 <= yy - ? yy - : tp->tm_year < -TM_YEAR_BASE - year_adjust - ? -yy - : yy + 100)); - } + switch (*f) + { + case L_('g'): + { + int yy = (tp->tm_year % 100 + year_adjust) % 100; + DO_NUMBER (2, (0 <= yy + ? yy + : tp->tm_year < -TM_YEAR_BASE - year_adjust + ? -yy + : yy + 100)); + } - case L_('G'): - DO_SIGNED_NUMBER (4, tp->tm_year < -TM_YEAR_BASE - year_adjust, - (tp->tm_year + (unsigned int) TM_YEAR_BASE - + year_adjust)); + case L_('G'): + DO_SIGNED_NUMBER (4, tp->tm_year < -TM_YEAR_BASE - year_adjust, + (tp->tm_year + (unsigned int) TM_YEAR_BASE + + year_adjust)); - default: - DO_NUMBER (2, days / 7 + 1); - } - } + default: + DO_NUMBER (2, days / 7 + 1); + } + } - case L_('W'): - if (modifier == L_('E')) - goto bad_format; + case L_('W'): + if (modifier == L_('E')) + goto bad_format; - DO_NUMBER (2, (tp->tm_yday - (tp->tm_wday - 1 + 7) % 7 + 7) / 7); + DO_NUMBER (2, (tp->tm_yday - (tp->tm_wday - 1 + 7) % 7 + 7) / 7); - case L_('w'): - if (modifier == L_('E')) - goto bad_format; + case L_('w'): + if (modifier == L_('E')) + goto bad_format; - DO_NUMBER (1, tp->tm_wday); + DO_NUMBER (1, tp->tm_wday); - case L_('Y'): - if (modifier == 'E') - { + case L_('Y'): + if (modifier == 'E') + { #if HAVE_STRUCT_ERA_ENTRY - struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); - if (era) - { + struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); + if (era) + { # ifdef COMPILE_WIDE - subfmt = era->era_wformat; + subfmt = era->era_wformat; # else - subfmt = era->era_format; + subfmt = era->era_format; # endif - goto subformat; - } + goto subformat; + } #else - goto underlying_strftime; + goto underlying_strftime; #endif - } - if (modifier == L_('O')) - goto bad_format; - else - DO_SIGNED_NUMBER (4, tp->tm_year < -TM_YEAR_BASE, - tp->tm_year + (unsigned int) TM_YEAR_BASE); + } + if (modifier == L_('O')) + goto bad_format; + else + DO_SIGNED_NUMBER (4, tp->tm_year < -TM_YEAR_BASE, + tp->tm_year + (unsigned int) TM_YEAR_BASE); - case L_('y'): - if (modifier == L_('E')) - { + case L_('y'): + if (modifier == L_('E')) + { #if HAVE_STRUCT_ERA_ENTRY - struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); - if (era) - { - int delta = tp->tm_year - era->start_date[0]; - DO_NUMBER (1, (era->offset - + delta * era->absolute_direction)); - } + struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); + if (era) + { + int delta = tp->tm_year - era->start_date[0]; + DO_NUMBER (1, (era->offset + + delta * era->absolute_direction)); + } #else - goto underlying_strftime; + goto underlying_strftime; #endif - } + } - { - int yy = tp->tm_year % 100; - if (yy < 0) - yy = tp->tm_year < - TM_YEAR_BASE ? -yy : yy + 100; - DO_NUMBER (2, yy); - } + { + int yy = tp->tm_year % 100; + if (yy < 0) + yy = tp->tm_year < - TM_YEAR_BASE ? -yy : yy + 100; + DO_NUMBER (2, yy); + } - case L_('Z'): - if (change_case) - { - to_uppcase = false; - to_lowcase = true; - } + case L_('Z'): + if (change_case) + { + to_uppcase = false; + to_lowcase = true; + } #if HAVE_TZNAME - /* The tzset() call might have changed the value. */ - if (!(zone && *zone) && tp->tm_isdst >= 0) - zone = tzname[tp->tm_isdst != 0]; + /* The tzset() call might have changed the value. */ + if (!(zone && *zone) && tp->tm_isdst >= 0) + zone = tzname[tp->tm_isdst != 0]; #endif - if (! zone) - zone = ""; + if (! zone) + zone = ""; #ifdef COMPILE_WIDE - { - /* The zone string is always given in multibyte form. We have - to transform it first. */ - wchar_t *wczone; - size_t len; - widen (zone, wczone, len); - cpy (len, wczone); - } + { + /* The zone string is always given in multibyte form. We have + to transform it first. */ + wchar_t *wczone; + size_t len; + widen (zone, wczone, len); + cpy (len, wczone); + } #else - cpy (strlen (zone), zone); + cpy (strlen (zone), zone); #endif - break; + break; - case L_(':'): - /* :, ::, and ::: are valid only just before 'z'. - :::: etc. are rejected later. */ - for (colons = 1; f[colons] == L_(':'); colons++) - continue; - if (f[colons] != L_('z')) - goto bad_format; - f += colons; - goto do_z_conversion; + case L_(':'): + /* :, ::, and ::: are valid only just before 'z'. + :::: etc. are rejected later. */ + for (colons = 1; f[colons] == L_(':'); colons++) + continue; + if (f[colons] != L_('z')) + goto bad_format; + f += colons; + goto do_z_conversion; - case L_('z'): - colons = 0; + case L_('z'): + colons = 0; - do_z_conversion: - if (tp->tm_isdst < 0) - break; + do_z_conversion: + if (tp->tm_isdst < 0) + break; - { - int diff; - int hour_diff; - int min_diff; - int sec_diff; + { + int diff; + int hour_diff; + int min_diff; + int sec_diff; #if HAVE_TM_GMTOFF - diff = tp->tm_gmtoff; + diff = tp->tm_gmtoff; #else - if (ut) - diff = 0; - else - { - struct tm gtm; - struct tm ltm; - time_t lt; + if (ut) + diff = 0; + else + { + struct tm gtm; + struct tm ltm; + time_t lt; - ltm = *tp; - lt = mktime (<m); + ltm = *tp; + lt = mktime (<m); - if (lt == (time_t) -1) - { - /* mktime returns -1 for errors, but -1 is also a - valid time_t value. Check whether an error really - occurred. */ - struct tm tm; + if (lt == (time_t) -1) + { + /* mktime returns -1 for errors, but -1 is also a + valid time_t value. Check whether an error really + occurred. */ + struct tm tm; - if (! __localtime_r (<, &tm) - || ((ltm.tm_sec ^ tm.tm_sec) - | (ltm.tm_min ^ tm.tm_min) - | (ltm.tm_hour ^ tm.tm_hour) - | (ltm.tm_mday ^ tm.tm_mday) - | (ltm.tm_mon ^ tm.tm_mon) - | (ltm.tm_year ^ tm.tm_year))) - break; - } + if (! __localtime_r (<, &tm) + || ((ltm.tm_sec ^ tm.tm_sec) + | (ltm.tm_min ^ tm.tm_min) + | (ltm.tm_hour ^ tm.tm_hour) + | (ltm.tm_mday ^ tm.tm_mday) + | (ltm.tm_mon ^ tm.tm_mon) + | (ltm.tm_year ^ tm.tm_year))) + break; + } - if (! __gmtime_r (<, >m)) - break; + if (! __gmtime_r (<, >m)) + break; - diff = tm_diff (<m, >m); - } + diff = tm_diff (<m, >m); + } #endif - hour_diff = diff / 60 / 60; - min_diff = diff / 60 % 60; - sec_diff = diff % 60; + hour_diff = diff / 60 / 60; + min_diff = diff / 60 % 60; + sec_diff = diff % 60; - switch (colons) - { - case 0: /* +hhmm */ - DO_TZ_OFFSET (5, diff < 0, 0, hour_diff * 100 + min_diff); + switch (colons) + { + case 0: /* +hhmm */ + DO_TZ_OFFSET (5, diff < 0, 0, hour_diff * 100 + min_diff); - case 1: tz_hh_mm: /* +hh:mm */ - DO_TZ_OFFSET (6, diff < 0, 04, hour_diff * 100 + min_diff); + case 1: tz_hh_mm: /* +hh:mm */ + DO_TZ_OFFSET (6, diff < 0, 04, hour_diff * 100 + min_diff); - case 2: tz_hh_mm_ss: /* +hh:mm:ss */ - DO_TZ_OFFSET (9, diff < 0, 024, - hour_diff * 10000 + min_diff * 100 + sec_diff); + case 2: tz_hh_mm_ss: /* +hh:mm:ss */ + DO_TZ_OFFSET (9, diff < 0, 024, + hour_diff * 10000 + min_diff * 100 + sec_diff); - case 3: /* +hh if possible, else +hh:mm, else +hh:mm:ss */ - if (sec_diff != 0) - goto tz_hh_mm_ss; - if (min_diff != 0) - goto tz_hh_mm; - DO_TZ_OFFSET (3, diff < 0, 0, hour_diff); + case 3: /* +hh if possible, else +hh:mm, else +hh:mm:ss */ + if (sec_diff != 0) + goto tz_hh_mm_ss; + if (min_diff != 0) + goto tz_hh_mm; + DO_TZ_OFFSET (3, diff < 0, 0, hour_diff); - default: - goto bad_format; - } - } + default: + goto bad_format; + } + } - case L_('\0'): /* GNU extension: % at end of format. */ - --f; - /* Fall through. */ - default: - /* Unknown format; output the format, including the '%', - since this is most likely the right thing to do if a - multibyte string has been misparsed. */ - bad_format: - { - int flen; - for (flen = 1; f[1 - flen] != L_('%'); flen++) - continue; - cpy (flen, &f[1 - flen]); - } - break; - } + case L_('\0'): /* GNU extension: % at end of format. */ + --f; + /* Fall through. */ + default: + /* Unknown format; output the format, including the '%', + since this is most likely the right thing to do if a + multibyte string has been misparsed. */ + bad_format: + { + int flen; + for (flen = 1; f[1 - flen] != L_('%'); flen++) + continue; + cpy (flen, &f[1 - flen]); + } + break; + } } #if ! FPRINTFTIME @@ -1428,11 +1441,11 @@ strftime_case_ (bool upcase, STREAM_OR_CHAR_T *s, written, use NULL for S and (size_t) -1 for MAXSIZE. */ size_t my_strftime (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) - const CHAR_T *format, - const struct tm *tp extra_args_spec LOCALE_PARAM_PROTO) + const CHAR_T *format, + const struct tm *tp extra_args_spec LOCALE_PARAM_PROTO) { return strftime_case_ (false, s, STRFTIME_ARG (maxsize) - format, tp extra_args LOCALE_ARG); + format, tp extra_args LOCALE_ARG); } #if defined _LIBC && ! FPRINTFTIME @@ -1445,7 +1458,7 @@ libc_hidden_def (my_strftime) strftime function plus the ut argument, but without the ns argument. */ size_t emacs_strftimeu (char *s, size_t maxsize, const char *format, - const struct tm *tp, int ut) + const struct tm *tp, int ut) { return my_strftime (s, maxsize, format, tp, ut, 0); } diff --git a/src/bin/coreutils/lib/strftime.h b/src/bin/coreutils/lib/strftime.h index c3c183ec92..bf14540421 100644 --- a/src/bin/coreutils/lib/strftime.h +++ b/src/bin/coreutils/lib/strftime.h @@ -1,6 +1,6 @@ /* declarations for strftime.c - Copyright (C) 2002, 2004, 2008 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,10 +17,18 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + /* Just like strftime, but with two more arguments: POSIX requires that strftime use the local timezone information. When __UTC is nonzero and tm->tm_zone is NULL or the empty string, use UTC instead. Use __NS as the number of nanoseconds in the %N directive. */ size_t nstrftime (char *, size_t, char const *, struct tm const *, - int __utc, int __ns); + int __utc, int __ns); + +#ifdef __cplusplus +} +#endif diff --git a/src/bin/coreutils/lib/striconv.c b/src/bin/coreutils/lib/striconv.c index ba6305ff8b..2f038abead 100644 --- a/src/bin/coreutils/lib/striconv.c +++ b/src/bin/coreutils/lib/striconv.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Charset conversion. - Copyright (C) 2001-2007 Free Software Foundation, Inc. + Copyright (C) 2001-2007, 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible and Simon Josefsson. This program is free software; you can redistribute it and/or modify @@ -45,7 +45,7 @@ int mem_cd_iconv (const char *src, size_t srclen, iconv_t cd, - char **resultp, size_t *lengthp) + char **resultp, size_t *lengthp) { # define tmpbufsize 4096 size_t length; @@ -70,33 +70,33 @@ mem_cd_iconv (const char *src, size_t srclen, iconv_t cd, while (insize > 0) { - char *outptr = tmpbuf; - size_t outsize = tmpbufsize; - size_t res = iconv (cd, - (ICONV_CONST char **) &inptr, &insize, - &outptr, &outsize); + char *outptr = tmpbuf; + size_t outsize = tmpbufsize; + size_t res = iconv (cd, + (ICONV_CONST char **) &inptr, &insize, + &outptr, &outsize); - if (res == (size_t)(-1)) - { - if (errno == E2BIG) - ; - else if (errno == EINVAL) - break; - else - return -1; - } + if (res == (size_t)(-1)) + { + if (errno == E2BIG) + ; + else if (errno == EINVAL) + break; + else + return -1; + } # if !defined _LIBICONV_VERSION && !defined __GLIBC__ - /* Irix iconv() inserts a NUL byte if it cannot convert. - NetBSD iconv() inserts a question mark if it cannot convert. - Only GNU libiconv and GNU libc are known to prefer to fail rather - than doing a lossy conversion. */ - else if (res > 0) - { - errno = EILSEQ; - return -1; - } + /* Irix iconv() inserts a NUL byte if it cannot convert. + NetBSD iconv() inserts a question mark if it cannot convert. + Only GNU libiconv and GNU libc are known to prefer to fail rather + than doing a lossy conversion. */ + else if (res > 0) + { + errno = EILSEQ; + return -1; + } # endif - count += outptr - tmpbuf; + count += outptr - tmpbuf; } /* Avoid glibc-2.1 bug and Solaris 2.7 bug. */ # if defined _LIBICONV_VERSION \ @@ -107,7 +107,7 @@ mem_cd_iconv (const char *src, size_t srclen, iconv_t cd, size_t res = iconv (cd, NULL, NULL, &outptr, &outsize); if (res == (size_t)(-1)) - return -1; + return -1; count += outptr - tmpbuf; } # endif @@ -126,10 +126,10 @@ mem_cd_iconv (const char *src, size_t srclen, iconv_t cd, { result = (char *) malloc (length); if (result == NULL) - { - errno = ENOMEM; - return -1; - } + { + errno = ENOMEM; + return -1; + } } /* Avoid glibc-2.1 bug and Solaris 2.7-2.9 bug. */ @@ -148,27 +148,27 @@ mem_cd_iconv (const char *src, size_t srclen, iconv_t cd, while (insize > 0) { - size_t res = iconv (cd, - (ICONV_CONST char **) &inptr, &insize, - &outptr, &outsize); + size_t res = iconv (cd, + (ICONV_CONST char **) &inptr, &insize, + &outptr, &outsize); - if (res == (size_t)(-1)) - { - if (errno == EINVAL) - break; - else - goto fail; - } + if (res == (size_t)(-1)) + { + if (errno == EINVAL) + break; + else + goto fail; + } # if !defined _LIBICONV_VERSION && !defined __GLIBC__ - /* Irix iconv() inserts a NUL byte if it cannot convert. - NetBSD iconv() inserts a question mark if it cannot convert. - Only GNU libiconv and GNU libc are known to prefer to fail rather - than doing a lossy conversion. */ - else if (res > 0) - { - errno = EILSEQ; - goto fail; - } + /* Irix iconv() inserts a NUL byte if it cannot convert. + NetBSD iconv() inserts a question mark if it cannot convert. + Only GNU libiconv and GNU libc are known to prefer to fail rather + than doing a lossy conversion. */ + else if (res > 0) + { + errno = EILSEQ; + goto fail; + } # endif } /* Avoid glibc-2.1 bug and Solaris 2.7 bug. */ @@ -178,7 +178,7 @@ mem_cd_iconv (const char *src, size_t srclen, iconv_t cd, size_t res = iconv (cd, NULL, NULL, &outptr, &outsize); if (res == (size_t)(-1)) - goto fail; + goto fail; } # endif if (outsize != 0) @@ -194,9 +194,9 @@ mem_cd_iconv (const char *src, size_t srclen, iconv_t cd, { if (result != *resultp) { - int saved_errno = errno; - free (result); - errno = saved_errno; + int saved_errno = errno; + free (result); + errno = saved_errno; } return -1; } @@ -227,7 +227,7 @@ str_cd_iconv (const char *src, iconv_t cd) if (retval < 0) { if (result != NULL) - abort (); + abort (); return NULL; } @@ -237,7 +237,7 @@ str_cd_iconv (const char *src, iconv_t cd) if (final_result == NULL) { if (result != NULL) - free (result); + free (result); errno = ENOMEM; return NULL; } @@ -288,81 +288,81 @@ str_cd_iconv (const char *src, iconv_t cd) for (;;) { - /* Here inptr + inbytes_remaining = src + strlen (src), - outptr + outbytes_remaining = result + result_size - 1. */ - size_t res = iconv (cd, - (ICONV_CONST char **) &inptr, &inbytes_remaining, - &outptr, &outbytes_remaining); + /* Here inptr + inbytes_remaining = src + strlen (src), + outptr + outbytes_remaining = result + result_size - 1. */ + size_t res = iconv (cd, + (ICONV_CONST char **) &inptr, &inbytes_remaining, + &outptr, &outbytes_remaining); - if (res == (size_t)(-1)) - { - if (errno == EINVAL) - break; - else if (errno == E2BIG) - { - size_t used = outptr - result; - size_t newsize = result_size * 2; - char *newresult; + if (res == (size_t)(-1)) + { + if (errno == EINVAL) + break; + else if (errno == E2BIG) + { + size_t used = outptr - result; + size_t newsize = result_size * 2; + char *newresult; - if (!(newsize > result_size)) - { - errno = ENOMEM; - goto failed; - } - newresult = (char *) realloc (result, newsize); - if (newresult == NULL) - { - errno = ENOMEM; - goto failed; - } - result = newresult; - result_size = newsize; - outptr = result + used; - outbytes_remaining = result_size - 1 - used; - } - else - goto failed; - } - else - break; + if (!(newsize > result_size)) + { + errno = ENOMEM; + goto failed; + } + newresult = (char *) realloc (result, newsize); + if (newresult == NULL) + { + errno = ENOMEM; + goto failed; + } + result = newresult; + result_size = newsize; + outptr = result + used; + outbytes_remaining = result_size - 1 - used; + } + else + goto failed; + } + else + break; } /* Avoid glibc-2.1 bug and Solaris 2.7 bug. */ # if defined _LIBICONV_VERSION \ || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun) for (;;) { - /* Here outptr + outbytes_remaining = result + result_size - 1. */ - size_t res = iconv (cd, NULL, NULL, &outptr, &outbytes_remaining); + /* Here outptr + outbytes_remaining = result + result_size - 1. */ + size_t res = iconv (cd, NULL, NULL, &outptr, &outbytes_remaining); - if (res == (size_t)(-1)) - { - if (errno == E2BIG) - { - size_t used = outptr - result; - size_t newsize = result_size * 2; - char *newresult; + if (res == (size_t)(-1)) + { + if (errno == E2BIG) + { + size_t used = outptr - result; + size_t newsize = result_size * 2; + char *newresult; - if (!(newsize > result_size)) - { - errno = ENOMEM; - goto failed; - } - newresult = (char *) realloc (result, newsize); - if (newresult == NULL) - { - errno = ENOMEM; - goto failed; - } - result = newresult; - result_size = newsize; - outptr = result + used; - outbytes_remaining = result_size - 1 - used; - } - else - goto failed; - } - else - break; + if (!(newsize > result_size)) + { + errno = ENOMEM; + goto failed; + } + newresult = (char *) realloc (result, newsize); + if (newresult == NULL) + { + errno = ENOMEM; + goto failed; + } + result = newresult; + result_size = newsize; + outptr = result + used; + outbytes_remaining = result_size - 1 - used; + } + else + goto failed; + } + else + break; } # endif @@ -378,7 +378,7 @@ str_cd_iconv (const char *src, iconv_t cd) char *smaller_result = (char *) realloc (result, length); if (smaller_result != NULL) - result = smaller_result; + result = smaller_result; } return result; @@ -404,7 +404,7 @@ str_iconv (const char *src, const char *from_codeset, const char *to_codeset) char *result = strdup (src); if (result == NULL) - errno = ENOMEM; + errno = ENOMEM; return result; } else @@ -416,44 +416,44 @@ str_iconv (const char *src, const char *from_codeset, const char *to_codeset) /* Avoid glibc-2.1 bug with EUC-KR. */ # if (__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) && !defined _LIBICONV_VERSION if (c_strcasecmp (from_codeset, "EUC-KR") == 0 - || c_strcasecmp (to_codeset, "EUC-KR") == 0) - { - errno = EINVAL; - return NULL; - } + || c_strcasecmp (to_codeset, "EUC-KR") == 0) + { + errno = EINVAL; + return NULL; + } # endif cd = iconv_open (to_codeset, from_codeset); if (cd == (iconv_t) -1) - return NULL; + return NULL; result = str_cd_iconv (src, cd); if (result == NULL) - { - /* Close cd, but preserve the errno from str_cd_iconv. */ - int saved_errno = errno; - iconv_close (cd); - errno = saved_errno; - } + { + /* Close cd, but preserve the errno from str_cd_iconv. */ + int saved_errno = errno; + iconv_close (cd); + errno = saved_errno; + } else - { - if (iconv_close (cd) < 0) - { - /* Return NULL, but free the allocated memory, and while doing - that, preserve the errno from iconv_close. */ - int saved_errno = errno; - free (result); - errno = saved_errno; - return NULL; - } - } + { + if (iconv_close (cd) < 0) + { + /* Return NULL, but free the allocated memory, and while doing + that, preserve the errno from iconv_close. */ + int saved_errno = errno; + free (result); + errno = saved_errno; + return NULL; + } + } return result; #else /* This is a different error code than if iconv_open existed but didn't - support from_codeset and to_codeset, so that the caller can emit - an error message such as - "iconv() is not supported. Installing GNU libiconv and - then reinstalling this package would fix this." */ + support from_codeset and to_codeset, so that the caller can emit + an error message such as + "iconv() is not supported. Installing GNU libiconv and + then reinstalling this package would fix this." */ errno = ENOSYS; return NULL; #endif diff --git a/src/bin/coreutils/lib/striconv.h b/src/bin/coreutils/lib/striconv.h index 61892027a4..ba447fac9b 100644 --- a/src/bin/coreutils/lib/striconv.h +++ b/src/bin/coreutils/lib/striconv.h @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Charset conversion. - Copyright (C) 2001-2004, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2006-2007, 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible and Simon Josefsson. This program is free software; you can redistribute it and/or modify @@ -46,7 +46,7 @@ extern "C" { in *LENGTHP. *RESULTP is set to a freshly allocated memory block, or is unchanged if no dynamic memory allocation was necessary. */ extern int mem_cd_iconv (const char *src, size_t srclen, iconv_t cd, - char **resultp, size_t *lengthp); + char **resultp, size_t *lengthp); /* Convert an entire string from one encoding to another, using iconv. The original string is the NUL-terminated string starting at SRC. @@ -68,7 +68,7 @@ extern char * str_cd_iconv (const char *src, iconv_t cd); Return value: the freshly allocated resulting NUL-terminated string if successful, otherwise NULL and errno set. */ extern char * str_iconv (const char *src, - const char *from_codeset, const char *to_codeset); + const char *from_codeset, const char *to_codeset); #ifdef __cplusplus diff --git a/src/bin/coreutils/lib/string.h b/src/bin/coreutils/lib/string.h new file mode 100644 index 0000000000..0db7423865 --- /dev/null +++ b/src/bin/coreutils/lib/string.h @@ -0,0 +1,698 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +#line 1 +/* A GNU-like . + + Copyright (C) 1995-1996, 2001-2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef _GL_STRING_H + +#if __GNUC__ >= 3 +#pragma GCC system_header +#endif + +/* The include_next requires a split double-inclusion guard. */ +#include_next + +#ifndef _GL_STRING_H +#define _GL_STRING_H + +/* NetBSD 5.0 mis-defines NULL. */ +#include + +/* MirBSD defines mbslen as a macro. */ +#if 1 && defined __MirBSD__ +# include +#endif + +#ifndef __attribute__ +/* This feature is available in gcc versions 2.5 and later. */ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) +# define __attribute__(Spec) /* empty */ +# endif +/* The attribute __pure__ was added in gcc 2.96. */ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96) +# define __pure__ /* empty */ +# endif +#endif + + +/* The definition of GL_LINK_WARNING is copied here. */ +/* GL_LINK_WARNING("literal string") arranges to emit the literal string as + a linker warning on most glibc systems. + We use a linker warning rather than a preprocessor warning, because + #warning cannot be used inside macros. */ +#ifndef GL_LINK_WARNING + /* This works on platforms with GNU ld and ELF object format. + Testing __GLIBC__ is sufficient for asserting that GNU ld is in use. + Testing __ELF__ guarantees the ELF object format. + Testing __GNUC__ is necessary for the compound expression syntax. */ +# if defined __GLIBC__ && defined __ELF__ && defined __GNUC__ +# define GL_LINK_WARNING(message) \ + GL_LINK_WARNING1 (__FILE__, __LINE__, message) +# define GL_LINK_WARNING1(file, line, message) \ + GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */ +# define GL_LINK_WARNING2(file, line, message) \ + GL_LINK_WARNING3 (file ":" #line ": warning: " message) +# define GL_LINK_WARNING3(message) \ + ({ static const char warning[sizeof (message)] \ + __attribute__ ((__unused__, \ + __section__ (".gnu.warning"), \ + __aligned__ (1))) \ + = message "\n"; \ + (void)0; \ + }) +# else +# define GL_LINK_WARNING(message) ((void) 0) +# endif +#endif + +/* The definition of _GL_ARG_NONNULL is copied here. */ +/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools + that the values passed as arguments n, ..., m must be non-NULL pointers. + n = 1 stands for the first argument, n = 2 for the second argument etc. */ +#ifndef _GL_ARG_NONNULL +# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 +# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) +# else +# define _GL_ARG_NONNULL(params) +# endif +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Return the first instance of C within N bytes of S, or NULL. */ +#if 1 +# if 0 +# define memchr rpl_memchr +extern void *memchr (void const *__s, int __c, size_t __n) + __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef memchr +# define memchr(s,c,n) \ + (GL_LINK_WARNING ("memchr has platform-specific bugs - " \ + "use gnulib module memchr for portability" ), \ + memchr (s, c, n)) +#endif + +/* Return the first occurrence of NEEDLE in HAYSTACK. */ +#if 0 +# if 0 +# define memmem rpl_memmem +# endif +# if ! 1 || 0 +extern void *memmem (void const *__haystack, size_t __haystack_len, + void const *__needle, size_t __needle_len) + __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef memmem +# define memmem(a,al,b,bl) \ + (GL_LINK_WARNING ("memmem is unportable and often quadratic - " \ + "use gnulib module memmem-simple for portability, " \ + "and module memmem for speed" ), \ + memmem (a, al, b, bl)) +#endif + +/* Copy N bytes of SRC to DEST, return pointer to bytes after the + last written byte. */ +#if 1 +# if ! 0 +extern void *mempcpy (void *restrict __dest, void const *restrict __src, + size_t __n) + _GL_ARG_NONNULL ((1, 2)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mempcpy +# define mempcpy(a,b,n) \ + (GL_LINK_WARNING ("mempcpy is unportable - " \ + "use gnulib module mempcpy for portability"), \ + mempcpy (a, b, n)) +#endif + +/* Search backwards through a block for a byte (specified as an int). */ +#if 1 +# if ! 0 +extern void *memrchr (void const *, int, size_t) + __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef memrchr +# define memrchr(a,b,c) \ + (GL_LINK_WARNING ("memrchr is unportable - " \ + "use gnulib module memrchr for portability"), \ + memrchr (a, b, c)) +#endif + +/* Find the first occurrence of C in S. More efficient than + memchr(S,C,N), at the expense of undefined behavior if C does not + occur within N bytes. */ +#if 0 +# if ! 1 +extern void *rawmemchr (void const *__s, int __c_in) + __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef rawmemchr +# define rawmemchr(a,b) \ + (GL_LINK_WARNING ("rawmemchr is unportable - " \ + "use gnulib module rawmemchr for portability"), \ + rawmemchr (a, b)) +#endif + +/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */ +#if 1 +# if ! 1 +extern char *stpcpy (char *restrict __dst, char const *restrict __src) + _GL_ARG_NONNULL ((1, 2)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef stpcpy +# define stpcpy(a,b) \ + (GL_LINK_WARNING ("stpcpy is unportable - " \ + "use gnulib module stpcpy for portability"), \ + stpcpy (a, b)) +#endif + +/* Copy no more than N bytes of SRC to DST, returning a pointer past the + last non-NUL byte written into DST. */ +#if 1 +# if ! 0 +# define stpncpy gnu_stpncpy +extern char *stpncpy (char *restrict __dst, char const *restrict __src, + size_t __n) + _GL_ARG_NONNULL ((1, 2)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef stpncpy +# define stpncpy(a,b,n) \ + (GL_LINK_WARNING ("stpncpy is unportable - " \ + "use gnulib module stpncpy for portability"), \ + stpncpy (a, b, n)) +#endif + +#if defined GNULIB_POSIXCHECK +/* strchr() does not work with multibyte strings if the locale encoding is + GB18030 and the character to be searched is a digit. */ +# undef strchr +# define strchr(s,c) \ + (GL_LINK_WARNING ("strchr cannot work correctly on character strings " \ + "in some multibyte locales - " \ + "use mbschr if you care about internationalization"), \ + strchr (s, c)) +#endif + +/* Find the first occurrence of C in S or the final NUL byte. */ +#if 0 +# if ! 1 +extern char *strchrnul (char const *__s, int __c_in) + __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strchrnul +# define strchrnul(a,b) \ + (GL_LINK_WARNING ("strchrnul is unportable - " \ + "use gnulib module strchrnul for portability"), \ + strchrnul (a, b)) +#endif + +/* Duplicate S, returning an identical malloc'd string. */ +#if 1 +# if 0 +# undef strdup +# define strdup rpl_strdup +# endif +# if !(1 || defined strdup) || 0 +extern char *strdup (char const *__s) _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strdup +# define strdup(a) \ + (GL_LINK_WARNING ("strdup is unportable - " \ + "use gnulib module strdup for portability"), \ + strdup (a)) +#endif + +/* Return a newly allocated copy of at most N bytes of STRING. */ +#if 1 +# if 0 +# undef strndup +# define strndup rpl_strndup +# endif +# if 0 || ! 1 +extern char *strndup (char const *__string, size_t __n) _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strndup +# define strndup(a,n) \ + (GL_LINK_WARNING ("strndup is unportable - " \ + "use gnulib module strndup for portability"), \ + strndup (a, n)) +#endif + +/* Find the length (number of bytes) of STRING, but scan at most + MAXLEN bytes. If no '\0' terminator is found in that many bytes, + return MAXLEN. */ +#if 1 +# if ! 1 +extern size_t strnlen (char const *__string, size_t __maxlen) + __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strnlen +# define strnlen(a,n) \ + (GL_LINK_WARNING ("strnlen is unportable - " \ + "use gnulib module strnlen for portability"), \ + strnlen (a, n)) +#endif + +#if defined GNULIB_POSIXCHECK +/* strcspn() assumes the second argument is a list of single-byte characters. + Even in this simple case, it does not work with multibyte strings if the + locale encoding is GB18030 and one of the characters to be searched is a + digit. */ +# undef strcspn +# define strcspn(s,a) \ + (GL_LINK_WARNING ("strcspn cannot work correctly on character strings " \ + "in multibyte locales - " \ + "use mbscspn if you care about internationalization"), \ + strcspn (s, a)) +#endif + +/* Find the first occurrence in S of any character in ACCEPT. */ +#if 1 +# if ! 1 +extern char *strpbrk (char const *__s, char const *__accept) + __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2)); +# endif +# if defined GNULIB_POSIXCHECK +/* strpbrk() assumes the second argument is a list of single-byte characters. + Even in this simple case, it does not work with multibyte strings if the + locale encoding is GB18030 and one of the characters to be searched is a + digit. */ +# undef strpbrk +# define strpbrk(s,a) \ + (GL_LINK_WARNING ("strpbrk cannot work correctly on character strings " \ + "in multibyte locales - " \ + "use mbspbrk if you care about internationalization"), \ + strpbrk (s, a)) +# endif +#elif defined GNULIB_POSIXCHECK +# undef strpbrk +# define strpbrk(s,a) \ + (GL_LINK_WARNING ("strpbrk is unportable - " \ + "use gnulib module strpbrk for portability"), \ + strpbrk (s, a)) +#endif + +#if defined GNULIB_POSIXCHECK +/* strspn() assumes the second argument is a list of single-byte characters. + Even in this simple case, it cannot work with multibyte strings. */ +# undef strspn +# define strspn(s,a) \ + (GL_LINK_WARNING ("strspn cannot work correctly on character strings " \ + "in multibyte locales - " \ + "use mbsspn if you care about internationalization"), \ + strspn (s, a)) +#endif + +#if defined GNULIB_POSIXCHECK +/* strrchr() does not work with multibyte strings if the locale encoding is + GB18030 and the character to be searched is a digit. */ +# undef strrchr +# define strrchr(s,c) \ + (GL_LINK_WARNING ("strrchr cannot work correctly on character strings " \ + "in some multibyte locales - " \ + "use mbsrchr if you care about internationalization"), \ + strrchr (s, c)) +#endif + +/* Search the next delimiter (char listed in DELIM) starting at *STRINGP. + If one is found, overwrite it with a NUL, and advance *STRINGP + to point to the next char after it. Otherwise, set *STRINGP to NULL. + If *STRINGP was already NULL, nothing happens. + Return the old value of *STRINGP. + + This is a variant of strtok() that is multithread-safe and supports + empty fields. + + Caveat: It modifies the original string. + Caveat: These functions cannot be used on constant strings. + Caveat: The identity of the delimiting character is lost. + Caveat: It doesn't work with multibyte strings unless all of the delimiter + characters are ASCII characters < 0x30. + + See also strtok_r(). */ +#if 0 +# if ! 1 +extern char *strsep (char **restrict __stringp, char const *restrict __delim) + _GL_ARG_NONNULL ((1, 2)); +# endif +# if defined GNULIB_POSIXCHECK +# undef strsep +# define strsep(s,d) \ + (GL_LINK_WARNING ("strsep cannot work correctly on character strings " \ + "in multibyte locales - " \ + "use mbssep if you care about internationalization"), \ + strsep (s, d)) +# endif +#elif defined GNULIB_POSIXCHECK +# undef strsep +# define strsep(s,d) \ + (GL_LINK_WARNING ("strsep is unportable - " \ + "use gnulib module strsep for portability"), \ + strsep (s, d)) +#endif + +#if 1 +# if 0 +# define strstr rpl_strstr +extern char *strstr (const char *haystack, const char *needle) + __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2)); +# endif +#elif defined GNULIB_POSIXCHECK +/* strstr() does not work with multibyte strings if the locale encoding is + different from UTF-8: + POSIX says that it operates on "strings", and "string" in POSIX is defined + as a sequence of bytes, not of characters. */ +# undef strstr +# define strstr(a,b) \ + (GL_LINK_WARNING ("strstr is quadratic on many systems, and cannot " \ + "work correctly on character strings in most " \ + "multibyte locales - " \ + "use mbsstr if you care about internationalization, " \ + "or use strstr if you care about speed"), \ + strstr (a, b)) +#endif + +/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive + comparison. */ +#if 0 +# if 0 +# define strcasestr rpl_strcasestr +# endif +# if ! 1 || 0 +extern char *strcasestr (const char *haystack, const char *needle) + __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2)); +# endif +#elif defined GNULIB_POSIXCHECK +/* strcasestr() does not work with multibyte strings: + It is a glibc extension, and glibc implements it only for unibyte + locales. */ +# undef strcasestr +# define strcasestr(a,b) \ + (GL_LINK_WARNING ("strcasestr does work correctly on character strings " \ + "in multibyte locales - " \ + "use mbscasestr if you care about " \ + "internationalization, or use c-strcasestr if you want " \ + "a locale independent function"), \ + strcasestr (a, b)) +#endif + +/* Parse S into tokens separated by characters in DELIM. + If S is NULL, the saved pointer in SAVE_PTR is used as + the next starting point. For example: + char s[] = "-abc-=-def"; + char *sp; + x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" + x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL + x = strtok_r(NULL, "=", &sp); // x = NULL + // s = "abc\0-def\0" + + This is a variant of strtok() that is multithread-safe. + + For the POSIX documentation for this function, see: + http://www.opengroup.org/susv3xsh/strtok.html + + Caveat: It modifies the original string. + Caveat: These functions cannot be used on constant strings. + Caveat: The identity of the delimiting character is lost. + Caveat: It doesn't work with multibyte strings unless all of the delimiter + characters are ASCII characters < 0x30. + + See also strsep(). */ +#if 0 +# if 0 +# undef strtok_r +# define strtok_r rpl_strtok_r +# elif 0 +# undef strtok_r +# endif +# if ! 1 || 0 +extern char *strtok_r (char *restrict s, char const *restrict delim, + char **restrict save_ptr) + _GL_ARG_NONNULL ((2, 3)); +# endif +# if defined GNULIB_POSIXCHECK +# undef strtok_r +# define strtok_r(s,d,p) \ + (GL_LINK_WARNING ("strtok_r cannot work correctly on character strings " \ + "in multibyte locales - " \ + "use mbstok_r if you care about internationalization"), \ + strtok_r (s, d, p)) +# endif +#elif defined GNULIB_POSIXCHECK +# undef strtok_r +# define strtok_r(s,d,p) \ + (GL_LINK_WARNING ("strtok_r is unportable - " \ + "use gnulib module strtok_r for portability"), \ + strtok_r (s, d, p)) +#endif + + +/* The following functions are not specified by POSIX. They are gnulib + extensions. */ + +#if 1 +/* Return the number of multibyte characters in the character string STRING. + This considers multibyte characters, unlike strlen, which counts bytes. */ +# ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */ +# undef mbslen +# endif +# if 0 /* AIX, OSF/1, MirBSD define mbslen already in libc. */ +# define mbslen rpl_mbslen +# endif +extern size_t mbslen (const char *string) _GL_ARG_NONNULL ((1)); +#endif + +#if 0 +/* Return the number of multibyte characters in the character string starting + at STRING and ending at STRING + LEN. */ +extern size_t mbsnlen (const char *string, size_t len) _GL_ARG_NONNULL ((1)); +#endif + +#if 0 +/* Locate the first single-byte character C in the character string STRING, + and return a pointer to it. Return NULL if C is not found in STRING. + Unlike strchr(), this function works correctly in multibyte locales with + encodings such as GB18030. */ +# define mbschr rpl_mbschr /* avoid collision with HP-UX function */ +extern char * mbschr (const char *string, int c) _GL_ARG_NONNULL ((1)); +#endif + +#if 0 +/* Locate the last single-byte character C in the character string STRING, + and return a pointer to it. Return NULL if C is not found in STRING. + Unlike strrchr(), this function works correctly in multibyte locales with + encodings such as GB18030. */ +# define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */ +extern char * mbsrchr (const char *string, int c) _GL_ARG_NONNULL ((1)); +#endif + +#if 1 +/* Find the first occurrence of the character string NEEDLE in the character + string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK. + Unlike strstr(), this function works correctly in multibyte locales with + encodings different from UTF-8. */ +extern char * mbsstr (const char *haystack, const char *needle) + _GL_ARG_NONNULL ((1, 2)); +#endif + +#if 1 +/* Compare the character strings S1 and S2, ignoring case, returning less than, + equal to or greater than zero if S1 is lexicographically less than, equal to + or greater than S2. + Note: This function may, in multibyte locales, return 0 for strings of + different lengths! + Unlike strcasecmp(), this function works correctly in multibyte locales. */ +extern int mbscasecmp (const char *s1, const char *s2) + _GL_ARG_NONNULL ((1, 2)); +#endif + +#if 0 +/* Compare the initial segment of the character string S1 consisting of at most + N characters with the initial segment of the character string S2 consisting + of at most N characters, ignoring case, returning less than, equal to or + greater than zero if the initial segment of S1 is lexicographically less + than, equal to or greater than the initial segment of S2. + Note: This function may, in multibyte locales, return 0 for initial segments + of different lengths! + Unlike strncasecmp(), this function works correctly in multibyte locales. + But beware that N is not a byte count but a character count! */ +extern int mbsncasecmp (const char *s1, const char *s2, size_t n) + _GL_ARG_NONNULL ((1, 2)); +#endif + +#if 0 +/* Compare the initial segment of the character string STRING consisting of + at most mbslen (PREFIX) characters with the character string PREFIX, + ignoring case, returning less than, equal to or greater than zero if this + initial segment is lexicographically less than, equal to or greater than + PREFIX. + Note: This function may, in multibyte locales, return 0 if STRING is of + smaller length than PREFIX! + Unlike strncasecmp(), this function works correctly in multibyte + locales. */ +extern char * mbspcasecmp (const char *string, const char *prefix) + _GL_ARG_NONNULL ((1, 2)); +#endif + +#if 0 +/* Find the first occurrence of the character string NEEDLE in the character + string HAYSTACK, using case-insensitive comparison. + Note: This function may, in multibyte locales, return success even if + strlen (haystack) < strlen (needle) ! + Unlike strcasestr(), this function works correctly in multibyte locales. */ +extern char * mbscasestr (const char *haystack, const char *needle) + _GL_ARG_NONNULL ((1, 2)); +#endif + +#if 0 +/* Find the first occurrence in the character string STRING of any character + in the character string ACCEPT. Return the number of bytes from the + beginning of the string to this occurrence, or to the end of the string + if none exists. + Unlike strcspn(), this function works correctly in multibyte locales. */ +extern size_t mbscspn (const char *string, const char *accept) + _GL_ARG_NONNULL ((1, 2)); +#endif + +#if 0 +/* Find the first occurrence in the character string STRING of any character + in the character string ACCEPT. Return the pointer to it, or NULL if none + exists. + Unlike strpbrk(), this function works correctly in multibyte locales. */ +# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ +extern char * mbspbrk (const char *string, const char *accept) + _GL_ARG_NONNULL ((1, 2)); +#endif + +#if 0 +/* Find the first occurrence in the character string STRING of any character + not in the character string REJECT. Return the number of bytes from the + beginning of the string to this occurrence, or to the end of the string + if none exists. + Unlike strspn(), this function works correctly in multibyte locales. */ +extern size_t mbsspn (const char *string, const char *reject) + _GL_ARG_NONNULL ((1, 2)); +#endif + +#if 0 +/* Search the next delimiter (multibyte character listed in the character + string DELIM) starting at the character string *STRINGP. + If one is found, overwrite it with a NUL, and advance *STRINGP to point + to the next multibyte character after it. Otherwise, set *STRINGP to NULL. + If *STRINGP was already NULL, nothing happens. + Return the old value of *STRINGP. + + This is a variant of mbstok_r() that supports empty fields. + + Caveat: It modifies the original string. + Caveat: These functions cannot be used on constant strings. + Caveat: The identity of the delimiting character is lost. + + See also mbstok_r(). */ +extern char * mbssep (char **stringp, const char *delim) + _GL_ARG_NONNULL ((1, 2)); +#endif + +#if 0 +/* Parse the character string STRING into tokens separated by characters in + the character string DELIM. + If STRING is NULL, the saved pointer in SAVE_PTR is used as + the next starting point. For example: + char s[] = "-abc-=-def"; + char *sp; + x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def" + x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL + x = mbstok_r(NULL, "=", &sp); // x = NULL + // s = "abc\0-def\0" + + Caveat: It modifies the original string. + Caveat: These functions cannot be used on constant strings. + Caveat: The identity of the delimiting character is lost. + + See also mbssep(). */ +extern char * mbstok_r (char *string, const char *delim, char **save_ptr) + _GL_ARG_NONNULL ((2, 3)); +#endif + +/* Map any int, typically from errno, into an error message. */ +#if 1 +# if 0 +# undef strerror +# define strerror rpl_strerror +extern char *strerror (int); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strerror +# define strerror(e) \ + (GL_LINK_WARNING ("strerror is unportable - " \ + "use gnulib module strerror to guarantee non-NULL result"), \ + strerror (e)) +#endif + +#if 1 +# if 0 +# define strsignal rpl_strsignal +# endif +# if ! 1 || 0 +extern char *strsignal (int __sig); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strsignal +# define strsignal(a) \ + (GL_LINK_WARNING ("strsignal is unportable - " \ + "use gnulib module strsignal for portability"), \ + strsignal (a)) +#endif + +#if 0 +# if !1 +extern int strverscmp (const char *, const char *) _GL_ARG_NONNULL ((1, 2)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strverscmp +# define strverscmp(a, b) \ + (GL_LINK_WARNING ("strverscmp is unportable - " \ + "use gnulib module strverscmp for portability"), \ + strverscmp (a, b)) +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* _GL_STRING_H */ +#endif /* _GL_STRING_H */ diff --git a/src/bin/coreutils/lib/string.in.h b/src/bin/coreutils/lib/string.in.h index c1f825e359..6b10f0cf9b 100644 --- a/src/bin/coreutils/lib/string.in.h +++ b/src/bin/coreutils/lib/string.in.h @@ -3,7 +3,7 @@ #line 1 /* A GNU-like . - Copyright (C) 1995-1996, 2001-2009 Free Software Foundation, Inc. + Copyright (C) 1995-1996, 2001-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,6 +34,11 @@ /* NetBSD 5.0 mis-defines NULL. */ #include +/* MirBSD defines mbslen as a macro. */ +#if @GNULIB_MBSLEN@ && defined __MirBSD__ +# include +#endif + #ifndef __attribute__ /* This feature is available in gcc versions 2.5 and later. */ # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) @@ -48,6 +53,8 @@ /* The definition of GL_LINK_WARNING is copied here. */ +/* The definition of _GL_ARG_NONNULL is copied here. */ + #ifdef __cplusplus extern "C" { @@ -59,7 +66,7 @@ extern "C" { # if @REPLACE_MEMCHR@ # define memchr rpl_memchr extern void *memchr (void const *__s, int __c, size_t __n) - __attribute__ ((__pure__)); + __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef memchr @@ -76,8 +83,8 @@ extern void *memchr (void const *__s, int __c, size_t __n) # endif # if ! @HAVE_DECL_MEMMEM@ || @REPLACE_MEMMEM@ extern void *memmem (void const *__haystack, size_t __haystack_len, - void const *__needle, size_t __needle_len) - __attribute__ ((__pure__)); + void const *__needle, size_t __needle_len) + __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3)); # endif #elif defined GNULIB_POSIXCHECK # undef memmem @@ -93,7 +100,8 @@ extern void *memmem (void const *__haystack, size_t __haystack_len, #if @GNULIB_MEMPCPY@ # if ! @HAVE_MEMPCPY@ extern void *mempcpy (void *restrict __dest, void const *restrict __src, - size_t __n); + size_t __n) + _GL_ARG_NONNULL ((1, 2)); # endif #elif defined GNULIB_POSIXCHECK # undef mempcpy @@ -107,7 +115,7 @@ extern void *mempcpy (void *restrict __dest, void const *restrict __src, #if @GNULIB_MEMRCHR@ # if ! @HAVE_DECL_MEMRCHR@ extern void *memrchr (void const *, int, size_t) - __attribute__ ((__pure__)); + __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef memrchr @@ -123,7 +131,7 @@ extern void *memrchr (void const *, int, size_t) #if @GNULIB_RAWMEMCHR@ # if ! @HAVE_RAWMEMCHR@ extern void *rawmemchr (void const *__s, int __c_in) - __attribute__ ((__pure__)); + __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef rawmemchr @@ -136,7 +144,8 @@ extern void *rawmemchr (void const *__s, int __c_in) /* Copy SRC to DST, returning the address of the terminating '\0' in DST. */ #if @GNULIB_STPCPY@ # if ! @HAVE_STPCPY@ -extern char *stpcpy (char *restrict __dst, char const *restrict __src); +extern char *stpcpy (char *restrict __dst, char const *restrict __src) + _GL_ARG_NONNULL ((1, 2)); # endif #elif defined GNULIB_POSIXCHECK # undef stpcpy @@ -152,7 +161,8 @@ extern char *stpcpy (char *restrict __dst, char const *restrict __src); # if ! @HAVE_STPNCPY@ # define stpncpy gnu_stpncpy extern char *stpncpy (char *restrict __dst, char const *restrict __src, - size_t __n); + size_t __n) + _GL_ARG_NONNULL ((1, 2)); # endif #elif defined GNULIB_POSIXCHECK # undef stpncpy @@ -177,7 +187,7 @@ extern char *stpncpy (char *restrict __dst, char const *restrict __src, #if @GNULIB_STRCHRNUL@ # if ! @HAVE_STRCHRNUL@ extern char *strchrnul (char const *__s, int __c_in) - __attribute__ ((__pure__)); + __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef strchrnul @@ -194,7 +204,7 @@ extern char *strchrnul (char const *__s, int __c_in) # define strdup rpl_strdup # endif # if !(@HAVE_DECL_STRDUP@ || defined strdup) || @REPLACE_STRDUP@ -extern char *strdup (char const *__s); +extern char *strdup (char const *__s) _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef strdup @@ -211,7 +221,7 @@ extern char *strdup (char const *__s); # define strndup rpl_strndup # endif # if @REPLACE_STRNDUP@ || ! @HAVE_DECL_STRNDUP@ -extern char *strndup (char const *__string, size_t __n); +extern char *strndup (char const *__string, size_t __n) _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef strndup @@ -227,7 +237,7 @@ extern char *strndup (char const *__string, size_t __n); #if @GNULIB_STRNLEN@ # if ! @HAVE_DECL_STRNLEN@ extern size_t strnlen (char const *__string, size_t __maxlen) - __attribute__ ((__pure__)); + __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef strnlen @@ -254,7 +264,7 @@ extern size_t strnlen (char const *__string, size_t __maxlen) #if @GNULIB_STRPBRK@ # if ! @HAVE_STRPBRK@ extern char *strpbrk (char const *__s, char const *__accept) - __attribute__ ((__pure__)); + __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2)); # endif # if defined GNULIB_POSIXCHECK /* strpbrk() assumes the second argument is a list of single-byte characters. @@ -316,7 +326,8 @@ extern char *strpbrk (char const *__s, char const *__accept) See also strtok_r(). */ #if @GNULIB_STRSEP@ # if ! @HAVE_STRSEP@ -extern char *strsep (char **restrict __stringp, char const *restrict __delim); +extern char *strsep (char **restrict __stringp, char const *restrict __delim) + _GL_ARG_NONNULL ((1, 2)); # endif # if defined GNULIB_POSIXCHECK # undef strsep @@ -337,8 +348,8 @@ extern char *strsep (char **restrict __stringp, char const *restrict __delim); #if @GNULIB_STRSTR@ # if @REPLACE_STRSTR@ # define strstr rpl_strstr -char *strstr (const char *haystack, const char *needle) - __attribute__ ((__pure__)); +extern char *strstr (const char *haystack, const char *needle) + __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2)); # endif #elif defined GNULIB_POSIXCHECK /* strstr() does not work with multibyte strings if the locale encoding is @@ -363,7 +374,7 @@ char *strstr (const char *haystack, const char *needle) # endif # if ! @HAVE_STRCASESTR@ || @REPLACE_STRCASESTR@ extern char *strcasestr (const char *haystack, const char *needle) - __attribute__ ((__pure__)); + __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2)); # endif #elif defined GNULIB_POSIXCHECK /* strcasestr() does not work with multibyte strings: @@ -382,12 +393,12 @@ extern char *strcasestr (const char *haystack, const char *needle) /* Parse S into tokens separated by characters in DELIM. If S is NULL, the saved pointer in SAVE_PTR is used as the next starting point. For example: - char s[] = "-abc-=-def"; - char *sp; - x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" - x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL - x = strtok_r(NULL, "=", &sp); // x = NULL - // s = "abc\0-def\0" + char s[] = "-abc-=-def"; + char *sp; + x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" + x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL + x = strtok_r(NULL, "=", &sp); // x = NULL + // s = "abc\0-def\0" This is a variant of strtok() that is multithread-safe. @@ -410,7 +421,8 @@ extern char *strcasestr (const char *haystack, const char *needle) # endif # if ! @HAVE_DECL_STRTOK_R@ || @REPLACE_STRTOK_R@ extern char *strtok_r (char *restrict s, char const *restrict delim, - char **restrict save_ptr); + char **restrict save_ptr) + _GL_ARG_NONNULL ((2, 3)); # endif # if defined GNULIB_POSIXCHECK # undef strtok_r @@ -435,13 +447,19 @@ extern char *strtok_r (char *restrict s, char const *restrict delim, #if @GNULIB_MBSLEN@ /* Return the number of multibyte characters in the character string STRING. This considers multibyte characters, unlike strlen, which counts bytes. */ -extern size_t mbslen (const char *string); +# ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */ +# undef mbslen +# endif +# if @HAVE_MBSLEN@ /* AIX, OSF/1, MirBSD define mbslen already in libc. */ +# define mbslen rpl_mbslen +# endif +extern size_t mbslen (const char *string) _GL_ARG_NONNULL ((1)); #endif #if @GNULIB_MBSNLEN@ /* Return the number of multibyte characters in the character string starting at STRING and ending at STRING + LEN. */ -extern size_t mbsnlen (const char *string, size_t len); +extern size_t mbsnlen (const char *string, size_t len) _GL_ARG_NONNULL ((1)); #endif #if @GNULIB_MBSCHR@ @@ -450,7 +468,7 @@ extern size_t mbsnlen (const char *string, size_t len); Unlike strchr(), this function works correctly in multibyte locales with encodings such as GB18030. */ # define mbschr rpl_mbschr /* avoid collision with HP-UX function */ -extern char * mbschr (const char *string, int c); +extern char * mbschr (const char *string, int c) _GL_ARG_NONNULL ((1)); #endif #if @GNULIB_MBSRCHR@ @@ -459,7 +477,7 @@ extern char * mbschr (const char *string, int c); Unlike strrchr(), this function works correctly in multibyte locales with encodings such as GB18030. */ # define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */ -extern char * mbsrchr (const char *string, int c); +extern char * mbsrchr (const char *string, int c) _GL_ARG_NONNULL ((1)); #endif #if @GNULIB_MBSSTR@ @@ -467,7 +485,8 @@ extern char * mbsrchr (const char *string, int c); string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK. Unlike strstr(), this function works correctly in multibyte locales with encodings different from UTF-8. */ -extern char * mbsstr (const char *haystack, const char *needle); +extern char * mbsstr (const char *haystack, const char *needle) + _GL_ARG_NONNULL ((1, 2)); #endif #if @GNULIB_MBSCASECMP@ @@ -477,7 +496,8 @@ extern char * mbsstr (const char *haystack, const char *needle); Note: This function may, in multibyte locales, return 0 for strings of different lengths! Unlike strcasecmp(), this function works correctly in multibyte locales. */ -extern int mbscasecmp (const char *s1, const char *s2); +extern int mbscasecmp (const char *s1, const char *s2) + _GL_ARG_NONNULL ((1, 2)); #endif #if @GNULIB_MBSNCASECMP@ @@ -490,7 +510,8 @@ extern int mbscasecmp (const char *s1, const char *s2); of different lengths! Unlike strncasecmp(), this function works correctly in multibyte locales. But beware that N is not a byte count but a character count! */ -extern int mbsncasecmp (const char *s1, const char *s2, size_t n); +extern int mbsncasecmp (const char *s1, const char *s2, size_t n) + _GL_ARG_NONNULL ((1, 2)); #endif #if @GNULIB_MBSPCASECMP@ @@ -503,7 +524,8 @@ extern int mbsncasecmp (const char *s1, const char *s2, size_t n); smaller length than PREFIX! Unlike strncasecmp(), this function works correctly in multibyte locales. */ -extern char * mbspcasecmp (const char *string, const char *prefix); +extern char * mbspcasecmp (const char *string, const char *prefix) + _GL_ARG_NONNULL ((1, 2)); #endif #if @GNULIB_MBSCASESTR@ @@ -512,7 +534,8 @@ extern char * mbspcasecmp (const char *string, const char *prefix); Note: This function may, in multibyte locales, return success even if strlen (haystack) < strlen (needle) ! Unlike strcasestr(), this function works correctly in multibyte locales. */ -extern char * mbscasestr (const char *haystack, const char *needle); +extern char * mbscasestr (const char *haystack, const char *needle) + _GL_ARG_NONNULL ((1, 2)); #endif #if @GNULIB_MBSCSPN@ @@ -521,7 +544,8 @@ extern char * mbscasestr (const char *haystack, const char *needle); beginning of the string to this occurrence, or to the end of the string if none exists. Unlike strcspn(), this function works correctly in multibyte locales. */ -extern size_t mbscspn (const char *string, const char *accept); +extern size_t mbscspn (const char *string, const char *accept) + _GL_ARG_NONNULL ((1, 2)); #endif #if @GNULIB_MBSPBRK@ @@ -530,7 +554,8 @@ extern size_t mbscspn (const char *string, const char *accept); exists. Unlike strpbrk(), this function works correctly in multibyte locales. */ # define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ -extern char * mbspbrk (const char *string, const char *accept); +extern char * mbspbrk (const char *string, const char *accept) + _GL_ARG_NONNULL ((1, 2)); #endif #if @GNULIB_MBSSPN@ @@ -539,7 +564,8 @@ extern char * mbspbrk (const char *string, const char *accept); beginning of the string to this occurrence, or to the end of the string if none exists. Unlike strspn(), this function works correctly in multibyte locales. */ -extern size_t mbsspn (const char *string, const char *reject); +extern size_t mbsspn (const char *string, const char *reject) + _GL_ARG_NONNULL ((1, 2)); #endif #if @GNULIB_MBSSEP@ @@ -557,7 +583,8 @@ extern size_t mbsspn (const char *string, const char *reject); Caveat: The identity of the delimiting character is lost. See also mbstok_r(). */ -extern char * mbssep (char **stringp, const char *delim); +extern char * mbssep (char **stringp, const char *delim) + _GL_ARG_NONNULL ((1, 2)); #endif #if @GNULIB_MBSTOK_R@ @@ -565,19 +592,20 @@ extern char * mbssep (char **stringp, const char *delim); the character string DELIM. If STRING is NULL, the saved pointer in SAVE_PTR is used as the next starting point. For example: - char s[] = "-abc-=-def"; - char *sp; - x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def" - x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL - x = mbstok_r(NULL, "=", &sp); // x = NULL - // s = "abc\0-def\0" + char s[] = "-abc-=-def"; + char *sp; + x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def" + x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL + x = mbstok_r(NULL, "=", &sp); // x = NULL + // s = "abc\0-def\0" Caveat: It modifies the original string. Caveat: These functions cannot be used on constant strings. Caveat: The identity of the delimiting character is lost. See also mbssep(). */ -extern char * mbstok_r (char *string, const char *delim, char **save_ptr); +extern char * mbstok_r (char *string, const char *delim, char **save_ptr) + _GL_ARG_NONNULL ((2, 3)); #endif /* Map any int, typically from errno, into an error message. */ @@ -612,7 +640,7 @@ extern char *strsignal (int __sig); #if @GNULIB_STRVERSCMP@ # if !@HAVE_STRVERSCMP@ -extern int strverscmp (const char *, const char *); +extern int strverscmp (const char *, const char *) _GL_ARG_NONNULL ((1, 2)); # endif #elif defined GNULIB_POSIXCHECK # undef strverscmp diff --git a/src/bin/coreutils/lib/strintcmp.c b/src/bin/coreutils/lib/strintcmp.c index 3e107e31e1..e1783b2c15 100644 --- a/src/bin/coreutils/lib/strintcmp.c +++ b/src/bin/coreutils/lib/strintcmp.c @@ -1,6 +1,6 @@ /* Compare integer strings. - Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/stripslash.c b/src/bin/coreutils/lib/stripslash.c index 40844102ff..3a5996fd90 100644 --- a/src/bin/coreutils/lib/stripslash.c +++ b/src/bin/coreutils/lib/stripslash.c @@ -1,6 +1,7 @@ /* stripslash.c -- remove redundant trailing slashes from a file name - Copyright (C) 1990, 2001, 2003-2006 Free Software Foundation, Inc. + Copyright (C) 1990, 2001, 2003-2006, 2009-2010 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/strndup.c b/src/bin/coreutils/lib/strndup.c index e458a55b32..3b2a1d4b28 100644 --- a/src/bin/coreutils/lib/strndup.c +++ b/src/bin/coreutils/lib/strndup.c @@ -3,8 +3,8 @@ #line 1 /* A replacement function, for systems that lack strndup. - Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2005, 2006, 2007 - Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2005, 2006, 2007, 2009, + 2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the diff --git a/src/bin/coreutils/lib/strnlen.c b/src/bin/coreutils/lib/strnlen.c index 25eaaec245..12cf537e63 100644 --- a/src/bin/coreutils/lib/strnlen.c +++ b/src/bin/coreutils/lib/strnlen.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Find the length of STRING, but scan at most MAXLEN characters. - Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. Written by Simon Josefsson. This program is free software; you can redistribute it and/or modify diff --git a/src/bin/coreutils/lib/strnlen1.c b/src/bin/coreutils/lib/strnlen1.c index 752d4fe8fd..b8cd2bff03 100644 --- a/src/bin/coreutils/lib/strnlen1.c +++ b/src/bin/coreutils/lib/strnlen1.c @@ -1,5 +1,5 @@ /* Find the length of STRING + 1, but scan at most MAXLEN bytes. - Copyright (C) 2005-2006 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/strnlen1.h b/src/bin/coreutils/lib/strnlen1.h index c0ea357046..dfaf62dcbd 100644 --- a/src/bin/coreutils/lib/strnlen1.h +++ b/src/bin/coreutils/lib/strnlen1.h @@ -1,5 +1,5 @@ /* Find the length of STRING + 1, but scan at most MAXLEN bytes. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/strnumcmp-in.h b/src/bin/coreutils/lib/strnumcmp-in.h index 8864274902..94223c17b6 100644 --- a/src/bin/coreutils/lib/strnumcmp-in.h +++ b/src/bin/coreutils/lib/strnumcmp-in.h @@ -1,7 +1,7 @@ /* Compare numeric strings. This is an internal include file. - Copyright (C) 1988, 1991, 1992, 1993, 1995, 1996, 1998, 1999, 2000, - 2003, 2004, 2005, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 1988, 1991-1993, 1995-1996, 1998-2000, 2003-2006, 2009-2010 + Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/strnumcmp.c b/src/bin/coreutils/lib/strnumcmp.c index aae09e1563..172c7bdce7 100644 --- a/src/bin/coreutils/lib/strnumcmp.c +++ b/src/bin/coreutils/lib/strnumcmp.c @@ -1,6 +1,6 @@ /* Compare numeric strings. - Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/strpbrk.c b/src/bin/coreutils/lib/strpbrk.c index 31d21d02f3..f7efc56cc9 100644 --- a/src/bin/coreutils/lib/strpbrk.c +++ b/src/bin/coreutils/lib/strpbrk.c @@ -1,7 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 -/* Copyright (C) 1991, 1994, 2000, 2002-2003, 2006 Free Software +/* Copyright (C) 1991, 1994, 2000, 2002-2003, 2006, 2009-2010 Free Software Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. @@ -36,8 +36,8 @@ strpbrk (const char *s, const char *accept) { const char *a = accept; while (*a != '\0') - if (*a++ == *s) - return (char *) s; + if (*a++ == *s) + return (char *) s; ++s; } diff --git a/src/bin/coreutils/lib/strsignal.c b/src/bin/coreutils/lib/strsignal.c new file mode 100644 index 0000000000..8cd09d2b7e --- /dev/null +++ b/src/bin/coreutils/lib/strsignal.c @@ -0,0 +1,196 @@ +/* Copyright (C) 1991, 1994-2002, 2005, 2008-2010 Free Software Foundation, + Inc. + This file is part of the GNU C Library. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef _LIBC +# include +#endif + +#include +#include +#include +#include + +#ifdef _LIBC +# include +#else /* !_LIBC */ +# include "gettext.h" +# define _(msgid) gettext (msgid) +# define N_(msgid) gettext_noop (msgid) +#endif /* _LIBC */ + +#ifdef _LIBC +# include +#else /* !_LIBC */ +# include "glthread/lock.h" +# include "glthread/tls.h" +# define __libc_once_define(CLASS, NAME) gl_once_define (CLASS, NAME) +# define __libc_once(NAME, INIT) gl_once ((NAME), (INIT)) +# define __libc_key_t gl_tls_key_t +# define __libc_getspecific(NAME) gl_tls_get ((NAME)) +# define __libc_setspecific(NAME, POINTER) gl_tls_set ((NAME), (POINTER)) +# define __snprintf snprintf +#endif /* _LIBC */ + +#ifdef _LIBC + +/* Defined in siglist.c. */ +extern const char *const _sys_siglist[]; +extern const char *const _sys_siglist_internal[] attribute_hidden; + +#else /* !_LIBC */ + +/* NetBSD declares sys_siglist in unistd.h. */ +# include + +# define INTUSE(x) (x) + +# if HAVE_DECL_SYS_SIGLIST +# undef _sys_siglist +# define _sys_siglist sys_siglist +# else /* !HAVE_DECL_SYS_SIGLIST */ +# ifndef NSIG +# define NSIG 32 +# endif /* NSIG */ +# if !HAVE_DECL__SYS_SIGLIST +static const char *_sys_siglist[NSIG]; +# endif +# endif /* !HAVE_DECL_SYS_SIGLIST */ + +#endif /* _LIBC */ + +static __libc_key_t key; + +/* If nonzero the key allocation failed and we should better use a + static buffer than fail. */ +#define BUFFERSIZ 100 +static char local_buf[BUFFERSIZ]; +static char *static_buf; + +/* Destructor for the thread-specific data. */ +static void init (void); +static void free_key_mem (void *mem); +static char *getbuffer (void); + + +/* Return a string describing the meaning of the signal number SIGNUM. */ +char * +strsignal (int signum) +{ + const char *desc; + __libc_once_define (static, once); + + /* If we have not yet initialized the buffer do it now. */ + __libc_once (once, init); + + if ( +#ifdef SIGRTMIN + (signum >= SIGRTMIN && signum <= SIGRTMAX) || +#endif + signum < 0 || signum >= NSIG + || (desc = INTUSE(_sys_siglist)[signum]) == NULL) + { + char *buffer = getbuffer (); + int len; +#ifdef SIGRTMIN + if (signum >= SIGRTMIN && signum <= SIGRTMAX) + len = __snprintf (buffer, BUFFERSIZ - 1, _("Real-time signal %d"), + signum - SIGRTMIN); + else +#endif + len = __snprintf (buffer, BUFFERSIZ - 1, _("Unknown signal %d"), + signum); + if (len >= BUFFERSIZ) + buffer = NULL; + else + buffer[len] = '\0'; + + return buffer; + } + + return (char *) _(desc); +} + + +/* Initialize buffer. */ +static void +init (void) +{ +#ifdef _LIBC + if (__libc_key_create (&key, free_key_mem)) + /* Creating the key failed. This means something really went + wrong. In any case use a static buffer which is better than + nothing. */ + static_buf = local_buf; +#else /* !_LIBC */ + gl_tls_key_init (key, free_key_mem); + +# if !HAVE_DECL_SYS_SIGLIST + memset (_sys_siglist, 0, NSIG * sizeof *_sys_siglist); + + /* No need to use a do {} while (0) here since init_sig(...) must expand + to a complete statement. (We cannot use the ISO C99 designated array + initializer syntax since it is not supported by ANSI C compilers and + since some signal numbers might exceed NSIG.) */ +# define init_sig(sig, abbrev, desc) \ + if (sig >= 0 && sig < NSIG) \ + _sys_siglist[sig] = desc; + +# include "siglist.h" + +# undef init_sig + +# endif /* !HAVE_DECL_SYS_SIGLIST */ +#endif /* !_LIBC */ +} + + +/* Free the thread specific data, this is done if a thread terminates. */ +static void +free_key_mem (void *mem) +{ + free (mem); + __libc_setspecific (key, NULL); +} + + +/* Return the buffer to be used. */ +static char * +getbuffer (void) +{ + char *result; + + if (static_buf != NULL) + result = static_buf; + else + { + /* We don't use the static buffer and so we have a key. Use it + to get the thread-specific buffer. */ + result = __libc_getspecific (key); + if (result == NULL) + { + /* No buffer allocated so far. */ + result = malloc (BUFFERSIZ); + if (result == NULL) + /* No more memory available. We use the static buffer. */ + result = local_buf; + else + __libc_setspecific (key, result); + } + } + + return result; +} diff --git a/src/bin/coreutils/lib/strstr.c b/src/bin/coreutils/lib/strstr.c index 4b4d3e024f..5df0a96f58 100644 --- a/src/bin/coreutils/lib/strstr.c +++ b/src/bin/coreutils/lib/strstr.c @@ -1,8 +1,8 @@ /* -*- buffer-read-only: t -*- vi: set ro: */ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 -/* Copyright (C) 1991,92,93,94,96,97,98,2000,2004,2007,2008 Free Software - Foundation, Inc. +/* Copyright (C) 1991, 1992, 1993, 1994, 1996, 1997, 1998, 2000, 2004, 2007, + 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software; you can redistribute it and/or modify @@ -35,8 +35,8 @@ #endif #define RETURN_TYPE char * -#define AVAILABLE(h, h_l, j, n_l) \ - (!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l)) \ +#define AVAILABLE(h, h_l, j, n_l) \ + (!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l)) \ && ((h_l) = (j) + (n_l))) #include "str-two-way.h" @@ -70,17 +70,17 @@ strstr (const char *haystack_start, const char *needle_start) return (char *) haystack; needle -= needle_len; haystack_len = (haystack > haystack_start + needle_len ? 1 - : needle_len + haystack_start - haystack); + : needle_len + haystack_start - haystack); /* Perform the search. Abstract memory is considered to be an array of 'unsigned char' values, not an array of 'char' values. See ISO C 99 section 6.2.6.1. */ if (needle_len < LONG_NEEDLE_THRESHOLD) return two_way_short_needle ((const unsigned char *) haystack, - haystack_len, - (const unsigned char *) needle, needle_len); + haystack_len, + (const unsigned char *) needle, needle_len); return two_way_long_needle ((const unsigned char *) haystack, haystack_len, - (const unsigned char *) needle, needle_len); + (const unsigned char *) needle, needle_len); } #undef LONG_NEEDLE_THRESHOLD diff --git a/src/bin/coreutils/lib/strtod.c b/src/bin/coreutils/lib/strtod.c index a2a4d3db65..371476ee4d 100644 --- a/src/bin/coreutils/lib/strtod.c +++ b/src/bin/coreutils/lib/strtod.c @@ -1,5 +1,5 @@ -/* Copyright (C) 1991, 1992, 1997, 1999, 2003, 2006, 2008 Free - Software Foundation, Inc. +/* Copyright (C) 1991-1992, 1997, 1999, 2003, 2006, 2008-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,6 +16,10 @@ #include +/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc + optimizes away the nptr == NULL test below. */ +#define _GL_ARG_NONNULL(params) + #include #include @@ -38,9 +42,9 @@ strtod (const char *nptr, char **endptr) /* The number so far. */ double num; - bool got_dot; /* Found a decimal point. */ - bool got_digit; /* Seen any digits. */ - bool hex = false; /* Look for hex float exponent. */ + bool got_dot; /* Found a decimal point. */ + bool got_digit; /* Seen any digits. */ + bool hex = false; /* Look for hex float exponent. */ /* The exponent of the number. */ long int exponent; @@ -75,114 +79,114 @@ strtod (const char *nptr, char **endptr) hex = true; s += 2; for (;; ++s) - { - if (c_isxdigit (*s)) - { - got_digit = true; + { + if (c_isxdigit (*s)) + { + got_digit = true; - /* Make sure that multiplication by 16 will not overflow. */ - if (num > DBL_MAX / 16) - /* The value of the digit doesn't matter, since we have already - gotten as many digits as can be represented in a `double'. - This doesn't necessarily mean the result will overflow. - The exponent may reduce it to within range. + /* Make sure that multiplication by 16 will not overflow. */ + if (num > DBL_MAX / 16) + /* The value of the digit doesn't matter, since we have already + gotten as many digits as can be represented in a `double'. + This doesn't necessarily mean the result will overflow. + The exponent may reduce it to within range. - We just need to record that there was another - digit so that we can multiply by 16 later. */ - ++exponent; - else - num = ((num * 16.0) - + (c_tolower (*s) - (c_isdigit (*s) ? '0' : 'a' - 10))); + We just need to record that there was another + digit so that we can multiply by 16 later. */ + ++exponent; + else + num = ((num * 16.0) + + (c_tolower (*s) - (c_isdigit (*s) ? '0' : 'a' - 10))); - /* Keep track of the number of digits after the decimal point. - If we just divided by 16 here, we would lose precision. */ - if (got_dot) - --exponent; - } - else if (!got_dot && *s == '.') - /* Record that we have found the decimal point. */ - got_dot = true; - else - /* Any other character terminates the number. */ - break; - } + /* Keep track of the number of digits after the decimal point. + If we just divided by 16 here, we would lose precision. */ + if (got_dot) + --exponent; + } + else if (!got_dot && *s == '.') + /* Record that we have found the decimal point. */ + got_dot = true; + else + /* Any other character terminates the number. */ + break; + } } /* Not a hex float. */ else { for (;; ++s) - { - if (c_isdigit (*s)) - { - got_digit = true; + { + if (c_isdigit (*s)) + { + got_digit = true; - /* Make sure that multiplication by 10 will not overflow. */ - if (num > DBL_MAX * 0.1) - /* The value of the digit doesn't matter, since we have already - gotten as many digits as can be represented in a `double'. - This doesn't necessarily mean the result will overflow. - The exponent may reduce it to within range. + /* Make sure that multiplication by 10 will not overflow. */ + if (num > DBL_MAX * 0.1) + /* The value of the digit doesn't matter, since we have already + gotten as many digits as can be represented in a `double'. + This doesn't necessarily mean the result will overflow. + The exponent may reduce it to within range. - We just need to record that there was another - digit so that we can multiply by 10 later. */ - ++exponent; - else - num = (num * 10.0) + (*s - '0'); + We just need to record that there was another + digit so that we can multiply by 10 later. */ + ++exponent; + else + num = (num * 10.0) + (*s - '0'); - /* Keep track of the number of digits after the decimal point. - If we just divided by 10 here, we would lose precision. */ - if (got_dot) - --exponent; - } - else if (!got_dot && *s == '.') - /* Record that we have found the decimal point. */ - got_dot = true; - else - /* Any other character terminates the number. */ - break; - } + /* Keep track of the number of digits after the decimal point. + If we just divided by 10 here, we would lose precision. */ + if (got_dot) + --exponent; + } + else if (!got_dot && *s == '.') + /* Record that we have found the decimal point. */ + got_dot = true; + else + /* Any other character terminates the number. */ + break; + } } if (!got_digit) { /* Check for infinities and NaNs. */ if (c_tolower (*s) == 'i' - && c_tolower (s[1]) == 'n' - && c_tolower (s[2]) == 'f') - { - s += 3; - num = HUGE_VAL; - if (c_tolower (*s) == 'i' - && c_tolower (s[1]) == 'n' - && c_tolower (s[2]) == 'i' - && c_tolower (s[3]) == 't' - && c_tolower (s[4]) == 'y') - s += 5; - goto valid; - } + && c_tolower (s[1]) == 'n' + && c_tolower (s[2]) == 'f') + { + s += 3; + num = HUGE_VAL; + if (c_tolower (*s) == 'i' + && c_tolower (s[1]) == 'n' + && c_tolower (s[2]) == 'i' + && c_tolower (s[3]) == 't' + && c_tolower (s[4]) == 'y') + s += 5; + goto valid; + } #ifdef NAN else if (c_tolower (*s) == 'n' - && c_tolower (s[1]) == 'a' - && c_tolower (s[2]) == 'n') - { - s += 3; - num = NAN; - /* Since nan() is implementation-defined, - we define it by ignoring . A nicer - implementation would populate the bits of the NaN - according to interpreting n-char-sequence as a - hexadecimal number, but the result is still a NaN. */ - if (*s == '(') - { - const unsigned char *p = s + 1; - while (c_isalnum (*p)) - p++; - if (*p == ')') - s = p + 1; - } - goto valid; - } + && c_tolower (s[1]) == 'a' + && c_tolower (s[2]) == 'n') + { + s += 3; + num = NAN; + /* Since nan() is implementation-defined, + we define it by ignoring . A nicer + implementation would populate the bits of the NaN + according to interpreting n-char-sequence as a + hexadecimal number, but the result is still a NaN. */ + if (*s == '(') + { + const unsigned char *p = s + 1; + while (c_isalnum (*p)) + p++; + if (*p == ')') + s = p + 1; + } + goto valid; + } #endif goto noconv; } @@ -198,21 +202,21 @@ strtod (const char *nptr, char **endptr) ++s; value = strtol ((char *) s, &end, 10); if (errno == ERANGE && num) - { - /* The exponent overflowed a `long int'. It is probably a safe - assumption that an exponent that cannot be represented by - a `long int' exceeds the limits of a `double'. */ - if (endptr != NULL) - *endptr = end; - if (value < 0) - goto underflow; - else - goto overflow; - } + { + /* The exponent overflowed a `long int'. It is probably a safe + assumption that an exponent that cannot be represented by + a `long int' exceeds the limits of a `double'. */ + if (endptr != NULL) + *endptr = end; + if (value < 0) + goto underflow; + else + goto overflow; + } else if (end == (char *) s) - /* There was no exponent. Reset END to point to - the 'e' or 'E', so *ENDPTR will be set there. */ - end = (char *) s - 1; + /* There was no exponent. Reset END to point to + the 'e' or 'E', so *ENDPTR will be set there. */ + end = (char *) s - 1; errno = save; s = (unsigned char *) end; exponent += value; @@ -234,12 +238,12 @@ strtod (const char *nptr, char **endptr) if (exponent < 0) { if (num < DBL_MIN * pow (10.0, (double) -exponent)) - goto underflow; + goto underflow; } else if (exponent > 0) { if (num > DBL_MAX * pow (10.0, (double) -exponent)) - goto overflow; + goto overflow; } num *= pow (10.0, (double) exponent); diff --git a/src/bin/coreutils/lib/strtoimax.c b/src/bin/coreutils/lib/strtoimax.c index ab9bcff3c7..ce873f79f7 100644 --- a/src/bin/coreutils/lib/strtoimax.c +++ b/src/bin/coreutils/lib/strtoimax.c @@ -1,6 +1,6 @@ /* Convert string representation of a number into an intmax_t value. - Copyright (C) 1999, 2001, 2002, 2003, 2004, 2006 Free Software + Copyright (C) 1999, 2001, 2002, 2003, 2004, 2006, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -63,7 +63,7 @@ strtoimax (char const *ptr, char **endptr, int base) { #if Have_long_long verify (sizeof (Int) == sizeof (Unsigned long int) - || sizeof (Int) == sizeof (Unsigned long long int)); + || sizeof (Int) == sizeof (Unsigned long long int)); if (sizeof (Int) != sizeof (Unsigned long int)) return strtoll (ptr, endptr, base); diff --git a/src/bin/coreutils/lib/strtol.c b/src/bin/coreutils/lib/strtol.c index 0b2c82a01c..d1b5bc0cb6 100644 --- a/src/bin/coreutils/lib/strtol.c +++ b/src/bin/coreutils/lib/strtol.c @@ -1,8 +1,7 @@ /* Convert string representation of a number into an integer value. Copyright (C) 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2003, 2005, - 2006, 2007 - Free Software Foundation, Inc. + 2006, 2007, 2009, 2010 Free Software Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@gnu.org. @@ -139,14 +138,14 @@ your host. */ # define TYPE_MINIMUM(t) \ ((t) (! TYPE_SIGNED (t) \ - ? (t) 0 \ - : TYPE_SIGNED_MAGNITUDE (t) \ - ? ~ (t) 0 \ - : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))) + ? (t) 0 \ + : TYPE_SIGNED_MAGNITUDE (t) \ + ? ~ (t) 0 \ + : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))) # define TYPE_MAXIMUM(t) \ ((t) (! TYPE_SIGNED (t) \ - ? (t) -1 \ - : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))) + ? (t) -1 \ + : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))) # ifndef ULONG_LONG_MAX # define ULONG_LONG_MAX TYPE_MAXIMUM (unsigned long long) @@ -238,7 +237,7 @@ INT INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr, - int base, int group LOCALE_PARAM_PROTO) + int base, int group LOCALE_PARAM_PROTO) { int negative; register unsigned LONG int cutoff; @@ -263,18 +262,18 @@ INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr, { grouping = _NL_CURRENT (LC_NUMERIC, GROUPING); if (*grouping <= 0 || *grouping == CHAR_MAX) - grouping = NULL; + grouping = NULL; else - { - /* Figure out the thousands separator character. */ + { + /* Figure out the thousands separator character. */ # if defined _LIBC || defined _HAVE_BTOWC - thousands = __btowc (*_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP)); - if (thousands == WEOF) - thousands = L'\0'; + thousands = __btowc (*_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP)); + if (thousands == WEOF) + thousands = L'\0'; # endif - if (thousands == L'\0') - grouping = NULL; - } + if (thousands == L'\0') + grouping = NULL; + } } else grouping = NULL; @@ -312,12 +311,12 @@ INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr, if (*s == L_('0')) { if ((base == 0 || base == 16) && TOUPPER (s[1]) == L_('X')) - { - s += 2; - base = 16; - } + { + s += 2; + base = 16; + } else if (base == 0) - base = 8; + base = 8; } else if (base == 0) base = 10; @@ -331,14 +330,14 @@ INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr, /* Find the end of the digit string and check its grouping. */ end = s; for (c = *end; c != L_('\0'); c = *++end) - if ((wchar_t) c != thousands - && ((wchar_t) c < L_('0') || (wchar_t) c > L_('9')) - && (!ISALPHA (c) || (int) (TOUPPER (c) - L_('A') + 10) >= base)) - break; + if ((wchar_t) c != thousands + && ((wchar_t) c < L_('0') || (wchar_t) c > L_('9')) + && (!ISALPHA (c) || (int) (TOUPPER (c) - L_('A') + 10) >= base)) + break; if (*s == thousands) - end = s; + end = s; else - end = correctly_grouped_prefix (s, end, thousands, grouping); + end = correctly_grouped_prefix (s, end, thousands, grouping); } else #endif @@ -352,23 +351,23 @@ INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr, for (c = *s; c != L_('\0'); c = *++s) { if (s == end) - break; + break; if (c >= L_('0') && c <= L_('9')) - c -= L_('0'); + c -= L_('0'); else if (ISALPHA (c)) - c = TOUPPER (c) - L_('A') + 10; + c = TOUPPER (c) - L_('A') + 10; else - break; + break; if ((int) c >= base) - break; + break; /* Check for overflow. */ if (i > cutoff || (i == cutoff && c > cutlim)) - overflow = 1; + overflow = 1; else - { - i *= (unsigned LONG int) base; - i += c; - } + { + i *= (unsigned LONG int) base; + i += c; + } } /* Check if anything actually happened. */ @@ -385,8 +384,8 @@ INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr, `unsigned LONG int', but outside the range of `LONG int'. */ if (overflow == 0 && i > (negative - ? -((unsigned LONG int) (STRTOL_LONG_MIN + 1)) + 1 - : (unsigned LONG int) STRTOL_LONG_MAX)) + ? -((unsigned LONG int) (STRTOL_LONG_MIN + 1)) + 1 + : (unsigned LONG int) STRTOL_LONG_MAX)) overflow = 1; #endif @@ -411,11 +410,11 @@ noconv: if (endptr != NULL) { if (save - nptr >= 2 && TOUPPER (save[-1]) == L_('X') - && save[-2] == L_('0')) - *endptr = (STRING_TYPE *) &save[-1]; + && save[-2] == L_('0')) + *endptr = (STRING_TYPE *) &save[-1]; else - /* There was no number to convert. */ - *endptr = (STRING_TYPE *) nptr; + /* There was no number to convert. */ + *endptr = (STRING_TYPE *) nptr; } return 0L; @@ -429,7 +428,7 @@ INT weak_function #endif strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr, - int base LOCALE_PARAM_PROTO) + int base LOCALE_PARAM_PROTO) { return INTERNAL (strtol) (nptr, endptr, base, 0 LOCALE_PARAM); } diff --git a/src/bin/coreutils/lib/strtoll.c b/src/bin/coreutils/lib/strtoll.c index ccc99cb43c..8d25b0c70c 100644 --- a/src/bin/coreutils/lib/strtoll.c +++ b/src/bin/coreutils/lib/strtoll.c @@ -1,5 +1,6 @@ /* Function to parse a `long long int' from text. - Copyright (C) 1995, 1996, 1997, 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1999, 2001, 2009, 2010 Free Software + Foundation, Inc. This file is part of the GNU C Library. This program is free software: you can redistribute it and/or modify @@ -15,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#define QUAD 1 +#define QUAD 1 #include diff --git a/src/bin/coreutils/lib/strtoul.c b/src/bin/coreutils/lib/strtoul.c index 88dbfc0741..def103ff96 100644 --- a/src/bin/coreutils/lib/strtoul.c +++ b/src/bin/coreutils/lib/strtoul.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1997, 2009, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software: you can redistribute it and/or modify @@ -14,6 +14,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#define UNSIGNED 1 +#define UNSIGNED 1 #include "strtol.c" diff --git a/src/bin/coreutils/lib/strtoull.c b/src/bin/coreutils/lib/strtoull.c index eda4a70697..d4e65e352b 100644 --- a/src/bin/coreutils/lib/strtoull.c +++ b/src/bin/coreutils/lib/strtoull.c @@ -1,5 +1,6 @@ /* Function to parse an `unsigned long long int' from text. - Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1999, 2009, 2010 Free Software Foundation, + Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@gnu.org. diff --git a/src/bin/coreutils/lib/strverscmp.c b/src/bin/coreutils/lib/strverscmp.c deleted file mode 100644 index 4fb147a885..0000000000 --- a/src/bin/coreutils/lib/strverscmp.c +++ /dev/null @@ -1,134 +0,0 @@ -/* -*- buffer-read-only: t -*- vi: set ro: */ -/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ -#line 1 -/* Compare strings while treating digits characters numerically. - Copyright (C) 1997, 2000, 2002, 2004, 2006 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Jean-François Bignolles , 1997. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -#if !_LIBC -# include -#endif - -#include -#include - -/* states: S_N: normal, S_I: comparing integral part, S_F: comparing - fractional parts, S_Z: idem but with leading Zeroes only */ -#define S_N 0x0 -#define S_I 0x4 -#define S_F 0x8 -#define S_Z 0xC - -/* result_type: CMP: return diff; LEN: compare using len_diff/diff */ -#define CMP 2 -#define LEN 3 - - -/* ISDIGIT differs from isdigit, as follows: - - Its arg may be any int or unsigned int; it need not be an unsigned char - or EOF. - - It's typically faster. - POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to - isdigit unless it's important to use the locale's definition - of `digit' even when the host does not conform to POSIX. */ -#define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9) - -#undef __strverscmp -#undef strverscmp - -#ifndef weak_alias -# define __strverscmp strverscmp -#endif - -/* Compare S1 and S2 as strings holding indices/version numbers, - returning less than, equal to or greater than zero if S1 is less than, - equal to or greater than S2 (for more info, see the texinfo doc). -*/ - -int -__strverscmp (const char *s1, const char *s2) -{ - const unsigned char *p1 = (const unsigned char *) s1; - const unsigned char *p2 = (const unsigned char *) s2; - unsigned char c1, c2; - int state; - int diff; - - /* Symbol(s) 0 [1-9] others (padding) - Transition (10) 0 (01) d (00) x (11) - */ - static const unsigned int next_state[] = - { - /* state x d 0 - */ - /* S_N */ S_N, S_I, S_Z, S_N, - /* S_I */ S_N, S_I, S_I, S_I, - /* S_F */ S_N, S_F, S_F, S_F, - /* S_Z */ S_N, S_F, S_Z, S_Z - }; - - static const int result_type[] = - { - /* state x/x x/d x/0 x/- d/x d/d d/0 d/- - 0/x 0/d 0/0 0/- -/x -/d -/0 -/- */ - - /* S_N */ CMP, CMP, CMP, CMP, CMP, LEN, CMP, CMP, - CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, - /* S_I */ CMP, -1, -1, CMP, 1, LEN, LEN, CMP, - 1, LEN, LEN, CMP, CMP, CMP, CMP, CMP, - /* S_F */ CMP, CMP, CMP, CMP, CMP, LEN, CMP, CMP, - CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, - /* S_Z */ CMP, 1, 1, CMP, -1, CMP, CMP, CMP, - -1, CMP, CMP, CMP - }; - - if (p1 == p2) - return 0; - - c1 = *p1++; - c2 = *p2++; - /* Hint: '0' is a digit too. */ - state = S_N | ((c1 == '0') + (ISDIGIT (c1) != 0)); - - while ((diff = c1 - c2) == 0 && c1 != '\0') - { - state = next_state[state]; - c1 = *p1++; - c2 = *p2++; - state |= (c1 == '0') + (ISDIGIT (c1) != 0); - } - - state = result_type[state << 2 | ((c2 == '0') + (ISDIGIT (c2) != 0))]; - - switch (state) - { - case CMP: - return diff; - - case LEN: - while (ISDIGIT (*p1++)) - if (!ISDIGIT (*p2++)) - return 1; - - return ISDIGIT (*p2) ? -1 : diff; - - default: - return state; - } -} -#ifdef weak_alias -weak_alias (__strverscmp, strverscmp) -#endif diff --git a/src/bin/coreutils/lib/symlink.c b/src/bin/coreutils/lib/symlink.c new file mode 100644 index 0000000000..40bbb8041d --- /dev/null +++ b/src/bin/coreutils/lib/symlink.c @@ -0,0 +1,57 @@ +/* Stub for symlink(). + Copyright (C) 2009, 2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#include +#include +#include + + +#if HAVE_SYMLINK + +# undef symlink + +/* Create a symlink, but reject trailing slash. */ +int +rpl_symlink (char const *contents, char const *name) +{ + size_t len = strlen (name); + if (len && name[len - 1] == '/') + { + struct stat st; + if (lstat (name, &st) == 0) + errno = EEXIST; + return -1; + } + return symlink (contents, name); +} + +#else /* !HAVE_SYMLINK */ + +/* The system does not support symlinks. */ +int +symlink (char const *contents _GL_UNUSED, + char const *name _GL_UNUSED) +{ + errno = ENOSYS; + return -1; +} + +#endif /* !HAVE_SYMLINK */ diff --git a/src/bin/coreutils/lib/symlinkat.c b/src/bin/coreutils/lib/symlinkat.c new file mode 100644 index 0000000000..c01b3228d9 --- /dev/null +++ b/src/bin/coreutils/lib/symlinkat.c @@ -0,0 +1,102 @@ +/* Create a symlink relative to an open directory. + Copyright (C) 2009-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* written by Eric Blake */ + +#include + +#include + +#if !HAVE_SYMLINK +/* Mingw lacks symlink, and it is more efficient to provide a trivial + wrapper than to go through at-func.c to call rpl_symlink. */ + +# include + +int +symlinkat (char const *path1 _GL_UNUSED, int fd _GL_UNUSED, + char const *path2 _GL_UNUSED) +{ + errno = ENOSYS; + return -1; +} + +#else /* HAVE_SYMLINK */ + +/* Our openat helper functions expect the directory parameter first, + not second. These shims make life easier. */ + +/* Like symlink, but with arguments reversed. */ +static int +symlink_reversed (char const *file, char const *contents) +{ + return symlink (contents, file); +} + +/* Like symlinkat, but with arguments reversed. */ + +static int +symlinkat_reversed (int fd, char const *file, char const *contents); + +# define AT_FUNC_NAME symlinkat_reversed +# define AT_FUNC_F1 symlink_reversed +# define AT_FUNC_POST_FILE_PARAM_DECLS , char const *contents +# define AT_FUNC_POST_FILE_ARGS , contents +# include "at-func.c" +# undef AT_FUNC_NAME +# undef AT_FUNC_F1 +# undef AT_FUNC_POST_FILE_PARAM_DECLS +# undef AT_FUNC_POST_FILE_ARGS + +/* Create a symlink FILE, in the directory open on descriptor FD, + holding CONTENTS. If possible, do it without changing the + working directory. Otherwise, resort to using save_cwd/fchdir, + then symlink/restore_cwd. If either the save_cwd or the restore_cwd + fails, then give a diagnostic and exit nonzero. */ + +int +symlinkat (char const *contents, int fd, char const *file) +{ + return symlinkat_reversed (fd, file, contents); +} + +#endif /* HAVE_SYMLINK */ + +/* Gnulib provides a readlink stub for mingw; use it for distinction + between EINVAL and ENOENT, rather than always failing with ENOSYS. */ + +/* POSIX 2008 says that unlike readlink, readlinkat returns 0 for + success instead of the buffer length. But this would render + readlinkat worthless since readlink does not guarantee a + NUL-terminated buffer. Assume this was a bug in POSIX. */ + +/* Read the contents of symlink FILE into buffer BUF of size LEN, in the + directory open on descriptor FD. If possible, do it without changing + the working directory. Otherwise, resort to using save_cwd/fchdir, + then readlink/restore_cwd. If either the save_cwd or the restore_cwd + fails, then give a diagnostic and exit nonzero. */ + +#define AT_FUNC_NAME readlinkat +#define AT_FUNC_F1 readlink +#define AT_FUNC_POST_FILE_PARAM_DECLS , char *buf, size_t len +#define AT_FUNC_POST_FILE_ARGS , buf, len +#define AT_FUNC_RESULT ssize_t +#include "at-func.c" +#undef AT_FUNC_NAME +#undef AT_FUNC_F1 +#undef AT_FUNC_POST_FILE_PARAM_DECLS +#undef AT_FUNC_POST_FILE_ARGS +#undef AT_FUNC_RESULT diff --git a/src/bin/coreutils/lib/sys_select.in.h b/src/bin/coreutils/lib/sys_select.in.h index f51534abf5..0c5a7560e3 100644 --- a/src/bin/coreutils/lib/sys_select.in.h +++ b/src/bin/coreutils/lib/sys_select.in.h @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Substitute for . - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -45,12 +45,18 @@ # include /* On OSF/1 4.0, provides only a forward declaration - of 'struct timeval', and no definition of this type. */ -# include + of 'struct timeval', and no definition of this type. + But avoid namespace pollution on glibc systems. */ +# ifndef __GLIBC__ +# include +# endif /* On Solaris 10, provides an FD_ZERO implementation - that relies on memset(), but without including . */ -# include + that relies on memset(), but without including . + But avoid namespace pollution on glibc systems. */ +# ifndef __GLIBC__ +# include +# endif /* The include_next requires a split double-inclusion guard. */ # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@ diff --git a/src/bin/coreutils/lib/sys_socket.in.h b/src/bin/coreutils/lib/sys_socket.in.h index 5d898dfbfe..92810dbf00 100644 --- a/src/bin/coreutils/lib/sys_socket.in.h +++ b/src/bin/coreutils/lib/sys_socket.in.h @@ -3,7 +3,7 @@ #line 1 /* Provide a sys/socket header file for systems lacking it (read: MinGW) and for systems where it is incomplete. - Copyright (C) 2005-2009 Free Software Foundation, Inc. + Copyright (C) 2005-2010 Free Software Foundation, Inc. Written by Simon Josefsson. This program is free software; you can redistribute it and/or modify @@ -46,6 +46,8 @@ #ifndef _GL_SYS_SOCKET_H #define _GL_SYS_SOCKET_H +/* The definition of _GL_ARG_NONNULL is copied here. */ + #if !@HAVE_SA_FAMILY_T@ typedef unsigned short sa_family_t; #endif @@ -57,10 +59,10 @@ typedef unsigned short sa_family_t; # define __ss_aligntype unsigned long int # define _SS_SIZE 256 # define _SS_PADSIZE \ - (_SS_SIZE - ((sizeof (sa_family_t) >= alignof (__ss_aligntype) \ - ? sizeof (sa_family_t) \ - : alignof (__ss_aligntype)) \ - + sizeof (__ss_aligntype))) + (_SS_SIZE - ((sizeof (sa_family_t) >= alignof (__ss_aligntype) \ + ? sizeof (sa_family_t) \ + : alignof (__ss_aligntype)) \ + + sizeof (__ss_aligntype))) struct sockaddr_storage { @@ -180,7 +182,7 @@ rpl_fd_isset (SOCKET fd, fd_set * set) # if @GNULIB_SOCKET@ # if @HAVE_WINSOCK2_H@ # undef socket -# define socket rpl_socket +# define socket rpl_socket extern int rpl_socket (int, int, int protocol); # endif # elif @HAVE_WINSOCK2_H@ @@ -197,8 +199,8 @@ extern int rpl_socket (int, int, int protocol); # if @GNULIB_CONNECT@ # if @HAVE_WINSOCK2_H@ # undef connect -# define connect rpl_connect -extern int rpl_connect (int, struct sockaddr *, int); +# define connect rpl_connect +extern int rpl_connect (int, struct sockaddr *, int) _GL_ARG_NONNULL ((2)); # endif # elif @HAVE_WINSOCK2_H@ # undef connect @@ -214,7 +216,7 @@ extern int rpl_connect (int, struct sockaddr *, int); # if @GNULIB_ACCEPT@ # if @HAVE_WINSOCK2_H@ # undef accept -# define accept rpl_accept +# define accept rpl_accept extern int rpl_accept (int, struct sockaddr *, int *); # endif # elif @HAVE_WINSOCK2_H@ @@ -231,8 +233,8 @@ extern int rpl_accept (int, struct sockaddr *, int *); # if @GNULIB_BIND@ # if @HAVE_WINSOCK2_H@ # undef bind -# define bind rpl_bind -extern int rpl_bind (int, struct sockaddr *, int); +# define bind rpl_bind +extern int rpl_bind (int, struct sockaddr *, int) _GL_ARG_NONNULL ((2)); # endif # elif @HAVE_WINSOCK2_H@ # undef bind @@ -248,8 +250,9 @@ extern int rpl_bind (int, struct sockaddr *, int); # if @GNULIB_GETPEERNAME@ # if @HAVE_WINSOCK2_H@ # undef getpeername -# define getpeername rpl_getpeername -extern int rpl_getpeername (int, struct sockaddr *, int *); +# define getpeername rpl_getpeername +extern int rpl_getpeername (int, struct sockaddr *, int *) + _GL_ARG_NONNULL ((2, 3)); # endif # elif @HAVE_WINSOCK2_H@ # undef getpeername @@ -265,8 +268,9 @@ extern int rpl_getpeername (int, struct sockaddr *, int *); # if @GNULIB_GETSOCKNAME@ # if @HAVE_WINSOCK2_H@ # undef getsockname -# define getsockname rpl_getsockname -extern int rpl_getsockname (int, struct sockaddr *, int *); +# define getsockname rpl_getsockname +extern int rpl_getsockname (int, struct sockaddr *, int *) + _GL_ARG_NONNULL ((2, 3)); # endif # elif @HAVE_WINSOCK2_H@ # undef getsockname @@ -282,8 +286,9 @@ extern int rpl_getsockname (int, struct sockaddr *, int *); # if @GNULIB_GETSOCKOPT@ # if @HAVE_WINSOCK2_H@ # undef getsockopt -# define getsockopt rpl_getsockopt -extern int rpl_getsockopt (int, int, int, void *, socklen_t *); +# define getsockopt rpl_getsockopt +extern int rpl_getsockopt (int, int, int, void *, socklen_t *) + _GL_ARG_NONNULL ((4, 5)); # endif # elif @HAVE_WINSOCK2_H@ # undef getsockopt @@ -299,7 +304,7 @@ extern int rpl_getsockopt (int, int, int, void *, socklen_t *); # if @GNULIB_LISTEN@ # if @HAVE_WINSOCK2_H@ # undef listen -# define listen rpl_listen +# define listen rpl_listen extern int rpl_listen (int, int); # endif # elif @HAVE_WINSOCK2_H@ @@ -316,8 +321,8 @@ extern int rpl_listen (int, int); # if @GNULIB_RECV@ # if @HAVE_WINSOCK2_H@ # undef recv -# define recv rpl_recv -extern int rpl_recv (int, void *, int, int); +# define recv rpl_recv +extern int rpl_recv (int, void *, int, int) _GL_ARG_NONNULL ((2)); # endif # elif @HAVE_WINSOCK2_H@ # undef recv @@ -333,8 +338,8 @@ extern int rpl_recv (int, void *, int, int); # if @GNULIB_SEND@ # if @HAVE_WINSOCK2_H@ # undef send -# define send rpl_send -extern int rpl_send (int, const void *, int, int); +# define send rpl_send +extern int rpl_send (int, const void *, int, int) _GL_ARG_NONNULL ((2)); # endif # elif @HAVE_WINSOCK2_H@ # undef send @@ -350,8 +355,9 @@ extern int rpl_send (int, const void *, int, int); # if @GNULIB_RECVFROM@ # if @HAVE_WINSOCK2_H@ # undef recvfrom -# define recvfrom rpl_recvfrom -extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *); +# define recvfrom rpl_recvfrom +extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *) + _GL_ARG_NONNULL ((2)); # endif # elif @HAVE_WINSOCK2_H@ # undef recvfrom @@ -367,8 +373,9 @@ extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *); # if @GNULIB_SENDTO@ # if @HAVE_WINSOCK2_H@ # undef sendto -# define sendto rpl_sendto -extern int rpl_sendto (int, const void *, int, int, struct sockaddr *, int); +# define sendto rpl_sendto +extern int rpl_sendto (int, const void *, int, int, struct sockaddr *, int) + _GL_ARG_NONNULL ((2)); # endif # elif @HAVE_WINSOCK2_H@ # undef sendto @@ -384,8 +391,9 @@ extern int rpl_sendto (int, const void *, int, int, struct sockaddr *, int); # if @GNULIB_SETSOCKOPT@ # if @HAVE_WINSOCK2_H@ # undef setsockopt -# define setsockopt rpl_setsockopt -extern int rpl_setsockopt (int, int, int, const void *, socklen_t); +# define setsockopt rpl_setsockopt +extern int rpl_setsockopt (int, int, int, const void *, socklen_t) + _GL_ARG_NONNULL ((4)); # endif # elif @HAVE_WINSOCK2_H@ # undef setsockopt @@ -401,7 +409,7 @@ extern int rpl_setsockopt (int, int, int, const void *, socklen_t); # if @GNULIB_SHUTDOWN@ # if @HAVE_WINSOCK2_H@ # undef shutdown -# define shutdown rpl_shutdown +# define shutdown rpl_shutdown extern int rpl_shutdown (int, int); # endif # elif @HAVE_WINSOCK2_H@ @@ -417,7 +425,7 @@ extern int rpl_shutdown (int, int); # if @HAVE_WINSOCK2_H@ # undef select -# define select select_used_without_including_sys_select_h +# define select select_used_without_including_sys_select_h # endif # ifdef __cplusplus @@ -440,7 +448,7 @@ extern "C" { # define accept4 rpl_accept4 # endif extern int accept4 (int sockfd, struct sockaddr *addr, socklen_t *addrlen, - int flags); + int flags); #elif defined GNULIB_POSIXCHECK # undef accept4 # define accept4(s,a,l,f) \ diff --git a/src/bin/coreutils/lib/sys_stat.in.h b/src/bin/coreutils/lib/sys_stat.in.h index b8d565e899..7fbd11d474 100644 --- a/src/bin/coreutils/lib/sys_stat.in.h +++ b/src/bin/coreutils/lib/sys_stat.in.h @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Provide a more complete sys/stat header file. - Copyright (C) 2005-2009 Free Software Foundation, Inc. + Copyright (C) 2005-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -41,6 +41,9 @@ /* Get nlink_t. */ #include +/* Get struct timespec. */ +#include + /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@ @@ -49,6 +52,8 @@ /* The definition of GL_LINK_WARNING is copied here. */ +/* The definition of _GL_ARG_NONNULL is copied here. */ + /* Before doing "#define mkdir rpl_mkdir" below, we need to include all headers that may declare mkdir(). */ #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ @@ -281,12 +286,98 @@ # define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO) #endif +/* Macros for futimens and utimensat. */ +#ifndef UTIME_NOW +# define UTIME_NOW (-1) +# define UTIME_OMIT (-2) +#endif + #ifdef __cplusplus extern "C" { #endif +#if @GNULIB_FCHMODAT@ +# if !@HAVE_FCHMODAT@ +extern int fchmodat (int fd, char const *file, mode_t mode, int flag) + _GL_ARG_NONNULL ((2)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fchmodat +# define fchmodat(d,n,m,f) \ + (GL_LINK_WARNING ("fchmodat is not portable - " \ + "use gnulib module openat for portability"), \ + fchmodat (d, n, m, f)) +#endif + + +#if @REPLACE_FSTAT@ +# define fstat rpl_fstat +extern int fstat (int fd, struct stat *buf) _GL_ARG_NONNULL ((2)); +#endif + + +#if @GNULIB_FSTATAT@ +# if @REPLACE_FSTATAT@ +# undef fstatat +# define fstatat rpl_fstatat +# endif +# if !@HAVE_FSTATAT@ || @REPLACE_FSTATAT@ +extern int fstatat (int fd, char const *name, struct stat *st, int flags) + _GL_ARG_NONNULL ((2, 3)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fstatat +# define fstatat(d,n,s,f) \ + (GL_LINK_WARNING ("fstatat is not portable - " \ + "use gnulib module openat for portability"), \ + fstatat (d, n, s, f)) +#endif + + +#if @GNULIB_FUTIMENS@ +# if @REPLACE_FUTIMENS@ +# undef futimens +# define futimens rpl_futimens +# endif +# if !@HAVE_FUTIMENS@ || @REPLACE_FUTIMENS@ +extern int futimens (int fd, struct timespec const times[2]); +# endif +#elif defined GNULIB_POSIXCHECK +# undef futimens +# define futimens(f,t) \ + (GL_LINK_WARNING ("futimens is not portable - " \ + "use gnulib module futimens for portability"), \ + futimens (f, t)) +#endif + + +#if @GNULIB_LCHMOD@ +/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME + denotes a symbolic link. */ +# if !@HAVE_LCHMOD@ +/* The lchmod replacement follows symbolic links. Callers should take + this into account; lchmod should be applied only to arguments that + are known to not be symbolic links. On hosts that lack lchmod, + this can lead to race conditions between the check and the + invocation of lchmod, but we know of no workarounds that are + reliable in general. You might try requesting support for lchmod + from your operating system supplier. */ +# define lchmod chmod +# endif +# if 0 /* assume already declared */ +extern int lchmod (const char *filename, mode_t mode) _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef lchmod +# define lchmod(f,m) \ + (GL_LINK_WARNING ("lchmod is unportable - " \ + "use gnulib module lchmod for portability"), \ + lchmod (f, m)) +#endif + + #if @GNULIB_LSTAT@ # if ! @HAVE_LSTAT@ /* mingw does not support symlinks, therefore it does not have lstat. But @@ -295,92 +386,22 @@ extern "C" { # elif @REPLACE_LSTAT@ # undef lstat # define lstat rpl_lstat -extern int rpl_lstat (const char *name, struct stat *buf); +extern int rpl_lstat (const char *name, struct stat *buf) + _GL_ARG_NONNULL ((1, 2)); # endif #elif defined GNULIB_POSIXCHECK # undef lstat -# define lstat(p,b) \ - (GL_LINK_WARNING ("lstat is unportable - " \ - "use gnulib module lstat for portability"), \ +# define lstat(p,b) \ + (GL_LINK_WARNING ("lstat is unportable - " \ + "use gnulib module lstat for portability"), \ lstat (p, b)) #endif -#if @GNULIB_FCHMODAT@ -# if !@HAVE_FCHMODAT@ -extern int fchmodat (int fd, char const *file, mode_t mode, int flag); -# endif -#elif defined GNULIB_POSIXCHECK -# undef fchmodat -# define fchmodat(d,n,m,f) \ - (GL_LINK_WARNING ("fchmodat is not portable - " \ - "use gnulib module openat for portability"), \ - fchmodat (d, n, m, f)) -#endif - - -#if @GNULIB_FSTATAT@ -# if @REPLACE_FSTATAT@ -# undef fstatat -# define fstatat rpl_fstatat -# endif -# if !@HAVE_FSTATAT@ || @REPLACE_FSTATAT@ -extern int fstatat (int fd, char const *name, struct stat *st, int flags); -# endif -#elif defined GNULIB_POSIXCHECK -# undef fstatat -# define fstatat(d,n,s,f) \ - (GL_LINK_WARNING ("fstatat is not portable - " \ - "use gnulib module openat for portability"), \ - fstatat (d, n, s, f)) -#endif - - -#if @GNULIB_MKDIRAT@ -# if !@HAVE_MKDIRAT@ -extern int mkdirat (int fd, char const *file, mode_t mode); -# endif -#elif defined GNULIB_POSIXCHECK -# undef mkdirat -# define mkdirat(d,n,m) \ - (GL_LINK_WARNING ("mkdirat is not portable - " \ - "use gnulib module openat for portability"), \ - mkdirat (d, n, m)) -#endif - -#if @GNULIB_MKFIFOAT@ -# if !@HAVE_MKFIFOAT@ -int mkfifoat (int fd, char const *file, mode_t mode); -# endif -#elif defined GNULIB_POSIXCHECK -# undef mkfifoat -# define mkfifoat(d,n,m) \ - (GL_LINK_WARNING ("mkfifoat is not portable - " \ - "use gnulib module mkfifoat for portability"), \ - mkfifoat (d, n, m)) -#endif - -#if @GNULIB_MKNODAT@ -# if !@HAVE_MKNODAT@ -int mknodat (int fd, char const *file, mode_t mode, dev_t dev); -# endif -#elif defined GNULIB_POSIXCHECK -# undef mknodat -# define mknodat(f,n,m,d) \ - (GL_LINK_WARNING ("mknodat is not portable - " \ - "use gnulib module mkfifoat for portability"), \ - mknodat (f, n, m, d)) -#endif - -#if @REPLACE_FCHDIR@ -# define fstat rpl_fstat -extern int fstat (int fd, struct stat *buf); -#endif - #if @REPLACE_MKDIR@ # undef mkdir # define mkdir rpl_mkdir -extern int mkdir (char const *name, mode_t mode); +extern int mkdir (char const *name, mode_t mode) _GL_ARG_NONNULL ((1)); #else /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments. Additionally, it declares _mkdir (and depending on compile flags, an @@ -398,30 +419,125 @@ rpl_mkdir (char const *name, mode_t mode) #endif -/* Declare BSD extensions. */ - -#if @GNULIB_LCHMOD@ -/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME - denotes a symbolic link. */ -# if !@HAVE_LCHMOD@ -/* The lchmod replacement follows symbolic links. Callers should take - this into account; lchmod should be applied only to arguments that - are known to not be symbolic links. On hosts that lack lchmod, - this can lead to race conditions between the check and the - invocation of lchmod, but we know of no workarounds that are - reliable in general. You might try requesting support for lchmod - from your operating system supplier. */ -# define lchmod chmod -# endif -# if 0 /* assume already declared */ -extern int lchmod (const char *filename, mode_t mode); +#if @GNULIB_MKDIRAT@ +# if !@HAVE_MKDIRAT@ +extern int mkdirat (int fd, char const *file, mode_t mode) + _GL_ARG_NONNULL ((2)); # endif #elif defined GNULIB_POSIXCHECK -# undef lchmod -# define lchmod(f,m) \ - (GL_LINK_WARNING ("lchmod is unportable - " \ - "use gnulib module lchmod for portability"), \ - lchmod (f, m)) +# undef mkdirat +# define mkdirat(d,n,m) \ + (GL_LINK_WARNING ("mkdirat is not portable - " \ + "use gnulib module openat for portability"), \ + mkdirat (d, n, m)) +#endif + + +#if @GNULIB_MKFIFO@ +# if @REPLACE_MKFIFO@ +# undef mkfifo +# define mkfifo rpl_mkfifo +# endif +# if !@HAVE_MKFIFO@ || @REPLACE_MKFIFO@ +extern int mkfifo (char const *file, mode_t mode) _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mkfifo +# define mkfifo(n,m) \ + (GL_LINK_WARNING ("mkfifo is not portable - " \ + "use gnulib module mkfifo for portability"), \ + mkfifo (n, m)) +#endif + + +#if @GNULIB_MKFIFOAT@ +# if !@HAVE_MKFIFOAT@ +extern int mkfifoat (int fd, char const *file, mode_t mode) + _GL_ARG_NONNULL ((2)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mkfifoat +# define mkfifoat(d,n,m) \ + (GL_LINK_WARNING ("mkfifoat is not portable - " \ + "use gnulib module mkfifoat for portability"), \ + mkfifoat (d, n, m)) +#endif + + +#if @GNULIB_MKNOD@ +# if @REPLACE_MKNOD@ +# undef mknod +# define mknod rpl_mknod +# endif +# if !@HAVE_MKNOD@ || @REPLACE_MKNOD@ +extern int mknod (char const *file, mode_t mode, dev_t dev) + _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mknod +# define mknod(n,m,d) \ + (GL_LINK_WARNING ("mknod is not portable - " \ + "use gnulib module mknod for portability"), \ + mknod (n, m, d)) +#endif + + +#if @GNULIB_MKNODAT@ +# if !@HAVE_MKNODAT@ +extern int mknodat (int fd, char const *file, mode_t mode, dev_t dev) + _GL_ARG_NONNULL ((2)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mknodat +# define mknodat(f,n,m,d) \ + (GL_LINK_WARNING ("mknodat is not portable - " \ + "use gnulib module mkfifoat for portability"), \ + mknodat (f, n, m, d)) +#endif + + +#if @GNULIB_STAT@ +# if @REPLACE_STAT@ +/* We can't use the object-like #define stat rpl_stat, because of + struct stat. This means that rpl_stat will not be used if the user + does (stat)(a,b). Oh well. */ +# undef stat +# ifdef _LARGE_FILES + /* With _LARGE_FILES defined, AIX (only) defines stat to stat64, + so we have to replace stat64() instead of stat(). */ +# define stat stat64 +# undef stat64 +# define stat64(name, st) rpl_stat (name, st) +# else /* !_LARGE_FILES */ +# define stat(name, st) rpl_stat (name, st) +# endif /* !_LARGE_FILES */ +extern int stat (const char *name, struct stat *buf) _GL_ARG_NONNULL ((1, 2)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef stat +# define stat(p,b) \ + (GL_LINK_WARNING ("stat is unportable - " \ + "use gnulib module stat for portability"), \ + stat (p, b)) +#endif + + +#if @GNULIB_UTIMENSAT@ +# if @REPLACE_UTIMENSAT@ +# undef utimensat +# define utimensat rpl_utimensat +# endif +# if !@HAVE_UTIMENSAT@ || @REPLACE_UTIMENSAT@ + extern int utimensat (int fd, char const *name, + struct timespec const times[2], int flag) + _GL_ARG_NONNULL ((2)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef utimensat +# define utimensat(d,n,t,f) \ + (GL_LINK_WARNING ("utimensat is not portable - " \ + "use gnulib module utimensat for portability"), \ + utimensat (d, n, t, f)) #endif diff --git a/src/bin/coreutils/lib/sys_time.in.h b/src/bin/coreutils/lib/sys_time.in.h index 520cfec692..7901871340 100644 --- a/src/bin/coreutils/lib/sys_time.in.h +++ b/src/bin/coreutils/lib/sys_time.in.h @@ -3,7 +3,7 @@ #line 1 /* Provide a more complete sys/time.h. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -42,6 +42,8 @@ # include # endif +/* The definition of _GL_ARG_NONNULL is copied here. */ + #ifdef __cplusplus extern "C" { #endif @@ -57,7 +59,8 @@ struct timeval # if @REPLACE_GETTIMEOFDAY@ # undef gettimeofday # define gettimeofday rpl_gettimeofday -int gettimeofday (struct timeval *restrict, void *restrict); +extern int gettimeofday (struct timeval *restrict, void *restrict) + _GL_ARG_NONNULL ((1)); # endif #ifdef __cplusplus diff --git a/src/bin/coreutils/lib/sys_utsname.in.h b/src/bin/coreutils/lib/sys_utsname.in.h new file mode 100644 index 0000000000..4716eff5cd --- /dev/null +++ b/src/bin/coreutils/lib/sys_utsname.in.h @@ -0,0 +1,99 @@ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +#line 1 +/* Substitute for . + Copyright (C) 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef _GL_SYS_UTSNAME_H + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif + +#if @HAVE_SYS_UTSNAME_H@ +# @INCLUDE_NEXT@ @NEXT_SYS_UTSNAME_H@ +#endif + +#define _GL_SYS_UTSNAME_H + +/* The definition of GL_LINK_WARNING is copied here. */ + +/* The definition of _GL_ARG_NONNULL is copied here. */ + + +#ifdef __cplusplus +extern "C" { +#endif + +#if !@HAVE_STRUCT_UTSNAME@ +/* Length of the entries in 'struct utsname' is 256. */ +# define _UTSNAME_LENGTH 256 + +# ifndef _UTSNAME_NODENAME_LENGTH +# define _UTSNAME_NODENAME_LENGTH _UTSNAME_LENGTH +# endif +# ifndef _UTSNAME_SYSNAME_LENGTH +# define _UTSNAME_SYSNAME_LENGTH _UTSNAME_LENGTH +# endif +# ifndef _UTSNAME_RELEASE_LENGTH +# define _UTSNAME_RELEASE_LENGTH _UTSNAME_LENGTH +# endif +# ifndef _UTSNAME_VERSION_LENGTH +# define _UTSNAME_VERSION_LENGTH _UTSNAME_LENGTH +# endif +# ifndef _UTSNAME_MACHINE_LENGTH +# define _UTSNAME_MACHINE_LENGTH _UTSNAME_LENGTH +# endif + +/* Structure describing the system and machine. */ +struct utsname + { + /* Name of this node on the network. */ + char nodename[_UTSNAME_NODENAME_LENGTH]; + + /* Name of the implementation of the operating system. */ + char sysname[_UTSNAME_SYSNAME_LENGTH]; + /* Current release level of this implementation. */ + char release[_UTSNAME_RELEASE_LENGTH]; + /* Current version level of this release. */ + char version[_UTSNAME_VERSION_LENGTH]; + + /* Name of the hardware type the system is running on. */ + char machine[_UTSNAME_MACHINE_LENGTH]; + }; +#endif /* !@HAVE_STRUCT_UTSNAME@ */ + + +#if @GNULIB_UNAME@ +# if !@HAVE_UNAME@ +extern int uname (struct utsname *buf) _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef uname +# define uname(b) \ + (GL_LINK_WARNING ("uname is unportable - " \ + "use gnulib module uname for portability"), \ + uname (b)) +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif /* _GL_SYS_UTSNAME_H */ diff --git a/src/bin/coreutils/lib/tempname.c b/src/bin/coreutils/lib/tempname.c index 01715168d6..3403181e43 100644 --- a/src/bin/coreutils/lib/tempname.c +++ b/src/bin/coreutils/lib/tempname.c @@ -1,8 +1,9 @@ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +#line 1 /* tempname.c - generate the name of a temporary file. - Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2009 Free Software Foundation, - Inc. + Copyright (C) 1991-2003, 2005-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -41,10 +42,13 @@ # define TMP_MAX 238328 #endif #ifndef __GT_FILE -# define __GT_FILE 0 -# define __GT_BIGFILE 1 -# define __GT_DIR 2 -# define __GT_NOCREATE 3 +# define __GT_FILE 0 +# define __GT_DIR 1 +# define __GT_NOCREATE 2 +#endif +#if !_LIBC && (GT_FILE != __GT_FILE || GT_DIR != __GT_DIR \ + || GT_NOCREATE != __GT_NOCREATE) +# error report this to bug-gnulib@gnu.org #endif #include @@ -61,16 +65,14 @@ #if _LIBC # define struct_stat64 struct stat64 -# define small_open __open -# define large_open __open64 #else # define struct_stat64 struct stat -# define small_open open -# define large_open open # define __gen_tempname gen_tempname # define __getpid getpid # define __gettimeofday gettimeofday # define __mkdir mkdir +# define __open open +# define __open64 open # define __lxstat64(version, file, buf) lstat (file, buf) # define __xstat64(version, file, buf) stat (file, buf) #endif @@ -79,6 +81,34 @@ # define __secure_getenv getenv #endif +#ifdef _LIBC +# include +# if HP_TIMING_AVAIL +# define RANDOM_BITS(Var) \ + if (__builtin_expect (value == UINT64_C (0), 0)) \ + { \ + /* If this is the first time this function is used initialize \ + the variable we accumulate the value in to some somewhat \ + random value. If we'd not do this programs at startup time \ + might have a reduced set of possible names, at least on slow \ + machines. */ \ + struct timeval tv; \ + __gettimeofday (&tv, NULL); \ + value = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec; \ + } \ + HP_TIMING_NOW (Var) +# endif +#endif + +/* Use the widest available unsigned type if uint64_t is not + available. The algorithm below extracts a number less than 62**6 + (approximately 2**35.725) from uint64_t, so ancient hosts where + uintmax_t is only 32 bits lose about 3.725 bits of randomness, + which is better than not having mkstemp at all. */ +#if !defined UINT64_MAX && !defined uint64_t +# define uint64_t uintmax_t +#endif + #if _LIBC /* Return nonzero if DIR is an existent directory. */ static int @@ -138,7 +168,7 @@ __path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx, dlen = strlen (dir); while (dlen > 1 && dir[dlen - 1] == '/') - dlen--; /* remove trailing slashes */ + dlen--; /* remove trailing slashes */ /* check we have room for "${dir}/${pfx}XXXXXX\0" */ if (tmpl_len < dlen + 1 + plen + 6 + 1) @@ -155,29 +185,30 @@ __path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx, static inline bool check_x_suffix (char const *s, size_t len) { - return strspn (s, "X") == len; + return len <= strspn (s, "X"); } /* These are the characters used in temporary file names. */ static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; -/* Generate a temporary file name based on TMPL. TMPL must end in a - a sequence of at least X_SUFFIX_LEN "X"s. The name constructed - does not exist at the time of the call to __gen_tempname. TMPL is - overwritten with the result. +/* Generate a temporary file name based on TMPL. TMPL must match the + rules for mk[s]temp (i.e. end in at least X_SUFFIX_LEN "X"s, + possibly with a suffix). + The name constructed does not exist at the time of the call to + this function. TMPL is overwritten with the result. KIND may be one of: - __GT_NOCREATE: simply verify that the name does not exist + __GT_NOCREATE: simply verify that the name does not exist at the time of the call. - __GT_FILE: create the file using open(O_CREAT|O_EXCL) + __GT_FILE: create the file using open(O_CREAT|O_EXCL) and return a read-write fd. The file is mode 0600. - __GT_BIGFILE: same as __GT_FILE but use open64(). - __GT_DIR: create a directory, which will be mode 0700. + __GT_DIR: create a directory, which will be mode 0700. We use a clever algorithm to get hard-to-predict names. */ int -gen_tempname_len (char *tmpl, int kind, size_t x_suffix_len) +gen_tempname_len (char *tmpl, int suffixlen, int flags, int kind, + size_t x_suffix_len) { size_t len; char *XXXXXX; @@ -192,7 +223,8 @@ gen_tempname_len (char *tmpl, int kind, size_t x_suffix_len) can exist for a given template is 62**6. It should never be necessary to try all these combinations. Instead if a reasonable number of names is tried (we define reasonable as 62**3) fail to - give the system administrator the chance to remove the problems. */ + give the system administrator the chance to remove the problems. + This value requires that X_SUFFIX_LEN be at least 3. */ #define ATTEMPTS_MIN (62 * 62 * 62) /* The number of times to attempt to generate a temporary file. To @@ -204,37 +236,35 @@ gen_tempname_len (char *tmpl, int kind, size_t x_suffix_len) #endif len = strlen (tmpl); - if (len < x_suffix_len || ! check_x_suffix (&tmpl[len - x_suffix_len], - x_suffix_len)) + if (len < x_suffix_len + suffixlen + || ! check_x_suffix (&tmpl[len - x_suffix_len - suffixlen], + x_suffix_len)) { __set_errno (EINVAL); return -1; } + /* This is where the Xs start. */ + XXXXXX = &tmpl[len - x_suffix_len - suffixlen]; + + /* Get some more or less random data. */ rand_src = randint_all_new (NULL, 8); if (! rand_src) return -1; - /* This is where the Xs start. */ - XXXXXX = &tmpl[len - x_suffix_len]; - for (count = 0; count < attempts; ++count) { size_t i; for (i = 0; i < x_suffix_len; i++) - { - XXXXXX[i] = letters[randint_genmax (rand_src, sizeof letters - 2)]; - } + XXXXXX[i] = letters[randint_genmax (rand_src, sizeof letters - 2)]; switch (kind) { case __GT_FILE: - fd = small_open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); - break; - - case __GT_BIGFILE: - fd = large_open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); + fd = __open (tmpl, + (flags & ~O_ACCMODE) + | O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); break; case __GT_DIR: @@ -265,6 +295,7 @@ gen_tempname_len (char *tmpl, int kind, size_t x_suffix_len) default: assert (! "invalid KIND in __gen_tempname"); + abort (); } if (fd >= 0) @@ -295,7 +326,7 @@ gen_tempname_len (char *tmpl, int kind, size_t x_suffix_len) } int -__gen_tempname (char *tmpl, int kind) +__gen_tempname (char *tmpl, int suffixlen, int flags, int kind) { - return gen_tempname_len (tmpl, kind, 6); + return gen_tempname_len (tmpl, suffixlen, flags, kind, 6); } diff --git a/src/bin/coreutils/lib/tempname.h b/src/bin/coreutils/lib/tempname.h index ee34aca219..2c1f385b3a 100644 --- a/src/bin/coreutils/lib/tempname.h +++ b/src/bin/coreutils/lib/tempname.h @@ -1,6 +1,9 @@ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +#line 1 /* Create a temporary file or directory. - Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,25 +20,36 @@ /* header written by Eric Blake */ -/* In gnulib, always prefer large files. GT_FILE maps to - __GT_BIGFILE, not __GT_FILE, for a reason. */ -#define GT_FILE 1 -#define GT_DIR 2 -#define GT_NOCREATE 3 +#ifndef GL_TEMPNAME_H +# define GL_TEMPNAME_H + +# include + +# ifdef __GT_FILE +# define GT_FILE __GT_FILE +# define GT_DIR __GT_DIR +# define GT_NOCREATE __GT_NOCREATE +# else +# define GT_FILE 0 +# define GT_DIR 1 +# define GT_NOCREATE 2 +# endif /* Generate a temporary file name based on TMPL. TMPL must match the - rules for mk[s]temp (i.e. end in "XXXXXX"). The name constructed - does not exist at the time of the call to gen_tempname. TMPL is - overwritten with the result. + rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix). + The name constructed does not exist at the time of the call to + gen_tempname. TMPL is overwritten with the result. KIND may be one of: - GT_NOCREATE: simply verify that the name does not exist + GT_NOCREATE: simply verify that the name does not exist at the time of the call. - GT_FILE: create a large file using open(O_CREAT|O_EXCL) + GT_FILE: create a large file using open(O_CREAT|O_EXCL) and return a read-write fd. The file is mode 0600. - GT_DIR: create a directory, which will be mode 0700. + GT_DIR: create a directory, which will be mode 0700. We use a clever algorithm to get hard-to-predict names. */ -#include -extern int gen_tempname (char *tmpl, int kind); -extern int gen_tempname_len (char *tmpl, int kind, size_t x_suffix_len); +extern int gen_tempname (char *tmpl, int suffixlen, int flags, int kind); +extern int gen_tempname_len (char *tmpl, int suffixlen, int flags, int kind, + size_t x_suffix_len); + +#endif /* GL_TEMPNAME_H */ diff --git a/src/bin/coreutils/lib/time.h b/src/bin/coreutils/lib/time.h new file mode 100644 index 0000000000..8a92c339f0 --- /dev/null +++ b/src/bin/coreutils/lib/time.h @@ -0,0 +1,148 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +#line 1 +/* A more-standard . + + Copyright (C) 2007-2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#if __GNUC__ >= 3 +#pragma GCC system_header +#endif + +/* Don't get in the way of glibc when it includes time.h merely to + declare a few standard symbols, rather than to declare all the + symbols. Also, Solaris 8 eventually includes itself + recursively; if that is happening, just include the system + without adding our own declarations. */ +#if (defined __need_time_t || defined __need_clock_t \ + || defined __need_timespec \ + || defined _GL_TIME_H) + +# include_next + +#else + +# define _GL_TIME_H + +# include_next + +/* NetBSD 5.0 mis-defines NULL. */ +#include + +/* The definition of _GL_ARG_NONNULL is copied here. */ +/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools + that the values passed as arguments n, ..., m must be non-NULL pointers. + n = 1 stands for the first argument, n = 2 for the second argument etc. */ +#ifndef _GL_ARG_NONNULL +# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 +# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) +# else +# define _GL_ARG_NONNULL(params) +# endif +#endif + +# ifdef __cplusplus +extern "C" { +# endif + +/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3). + Or they define it with the wrong member names or define it in + (e.g., FreeBSD circa 1997). */ +# if ! 1 +# if 0 +# include +# else +# undef timespec +# define timespec rpl_timespec +struct timespec +{ + time_t tv_sec; + long int tv_nsec; +}; +# endif +# endif + +/* Sleep for at least RQTP seconds unless interrupted, If interrupted, + return -1 and store the remaining time into RMTP. See + . */ +# if 0 +# define nanosleep rpl_nanosleep +extern int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp) + _GL_ARG_NONNULL ((1)); +# endif + +/* Return the 'time_t' representation of TP and normalize TP. */ +# if 0 +# define mktime rpl_mktime +extern time_t mktime (struct tm *__tp) _GL_ARG_NONNULL ((1)); +# endif + +/* Convert TIMER to RESULT, assuming local time and UTC respectively. See + and + . */ +# if 0 +# undef localtime_r +# define localtime_r rpl_localtime_r +# undef gmtime_r +# define gmtime_r rpl_gmtime_r +extern struct tm *localtime_r (time_t const *restrict __timer, + struct tm *restrict __result) + _GL_ARG_NONNULL ((1, 2)); +extern struct tm *gmtime_r (time_t const *restrict __timer, + struct tm *restrict __result) + _GL_ARG_NONNULL ((1, 2)); +# endif + +/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store + the resulting broken-down time into TM. See + . */ +# if GNULIB_PORTCHECK +# undef strptime +# define strptime rpl_strptime +extern char *strptime (char const *restrict __buf, + char const *restrict __format, + struct tm *restrict __tm) + _GL_ARG_NONNULL ((1, 2, 3)); +# endif + +/* Convert TM to a time_t value, assuming UTC. */ +# if GNULIB_PORTCHECK +# undef timegm +# define timegm rpl_timegm +extern time_t timegm (struct tm *__tm) _GL_ARG_NONNULL ((1)); +# endif + +/* Encourage applications to avoid unsafe functions that can overrun + buffers when given outlandish struct tm values. Portable + applications should use strftime (or even sprintf) instead. */ +# if GNULIB_PORTCHECK +# undef asctime +# define asctime eschew_asctime +# undef asctime_r +# define asctime_r eschew_asctime_r +# undef ctime +# define ctime eschew_ctime +# undef ctime_r +# define ctime_r eschew_ctime_r +# endif + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/src/bin/coreutils/lib/time.in.h b/src/bin/coreutils/lib/time.in.h index 4336593f93..63f08bfd1d 100644 --- a/src/bin/coreutils/lib/time.in.h +++ b/src/bin/coreutils/lib/time.in.h @@ -3,7 +3,7 @@ #line 1 /* A more-standard . - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -43,6 +43,8 @@ /* NetBSD 5.0 mis-defines NULL. */ #include +/* The definition of _GL_ARG_NONNULL is copied here. */ + # ifdef __cplusplus extern "C" { # endif @@ -69,13 +71,14 @@ struct timespec . */ # if @REPLACE_NANOSLEEP@ # define nanosleep rpl_nanosleep -int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp); +extern int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp) + _GL_ARG_NONNULL ((1)); # endif /* Return the 'time_t' representation of TP and normalize TP. */ # if @REPLACE_MKTIME@ # define mktime rpl_mktime -extern time_t mktime (struct tm *__tp); +extern time_t mktime (struct tm *__tp) _GL_ARG_NONNULL ((1)); # endif /* Convert TIMER to RESULT, assuming local time and UTC respectively. See @@ -86,10 +89,12 @@ extern time_t mktime (struct tm *__tp); # define localtime_r rpl_localtime_r # undef gmtime_r # define gmtime_r rpl_gmtime_r -struct tm *localtime_r (time_t const *restrict __timer, - struct tm *restrict __result); -struct tm *gmtime_r (time_t const *restrict __timer, - struct tm *restrict __result); +extern struct tm *localtime_r (time_t const *restrict __timer, + struct tm *restrict __result) + _GL_ARG_NONNULL ((1, 2)); +extern struct tm *gmtime_r (time_t const *restrict __timer, + struct tm *restrict __result) + _GL_ARG_NONNULL ((1, 2)); # endif /* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store @@ -98,15 +103,17 @@ struct tm *gmtime_r (time_t const *restrict __timer, # if @REPLACE_STRPTIME@ # undef strptime # define strptime rpl_strptime -char *strptime (char const *restrict __buf, char const *restrict __format, - struct tm *restrict __tm); +extern char *strptime (char const *restrict __buf, + char const *restrict __format, + struct tm *restrict __tm) + _GL_ARG_NONNULL ((1, 2, 3)); # endif /* Convert TM to a time_t value, assuming UTC. */ # if @REPLACE_TIMEGM@ # undef timegm # define timegm rpl_timegm -time_t timegm (struct tm *__tm); +extern time_t timegm (struct tm *__tm) _GL_ARG_NONNULL ((1)); # endif /* Encourage applications to avoid unsafe functions that can overrun diff --git a/src/bin/coreutils/lib/time_r.c b/src/bin/coreutils/lib/time_r.c index 91f368950b..9039350544 100644 --- a/src/bin/coreutils/lib/time_r.c +++ b/src/bin/coreutils/lib/time_r.c @@ -3,7 +3,7 @@ #line 1 /* Reentrant time functions like localtime_r. - Copyright (C) 2003, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2003, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/timespec.h b/src/bin/coreutils/lib/timespec.h index 3f51db8e4d..81b342300e 100644 --- a/src/bin/coreutils/lib/timespec.h +++ b/src/bin/coreutils/lib/timespec.h @@ -1,6 +1,7 @@ /* timespec -- System time interface - Copyright (C) 2000, 2002, 2004, 2005, 2007 Free Software Foundation, Inc. + Copyright (C) 2000, 2002, 2004-2005, 2007, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,8 +27,10 @@ static inline int timespec_cmp (struct timespec a, struct timespec b) { return (a.tv_sec < b.tv_sec ? -1 - : a.tv_sec > b.tv_sec ? 1 - : a.tv_nsec - b.tv_nsec); + : a.tv_sec > b.tv_sec ? 1 + : a.tv_nsec < b.tv_nsec ? -1 + : a.tv_nsec > b.tv_nsec ? 1 + : 0); } void gettime (struct timespec *); diff --git a/src/bin/coreutils/lib/trim.c b/src/bin/coreutils/lib/trim.c index 452d8bc740..62f8ebffe5 100644 --- a/src/bin/coreutils/lib/trim.c +++ b/src/bin/coreutils/lib/trim.c @@ -1,5 +1,5 @@ /* Removes leading and/or trailing whitespaces - Copyright (C) 2006-2008 Free Software Foundation, Inc. + Copyright (C) 2006-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -53,61 +53,61 @@ trim2(const char *s, int how) /* Trim leading whitespaces. */ if (how != TRIM_TRAILING) - { - mbi_init (i, d, strlen (d)); + { + mbi_init (i, d, strlen (d)); - for (; mbi_avail (i) && mb_isspace (mbi_cur (i)); mbi_advance (i)) - ; + for (; mbi_avail (i) && mb_isspace (mbi_cur (i)); mbi_advance (i)) + ; - memmove (d, mbi_cur_ptr (i), strlen (mbi_cur_ptr (i)) + 1); - } + memmove (d, mbi_cur_ptr (i), strlen (mbi_cur_ptr (i)) + 1); + } /* Trim trailing whitespaces. */ if (how != TRIM_LEADING) - { - int state = 0; - char *r IF_LINT (= NULL); /* used only while state = 2 */ + { + int state = 0; + char *r IF_LINT (= NULL); /* used only while state = 2 */ - mbi_init (i, d, strlen (d)); + mbi_init (i, d, strlen (d)); - for (; mbi_avail (i); mbi_advance (i)) - { - if (state == 0 && mb_isspace (mbi_cur (i))) - { - state = 0; - continue; - } + for (; mbi_avail (i); mbi_advance (i)) + { + if (state == 0 && mb_isspace (mbi_cur (i))) + { + state = 0; + continue; + } - if (state == 0 && !mb_isspace (mbi_cur (i))) - { - state = 1; - continue; - } + if (state == 0 && !mb_isspace (mbi_cur (i))) + { + state = 1; + continue; + } - if (state == 1 && !mb_isspace (mbi_cur (i))) - { - state = 1; - continue; - } + if (state == 1 && !mb_isspace (mbi_cur (i))) + { + state = 1; + continue; + } - if (state == 1 && mb_isspace (mbi_cur (i))) - { - state = 2; - r = (char *) mbi_cur_ptr (i); - } - else if (state == 2 && mb_isspace (mbi_cur (i))) - { - state = 2; - } - else - { - state = 1; - } - } + if (state == 1 && mb_isspace (mbi_cur (i))) + { + state = 2; + r = (char *) mbi_cur_ptr (i); + } + else if (state == 2 && mb_isspace (mbi_cur (i))) + { + state = 2; + } + else + { + state = 1; + } + } - if (state == 2) - *r = '\0'; - } + if (state == 2) + *r = '\0'; + } } else { @@ -115,16 +115,16 @@ trim2(const char *s, int how) /* Trim leading whitespaces. */ if (how != TRIM_TRAILING) { - for (p = d; *p && isspace ((unsigned char) *p); p++) - ; + for (p = d; *p && isspace ((unsigned char) *p); p++) + ; - memmove (d, p, strlen (p) + 1); + memmove (d, p, strlen (p) + 1); } /* Trim trailing whitespaces. */ if (how != TRIM_LEADING) { - for (p = d + strlen (d) - 1; p >= d && isspace ((unsigned char) *p); p--) - *p = '\0'; + for (p = d + strlen (d) - 1; p >= d && isspace ((unsigned char) *p); p--) + *p = '\0'; } } diff --git a/src/bin/coreutils/lib/trim.h b/src/bin/coreutils/lib/trim.h index ae5708b58a..61880c1f60 100644 --- a/src/bin/coreutils/lib/trim.h +++ b/src/bin/coreutils/lib/trim.h @@ -1,5 +1,5 @@ /* Removes leading and/or trailing whitespaces - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/u64.h b/src/bin/coreutils/lib/u64.h index 34fd32be02..0d35c55428 100644 --- a/src/bin/coreutils/lib/u64.h +++ b/src/bin/coreutils/lib/u64.h @@ -1,6 +1,6 @@ /* uint64_t-like operations that work even on hosts lacking uint64_t - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/uinttostr.c b/src/bin/coreutils/lib/uinttostr.c index 52d288e44e..1662985f40 100644 --- a/src/bin/coreutils/lib/uinttostr.c +++ b/src/bin/coreutils/lib/uinttostr.c @@ -1,3 +1,4 @@ #define inttostr uinttostr #define inttype unsigned int +#define inttype_is_signed 0 #include "inttostr.c" diff --git a/src/bin/coreutils/lib/umaxtostr.c b/src/bin/coreutils/lib/umaxtostr.c index 4f49a7f8dd..914f388d1b 100644 --- a/src/bin/coreutils/lib/umaxtostr.c +++ b/src/bin/coreutils/lib/umaxtostr.c @@ -1,3 +1,4 @@ #define inttostr umaxtostr #define inttype uintmax_t +#define inttype_is_signed 0 #include "inttostr.c" diff --git a/src/bin/coreutils/lib/uname.c b/src/bin/coreutils/lib/uname.c new file mode 100644 index 0000000000..9b6614126d --- /dev/null +++ b/src/bin/coreutils/lib/uname.c @@ -0,0 +1,268 @@ +/* uname replacement. + Copyright (C) 2009, 2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +/* This file provides an implementation only for the native Windows API. */ +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ + +#include +#include +#include +#include +#include + +/* Mingw headers don't have all the platform codes. */ +#ifndef VER_PLATFORM_WIN32_CE +# define VER_PLATFORM_WIN32_CE 3 +#endif + +/* Some headers don't have all the processor architecture codes. */ +#ifndef PROCESSOR_ARCHITECTURE_AMD64 +# define PROCESSOR_ARCHITECTURE_AMD64 9 +#endif +#ifndef PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 +# define PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 10 +#endif + +/* Mingw headers don't have the latest processor codes. */ +#ifndef PROCESSOR_AMD_X8664 +# define PROCESSOR_AMD_X8664 8664 +#endif + +int +uname (struct utsname *buf) +{ + OSVERSIONINFO version; + OSVERSIONINFOEX versionex; + BOOL have_versionex; /* indicates whether versionex is filled */ + const char *super_version; + + /* Preparation: Fill version and, if possible, also versionex. + But try to call GetVersionEx only once in the common case. */ + versionex.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX); + have_versionex = GetVersionEx ((OSVERSIONINFO *) &versionex); + if (have_versionex) + { + /* We know that OSVERSIONINFO is a subset of OSVERSIONINFOEX. */ + memcpy (&version, &versionex, sizeof (OSVERSIONINFO)); + } + else + { + version.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); + if (!GetVersionEx (&version)) + abort (); + } + + /* Fill in nodename. */ + if (gethostname (buf->nodename, sizeof (buf->nodename)) < 0) + strcpy (buf->nodename, "localhost"); + + /* Determine major-major Windows version. */ + if (version.dwPlatformId == VER_PLATFORM_WIN32_NT) + { + /* Windows NT or newer. */ + super_version = "NT"; + } + else if (version.dwPlatformId == VER_PLATFORM_WIN32_CE) + { + /* Windows CE or Embedded CE. */ + super_version = "CE"; + } + else if (version.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) + { + /* Windows 95/98/ME. */ + switch (version.dwMinorVersion) + { + case 0: + super_version = "95"; + break; + case 10: + super_version = "98"; + break; + case 90: + super_version = "ME"; + break; + default: + super_version = ""; + break; + } + } + else + super_version = ""; + + /* Fill in sysname. */ +#ifdef __MINGW32__ + /* Returns a string compatible with the MSYS uname.exe program, + so that no further changes are needed to GNU config.guess. + For example, + $ ./uname.exe -s => MINGW32_NT-5.1 + */ + sprintf (buf->sysname, "MINGW32_%s-%u.%u", super_version, + (unsigned int) version.dwMajorVersion, + (unsigned int) version.dwMinorVersion); +#else + sprintf (buf->sysname, "Windows%s", super_version); +#endif + + /* Fill in release, version. */ + /* The MSYS uname.exe programs uses strings from a modified Cygwin runtime: + $ ./uname.exe -r => 1.0.11(0.46/3/2) + $ ./uname.exe -v => 2008-08-25 23:40 + There is no point in imitating this behaviour. */ + if (version.dwPlatformId == VER_PLATFORM_WIN32_NT) + { + /* Windows NT or newer. */ + struct windows_version + { + int major; + int minor; + unsigned int server_offset; + const char *name; + }; + + /* Storing the workstation and server version names in a single + stream does not waste memory when they are the same. These + macros abstract the representation. VERSION1 is used if + version.wProductType does not matter, VERSION2 if it does. */ + #define VERSION1(major, minor, name) \ + { major, minor, 0, name } + #define VERSION2(major, minor, workstation, server) \ + { major, minor, sizeof workstation, workstation "\0" server } + static const struct windows_version versions[] = + { + VERSION2 (3, -1, "Windows NT Workstation", "Windows NT Server"), + VERSION2 (4, -1, "Windows NT Workstation", "Windows NT Server"), + VERSION1 (5, 0, "Windows 2000"), + VERSION1 (5, 1, "Windows XP"), + VERSION1 (5, 2, "Windows Server 2003"), + VERSION2 (6, 0, "Windows Vista", "Windows Server 2008"), + VERSION2 (6, 1, "Windows 7", "Windows Server 2008 R2"), + VERSION2 (-1, -1, "Windows", "Windows Server") + }; + const char *base; + const struct windows_version *v = versions; + + /* Find a version that matches ours. The last element is a + wildcard that always ends the loop. */ + while ((v->major != version.dwMajorVersion && v->major != -1) + || (v->minor != version.dwMinorVersion && v->minor != -1)) + v++; + + if (have_versionex && versionex.wProductType != VER_NT_WORKSTATION) + base = v->name + v->server_offset; + else + base = v->name; + if (v->major == -1 || v->minor == -1) + sprintf (buf->release, "%s %u.%u", + base, + (unsigned int) version.dwMajorVersion, + (unsigned int) version.dwMinorVersion); + else + strcpy (buf->release, base); + } + else if (version.dwPlatformId == VER_PLATFORM_WIN32_CE) + { + /* Windows CE or Embedded CE. */ + sprintf (buf->release, "Windows CE %u.%u", + (unsigned int) version.dwMajorVersion, + (unsigned int) version.dwMinorVersion); + } + else + { + /* Windows 95/98/ME. */ + sprintf (buf->release, "Windows %s", super_version); + } + strcpy (buf->version, version.szCSDVersion); + + /* Fill in machine. */ + { + SYSTEM_INFO info; + + GetSystemInfo (&info); + /* Check for Windows NT or CE, since the info.wProcessorLevel is + garbage on Windows 95. */ + if (version.dwPlatformId == VER_PLATFORM_WIN32_NT + || version.dwPlatformId == VER_PLATFORM_WIN32_CE) + { + /* Windows NT or newer, or Windows CE or Embedded CE. */ + switch (info.wProcessorArchitecture) + { + case PROCESSOR_ARCHITECTURE_AMD64: + strcpy (buf->machine, "x86_64"); + break; + case PROCESSOR_ARCHITECTURE_IA64: + strcpy (buf->machine, "ia64"); + break; + case PROCESSOR_ARCHITECTURE_INTEL: + strcpy (buf->machine, "i386"); + if (info.wProcessorLevel >= 3) + buf->machine[1] = + '0' + (info.wProcessorLevel <= 6 ? info.wProcessorLevel : 6); + break; + case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64: + strcpy (buf->machine, "i686"); + break; + case PROCESSOR_ARCHITECTURE_MIPS: + strcpy (buf->machine, "mips"); + break; + case PROCESSOR_ARCHITECTURE_ALPHA: + case PROCESSOR_ARCHITECTURE_ALPHA64: + strcpy (buf->machine, "alpha"); + break; + case PROCESSOR_ARCHITECTURE_PPC: + strcpy (buf->machine, "powerpc"); + break; + case PROCESSOR_ARCHITECTURE_SHX: + strcpy (buf->machine, "sh"); + break; + case PROCESSOR_ARCHITECTURE_ARM: + strcpy (buf->machine, "arm"); + break; + default: + strcpy (buf->machine, "unknown"); + break; + } + } + else + { + /* Windows 95/98/ME. */ + switch (info.dwProcessorType) + { + case PROCESSOR_AMD_X8664: + strcpy (buf->machine, "x86_64"); + break; + case PROCESSOR_INTEL_IA64: + strcpy (buf->machine, "ia64"); + break; + default: + if (info.dwProcessorType % 100 == 86) + sprintf (buf->machine, "i%u", + (unsigned int) info.dwProcessorType); + else + strcpy (buf->machine, "unknown"); + break; + } + } + } + + return 0; +} + +#endif diff --git a/src/bin/coreutils/lib/unicodeio.c b/src/bin/coreutils/lib/unicodeio.c index 781621c6f2..6f1f61d215 100644 --- a/src/bin/coreutils/lib/unicodeio.c +++ b/src/bin/coreutils/lib/unicodeio.c @@ -1,6 +1,6 @@ /* Unicode character output to streams with locale dependent encoding. - Copyright (C) 2000-2003, 2006, 2008 Free Software Foundation, Inc. + Copyright (C) 2000-2003, 2006, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -38,6 +38,7 @@ #include "localcharset.h" #include "unistr.h" +#include "ignore-value.h" /* When we pass a Unicode character to iconv(), we must pass it in a suitable encoding. The standardized Unicode encodings are @@ -62,11 +63,11 @@ Assumes that the locale doesn't change between two calls. */ long unicode_to_mb (unsigned int code, - long (*success) (const char *buf, size_t buflen, - void *callback_arg), - long (*failure) (unsigned int code, const char *msg, - void *callback_arg), - void *callback_arg) + long (*success) (const char *buf, size_t buflen, + void *callback_arg), + long (*failure) (unsigned int code, const char *msg, + void *callback_arg), + void *callback_arg) { static int initialized; static int is_utf8; @@ -84,12 +85,12 @@ unicode_to_mb (unsigned int code, is_utf8 = !strcmp (charset, UTF8_NAME); #if HAVE_ICONV if (!is_utf8) - { - utf8_to_local = iconv_open (charset, UTF8_NAME); - if (utf8_to_local == (iconv_t)(-1)) - /* For an unknown encoding, assume ASCII. */ - utf8_to_local = iconv_open ("ASCII", UTF8_NAME); - } + { + utf8_to_local = iconv_open (charset, UTF8_NAME); + if (utf8_to_local == (iconv_t)(-1)) + /* For an unknown encoding, assume ASCII. */ + utf8_to_local = iconv_open ("ASCII", UTF8_NAME); + } #endif initialized = 1; } @@ -99,7 +100,7 @@ unicode_to_mb (unsigned int code, { #if HAVE_ICONV if (utf8_to_local == (iconv_t)(-1)) - return failure (code, N_("iconv function not usable"), callback_arg); + return failure (code, N_("iconv function not usable"), callback_arg); #else return failure (code, N_("iconv function not available"), callback_arg); #endif @@ -127,15 +128,15 @@ unicode_to_mb (unsigned int code, /* Convert the character from UTF-8 to the locale's charset. */ res = iconv (utf8_to_local, - (ICONV_CONST char **)&inptr, &inbytesleft, - &outptr, &outbytesleft); + (ICONV_CONST char **)&inptr, &inbytesleft, + &outptr, &outbytesleft); if (inbytesleft > 0 || res == (size_t)(-1) - /* Irix iconv() inserts a NUL byte if it cannot convert. */ + /* Irix iconv() inserts a NUL byte if it cannot convert. */ # if !defined _LIBICONV_VERSION && (defined sgi || defined __sgi) - || (res > 0 && code != 0 && outptr - outbuf == 1 && *outbuf == '\0') + || (res > 0 && code != 0 && outptr - outbuf == 1 && *outbuf == '\0') # endif ) - return failure (code, NULL, callback_arg); + return failure (code, NULL, callback_arg); /* Avoid glibc-2.1 bug and Solaris 7 bug. */ # if defined _LIBICONV_VERSION \ @@ -144,7 +145,7 @@ unicode_to_mb (unsigned int code, /* Get back to the initial shift state. */ res = iconv (utf8_to_local, NULL, NULL, &outptr, &outbytesleft); if (res == (size_t)(-1)) - return failure (code, NULL, callback_arg); + return failure (code, NULL, callback_arg); # endif return success (outbuf, outptr - outbuf, callback_arg); @@ -162,20 +163,24 @@ fwrite_success_callback (const char *buf, size_t buflen, void *callback_arg) { FILE *stream = (FILE *) callback_arg; - fwrite (buf, 1, buflen, stream); + /* The return value of fwrite can be ignored here, because under normal + conditions (STREAM is an open stream and not wide-character oriented) + when fwrite() returns a value != buflen it also sets STREAM's error + indicator. */ + ignore_value (fwrite (buf, 1, buflen, stream)); return 0; } /* Simple failure callback that displays an error and exits. */ static long exit_failure_callback (unsigned int code, const char *msg, - void *callback_arg _UNUSED_PARAMETER_) + void *callback_arg _GL_UNUSED) { if (msg == NULL) error (1, 0, _("cannot convert U+%04X to local character set"), code); else error (1, 0, _("cannot convert U+%04X to local character set: %s"), code, - gettext (msg)); + gettext (msg)); return -1; } @@ -183,8 +188,8 @@ exit_failure_callback (unsigned int code, const char *msg, ASCII, using the same notation as ISO C99 strings. */ static long fallback_failure_callback (unsigned int code, - const char *msg _UNUSED_PARAMETER_, - void *callback_arg) + const char *msg _GL_UNUSED, + void *callback_arg) { FILE *stream = (FILE *) callback_arg; @@ -202,8 +207,8 @@ void print_unicode_char (FILE *stream, unsigned int code, int exit_on_error) { unicode_to_mb (code, fwrite_success_callback, - exit_on_error - ? exit_failure_callback - : fallback_failure_callback, - stream); + exit_on_error + ? exit_failure_callback + : fallback_failure_callback, + stream); } diff --git a/src/bin/coreutils/lib/unicodeio.h b/src/bin/coreutils/lib/unicodeio.h index 5a3400ddf0..3dd52cf065 100644 --- a/src/bin/coreutils/lib/unicodeio.h +++ b/src/bin/coreutils/lib/unicodeio.h @@ -1,6 +1,6 @@ /* Unicode character output to streams with locale dependent encoding. - Copyright (C) 2000-2003, 2005, 2008 Free Software Foundation, Inc. + Copyright (C) 2000-2003, 2005, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,21 +28,21 @@ Returns whatever the callback returned. Assumes that the locale doesn't change between two calls. */ extern long unicode_to_mb (unsigned int code, - long (*success) (const char *buf, size_t buflen, - void *callback_arg), - long (*failure) (unsigned int code, const char *msg, - void *callback_arg), - void *callback_arg); + long (*success) (const char *buf, size_t buflen, + void *callback_arg), + long (*failure) (unsigned int code, const char *msg, + void *callback_arg), + void *callback_arg); /* Outputs the Unicode character CODE to the output stream STREAM. Upon failure, exit if exit_on_error is true, otherwise output a fallback notation. */ extern void print_unicode_char (FILE *stream, unsigned int code, - int exit_on_error); + int exit_on_error); /* Simple success callback that outputs the converted string. The STREAM is passed as callback_arg. */ extern long fwrite_success_callback (const char *buf, size_t buflen, - void *callback_arg); + void *callback_arg); #endif diff --git a/src/bin/coreutils/lib/unistd--.h b/src/bin/coreutils/lib/unistd--.h index 1a7fd785b0..5283d2c573 100644 --- a/src/bin/coreutils/lib/unistd--.h +++ b/src/bin/coreutils/lib/unistd--.h @@ -1,6 +1,6 @@ /* Like unistd.h, but redefine some names to avoid glitches. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,3 +25,8 @@ #undef pipe #define pipe pipe_safer + +#if GNULIB_PIPE2_SAFER +# undef pipe2 +# define pipe2 pipe2_safer +#endif diff --git a/src/bin/coreutils/lib/unistd-safer.h b/src/bin/coreutils/lib/unistd-safer.h index 033e857d7a..190f108624 100644 --- a/src/bin/coreutils/lib/unistd-safer.h +++ b/src/bin/coreutils/lib/unistd-safer.h @@ -1,6 +1,6 @@ /* Invoke unistd-like functions, but avoid some glitches. - Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. + Copyright (C) 2001, 2003, 2005, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,8 +15,17 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -/* Written by Paul Eggert. */ +/* Written by Paul Eggert and Eric Blake. */ int dup_safer (int); int fd_safer (int); int pipe_safer (int[2]); + +#if GNULIB_FD_SAFER_FLAG +int dup_safer_flag (int, int); +int fd_safer_flag (int, int); +#endif + +#if GNULIB_PIPE2_SAFER +int pipe2_safer (int[2], int); +#endif diff --git a/src/bin/coreutils/lib/unistd.in.h b/src/bin/coreutils/lib/unistd.in.h index 151d16c5d5..e8984dd411 100644 --- a/src/bin/coreutils/lib/unistd.in.h +++ b/src/bin/coreutils/lib/unistd.in.h @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Substitute for and wrapper around . - Copyright (C) 2003-2009 Free Software Foundation, Inc. + Copyright (C) 2003-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -36,21 +36,43 @@ #include /* mingw doesn't define the SEEK_* or *_FILENO macros in . */ -#if !(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) +/* Cygwin 1.7.1 declares symlinkat in , not in . */ +/* But avoid namespace pollution on glibc systems. */ +#if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \ + || (@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK)) \ + && ! defined __GLIBC__ # include #endif +/* Cygwin 1.7.1 declares unlinkat in , not in . */ +/* But avoid namespace pollution on glibc systems. */ +#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ +# include +#endif + /* mingw fails to declare _exit in . */ /* mingw, BeOS, Haiku declare environ in , not in . */ -#include +/* Solaris declares getcwd not only in but also in . */ +/* But avoid namespace pollution on glibc systems. */ +#ifndef __GLIBC__ +# include +#endif -#if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@ +/* mingw declares getcwd in , not in . */ +#if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \ + && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) +# include +#endif + +#if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \ + || @GNULIB_PREAD@ || defined GNULIB_POSIXCHECK) /* Get ssize_t. */ # include #endif -/* Get getopt(), optarg, optind, opterr, optopt. */ -#if @GNULIB_UNISTD_H_GETOPT@ +/* Get getopt(), optarg, optind, opterr, optopt. + But avoid namespace pollution on glibc systems. */ +#if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT # include #endif @@ -60,43 +82,47 @@ # include # if !defined _GL_SYS_SOCKET_H # undef socket -# define socket socket_used_without_including_sys_socket_h +# define socket socket_used_without_including_sys_socket_h # undef connect -# define connect connect_used_without_including_sys_socket_h +# define connect connect_used_without_including_sys_socket_h # undef accept -# define accept accept_used_without_including_sys_socket_h +# define accept accept_used_without_including_sys_socket_h # undef bind -# define bind bind_used_without_including_sys_socket_h +# define bind bind_used_without_including_sys_socket_h # undef getpeername -# define getpeername getpeername_used_without_including_sys_socket_h +# define getpeername getpeername_used_without_including_sys_socket_h # undef getsockname -# define getsockname getsockname_used_without_including_sys_socket_h +# define getsockname getsockname_used_without_including_sys_socket_h # undef getsockopt -# define getsockopt getsockopt_used_without_including_sys_socket_h +# define getsockopt getsockopt_used_without_including_sys_socket_h # undef listen -# define listen listen_used_without_including_sys_socket_h +# define listen listen_used_without_including_sys_socket_h # undef recv -# define recv recv_used_without_including_sys_socket_h +# define recv recv_used_without_including_sys_socket_h # undef send -# define send send_used_without_including_sys_socket_h +# define send send_used_without_including_sys_socket_h # undef recvfrom -# define recvfrom recvfrom_used_without_including_sys_socket_h +# define recvfrom recvfrom_used_without_including_sys_socket_h # undef sendto -# define sendto sendto_used_without_including_sys_socket_h +# define sendto sendto_used_without_including_sys_socket_h # undef setsockopt -# define setsockopt setsockopt_used_without_including_sys_socket_h +# define setsockopt setsockopt_used_without_including_sys_socket_h # undef shutdown -# define shutdown shutdown_used_without_including_sys_socket_h +# define shutdown shutdown_used_without_including_sys_socket_h # endif # if !defined _GL_SYS_SELECT_H # undef select -# define select select_used_without_including_sys_select_h +# define select select_used_without_including_sys_select_h # endif # endif #endif /* The definition of GL_LINK_WARNING is copied here. */ +/* The definition of _GL_ARG_NONNULL is copied here. */ + +/* The definition of _GL_WARN_ON_USE is copied here. */ + /* OS/2 EMX lacks these macros. */ #ifndef STDIN_FILENO @@ -109,7 +135,7 @@ # define STDERR_FILENO 2 #endif -/* Ensure *_OK functions exist. */ +/* Ensure *_OK macros exist. */ #ifndef F_OK # define F_OK 0 # define X_OK 1 @@ -127,18 +153,17 @@ extern "C" { #if @GNULIB_CHOWN@ # if @REPLACE_CHOWN@ -# ifndef REPLACE_CHOWN -# define REPLACE_CHOWN 1 -# endif -# if REPLACE_CHOWN +# undef chown +# define chown rpl_chown +# endif +# if !@HAVE_CHOWN@ || @REPLACE_CHOWN@ /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE to GID (if GID is not -1). Follow symbolic links. Return 0 if successful, otherwise -1 and errno set. See the POSIX:2001 specification . */ -# define chown rpl_chown -extern int chown (const char *file, uid_t uid, gid_t gid); -# endif +extern int chown (const char *file, uid_t uid, gid_t gid) + _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef chown @@ -150,72 +175,6 @@ extern int chown (const char *file, uid_t uid, gid_t gid); #endif -#if @GNULIB_FCHOWNAT@ -# if @REPLACE_FCHOWNAT@ -# undef fchownat -# define fchownat rpl_fchownat -# endif -# if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@ -extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag); -# endif -#elif defined GNULIB_POSIXCHECK -# undef fchownat -# define fchownat(d,n,o,g,f) \ - (GL_LINK_WARNING ("fchownat is not portable - " \ - "use gnulib module openat for portability"), \ - fchownat (d, n, o, g, f)) -#endif - - -#if @GNULIB_UNLINKAT@ -# if !@HAVE_UNLINKAT@ -extern int unlinkat (int fd, char const *file, int flag); -# endif -#elif defined GNULIB_POSIXCHECK -# undef unlinkat -# define unlinkat(d,n,f) \ - (GL_LINK_WARNING ("unlinkat is not portable - " \ - "use gnulib module openat for portability"), \ - unlinkat (d, n, f)) -#endif - - -#if @GNULIB_FACCESSAT@ -# if !@HAVE_FACCESSAT@ -int faccessat (int fd, char const *file, int mode, int flag); -# endif -#elif defined GNULIB_POSIXCHECK -# undef faccessat -# define faccessat(d,n,m,f) \ - (GL_LINK_WARNING ("faccessat is not portable - " \ - "use gnulib module faccessat for portability"), \ - faccessat (d, n, m, f)) -#endif - -#if @GNULIB_SYMLINKAT@ -# if !@HAVE_SYMLINKAT@ -int symlinkat (char const *contents, int fd, char const *file); -# endif -#elif defined GNULIB_POSIXCHECK -# undef symlinkat -# define symlinkat(c,d,n) \ - (GL_LINK_WARNING ("symlinkat is not portable - " \ - "use gnulib module symlinkat for portability"), \ - symlinkat (c, d, n)) -#endif - -#if @GNULIB_READLINKAT@ -# if !@HAVE_READLINKAT@ -ssize_t readlinkat (int fd, char const *file, char *buf, size_t len); -# endif -#elif defined GNULIB_POSIXCHECK -# undef readlinkat -# define readlinkat(d,n,b,l) \ - (GL_LINK_WARNING ("readlinkat is not portable - " \ - "use gnulib module symlinkat for portability"), \ - readlinkat (d, n, b, l)) -#endif - #if @GNULIB_CLOSE@ # if @REPLACE_CLOSE@ /* Automatically included by modules that need a replacement for close. */ @@ -235,6 +194,12 @@ extern int close (int); #endif +#if @REPLACE_DUP@ +# define dup rpl_dup +extern int dup (int); +#endif + + #if @GNULIB_DUP2@ # if @REPLACE_DUP2@ # define dup2 rpl_dup2 @@ -290,19 +255,25 @@ extern char **environ; # endif # endif #elif defined GNULIB_POSIXCHECK -# undef environ -# define environ \ - (GL_LINK_WARNING ("environ is unportable - " \ - "use gnulib module environ for portability"), \ - environ) +# if HAVE_RAW_DECL_ENVIRON +static inline char *** +rpl_environ (void) +{ + return &environ; +} +_GL_WARN_ON_USE (rpl_environ, "environ is unportable - " + "use gnulib module environ for portability"); +# undef environ +# define environ (*rpl_environ ()) +# endif #endif #if @GNULIB_EUIDACCESS@ # if !@HAVE_EUIDACCESS@ -/* Like access(), except that is uses the effective user id and group id of +/* Like access(), except that it uses the effective user id and group id of the current process. */ -extern int euidaccess (const char *filename, int mode); +extern int euidaccess (const char *filename, int mode) _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef euidaccess @@ -313,9 +284,22 @@ extern int euidaccess (const char *filename, int mode); #endif +#if @GNULIB_FACCESSAT@ +# if !@HAVE_FACCESSAT@ +extern int faccessat (int fd, char const *file, int mode, int flag) + _GL_ARG_NONNULL ((2)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef faccessat +# define faccessat(d,n,m,f) \ + (GL_LINK_WARNING ("faccessat is not portable - " \ + "use gnulib module faccessat for portability"), \ + faccessat (d, n, m, f)) +#endif + + #if @GNULIB_FCHDIR@ # if @REPLACE_FCHDIR@ - /* Change the process' current working directory to the directory on which the given file descriptor is open. Return 0 if successful, otherwise -1 and errno set. @@ -323,11 +307,9 @@ extern int euidaccess (const char *filename, int mode); . */ extern int fchdir (int /*fd*/); -# define dup rpl_dup -extern int dup (int); - /* Gnulib internal hooks needed to maintain the fchdir metadata. */ -extern int _gl_register_fd (int fd, const char *filename); +extern int _gl_register_fd (int fd, const char *filename) + _GL_ARG_NONNULL ((2)); extern void _gl_unregister_fd (int fd); extern int _gl_register_dup (int oldfd, int newfd); extern const char *_gl_directory_name (int fd); @@ -342,6 +324,24 @@ extern const char *_gl_directory_name (int fd); #endif +#if @GNULIB_FCHOWNAT@ +# if @REPLACE_FCHOWNAT@ +# undef fchownat +# define fchownat rpl_fchownat +# endif +# if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@ +extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag) + _GL_ARG_NONNULL ((2)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fchownat +# define fchownat(d,n,o,g,f) \ + (GL_LINK_WARNING ("fchownat is not portable - " \ + "use gnulib module openat for portability"), \ + fchownat (d, n, o, g, f)) +#endif + + #if @GNULIB_FSYNC@ /* Synchronize changes to a file. Return 0 if successful, otherwise -1 and errno set. @@ -377,9 +377,6 @@ extern int ftruncate (int fd, off_t length); #if @GNULIB_GETCWD@ -/* Include the headers that might declare getcwd so that they will not - cause confusion if included after this file. */ -# include # if @REPLACE_GETCWD@ /* Get the name of the current working directory, and put it in SIZE bytes of BUF. @@ -415,7 +412,7 @@ extern char * getcwd (char *buf, size_t size); If the NIS domain name is longer than LEN, set errno = EINVAL and return -1. Return 0 if successful, otherwise set errno and return -1. */ # if !@HAVE_GETDOMAINNAME@ -extern int getdomainname(char *name, size_t len); +extern int getdomainname(char *name, size_t len) _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef getdomainname @@ -441,6 +438,28 @@ extern int getdtablesize (void); #endif +#if @GNULIB_GETGROUPS@ +# if @REPLACE_GETGROUPS@ +# undef getgroups +# define getgroups rpl_getgroups +# endif +# if !@HAVE_GETGROUPS@ || @REPLACE_GETGROUPS@ +/* Return the supplemental groups that the current process belongs to. + It is unspecified whether the effective group id is in the list. + If N is 0, return the group count; otherwise, N describes how many + entries are available in GROUPS. Return -1 and set errno if N is + not 0 and not large enough. Fails with ENOSYS on some systems. */ +int getgroups (int n, gid_t *groups); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getgroups +# define getgroups(n,g) \ + (GL_LINK_WARNING ("getgroups is unportable - " \ + "use gnulib module getgroups for portability"), \ + getgroups (n, g)) +#endif + + #if @GNULIB_GETHOSTNAME@ /* Return the standard host name of the machine. WARNING! The host name may or may not be fully qualified. @@ -454,7 +473,7 @@ extern int getdtablesize (void); # define gethostname rpl_gethostname # endif # if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@ -extern int gethostname(char *name, size_t len); +extern int gethostname(char *name, size_t len) _GL_ARG_NONNULL ((1)); # endif #elif @UNISTD_H_HAVE_WINSOCK2_H@ # undef gethostname @@ -468,6 +487,29 @@ extern int gethostname(char *name, size_t len); #endif +#if @GNULIB_GETLOGIN@ +/* Returns the user's login name, or NULL if it cannot be found. Upon error, + returns NULL with errno set. + + See . + + Most programs don't need to use this function, because the information is + available through environment variables: + ${LOGNAME-$USER} on Unix platforms, + $USERNAME on native Windows platforms. + */ +# if !@HAVE_GETLOGIN@ +extern char *getlogin (void); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getlogin +# define getlogin() \ + (GL_LINK_WARNING ("getlogin is unportable - " \ + "use gnulib module getlogin for portability"), \ + getlogin ()) +#endif + + #if @GNULIB_GETLOGIN_R@ /* Copies the user's login name to NAME. The array pointed to by NAME has room for SIZE bytes. @@ -477,9 +519,14 @@ extern int gethostname(char *name, size_t len); provided (this case is hopefully rare but is left open by the POSIX spec). See . + + Most programs don't need to use this function, because the information is + available through environment variables: + ${LOGNAME-$USER} on Unix platforms, + $USERNAME on native Windows platforms. */ # if !@HAVE_DECL_GETLOGIN_R@ -extern int getlogin_r (char *name, size_t size); +extern int getlogin_r (char *name, size_t size) _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef getlogin_r @@ -580,13 +627,17 @@ extern void endusershell (void); #if @GNULIB_LCHOWN@ # if @REPLACE_LCHOWN@ +# undef lchown +# define lchown rpl_lchown +# endif +# if !@HAVE_LCHOWN@ || @REPLACE_LCHOWN@ /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE to GID (if GID is not -1). Do not follow symbolic links. Return 0 if successful, otherwise -1 and errno set. See the POSIX:2001 specification . */ -# define lchown rpl_lchown -extern int lchown (char const *file, uid_t owner, gid_t group); +extern int lchown (char const *file, uid_t owner, gid_t group) + _GL_ARG_NONNULL ((1)); # endif #elif defined GNULIB_POSIXCHECK # undef lchown @@ -606,7 +657,8 @@ extern int lchown (char const *file, uid_t owner, gid_t group); See POSIX:2001 specification . */ # if !@HAVE_LINK@ || @REPLACE_LINK@ -extern int link (const char *path1, const char *path2); +extern int link (const char *path1, const char *path2) + _GL_ARG_NONNULL ((1, 2)); # endif #elif defined GNULIB_POSIXCHECK # undef link @@ -616,6 +668,26 @@ extern int link (const char *path1, const char *path2); link (path1, path2)) #endif +#if @GNULIB_LINKAT@ +# if @REPLACE_LINKAT@ +# undef linkat +# define linkat rpl_linkat +# endif +/* Create a new hard link for an existing file, relative to two + directories. FLAG controls whether symlinks are followed. + Return 0 if successful, otherwise -1 and errno set. */ +# if !@HAVE_LINKAT@ || @REPLACE_LINKAT@ +extern int linkat (int fd1, const char *path1, int fd2, const char *path2, + int flag) + _GL_ARG_NONNULL ((2, 4)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef linkat +# define linkat(f1,path1,f2,path2,f) \ + (GL_LINK_WARNING ("linkat is unportable - " \ + "use gnulib module linkat for portability"), \ + linkat (f1, path1, f2, path2,f)) +#endif #if @GNULIB_LSEEK@ # if @REPLACE_LSEEK@ @@ -647,7 +719,7 @@ extern int link (const char *path1, const char *path2); # if @HAVE_PIPE2@ # define pipe2 rpl_pipe2 # endif -extern int pipe2 (int fd[2], int flags); +extern int pipe2 (int fd[2], int flags) _GL_ARG_NONNULL ((1)); #elif defined GNULIB_POSIXCHECK # undef pipe2 # define pipe2(f,o) \ @@ -657,14 +729,39 @@ extern int pipe2 (int fd[2], int flags); #endif +#if @GNULIB_PREAD@ +# if @REPLACE_PREAD@ +# define pread rpl_pread +# endif +/* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET. + Return the number of bytes placed into BUF if successful, otherwise + set errno and return -1. 0 indicates EOF. See the POSIX:2001 + specification . */ +# if !@HAVE_PREAD@ || @REPLACE_PREAD@ + extern ssize_t pread (int fd, void *buf, size_t bufsize, off_t offset) + _GL_ARG_NONNULL ((2)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef pread +# define pread(f,b,s,o) \ + (GL_LINK_WARNING ("pread is unportable - " \ + "use gnulib module pread for portability"), \ + pread (f, b, s, o)) +#endif + + #if @GNULIB_READLINK@ +# if @REPLACE_READLINK@ +# define readlink rpl_readlink +# endif /* Read the contents of the symbolic link FILE and place the first BUFSIZE bytes of it into BUF. Return the number of bytes placed into BUF if successful, otherwise -1 and errno set. See the POSIX:2001 specification . */ -# if !@HAVE_READLINK@ -extern int readlink (const char *file, char *buf, size_t bufsize); +# if !@HAVE_READLINK@ || @REPLACE_READLINK@ +extern ssize_t readlink (const char *file, char *buf, size_t bufsize) + _GL_ARG_NONNULL ((1, 2)); # endif #elif defined GNULIB_POSIXCHECK # undef readlink @@ -675,12 +772,45 @@ extern int readlink (const char *file, char *buf, size_t bufsize); #endif +#if @GNULIB_READLINKAT@ +# if !@HAVE_READLINKAT@ +extern ssize_t readlinkat (int fd, char const *file, char *buf, size_t len) + _GL_ARG_NONNULL ((2, 3)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef readlinkat +# define readlinkat(d,n,b,l) \ + (GL_LINK_WARNING ("readlinkat is not portable - " \ + "use gnulib module symlinkat for portability"), \ + readlinkat (d, n, b, l)) +#endif + + +#if @GNULIB_RMDIR@ +# if @REPLACE_RMDIR@ +# define rmdir rpl_rmdir +/* Remove the directory DIR. */ +extern int rmdir (char const *name) _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef rmdir +# define rmdir(n) \ + (GL_LINK_WARNING ("rmdir is unportable - " \ + "use gnulib module rmdir for portability"), \ + rmdir (n)) +#endif + + #if @GNULIB_SLEEP@ +# if @REPLACE_SLEEP@ +# undef sleep +# define sleep rpl_sleep +# endif /* Pause the execution of the current thread for N seconds. Returns the number of seconds left to sleep. See the POSIX:2001 specification . */ -# if !@HAVE_SLEEP@ +# if !@HAVE_SLEEP@ || @REPLACE_SLEEP@ extern unsigned int sleep (unsigned int n); # endif #elif defined GNULIB_POSIXCHECK @@ -692,13 +822,99 @@ extern unsigned int sleep (unsigned int n); #endif +#if @GNULIB_SYMLINK@ +# if @REPLACE_SYMLINK@ +# undef symlink +# define symlink rpl_symlink +# endif +# if !@HAVE_SYMLINK@ || @REPLACE_SYMLINK@ +extern int symlink (char const *contents, char const *file) + _GL_ARG_NONNULL ((1, 2)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef symlink +# define symlink(c,n) \ + (GL_LINK_WARNING ("symlink is not portable - " \ + "use gnulib module symlink for portability"), \ + symlink (c, n)) +#endif + + +#if @GNULIB_SYMLINKAT@ +# if !@HAVE_SYMLINKAT@ +extern int symlinkat (char const *contents, int fd, char const *file) + _GL_ARG_NONNULL ((1, 3)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef symlinkat +# define symlinkat(c,d,n) \ + (GL_LINK_WARNING ("symlinkat is not portable - " \ + "use gnulib module symlinkat for portability"), \ + symlinkat (c, d, n)) +#endif + + +#if @GNULIB_UNLINK@ +# if @REPLACE_UNLINK@ +# undef unlink +# define unlink rpl_unlink +extern int unlink (char const *file) _GL_ARG_NONNULL ((1)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef unlink +# define unlink(n) \ + (GL_LINK_WARNING ("unlink is not portable - " \ + "use gnulib module unlink for portability"), \ + unlink (n)) +#endif + + +#if @GNULIB_UNLINKAT@ +# if @REPLACE_UNLINKAT@ +# undef unlinkat +# define unlinkat rpl_unlinkat +# endif +# if !@HAVE_UNLINKAT@ || @REPLACE_UNLINKAT@ +extern int unlinkat (int fd, char const *file, int flag) _GL_ARG_NONNULL ((2)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef unlinkat +# define unlinkat(d,n,f) \ + (GL_LINK_WARNING ("unlinkat is not portable - " \ + "use gnulib module openat for portability"), \ + unlinkat (d, n, f)) +#endif + + +#if @GNULIB_USLEEP@ +# if @REPLACE_USLEEP@ +# undef usleep +# define usleep rpl_usleep +# endif +# if !@HAVE_USLEEP@ || @REPLACE_USLEEP@ +/* Pause the execution of the current thread for N microseconds. + Returns 0 on completion, or -1 on range error. + See the POSIX:2001 specification + . */ +extern int usleep (useconds_t n); +# endif +#elif defined GNULIB_POSIXCHECK +# undef usleep +# define usleep(n) \ + (GL_LINK_WARNING ("usleep is unportable - " \ + "use gnulib module usleep for portability"), \ + usleep (n)) +#endif + + #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@ /* Write up to COUNT bytes starting at BUF to file descriptor FD. See the POSIX:2001 specification . */ # undef write # define write rpl_write -extern ssize_t write (int fd, const void *buf, size_t count); +extern ssize_t write (int fd, const void *buf, size_t count) + _GL_ARG_NONNULL ((2)); #endif diff --git a/src/bin/coreutils/lib/unistr.h b/src/bin/coreutils/lib/unistr.h index f2e1af1e84..e1f7007939 100644 --- a/src/bin/coreutils/lib/unistr.h +++ b/src/bin/coreutils/lib/unistr.h @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Elementary Unicode string functions. - Copyright (C) 2001-2002, 2005-2009 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2005-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -22,6 +22,9 @@ #include "unitypes.h" +/* Get common macros for C. */ +#include "unused-parameter.h" + /* Get bool. */ #include @@ -84,32 +87,32 @@ extern const uint32_t * /* Convert an UTF-8 string to an UTF-16 string. */ extern uint16_t * u8_to_u16 (const uint8_t *s, size_t n, uint16_t *resultbuf, - size_t *lengthp); + size_t *lengthp); /* Convert an UTF-8 string to an UCS-4 string. */ extern uint32_t * u8_to_u32 (const uint8_t *s, size_t n, uint32_t *resultbuf, - size_t *lengthp); + size_t *lengthp); /* Convert an UTF-16 string to an UTF-8 string. */ extern uint8_t * u16_to_u8 (const uint16_t *s, size_t n, uint8_t *resultbuf, - size_t *lengthp); + size_t *lengthp); /* Convert an UTF-16 string to an UCS-4 string. */ extern uint32_t * u16_to_u32 (const uint16_t *s, size_t n, uint32_t *resultbuf, - size_t *lengthp); + size_t *lengthp); /* Convert an UCS-4 string to an UTF-8 string. */ extern uint8_t * u32_to_u8 (const uint32_t *s, size_t n, uint8_t *resultbuf, - size_t *lengthp); + size_t *lengthp); /* Convert an UCS-4 string to an UTF-16 string. */ extern uint16_t * u32_to_u16 (const uint32_t *s, size_t n, uint16_t *resultbuf, - size_t *lengthp); + size_t *lengthp); /* Elementary string functions. */ @@ -186,7 +189,8 @@ extern int u32_mbtouc_unsafe (ucs4_t *puc, const uint32_t *s, size_t n); # else static inline int -u32_mbtouc_unsafe (ucs4_t *puc, const uint32_t *s, size_t n _UNUSED_PARAMETER_) +u32_mbtouc_unsafe (ucs4_t *puc, + const uint32_t *s, size_t n _GL_UNUSED_PARAMETER) { uint32_t c = *s; @@ -256,7 +260,7 @@ extern int u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n); # else static inline int -u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n _UNUSED_PARAMETER_) +u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n _GL_UNUSED_PARAMETER) { uint32_t c = *s; @@ -354,12 +358,12 @@ u32_uctomb (uint32_t *s, ucs4_t uc, int n) if (uc < 0xd800 || (uc >= 0xe000 && uc < 0x110000)) { if (n > 0) - { - *s = uc; - return 1; - } + { + *s = uc; + return 1; + } else - return -2; + return -2; } else return -1; @@ -528,8 +532,8 @@ extern uint16_t * extern uint32_t * u32_strncpy (uint32_t *dest, const uint32_t *src, size_t n); -/* Copy no more than N units of SRC to DEST, returning the address of - the last unit written into DEST. */ +/* Copy no more than N units of SRC to DEST. Return a pointer past the last + non-NUL unit written into DEST. */ /* Similar to stpncpy(). */ extern uint8_t * u8_stpncpy (uint8_t *dest, const uint8_t *src, size_t n); diff --git a/src/bin/coreutils/lib/unistr/u8-uctomb-aux.c b/src/bin/coreutils/lib/unistr/u8-uctomb-aux.c index 7fee7f66f1..6501892264 100644 --- a/src/bin/coreutils/lib/unistr/u8-uctomb-aux.c +++ b/src/bin/coreutils/lib/unistr/u8-uctomb-aux.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Conversion UCS-4 to UTF-8. - Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible , 2002. This program is free software: you can redistribute it and/or modify it @@ -36,9 +36,9 @@ u8_uctomb_aux (uint8_t *s, ucs4_t uc, int n) else if (uc < 0x10000) { if (uc < 0xd800 || uc >= 0xe000) - count = 3; + count = 3; else - return -1; + return -1; } #if 0 else if (uc < 0x200000) diff --git a/src/bin/coreutils/lib/unistr/u8-uctomb.c b/src/bin/coreutils/lib/unistr/u8-uctomb.c index a1d2ef4b3c..3fa3af3c0f 100644 --- a/src/bin/coreutils/lib/unistr/u8-uctomb.c +++ b/src/bin/coreutils/lib/unistr/u8-uctomb.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Store a character in UTF-8 string. - Copyright (C) 2002, 2005-2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2002, 2005-2006, 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible , 2002. This program is free software: you can redistribute it and/or modify it @@ -36,10 +36,10 @@ u8_uctomb (uint8_t *s, ucs4_t uc, int n) if (uc < 0x80) { if (n > 0) - { - s[0] = uc; - return 1; - } + { + s[0] = uc; + return 1; + } /* else return -2, below. */ } else @@ -47,43 +47,43 @@ u8_uctomb (uint8_t *s, ucs4_t uc, int n) int count; if (uc < 0x800) - count = 2; + count = 2; else if (uc < 0x10000) - { - if (uc < 0xd800 || uc >= 0xe000) - count = 3; - else - return -1; - } + { + if (uc < 0xd800 || uc >= 0xe000) + count = 3; + else + return -1; + } #if 0 else if (uc < 0x200000) - count = 4; + count = 4; else if (uc < 0x4000000) - count = 5; + count = 5; else if (uc <= 0x7fffffff) - count = 6; + count = 6; #else else if (uc < 0x110000) - count = 4; + count = 4; #endif else - return -1; + return -1; if (n >= count) - { - switch (count) /* note: code falls through cases! */ - { + { + switch (count) /* note: code falls through cases! */ + { #if 0 - case 6: s[5] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x4000000; - case 5: s[4] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x200000; + case 6: s[5] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x4000000; + case 5: s[4] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x200000; #endif - case 4: s[3] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x10000; - case 3: s[2] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x800; - case 2: s[1] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0xc0; - /*case 1:*/ s[0] = uc; - } - return count; - } + case 4: s[3] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x10000; + case 3: s[2] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x800; + case 2: s[1] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0xc0; + /*case 1:*/ s[0] = uc; + } + return count; + } } return -2; } diff --git a/src/bin/coreutils/lib/unitypes.h b/src/bin/coreutils/lib/unitypes.h index 60aa986d30..6174e5d80e 100644 --- a/src/bin/coreutils/lib/unitypes.h +++ b/src/bin/coreutils/lib/unitypes.h @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Elementary types for the GNU UniString library. - Copyright (C) 2002, 2005-2006 Free Software Foundation, Inc. + Copyright (C) 2002, 2005-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published diff --git a/src/bin/coreutils/lib/uniwidth.h b/src/bin/coreutils/lib/uniwidth.h index fbc68a5e63..fc6f71f434 100644 --- a/src/bin/coreutils/lib/uniwidth.h +++ b/src/bin/coreutils/lib/uniwidth.h @@ -2,7 +2,8 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Display width functions. - Copyright (C) 2001-2002, 2005, 2007 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2005, 2007, 2009-2010 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published diff --git a/src/bin/coreutils/lib/uniwidth/cjk.h b/src/bin/coreutils/lib/uniwidth/cjk.h index 61382bde60..20e5a79c3a 100644 --- a/src/bin/coreutils/lib/uniwidth/cjk.h +++ b/src/bin/coreutils/lib/uniwidth/cjk.h @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Test for CJK encoding. - Copyright (C) 2001-2002, 2005-2007 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2005-2007, 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible , 2002. This program is free software: you can redistribute it and/or modify it diff --git a/src/bin/coreutils/lib/uniwidth/width.c b/src/bin/coreutils/lib/uniwidth/width.c index 71e538fd8c..c034f46052 100644 --- a/src/bin/coreutils/lib/uniwidth/width.c +++ b/src/bin/coreutils/lib/uniwidth/width.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Determine display width of Unicode character. - Copyright (C) 2001-2002, 2006-2009 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2006-2010 Free Software Foundation, Inc. Written by Bruno Haible , 2002. This program is free software: you can redistribute it and/or modify it @@ -313,26 +313,26 @@ uc_width (ucs4_t uc, const char *encoding) { int ind = nonspacing_table_ind[uc >> 9]; if (ind >= 0) - if ((nonspacing_table_data[64*ind + ((uc >> 3) & 63)] >> (uc & 7)) & 1) - { - if (uc > 0 && uc < 0xa0) - return -1; - else - return 0; - } + if ((nonspacing_table_data[64*ind + ((uc >> 3) & 63)] >> (uc & 7)) & 1) + { + if (uc > 0 && uc < 0xa0) + return -1; + else + return 0; + } } else if ((uc >> 9) == (0xe0000 >> 9)) { if (uc >= 0xe0100) - { - if (uc <= 0xe01ef) - return 0; - } + { + if (uc <= 0xe01ef) + return 0; + } else - { - if (uc >= 0xe0020 ? uc <= 0xe007f : uc == 0xe0001) - return 0; - } + { + if (uc >= 0xe0020 ? uc <= 0xe007f : uc == 0xe0001) + return 0; + } } /* Test for double-width character. * Generated from "grep '^....;[WF]' EastAsianWidth.txt" @@ -340,17 +340,17 @@ uc_width (ucs4_t uc, const char *encoding) */ if (uc >= 0x1100 && ((uc < 0x1160) /* Hangul Jamo */ - || (uc >= 0x2329 && uc < 0x232b) /* Angle Brackets */ - || (uc >= 0x2e80 && uc < 0xa4d0 /* CJK ... Yi */ - && !(uc == 0x303f) && !(uc >= 0x4dc0 && uc < 0x4e00)) - || (uc >= 0xac00 && uc < 0xd7a4) /* Hangul Syllables */ - || (uc >= 0xf900 && uc < 0xfb00) /* CJK Compatibility Ideographs */ - || (uc >= 0xfe10 && uc < 0xfe20) /* Presentation Forms for Vertical */ - || (uc >= 0xfe30 && uc < 0xfe70) /* CJK Compatibility Forms */ - || (uc >= 0xff00 && uc < 0xff61) /* Fullwidth Forms */ - || (uc >= 0xffe0 && uc < 0xffe7) /* Fullwidth Signs */ - || (uc >= 0x20000 && uc <= 0x2a6d6) /* CJK */ - || (uc >= 0x2f800 && uc <= 0x2fa1d) /* CJK Compatibility Ideographs */ + || (uc >= 0x2329 && uc < 0x232b) /* Angle Brackets */ + || (uc >= 0x2e80 && uc < 0xa4d0 /* CJK ... Yi */ + && !(uc == 0x303f) && !(uc >= 0x4dc0 && uc < 0x4e00)) + || (uc >= 0xac00 && uc < 0xd7a4) /* Hangul Syllables */ + || (uc >= 0xf900 && uc < 0xfb00) /* CJK Compatibility Ideographs */ + || (uc >= 0xfe10 && uc < 0xfe20) /* Presentation Forms for Vertical */ + || (uc >= 0xfe30 && uc < 0xfe70) /* CJK Compatibility Forms */ + || (uc >= 0xff00 && uc < 0xff61) /* Fullwidth Forms */ + || (uc >= 0xffe0 && uc < 0xffe7) /* Fullwidth Signs */ + || (uc >= 0x20000 && uc <= 0x2a6d6) /* CJK */ + || (uc >= 0x2f800 && uc <= 0x2fa1d) /* CJK Compatibility Ideographs */ ) ) return 2; /* In ancient CJK encodings, Cyrillic and most other characters are diff --git a/src/bin/coreutils/lib/unlink.c b/src/bin/coreutils/lib/unlink.c new file mode 100644 index 0000000000..3e42e28692 --- /dev/null +++ b/src/bin/coreutils/lib/unlink.c @@ -0,0 +1,85 @@ +/* Work around unlink bugs. + + Copyright (C) 2009, 2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +#include + +#include +#include +#include +#include + +#undef unlink + +/* Remove file NAME. + Return 0 if successful, -1 if not. */ + +int +rpl_unlink (char const *name) +{ + /* Work around Solaris 9 bug where unlink("file/") succeeds. */ + size_t len = strlen (name); + int result = 0; + if (len && ISSLASH (name[len - 1])) + { + /* We can't unlink(2) something if it doesn't exist. If it does + exist, then it resolved to a directory, due to the trailing + slash, and POSIX requires that the unlink attempt to remove + that directory (which would leave the symlink dangling). + Unfortunately, Solaris 9 is one of the platforms where the + root user can unlink directories, and we don't want to + cripple this behavior on real directories, even if it is + seldom needed (at any rate, it's nicer to let coreutils' + unlink(1) give the correct errno for non-root users). But we + don't know whether name was an actual directory, or a symlink + to a directory; and due to the bug of ignoring trailing + slash, Solaris 9 would end up successfully unlinking the + symlink instead of the directory. Technically, we could use + realpath to find the canonical directory name to attempt + deletion on. But that is a lot of work for a corner case; so + we instead just use an lstat on the shortened name, and + reject symlinks with trailing slashes. The root user of + unlink(1) will just have to live with the rule that they + can't delete a directory via a symlink. */ + struct stat st; + result = lstat (name, &st); + if (result == 0) + { + /* Trailing NUL will overwrite the trailing slash. */ + char *short_name = malloc (len); + if (!short_name) + { + errno = EPERM; + return -1; + } + memcpy (short_name, name, len); + while (len && ISSLASH (short_name[len - 1])) + short_name[--len] = '\0'; + if (len && (lstat (short_name, &st) || S_ISLNK (st.st_mode))) + { + free (short_name); + errno = EPERM; + return -1; + } + free (short_name); + } + } + if (!result) + result = unlink (name); + return result; +} diff --git a/src/bin/coreutils/lib/unlinkat.c b/src/bin/coreutils/lib/unlinkat.c new file mode 100644 index 0000000000..008192e6d3 --- /dev/null +++ b/src/bin/coreutils/lib/unlinkat.c @@ -0,0 +1,105 @@ +/* Work around unlinkat bugs on Solaris 9. + + Copyright (C) 2009-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Eric Blake. */ + +#include + +#include + +#include +#include +#include +#include + +#include "openat.h" + +#if HAVE_UNLINKAT + +# undef unlinkat + +/* unlinkat without AT_REMOVEDIR does not honor trailing / on Solaris + 9. Solve it in a similar manner to unlink. */ + +int +rpl_unlinkat (int fd, char const *name, int flag) +{ + size_t len; + int result = 0; + /* rmdir behavior has no problems with trailing slash. */ + if (flag & AT_REMOVEDIR) + return unlinkat (fd, name, flag); + + len = strlen (name); + if (len && ISSLASH (name[len - 1])) + { + /* See the lengthy comment in unlink.c why we disobey the POSIX + rule of letting unlink("link-to-dir/") attempt to unlink a + directory. */ + struct stat st; + result = lstatat (fd, name, &st); + if (result == 0) + { + /* Trailing NUL will overwrite the trailing slash. */ + char *short_name = malloc (len); + if (!short_name) + { + errno = EPERM; + return -1; + } + memcpy (short_name, name, len); + while (len && ISSLASH (short_name[len - 1])) + short_name[--len] = '\0'; + if (len && (lstatat (fd, short_name, &st) || S_ISLNK (st.st_mode))) + { + free (short_name); + errno = EPERM; + return -1; + } + free (short_name); + } + } + if (!result) + result = unlinkat (fd, name, flag); + return result; +} + +#else /* !HAVE_UNLINKAT */ + +/* Replacement for Solaris' function by the same name. + + First, try to simulate it via (unlink|rmdir) ("/proc/self/fd/FD/FILE"). + Failing that, simulate it via save_cwd/fchdir/(unlink|rmdir)/restore_cwd. + If either the save_cwd or the restore_cwd fails (relatively unlikely), + then give a diagnostic and exit nonzero. + Otherwise, this function works just like Solaris' unlinkat. */ + +# define AT_FUNC_NAME unlinkat +# define AT_FUNC_F1 rmdir +# define AT_FUNC_F2 unlink +# define AT_FUNC_USE_F1_COND AT_REMOVEDIR +# define AT_FUNC_POST_FILE_PARAM_DECLS , int flag +# define AT_FUNC_POST_FILE_ARGS /* empty */ +# include "at-func.c" +# undef AT_FUNC_NAME +# undef AT_FUNC_F1 +# undef AT_FUNC_F2 +# undef AT_FUNC_USE_F1_COND +# undef AT_FUNC_POST_FILE_PARAM_DECLS +# undef AT_FUNC_POST_FILE_ARGS + +#endif /* !HAVE_UNLINKAT */ diff --git a/src/bin/coreutils/lib/unlinkdir.c b/src/bin/coreutils/lib/unlinkdir.c deleted file mode 100644 index a9713c79c7..0000000000 --- a/src/bin/coreutils/lib/unlinkdir.c +++ /dev/null @@ -1,54 +0,0 @@ -/* unlinkdir.c - determine whether we can unlink directories - - Copyright (C) 2005-2006, 2009 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* Written by Paul Eggert, Jim Meyering, and David Bartley. */ - -#include - -#include "unlinkdir.h" -#include "priv-set.h" -#include - -#if ! UNLINK_CANNOT_UNLINK_DIR - -/* Return true if we cannot unlink directories, false if we might be - able to unlink directories. */ - -bool -cannot_unlink_dir (void) -{ - static bool initialized; - static bool cannot; - - if (! initialized) - { -# if defined PRIV_SYS_LINKDIR - /* We might be able to unlink directories if we cannot - determine our privileges, or if we have the - PRIV_SYS_LINKDIR privilege. */ - cannot = (priv_set_ismember (PRIV_SYS_LINKDIR) == 0); -# else - /* In traditional Unix, only root can unlink directories. */ - cannot = (geteuid () != 0); -# endif - initialized = true; - } - - return cannot; -} - -#endif diff --git a/src/bin/coreutils/lib/unlocked-io.h b/src/bin/coreutils/lib/unlocked-io.h index 6b2939e1ba..75bf89f6c9 100644 --- a/src/bin/coreutils/lib/unlocked-io.h +++ b/src/bin/coreutils/lib/unlocked-io.h @@ -1,6 +1,6 @@ /* Prefer faster, non-thread-safe stdio functions if available. - Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/unsetenv.c b/src/bin/coreutils/lib/unsetenv.c index 73ea878a68..65a19cca12 100644 --- a/src/bin/coreutils/lib/unsetenv.c +++ b/src/bin/coreutils/lib/unsetenv.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992,1995-1999,2000-2002,2005-2008 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1995-2002, 2005-2010 Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software: you can redistribute it and/or modify @@ -16,6 +16,10 @@ #include +/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc + optimizes away the name == NULL test below. */ +#define _GL_ARG_NONNULL(params) + /* Specification. */ #include @@ -28,15 +32,15 @@ #include #if !_LIBC -# define __environ environ +# define __environ environ #endif #if _LIBC /* This lock protects against simultaneous modifications of `environ'. */ # include __libc_lock_define_initialized (static, envlock) -# define LOCK __libc_lock_lock (envlock) -# define UNLOCK __libc_lock_unlock (envlock) +# define LOCK __libc_lock_lock (envlock) +# define UNLOCK __libc_lock_unlock (envlock) #else # define LOCK # define UNLOCK @@ -47,6 +51,7 @@ __libc_lock_define_initialized (static, envlock) # define unsetenv __unsetenv #endif +#if _LIBC || !HAVE_UNSETENV int unsetenv (const char *name) @@ -68,13 +73,13 @@ unsetenv (const char *name) while (*ep != NULL) if (!strncmp (*ep, name, len) && (*ep)[len] == '=') { - /* Found it. Remove this pointer by moving later ones back. */ - char **dp = ep; + /* Found it. Remove this pointer by moving later ones back. */ + char **dp = ep; - do - dp[0] = dp[1]; - while (*dp++); - /* Continue the loop in case NAME appears again. */ + do + dp[0] = dp[1]; + while (*dp++); + /* Continue the loop in case NAME appears again. */ } else ++ep; @@ -88,3 +93,28 @@ unsetenv (const char *name) # undef unsetenv weak_alias (__unsetenv, unsetenv) #endif + +#else /* HAVE_UNSETENV */ + +# undef unsetenv + +/* Call the underlying unsetenv, in case there is hidden bookkeeping + that needs updating beyond just modifying environ. */ +int +rpl_unsetenv (const char *name) +{ + int result = 0; + if (!name || !*name || strchr (name, '=')) + { + errno = EINVAL; + return -1; + } + while (getenv (name)) +# if !VOID_UNSETENV + result = +# endif + unsetenv (name); + return result; +} + +#endif /* HAVE_UNSETENV */ diff --git a/src/bin/coreutils/lib/unused-parameter.h b/src/bin/coreutils/lib/unused-parameter.h new file mode 100644 index 0000000000..53474b5754 --- /dev/null +++ b/src/bin/coreutils/lib/unused-parameter.h @@ -0,0 +1,20 @@ +/* _GL_UNUSED_PARAMETER is a marker that can be appended to function parameter + declarations for parameters that are not used. This helps to reduce + warnings, such as from GCC -Wunused-parameter. The syntax is as follows: + type param _GL_UNUSED_PARAMETER + or more generally + param_decl _GL_UNUSED_PARAMETER + For example: + int param _GL_UNUSED_PARAMETER + int *(*param)(void) _GL_UNUSED_PARAMETER + Other possible, but obscure and discouraged syntaxes: + int _GL_UNUSED_PARAMETER *(*param)(void) + _GL_UNUSED_PARAMETER int *(*param)(void) + */ +#ifndef _GL_UNUSED_PARAMETER +# if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) +# define _GL_UNUSED_PARAMETER __attribute__ ((__unused__)) +# else +# define _GL_UNUSED_PARAMETER +# endif +#endif diff --git a/src/bin/coreutils/lib/userspec.c b/src/bin/coreutils/lib/userspec.c index 17f9326ae6..388f72332a 100644 --- a/src/bin/coreutils/lib/userspec.c +++ b/src/bin/coreutils/lib/userspec.c @@ -1,5 +1,5 @@ /* userspec.c -- Parse a user and group string. - Copyright (C) 1989-1992, 1997-1998, 2000, 2002-2007 Free Software + Copyright (C) 1989-1992, 1997-1998, 2000, 2002-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -90,7 +90,7 @@ is_number (const char *str) do { if (!ISDIGIT (*str)) - return false; + return false; } while (*++str); @@ -100,8 +100,8 @@ is_number (const char *str) static char const * parse_with_separator (char const *spec, char const *separator, - uid_t *uid, gid_t *gid, - char **username, char **groupname) + uid_t *uid, gid_t *gid, + char **username, char **groupname) { static const char *E_invalid_user = N_("invalid user"); static const char *E_invalid_group = N_("invalid group"); @@ -127,16 +127,16 @@ parse_with_separator (char const *spec, char const *separator, if (separator == NULL) { if (*spec) - u = xstrdup (spec); + u = xstrdup (spec); } else { size_t ulen = separator - spec; if (ulen != 0) - { - u = xmemdup (spec, ulen + 1); - u[ulen] = '\0'; - } + { + u = xmemdup (spec, ulen + 1); + u[ulen] = '\0'; + } } g = (separator == NULL || *(separator + 1) == '\0' @@ -157,38 +157,38 @@ parse_with_separator (char const *spec, char const *separator, /* If it starts with "+", skip the look-up. */ pwd = (*u == '+' ? NULL : getpwnam (u)); if (pwd == NULL) - { - bool use_login_group = (separator != NULL && g == NULL); - if (use_login_group) - { - /* If there is no group, - then there may not be a trailing ":", either. */ - error_msg = E_bad_spec; - } - else - { - unsigned long int tmp; - if (xstrtoul (u, NULL, 10, &tmp, "") == LONGINT_OK - && tmp <= MAXUID) - unum = tmp; - else - error_msg = E_invalid_user; - } - } + { + bool use_login_group = (separator != NULL && g == NULL); + if (use_login_group) + { + /* If there is no group, + then there may not be a trailing ":", either. */ + error_msg = E_bad_spec; + } + else + { + unsigned long int tmp; + if (xstrtoul (u, NULL, 10, &tmp, "") == LONGINT_OK + && tmp <= MAXUID && (uid_t) tmp != (uid_t) -1) + unum = tmp; + else + error_msg = E_invalid_user; + } + } else - { - unum = pwd->pw_uid; - if (g == NULL && separator != NULL) - { - /* A separator was given, but a group was not specified, - so get the login group. */ - char buf[INT_BUFSIZE_BOUND (uintmax_t)]; - gnum = pwd->pw_gid; - grp = getgrgid (gnum); - gname = xstrdup (grp ? grp->gr_name : umaxtostr (gnum, buf)); - endgrent (); - } - } + { + unum = pwd->pw_uid; + if (g == NULL && separator != NULL) + { + /* A separator was given, but a group was not specified, + so get the login group. */ + char buf[INT_BUFSIZE_BOUND (uintmax_t)]; + gnum = pwd->pw_gid; + grp = getgrgid (gnum); + gname = xstrdup (grp ? grp->gr_name : umaxtostr (gnum, buf)); + endgrent (); + } + } endpwent (); } @@ -198,16 +198,17 @@ parse_with_separator (char const *spec, char const *separator, /* If it starts with "+", skip the look-up. */ grp = (*g == '+' ? NULL : getgrnam (g)); if (grp == NULL) - { - unsigned long int tmp; - if (xstrtoul (g, NULL, 10, &tmp, "") == LONGINT_OK && tmp <= MAXGID) - gnum = tmp; - else - error_msg = E_invalid_group; - } + { + unsigned long int tmp; + if (xstrtoul (g, NULL, 10, &tmp, "") == LONGINT_OK + && tmp <= MAXGID && (gid_t) tmp != (gid_t) -1) + gnum = tmp; + else + error_msg = E_invalid_group; + } else - gnum = grp->gr_gid; - endgrent (); /* Save a file descriptor. */ + gnum = grp->gr_gid; + endgrent (); /* Save a file descriptor. */ gname = xstrdup (g); } @@ -244,7 +245,7 @@ parse_with_separator (char const *spec, char const *separator, char const * parse_user_spec (char const *spec, uid_t *uid, gid_t *gid, - char **username, char **groupname) + char **username, char **groupname) { char const *colon = strchr (spec, ':'); char const *error_msg = @@ -253,15 +254,15 @@ parse_user_spec (char const *spec, uid_t *uid, gid_t *gid, if (!colon && error_msg) { /* If there's no colon but there is a dot, and if looking up the - whole spec failed (i.e., the spec is not a owner name that - includes a dot), then try again, but interpret the dot as a - separator. This is a compatible extension to POSIX, since - the POSIX-required behavior is always tried first. */ + whole spec failed (i.e., the spec is not a owner name that + includes a dot), then try again, but interpret the dot as a + separator. This is a compatible extension to POSIX, since + the POSIX-required behavior is always tried first. */ char const *dot = strchr (spec, '.'); if (dot - && ! parse_with_separator (spec, dot, uid, gid, username, groupname)) - error_msg = NULL; + && ! parse_with_separator (spec, dot, uid, gid, username, groupname)) + error_msg = NULL; } return error_msg; @@ -288,15 +289,21 @@ main (int argc, char **argv) e = parse_user_spec (tmp, &uid, &gid, &username, &groupname); free (tmp); printf ("%s: %lu %lu %s %s %s\n", - argv[i], - (unsigned long int) uid, - (unsigned long int) gid, - NULL_CHECK (username), - NULL_CHECK (groupname), - NULL_CHECK (e)); + argv[i], + (unsigned long int) uid, + (unsigned long int) gid, + NULL_CHECK (username), + NULL_CHECK (groupname), + NULL_CHECK (e)); } exit (0); } #endif + +/* +Local Variables: +indent-tabs-mode: nil +End: +*/ diff --git a/src/bin/coreutils/lib/userspec.h b/src/bin/coreutils/lib/userspec.h index 8a09eaea0c..67af8451bf 100644 --- a/src/bin/coreutils/lib/userspec.h +++ b/src/bin/coreutils/lib/userspec.h @@ -5,6 +5,6 @@ const char * parse_user_spec (const char *spec_arg, uid_t *uid, gid_t *gid, - char **username_arg, char **groupname_arg); + char **username_arg, char **groupname_arg); #endif diff --git a/src/bin/coreutils/lib/utimecmp.c b/src/bin/coreutils/lib/utimecmp.c index 6a9087398b..63a0c9a822 100644 --- a/src/bin/coreutils/lib/utimecmp.c +++ b/src/bin/coreutils/lib/utimecmp.c @@ -1,6 +1,6 @@ /* utimecmp.c -- compare file time stamps - Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2004-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,6 +26,8 @@ #include #include #include +#include + #include "hash.h" #include "intprops.h" #include "stat-time.h" @@ -37,17 +39,19 @@ # define MAX(a, b) ((a) > (b) ? (a) : (b)) #endif -enum { BILLION = 1000 * 1000 * 1000 }; +#define BILLION (1000 * 1000 * 1000) /* Best possible resolution that utimens can set and stat can return, due to system-call limitations. It must be a power of 10 that is no greater than 1 billion. */ -#if (HAVE_WORKING_UTIMES \ - && (defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC \ - || defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC \ - || defined HAVE_STRUCT_STAT_ST_ATIMENSEC \ - || defined HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC \ - || defined HAVE_STRUCT_STAT_ST_SPARE1)) +#if HAVE_UTIMENSAT +enum { SYSCALL_RESOLUTION = 1 }; +#elif ((HAVE_FUTIMESAT || HAVE_WORKING_UTIMES) \ + && (defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC \ + || defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC \ + || defined HAVE_STRUCT_STAT_ST_ATIMENSEC \ + || defined HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC \ + || defined HAVE_STRUCT_STAT_ST_SPARE1)) enum { SYSCALL_RESOLUTION = 1000 }; #else enum { SYSCALL_RESOLUTION = BILLION }; @@ -100,6 +104,8 @@ dev_info_compare (void const *x, void const *y) DST_NAME and status DST_STAT) is older than SRC_STAT, the same age as SRC_STAT, or newer than SRC_STAT, respectively. + DST_NAME may be NULL if OPTIONS is 0. + If OPTIONS & UTIMECMP_TRUNCATE_SOURCE, do the comparison after SRC is converted to the destination's timestamp resolution as filtered through utimens. In this case, return -2 if the exact answer cannot be @@ -109,9 +115,9 @@ dev_info_compare (void const *x, void const *y) int utimecmp (char const *dst_name, - struct stat const *dst_stat, - struct stat const *src_stat, - int options) + struct stat const *dst_stat, + struct stat const *src_stat, + int options) { /* Things to watch out for: @@ -147,169 +153,195 @@ utimecmp (char const *dst_name, /* Time stamp resolution in nanoseconds. */ int res; + /* Quick exit, if possible. Since the worst resolution is 2 + seconds, anything that differs by more than that does not + needs source truncation. */ + if (dst_s == src_s && dst_ns == src_ns) + return 0; + if (dst_s <= src_s - 2) + return -1; + if (src_s <= dst_s - 2) + return 1; + if (! ht) - ht = hash_initialize (16, NULL, dev_info_hash, dev_info_compare, free); + ht = hash_initialize (16, NULL, dev_info_hash, dev_info_compare, free); if (! new_dst_res) - { - new_dst_res = xmalloc (sizeof *new_dst_res); - new_dst_res->resolution = 2 * BILLION; - new_dst_res->exact = false; - } + { + new_dst_res = xmalloc (sizeof *new_dst_res); + new_dst_res->resolution = 2 * BILLION; + new_dst_res->exact = false; + } new_dst_res->dev = dst_stat->st_dev; dst_res = hash_insert (ht, new_dst_res); if (! dst_res) - xalloc_die (); + xalloc_die (); if (dst_res == new_dst_res) - { - /* NEW_DST_RES is now in use in the hash table, so allocate a - new entry next time. */ - new_dst_res = NULL; - } + { + /* NEW_DST_RES is now in use in the hash table, so allocate a + new entry next time. */ + new_dst_res = NULL; + } res = dst_res->resolution; +#ifdef _PC_TIMESTAMP_RESOLUTION + /* If the system will tell us the resolution, we're set! */ if (! dst_res->exact) - { - /* This file system's resolution is not known exactly. - Deduce it, and store the result in the hash table. */ + { + res = pathconf (dst_name, _PC_TIMESTAMP_RESOLUTION); + if (0 < res) + { + dst_res->resolution = res; + dst_res->exact = true; + } + } +#endif - time_t dst_a_s = dst_stat->st_atime; - time_t dst_c_s = dst_stat->st_ctime; - time_t dst_m_s = dst_s; - int dst_a_ns = get_stat_atime_ns (dst_stat); - int dst_c_ns = get_stat_ctime_ns (dst_stat); - int dst_m_ns = dst_ns; + if (! dst_res->exact) + { + /* This file system's resolution is not known exactly. + Deduce it, and store the result in the hash table. */ - /* Set RES to an upper bound on the file system resolution - (after truncation due to SYSCALL_RESOLUTION) by inspecting - the atime, ctime and mtime of the existing destination. - We don't know of any file system that stores atime or - ctime with a higher precision than mtime, so it's valid to - look at them too. */ - { - bool odd_second = (dst_a_s | dst_c_s | dst_m_s) & 1; + time_t dst_a_s = dst_stat->st_atime; + time_t dst_c_s = dst_stat->st_ctime; + time_t dst_m_s = dst_s; + int dst_a_ns = get_stat_atime_ns (dst_stat); + int dst_c_ns = get_stat_ctime_ns (dst_stat); + int dst_m_ns = dst_ns; - if (SYSCALL_RESOLUTION == BILLION) - { - if (odd_second | dst_a_ns | dst_c_ns | dst_m_ns) - res = BILLION; - } - else - { - int a = dst_a_ns; - int c = dst_c_ns; - int m = dst_m_ns; + /* Set RES to an upper bound on the file system resolution + (after truncation due to SYSCALL_RESOLUTION) by inspecting + the atime, ctime and mtime of the existing destination. + We don't know of any file system that stores atime or + ctime with a higher precision than mtime, so it's valid to + look at them too. */ + { + bool odd_second = (dst_a_s | dst_c_s | dst_m_s) & 1; - /* Write it this way to avoid mistaken GCC warning - about integer overflow in constant expression. */ - int SR10 = SYSCALL_RESOLUTION; SR10 *= 10; + if (SYSCALL_RESOLUTION == BILLION) + { + if (odd_second | dst_a_ns | dst_c_ns | dst_m_ns) + res = BILLION; + } + else + { + int a = dst_a_ns; + int c = dst_c_ns; + int m = dst_m_ns; - if ((a % SR10 | c % SR10 | m % SR10) != 0) - res = SYSCALL_RESOLUTION; - else - for (res = SR10, a /= SR10, c /= SR10, m /= SR10; - (res < dst_res->resolution - && (a % 10 | c % 10 | m % 10) == 0); - res *= 10, a /= 10, c /= 10, m /= 10) - if (res == BILLION) - { - if (! odd_second) - res *= 2; - break; - } - } + /* Write it this way to avoid mistaken GCC warning + about integer overflow in constant expression. */ + int SR10 = SYSCALL_RESOLUTION; SR10 *= 10; - dst_res->resolution = res; - } + if ((a % SR10 | c % SR10 | m % SR10) != 0) + res = SYSCALL_RESOLUTION; + else + for (res = SR10, a /= SR10, c /= SR10, m /= SR10; + (res < dst_res->resolution + && (a % 10 | c % 10 | m % 10) == 0); + res *= 10, a /= 10, c /= 10, m /= 10) + if (res == BILLION) + { + if (! odd_second) + res *= 2; + break; + } + } - if (SYSCALL_RESOLUTION < res) - { - struct timespec timespec[2]; - struct stat dst_status; + dst_res->resolution = res; + } - /* Ignore source time stamp information that must necessarily - be lost when filtered through utimens. */ - src_ns -= src_ns % SYSCALL_RESOLUTION; + if (SYSCALL_RESOLUTION < res) + { + struct timespec timespec[2]; + struct stat dst_status; - /* If the time stamps disagree widely enough, there's no need - to interrogate the file system to deduce the exact time - stamp resolution; return the answer directly. */ - { - time_t s = src_s & ~ (res == 2 * BILLION); - if (src_s < dst_s || (src_s == dst_s && src_ns <= dst_ns)) - return 1; - if (dst_s < s - || (dst_s == s && dst_ns < src_ns - src_ns % res)) - return -1; - } + /* Ignore source time stamp information that must necessarily + be lost when filtered through utimens. */ + src_ns -= src_ns % SYSCALL_RESOLUTION; - /* Determine the actual time stamp resolution for the - destination file system (after truncation due to - SYSCALL_RESOLUTION) by setting the access time stamp of the - destination to the existing access time, except with - trailing nonzero digits. */ + /* If the time stamps disagree widely enough, there's no need + to interrogate the file system to deduce the exact time + stamp resolution; return the answer directly. */ + { + time_t s = src_s & ~ (res == 2 * BILLION); + if (src_s < dst_s || (src_s == dst_s && src_ns <= dst_ns)) + return 1; + if (dst_s < s + || (dst_s == s && dst_ns < src_ns - src_ns % res)) + return -1; + } - timespec[0].tv_sec = dst_a_s; - timespec[0].tv_nsec = dst_a_ns; - timespec[1].tv_sec = dst_m_s | (res == 2 * BILLION); - timespec[1].tv_nsec = dst_m_ns + res / 9; + /* Determine the actual time stamp resolution for the + destination file system (after truncation due to + SYSCALL_RESOLUTION) by setting the access time stamp of the + destination to the existing access time, except with + trailing nonzero digits. */ - /* Set the modification time. But don't try to set the - modification time of symbolic links; on many hosts this sets - the time of the pointed-to file. */ - if (S_ISLNK (dst_stat->st_mode) - || utimens (dst_name, timespec) != 0) - return -2; + timespec[0].tv_sec = dst_a_s; + timespec[0].tv_nsec = dst_a_ns; + timespec[1].tv_sec = dst_m_s | (res == 2 * BILLION); + timespec[1].tv_nsec = dst_m_ns + res / 9; - /* Read the modification time that was set. It's safe to call - 'stat' here instead of worrying about 'lstat'; either the - caller used 'stat', or the caller used 'lstat' and found - something other than a symbolic link. */ - { - int stat_result = stat (dst_name, &dst_status); + /* Set the modification time. But don't try to set the + modification time of symbolic links; on many hosts this sets + the time of the pointed-to file. */ + if ((S_ISLNK (dst_stat->st_mode) + ? lutimens (dst_name, timespec) + : utimens (dst_name, timespec)) != 0) + return -2; - if (stat_result - | (dst_status.st_mtime ^ dst_m_s) - | (get_stat_mtime_ns (&dst_status) ^ dst_m_ns)) - { - /* The modification time changed, or we can't tell whether - it changed. Change it back as best we can. */ - timespec[1].tv_sec = dst_m_s; - timespec[1].tv_nsec = dst_m_ns; - utimens (dst_name, timespec); - } + /* Read the modification time that was set. */ + { + int stat_result = (S_ISLNK (dst_stat->st_mode) + ? lstat (dst_name, &dst_status) + : stat (dst_name, &dst_status)); - if (stat_result != 0) - return -2; - } + if (stat_result + | (dst_status.st_mtime ^ dst_m_s) + | (get_stat_mtime_ns (&dst_status) ^ dst_m_ns)) + { + /* The modification time changed, or we can't tell whether + it changed. Change it back as best we can. */ + timespec[1].tv_sec = dst_m_s; + timespec[1].tv_nsec = dst_m_ns; + if (S_ISLNK (dst_stat->st_mode)) + lutimens (dst_name, timespec); + else + utimens (dst_name, timespec); + } - /* Determine the exact resolution from the modification time - that was read back. */ - { - int old_res = res; - int a = (BILLION * (dst_status.st_mtime & 1) - + get_stat_mtime_ns (&dst_status)); + if (stat_result != 0) + return -2; + } - res = SYSCALL_RESOLUTION; + /* Determine the exact resolution from the modification time + that was read back. */ + { + int old_res = res; + int a = (BILLION * (dst_status.st_mtime & 1) + + get_stat_mtime_ns (&dst_status)); - for (a /= res; a % 10 != 0; a /= 10) - { - if (res == BILLION) - { - res *= 2; - break; - } - res *= 10; - if (res == old_res) - break; - } - } - } + res = SYSCALL_RESOLUTION; - dst_res->resolution = res; - dst_res->exact = true; - } + for (a /= res; a % 10 != 0; a /= 10) + { + if (res == BILLION) + { + res *= 2; + break; + } + res *= 10; + if (res == old_res) + break; + } + } + } + + dst_res->resolution = res; + dst_res->exact = true; + } /* Truncate the source's time stamp according to the resolution. */ src_s &= ~ (res == 2 * BILLION); @@ -318,7 +350,7 @@ utimecmp (char const *dst_name, /* Compare the time stamps and return -1, 0, 1 accordingly. */ return (dst_s < src_s ? -1 - : dst_s > src_s ? 1 - : dst_ns < src_ns ? -1 - : dst_ns > src_ns); + : dst_s > src_s ? 1 + : dst_ns < src_ns ? -1 + : dst_ns > src_ns); } diff --git a/src/bin/coreutils/lib/utimecmp.h b/src/bin/coreutils/lib/utimecmp.h index 7d33c474d2..6e80c076a8 100644 --- a/src/bin/coreutils/lib/utimecmp.h +++ b/src/bin/coreutils/lib/utimecmp.h @@ -1,6 +1,6 @@ /* utimecmp.h -- compare file time stamps - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/utimens.c b/src/bin/coreutils/lib/utimens.c index f7bc75e653..bdb5a25ae6 100644 --- a/src/bin/coreutils/lib/utimens.c +++ b/src/bin/coreutils/lib/utimens.c @@ -1,7 +1,6 @@ /* Set file access and modification times. - Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free - Software Foundation, Inc. + Copyright (C) 2003-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -24,12 +23,17 @@ #include "utimens.h" +#include #include #include +#include #include #include #include +#include "stat-time.h" +#include "timespec.h" + #if HAVE_UTIME_H # include #endif @@ -44,15 +48,110 @@ struct utimbuf }; #endif -#ifndef __attribute__ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) -# define __attribute__(x) -# endif +/* Avoid recursion with rpl_futimens or rpl_utimensat. */ +#undef futimens +#undef utimensat + +/* Solaris 9 mistakenly succeeds when given a non-directory with a + trailing slash. Force the use of rpl_stat for a fix. */ +#ifndef REPLACE_FUNC_STAT_FILE +# define REPLACE_FUNC_STAT_FILE 0 #endif -#ifndef ATTRIBUTE_UNUSED -# define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) -#endif +#if HAVE_UTIMENSAT || HAVE_FUTIMENS +/* Cache variables for whether the utimensat syscall works; used to + avoid calling the syscall if we know it will just fail with ENOSYS, + and to avoid unnecessary work in massaging timestamps if the + syscall will work. Multiple variables are needed, to distinguish + between the following scenarios on Linux: + utimensat doesn't exist, or is in glibc but kernel 2.6.18 fails with ENOSYS + kernel 2.6.22 and earlier rejects AT_SYMLINK_NOFOLLOW + kernel 2.6.25 and earlier reject UTIME_NOW/UTIME_OMIT with non-zero tv_sec + kernel 2.6.32 used with xfs or ntfs-3g fail to honor UTIME_OMIT + utimensat completely works + For each cache variable: 0 = unknown, 1 = yes, -1 = no. */ +static int utimensat_works_really; +static int lutimensat_works_really; +#endif /* HAVE_UTIMENSAT || HAVE_FUTIMENS */ + +/* Validate the requested timestamps. Return 0 if the resulting + timespec can be used for utimensat (after possibly modifying it to + work around bugs in utimensat). Return a positive value if the + timespec needs further adjustment based on stat results: 1 if any + adjustment is needed for utimes, and 2 if any adjustment is needed + for Linux utimensat. Return -1, with errno set to EINVAL, if + timespec is out of range. */ +static int +validate_timespec (struct timespec timespec[2]) +{ + int result = 0; + int utime_omit_count = 0; + assert (timespec); + if ((timespec[0].tv_nsec != UTIME_NOW + && timespec[0].tv_nsec != UTIME_OMIT + && (timespec[0].tv_nsec < 0 || 1000000000 <= timespec[0].tv_nsec)) + || (timespec[1].tv_nsec != UTIME_NOW + && timespec[1].tv_nsec != UTIME_OMIT + && (timespec[1].tv_nsec < 0 || 1000000000 <= timespec[1].tv_nsec))) + { + errno = EINVAL; + return -1; + } + /* Work around Linux kernel 2.6.25 bug, where utimensat fails with + EINVAL if tv_sec is not 0 when using the flag values of tv_nsec. + Flag a Linux kernel 2.6.32 bug, where an mtime of UTIME_OMIT + fails to bump ctime. */ + if (timespec[0].tv_nsec == UTIME_NOW + || timespec[0].tv_nsec == UTIME_OMIT) + { + timespec[0].tv_sec = 0; + result = 1; + if (timespec[0].tv_nsec == UTIME_OMIT) + utime_omit_count++; + } + if (timespec[1].tv_nsec == UTIME_NOW + || timespec[1].tv_nsec == UTIME_OMIT) + { + timespec[1].tv_sec = 0; + result = 1; + if (timespec[1].tv_nsec == UTIME_OMIT) + utime_omit_count++; + } + return result + (utime_omit_count == 1); +} + +/* Normalize any UTIME_NOW or UTIME_OMIT values in *TS, using stat + buffer STATBUF to obtain the current timestamps of the file. If + both times are UTIME_NOW, set *TS to NULL (as this can avoid some + permissions issues). If both times are UTIME_OMIT, return true + (nothing further beyond the prior collection of STATBUF is + necessary); otherwise return false. */ +static bool +update_timespec (struct stat const *statbuf, struct timespec *ts[2]) +{ + struct timespec *timespec = *ts; + if (timespec[0].tv_nsec == UTIME_OMIT + && timespec[1].tv_nsec == UTIME_OMIT) + return true; + if (timespec[0].tv_nsec == UTIME_NOW + && timespec[1].tv_nsec == UTIME_NOW) + { + *ts = NULL; + return false; + } + + if (timespec[0].tv_nsec == UTIME_OMIT) + timespec[0] = get_stat_atime (statbuf); + else if (timespec[0].tv_nsec == UTIME_NOW) + gettime (×pec[0]); + + if (timespec[1].tv_nsec == UTIME_OMIT) + timespec[1] = get_stat_mtime (statbuf); + else if (timespec[1].tv_nsec == UTIME_NOW) + gettime (×pec[1]); + + return false; +} /* Set the access and modification time stamps of FD (a.k.a. FILE) to be TIMESPEC[0] and TIMESPEC[1], respectively. @@ -65,9 +164,36 @@ struct utimbuf Return 0 on success, -1 (setting errno) on failure. */ int -gl_futimens (int fd ATTRIBUTE_UNUSED, - char const *file, struct timespec const timespec[2]) +fdutimens (char const *file, int fd, struct timespec const timespec[2]) { + struct timespec adjusted_timespec[2]; + struct timespec *ts = timespec ? adjusted_timespec : NULL; + int adjustment_needed = 0; + struct stat st; + + if (ts) + { + adjusted_timespec[0] = timespec[0]; + adjusted_timespec[1] = timespec[1]; + adjustment_needed = validate_timespec (ts); + } + if (adjustment_needed < 0) + return -1; + + /* Require that at least one of FD or FILE are valid. Works around + a Linux bug where futimens (AT_FDCWD, NULL) changes "." rather + than failing. */ + if (!file) + { + if (fd < 0) + { + errno = EBADF; + return -1; + } + if (dup2 (fd, fd) != fd) + return -1; + } + /* Some Linux-based NFS clients are buggy, and mishandle time stamps of files in NFS file systems in some cases. We have no configure-time test for this, but please see @@ -85,57 +211,103 @@ gl_futimens (int fd ATTRIBUTE_UNUSED, fsync (fd); #endif - /* POSIX 200x added two interfaces to set file timestamps with - nanosecond resolution. We provide a fallback for ENOSYS (for - example, compiling against Linux 2.6.25 kernel headers and glibc - 2.7, but running on Linux 2.6.18 kernel). */ -#if HAVE_UTIMENSAT - if (fd < 0) + /* POSIX 2008 added two interfaces to set file timestamps with + nanosecond resolution; newer Linux implements both functions via + a single syscall. We provide a fallback for ENOSYS (for example, + compiling against Linux 2.6.25 kernel headers and glibc 2.7, but + running on Linux 2.6.18 kernel). */ +#if HAVE_UTIMENSAT || HAVE_FUTIMENS + if (0 <= utimensat_works_really) { - int result = utimensat (AT_FDCWD, file, timespec, 0); -# ifdef __linux__ - /* Work around what might be a kernel bug: - http://bugzilla.redhat.com/442352 - http://bugzilla.redhat.com/449910 - It appears that utimensat can mistakenly return 280 rather - than -1 upon failure. - FIXME: remove in 2010 or whenever the offending kernels - are no longer in common use. */ - if (0 < result) - errno = ENOSYS; -# endif - - if (result == 0 || errno != ENOSYS) - return result; + int result; +# if __linux__ + /* As recently as Linux kernel 2.6.32 (Dec 2009), several file + systems (xfs, ntfs-3g) have bugs with a single UTIME_OMIT, + but work if both times are either explicitly specified or + UTIME_NOW. Work around it with a preparatory [f]stat prior + to calling futimens/utimensat; fortunately, there is not much + timing impact due to the extra syscall even on file systems + where UTIME_OMIT would have worked. FIXME: Simplify this in + 2012, when file system bugs are no longer common. */ + if (adjustment_needed == 2) + { + if (fd < 0 ? stat (file, &st) : fstat (fd, &st)) + return -1; + if (ts[0].tv_nsec == UTIME_OMIT) + ts[0] = get_stat_atime (&st); + else if (ts[1].tv_nsec == UTIME_OMIT) + ts[1] = get_stat_mtime (&st); + /* Note that st is good, in case utimensat gives ENOSYS. */ + adjustment_needed++; + } +# endif /* __linux__ */ +# if HAVE_UTIMENSAT + if (fd < 0) + { + result = utimensat (AT_FDCWD, file, ts, 0); +# ifdef __linux__ + /* Work around a kernel bug: + http://bugzilla.redhat.com/442352 + http://bugzilla.redhat.com/449910 + It appears that utimensat can mistakenly return 280 rather + than -1 upon ENOSYS failure. + FIXME: remove in 2010 or whenever the offending kernels + are no longer in common use. */ + if (0 < result) + errno = ENOSYS; +# endif /* __linux__ */ + if (result == 0 || errno != ENOSYS) + { + utimensat_works_really = 1; + return result; + } + } +# endif /* HAVE_UTIMENSAT */ +# if HAVE_FUTIMENS + if (0 <= fd) + { + result = futimens (fd, ts); +# ifdef __linux__ + /* Work around the same bug as above. */ + if (0 < result) + errno = ENOSYS; +# endif /* __linux__ */ + if (result == 0 || errno != ENOSYS) + { + utimensat_works_really = 1; + return result; + } + } +# endif /* HAVE_FUTIMENS */ } -#endif -#if HAVE_FUTIMENS - { - int result = futimens (fd, timespec); -# ifdef __linux__ - /* Work around the same bug as above. */ - if (0 < result) - errno = ENOSYS; -# endif - if (result == 0 || errno != ENOSYS) - return result; - } -#endif + utimensat_works_really = -1; + lutimensat_works_really = -1; +#endif /* HAVE_UTIMENSAT || HAVE_FUTIMENS */ /* The platform lacks an interface to set file timestamps with nanosecond resolution, so do the best we can, discarding any fractional part of the timestamp. */ + + if (adjustment_needed || (REPLACE_FUNC_STAT_FILE && fd < 0)) + { + if (adjustment_needed != 3 + && (fd < 0 ? stat (file, &st) : fstat (fd, &st))) + return -1; + if (ts && update_timespec (&st, &ts)) + return 0; + } + { #if HAVE_FUTIMESAT || HAVE_WORKING_UTIMES struct timeval timeval[2]; struct timeval const *t; - if (timespec) + if (ts) { - timeval[0].tv_sec = timespec[0].tv_sec; - timeval[0].tv_usec = timespec[0].tv_nsec / 1000; - timeval[1].tv_sec = timespec[1].tv_sec; - timeval[1].tv_usec = timespec[1].tv_nsec / 1000; - t = timeval; + timeval[0].tv_sec = ts[0].tv_sec; + timeval[0].tv_usec = ts[0].tv_nsec / 1000; + timeval[1].tv_sec = ts[1].tv_sec; + timeval[1].tv_usec = ts[1].tv_nsec / 1000; + t = timeval; } else t = NULL; @@ -143,48 +315,38 @@ gl_futimens (int fd ATTRIBUTE_UNUSED, if (fd < 0) { # if HAVE_FUTIMESAT - return futimesat (AT_FDCWD, file, t); + return futimesat (AT_FDCWD, file, t); # endif } else { - /* If futimesat or futimes fails here, don't try to speed things - up by returning right away. glibc can incorrectly fail with - errno == ENOENT if /proc isn't mounted. Also, Mandrake 10.0 - in high security mode doesn't allow ordinary users to read - /proc/self, so glibc incorrectly fails with errno == EACCES. - If errno == EIO, EPERM, or EROFS, it's probably safe to fail - right away, but these cases are rare enough that they're not - worth optimizing, and who knows what other messed-up systems - are out there? So play it safe and fall back on the code - below. */ -# if HAVE_FUTIMESAT - if (futimesat (fd, NULL, t) == 0) - return 0; + /* If futimesat or futimes fails here, don't try to speed things + up by returning right away. glibc can incorrectly fail with + errno == ENOENT if /proc isn't mounted. Also, Mandrake 10.0 + in high security mode doesn't allow ordinary users to read + /proc/self, so glibc incorrectly fails with errno == EACCES. + If errno == EIO, EPERM, or EROFS, it's probably safe to fail + right away, but these cases are rare enough that they're not + worth optimizing, and who knows what other messed-up systems + are out there? So play it safe and fall back on the code + below. */ +# if HAVE_FUTIMESAT && !FUTIMESAT_NULL_BUG + if (futimesat (fd, NULL, t) == 0) + return 0; # elif HAVE_FUTIMES - if (futimes (fd, t) == 0) - return 0; + if (futimes (fd, t) == 0) + return 0; # endif } #endif /* HAVE_FUTIMESAT || HAVE_WORKING_UTIMES */ if (!file) { -#if ! (HAVE_FUTIMESAT || (HAVE_WORKING_UTIMES && HAVE_FUTIMES)) - errno = ENOSYS; +#if ! ((HAVE_FUTIMESAT && !FUTIMESAT_NULL_BUG) \ + || (HAVE_WORKING_UTIMES && HAVE_FUTIMES)) + errno = ENOSYS; #endif - - /* Prefer EBADF to ENOSYS if both error numbers apply. */ - if (errno == ENOSYS) - { - int fd2 = dup (fd); - int dup_errno = errno; - if (0 <= fd2) - close (fd2); - errno = (fd2 < 0 && dup_errno == EBADF ? EBADF : ENOSYS); - } - - return -1; + return -1; } #if HAVE_WORKING_UTIMES @@ -192,15 +354,15 @@ gl_futimens (int fd ATTRIBUTE_UNUSED, #else { struct utimbuf utimbuf; - struct utimbuf const *ut; - if (timespec) - { - utimbuf.actime = timespec[0].tv_sec; - utimbuf.modtime = timespec[1].tv_sec; - ut = &utimbuf; - } + struct utimbuf *ut; + if (ts) + { + utimbuf.actime = ts[0].tv_sec; + utimbuf.modtime = ts[1].tv_sec; + ut = &utimbuf; + } else - ut = NULL; + ut = NULL; return utime (file, ut); } @@ -208,10 +370,144 @@ gl_futimens (int fd ATTRIBUTE_UNUSED, } } +/* Set the access and modification time stamps of FD (a.k.a. FILE) to be + TIMESPEC[0] and TIMESPEC[1], respectively. + FD must be either negative -- in which case it is ignored -- + or a file descriptor that is open on FILE. + If FD is nonnegative, then FILE can be NULL, which means + use just futimes (or equivalent) instead of utimes (or equivalent), + and fail if on an old system without futimes (or equivalent). + If TIMESPEC is null, set the time stamps to the current time. + Return 0 on success, -1 (setting errno) on failure. */ + +int +gl_futimens (int fd, char const *file, struct timespec const timespec[2]) +{ + return fdutimens (file, fd, timespec); +} + /* Set the access and modification time stamps of FILE to be TIMESPEC[0] and TIMESPEC[1], respectively. */ int utimens (char const *file, struct timespec const timespec[2]) { - return gl_futimens (-1, file, timespec); + return fdutimens (file, -1, timespec); +} + +/* Set the access and modification time stamps of FILE to be + TIMESPEC[0] and TIMESPEC[1], respectively, without dereferencing + symlinks. Fail with ENOSYS if the platform does not support + changing symlink timestamps, but FILE was a symlink. */ +int +lutimens (char const *file, struct timespec const timespec[2]) +{ + struct timespec adjusted_timespec[2]; + struct timespec *ts = timespec ? adjusted_timespec : NULL; + int adjustment_needed = 0; + struct stat st; + + if (ts) + { + adjusted_timespec[0] = timespec[0]; + adjusted_timespec[1] = timespec[1]; + adjustment_needed = validate_timespec (ts); + } + if (adjustment_needed < 0) + return -1; + + /* The Linux kernel did not support symlink timestamps until + utimensat, in version 2.6.22, so we don't need to mimic + gl_futimens' worry about buggy NFS clients. But we do have to + worry about bogus return values. */ + +#if HAVE_UTIMENSAT + if (0 <= lutimensat_works_really) + { + int result; +# if __linux__ + /* As recently as Linux kernel 2.6.32 (Dec 2009), several file + systems (xfs, ntfs-3g) have bugs with a single UTIME_OMIT, + but work if both times are either explicitly specified or + UTIME_NOW. Work around it with a preparatory lstat prior to + calling utimensat; fortunately, there is not much timing + impact due to the extra syscall even on file systems where + UTIME_OMIT would have worked. FIXME: Simplify this in 2012, + when file system bugs are no longer common. */ + if (adjustment_needed == 2) + { + if (lstat (file, &st)) + return -1; + if (ts[0].tv_nsec == UTIME_OMIT) + ts[0] = get_stat_atime (&st); + else if (ts[1].tv_nsec == UTIME_OMIT) + ts[1] = get_stat_mtime (&st); + /* Note that st is good, in case utimensat gives ENOSYS. */ + adjustment_needed++; + } +# endif /* __linux__ */ + result = utimensat (AT_FDCWD, file, ts, AT_SYMLINK_NOFOLLOW); +# ifdef __linux__ + /* Work around a kernel bug: + http://bugzilla.redhat.com/442352 + http://bugzilla.redhat.com/449910 + It appears that utimensat can mistakenly return 280 rather + than -1 upon ENOSYS failure. + FIXME: remove in 2010 or whenever the offending kernels + are no longer in common use. */ + if (0 < result) + errno = ENOSYS; +# endif + if (result == 0 || errno != ENOSYS) + { + utimensat_works_really = 1; + lutimensat_works_really = 1; + return result; + } + } + lutimensat_works_really = -1; +#endif /* HAVE_UTIMENSAT */ + + /* The platform lacks an interface to set file timestamps with + nanosecond resolution, so do the best we can, discarding any + fractional part of the timestamp. */ + + if (adjustment_needed || REPLACE_FUNC_STAT_FILE) + { + if (adjustment_needed != 3 && lstat (file, &st)) + return -1; + if (ts && update_timespec (&st, &ts)) + return 0; + } + + /* On Linux, lutimes is a thin wrapper around utimensat, so there is + no point trying lutimes if utimensat failed with ENOSYS. */ +#if HAVE_LUTIMES && !HAVE_UTIMENSAT + { + struct timeval timeval[2]; + struct timeval const *t; + int result; + if (ts) + { + timeval[0].tv_sec = ts[0].tv_sec; + timeval[0].tv_usec = ts[0].tv_nsec / 1000; + timeval[1].tv_sec = ts[1].tv_sec; + timeval[1].tv_usec = ts[1].tv_nsec / 1000; + t = timeval; + } + else + t = NULL; + + result = lutimes (file, t); + if (result == 0 || errno != ENOSYS) + return result; + } +#endif /* HAVE_LUTIMES && !HAVE_UTIMENSAT */ + + /* Out of luck for symlinks, but we still handle regular files. */ + if (!(adjustment_needed || REPLACE_FUNC_STAT_FILE) && lstat (file, &st)) + return -1; + if (!S_ISLNK (st.st_mode)) + return fdutimens (file, -1, ts); + errno = ENOSYS; + return -1; } diff --git a/src/bin/coreutils/lib/utimens.h b/src/bin/coreutils/lib/utimens.h index 169521da73..bb0326da5f 100644 --- a/src/bin/coreutils/lib/utimens.h +++ b/src/bin/coreutils/lib/utimens.h @@ -1,3 +1,19 @@ #include +int fdutimens (char const *, int, struct timespec const [2]); int gl_futimens (int, char const *, struct timespec const [2]); int utimens (char const *, struct timespec const [2]); +int lutimens (char const *, struct timespec const [2]); + +#if GNULIB_FDUTIMENSAT +# include +# include + +int fdutimensat (int dir, char const *name, int fd, struct timespec const [2]); + +/* Using this function makes application code slightly more readable. */ +static inline int +lutimensat (int fd, char const *file, struct timespec const times[2]) +{ + return utimensat (fd, file, times, AT_SYMLINK_NOFOLLOW); +} +#endif diff --git a/src/bin/coreutils/lib/vasnprintf.c b/src/bin/coreutils/lib/vasnprintf.c index a6fcd26939..7c74b451c8 100644 --- a/src/bin/coreutils/lib/vasnprintf.c +++ b/src/bin/coreutils/lib/vasnprintf.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* vsprintf with automatic memory allocation. - Copyright (C) 1999, 2002-2009 Free Software Foundation, Inc. + Copyright (C) 1999, 2002-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -70,13 +70,13 @@ # endif #endif -#include /* localeconv() */ -#include /* snprintf(), sprintf() */ -#include /* abort(), malloc(), realloc(), free() */ -#include /* memcpy(), strlen() */ -#include /* errno */ -#include /* CHAR_BIT */ -#include /* DBL_MAX_EXP, LDBL_MAX_EXP */ +#include /* localeconv() */ +#include /* snprintf(), sprintf() */ +#include /* abort(), malloc(), realloc(), free() */ +#include /* memcpy(), strlen() */ +#include /* errno */ +#include /* CHAR_BIT */ +#include /* DBL_MAX_EXP, LDBL_MAX_EXP */ #if HAVE_NL_LANGINFO # include #endif @@ -264,10 +264,10 @@ decimal_point_char (void) { const char *point; /* Determine it in a multithread-safe way. We know nl_langinfo is - multithread-safe on glibc systems, but is not required to be multithread- - safe by POSIX. sprintf(), however, is multithread-safe. localeconv() - is rarely multithread-safe. */ -# if HAVE_NL_LANGINFO && __GLIBC__ + multithread-safe on glibc systems and MacOS X systems, but is not required + to be multithread-safe by POSIX. sprintf(), however, is multithread-safe. + localeconv() is rarely multithread-safe. */ +# if HAVE_NL_LANGINFO && (__GLIBC__ || (defined __APPLE__ && defined __MACH__)) point = nl_langinfo (RADIXCHAR); # elif 1 char pointbuf[5]; @@ -367,26 +367,26 @@ multiply (mpn_t src1, mpn_t src2, mpn_t *dest) dlen = len1 + len2; dp = (mp_limb_t *) malloc (dlen * sizeof (mp_limb_t)); if (dp == NULL) - return NULL; + return NULL; for (k = len2; k > 0; ) - dp[--k] = 0; + dp[--k] = 0; for (i = 0; i < len1; i++) - { - mp_limb_t digit1 = p1[i]; - mp_twolimb_t carry = 0; - for (j = 0; j < len2; j++) - { - mp_limb_t digit2 = p2[j]; - carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2; - carry += dp[i + j]; - dp[i + j] = (mp_limb_t) carry; - carry = carry >> GMP_LIMB_BITS; - } - dp[i + len2] = (mp_limb_t) carry; - } + { + mp_limb_t digit1 = p1[i]; + mp_twolimb_t carry = 0; + for (j = 0; j < len2; j++) + { + mp_limb_t digit2 = p2[j]; + carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2; + carry += dp[i + j]; + dp[i + j] = (mp_limb_t) carry; + carry = carry >> GMP_LIMB_BITS; + } + dp[i + len2] = (mp_limb_t) carry; + } /* Normalise. */ while (dlen > 0 && dp[dlen - 1] == 0) - dlen--; + dlen--; dest->nlimbs = dlen; dest->limbs = dp; } @@ -480,12 +480,12 @@ divide (mpn_t a, mpn_t b, mpn_t *q) for (;;) { if (b_len == 0) - /* Division by zero. */ - abort (); + /* Division by zero. */ + abort (); if (b_ptr[b_len - 1] == 0) - b_len--; + b_len--; else - break; + break; } /* Here m = a_len >= 0 and n = b_len > 0. */ @@ -502,261 +502,261 @@ divide (mpn_t a, mpn_t b, mpn_t *q) else if (b_len == 1) { /* n=1: single precision division. - beta^(m-1) <= a < beta^m ==> beta^(m-2) <= a/b < beta^m */ + beta^(m-1) <= a < beta^m ==> beta^(m-2) <= a/b < beta^m */ r_ptr = roomptr; q_ptr = roomptr + 1; { - mp_limb_t den = b_ptr[0]; - mp_limb_t remainder = 0; - const mp_limb_t *sourceptr = a_ptr + a_len; - mp_limb_t *destptr = q_ptr + a_len; - size_t count; - for (count = a_len; count > 0; count--) - { - mp_twolimb_t num = - ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--sourceptr; - *--destptr = num / den; - remainder = num % den; - } - /* Normalise and store r. */ - if (remainder > 0) - { - r_ptr[0] = remainder; - r_len = 1; - } - else - r_len = 0; - /* Normalise q. */ - q_len = a_len; - if (q_ptr[q_len - 1] == 0) - q_len--; + mp_limb_t den = b_ptr[0]; + mp_limb_t remainder = 0; + const mp_limb_t *sourceptr = a_ptr + a_len; + mp_limb_t *destptr = q_ptr + a_len; + size_t count; + for (count = a_len; count > 0; count--) + { + mp_twolimb_t num = + ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--sourceptr; + *--destptr = num / den; + remainder = num % den; + } + /* Normalise and store r. */ + if (remainder > 0) + { + r_ptr[0] = remainder; + r_len = 1; + } + else + r_len = 0; + /* Normalise q. */ + q_len = a_len; + if (q_ptr[q_len - 1] == 0) + q_len--; } } else { /* n>1: multiple precision division. - beta^(m-1) <= a < beta^m, beta^(n-1) <= b < beta^n ==> - beta^(m-n-1) <= a/b < beta^(m-n+1). */ + beta^(m-1) <= a < beta^m, beta^(n-1) <= b < beta^n ==> + beta^(m-n-1) <= a/b < beta^(m-n+1). */ /* Determine s. */ size_t s; { - mp_limb_t msd = b_ptr[b_len - 1]; /* = b[n-1], > 0 */ - s = 31; - if (msd >= 0x10000) - { - msd = msd >> 16; - s -= 16; - } - if (msd >= 0x100) - { - msd = msd >> 8; - s -= 8; - } - if (msd >= 0x10) - { - msd = msd >> 4; - s -= 4; - } - if (msd >= 0x4) - { - msd = msd >> 2; - s -= 2; - } - if (msd >= 0x2) - { - msd = msd >> 1; - s -= 1; - } + mp_limb_t msd = b_ptr[b_len - 1]; /* = b[n-1], > 0 */ + s = 31; + if (msd >= 0x10000) + { + msd = msd >> 16; + s -= 16; + } + if (msd >= 0x100) + { + msd = msd >> 8; + s -= 8; + } + if (msd >= 0x10) + { + msd = msd >> 4; + s -= 4; + } + if (msd >= 0x4) + { + msd = msd >> 2; + s -= 2; + } + if (msd >= 0x2) + { + msd = msd >> 1; + s -= 1; + } } /* 0 <= s < GMP_LIMB_BITS. - Copy b, shifting it left by s bits. */ + Copy b, shifting it left by s bits. */ if (s > 0) - { - tmp_roomptr = (mp_limb_t *) malloc (b_len * sizeof (mp_limb_t)); - if (tmp_roomptr == NULL) - { - free (roomptr); - return NULL; - } - { - const mp_limb_t *sourceptr = b_ptr; - mp_limb_t *destptr = tmp_roomptr; - mp_twolimb_t accu = 0; - size_t count; - for (count = b_len; count > 0; count--) - { - accu += (mp_twolimb_t) *sourceptr++ << s; - *destptr++ = (mp_limb_t) accu; - accu = accu >> GMP_LIMB_BITS; - } - /* accu must be zero, since that was how s was determined. */ - if (accu != 0) - abort (); - } - b_ptr = tmp_roomptr; - } + { + tmp_roomptr = (mp_limb_t *) malloc (b_len * sizeof (mp_limb_t)); + if (tmp_roomptr == NULL) + { + free (roomptr); + return NULL; + } + { + const mp_limb_t *sourceptr = b_ptr; + mp_limb_t *destptr = tmp_roomptr; + mp_twolimb_t accu = 0; + size_t count; + for (count = b_len; count > 0; count--) + { + accu += (mp_twolimb_t) *sourceptr++ << s; + *destptr++ = (mp_limb_t) accu; + accu = accu >> GMP_LIMB_BITS; + } + /* accu must be zero, since that was how s was determined. */ + if (accu != 0) + abort (); + } + b_ptr = tmp_roomptr; + } /* Copy a, shifting it left by s bits, yields r. - Memory layout: - At the beginning: r = roomptr[0..a_len], - at the end: r = roomptr[0..b_len-1], q = roomptr[b_len..a_len] */ + Memory layout: + At the beginning: r = roomptr[0..a_len], + at the end: r = roomptr[0..b_len-1], q = roomptr[b_len..a_len] */ r_ptr = roomptr; if (s == 0) - { - memcpy (r_ptr, a_ptr, a_len * sizeof (mp_limb_t)); - r_ptr[a_len] = 0; - } + { + memcpy (r_ptr, a_ptr, a_len * sizeof (mp_limb_t)); + r_ptr[a_len] = 0; + } else - { - const mp_limb_t *sourceptr = a_ptr; - mp_limb_t *destptr = r_ptr; - mp_twolimb_t accu = 0; - size_t count; - for (count = a_len; count > 0; count--) - { - accu += (mp_twolimb_t) *sourceptr++ << s; - *destptr++ = (mp_limb_t) accu; - accu = accu >> GMP_LIMB_BITS; - } - *destptr++ = (mp_limb_t) accu; - } + { + const mp_limb_t *sourceptr = a_ptr; + mp_limb_t *destptr = r_ptr; + mp_twolimb_t accu = 0; + size_t count; + for (count = a_len; count > 0; count--) + { + accu += (mp_twolimb_t) *sourceptr++ << s; + *destptr++ = (mp_limb_t) accu; + accu = accu >> GMP_LIMB_BITS; + } + *destptr++ = (mp_limb_t) accu; + } q_ptr = roomptr + b_len; q_len = a_len - b_len + 1; /* q will have m-n+1 limbs */ { - size_t j = a_len - b_len; /* m-n */ - mp_limb_t b_msd = b_ptr[b_len - 1]; /* b[n-1] */ - mp_limb_t b_2msd = b_ptr[b_len - 2]; /* b[n-2] */ - mp_twolimb_t b_msdd = /* b[n-1]*beta+b[n-2] */ - ((mp_twolimb_t) b_msd << GMP_LIMB_BITS) | b_2msd; - /* Division loop, traversed m-n+1 times. - j counts down, b is unchanged, beta/2 <= b[n-1] < beta. */ - for (;;) - { - mp_limb_t q_star; - mp_limb_t c1; - if (r_ptr[j + b_len] < b_msd) /* r[j+n] < b[n-1] ? */ - { - /* Divide r[j+n]*beta+r[j+n-1] by b[n-1], no overflow. */ - mp_twolimb_t num = - ((mp_twolimb_t) r_ptr[j + b_len] << GMP_LIMB_BITS) - | r_ptr[j + b_len - 1]; - q_star = num / b_msd; - c1 = num % b_msd; - } - else - { - /* Overflow, hence r[j+n]*beta+r[j+n-1] >= beta*b[n-1]. */ - q_star = (mp_limb_t)~(mp_limb_t)0; /* q* = beta-1 */ - /* Test whether r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] >= beta - <==> r[j+n]*beta+r[j+n-1] + b[n-1] >= beta*b[n-1]+beta - <==> b[n-1] < floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta) - {<= beta !}. - If yes, jump directly to the subtraction loop. - (Otherwise, r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] < beta - <==> floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta) = b[n-1] ) */ - if (r_ptr[j + b_len] > b_msd - || (c1 = r_ptr[j + b_len - 1] + b_msd) < b_msd) - /* r[j+n] >= b[n-1]+1 or - r[j+n] = b[n-1] and the addition r[j+n-1]+b[n-1] gives a - carry. */ - goto subtract; - } - /* q_star = q*, - c1 = (r[j+n]*beta+r[j+n-1]) - q* * b[n-1] (>=0, 0, decrease it by - b[n-1]*beta+b[n-2]. Because of b[n-1]*beta+b[n-2] >= beta^2/2 - this can happen only twice. */ - if (c3 > c2) - { - q_star = q_star - 1; /* q* := q* - 1 */ - if (c3 - c2 > b_msdd) - q_star = q_star - 1; /* q* := q* - 1 */ - } - } - if (q_star > 0) - subtract: - { - /* Subtract r := r - b * q* * beta^j. */ - mp_limb_t cr; - { - const mp_limb_t *sourceptr = b_ptr; - mp_limb_t *destptr = r_ptr + j; - mp_twolimb_t carry = 0; - size_t count; - for (count = b_len; count > 0; count--) - { - /* Here 0 <= carry <= q*. */ - carry = - carry - + (mp_twolimb_t) q_star * (mp_twolimb_t) *sourceptr++ - + (mp_limb_t) ~(*destptr); - /* Here 0 <= carry <= beta*q* + beta-1. */ - *destptr++ = ~(mp_limb_t) carry; - carry = carry >> GMP_LIMB_BITS; /* <= q* */ - } - cr = (mp_limb_t) carry; - } - /* Subtract cr from r_ptr[j + b_len], then forget about - r_ptr[j + b_len]. */ - if (cr > r_ptr[j + b_len]) - { - /* Subtraction gave a carry. */ - q_star = q_star - 1; /* q* := q* - 1 */ - /* Add b back. */ - { - const mp_limb_t *sourceptr = b_ptr; - mp_limb_t *destptr = r_ptr + j; - mp_limb_t carry = 0; - size_t count; - for (count = b_len; count > 0; count--) - { - mp_limb_t source1 = *sourceptr++; - mp_limb_t source2 = *destptr; - *destptr++ = source1 + source2 + carry; - carry = - (carry - ? source1 >= (mp_limb_t) ~source2 - : source1 > (mp_limb_t) ~source2); - } - } - /* Forget about the carry and about r[j+n]. */ - } - } - /* q* is determined. Store it as q[j]. */ - q_ptr[j] = q_star; - if (j == 0) - break; - j--; - } + size_t j = a_len - b_len; /* m-n */ + mp_limb_t b_msd = b_ptr[b_len - 1]; /* b[n-1] */ + mp_limb_t b_2msd = b_ptr[b_len - 2]; /* b[n-2] */ + mp_twolimb_t b_msdd = /* b[n-1]*beta+b[n-2] */ + ((mp_twolimb_t) b_msd << GMP_LIMB_BITS) | b_2msd; + /* Division loop, traversed m-n+1 times. + j counts down, b is unchanged, beta/2 <= b[n-1] < beta. */ + for (;;) + { + mp_limb_t q_star; + mp_limb_t c1; + if (r_ptr[j + b_len] < b_msd) /* r[j+n] < b[n-1] ? */ + { + /* Divide r[j+n]*beta+r[j+n-1] by b[n-1], no overflow. */ + mp_twolimb_t num = + ((mp_twolimb_t) r_ptr[j + b_len] << GMP_LIMB_BITS) + | r_ptr[j + b_len - 1]; + q_star = num / b_msd; + c1 = num % b_msd; + } + else + { + /* Overflow, hence r[j+n]*beta+r[j+n-1] >= beta*b[n-1]. */ + q_star = (mp_limb_t)~(mp_limb_t)0; /* q* = beta-1 */ + /* Test whether r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] >= beta + <==> r[j+n]*beta+r[j+n-1] + b[n-1] >= beta*b[n-1]+beta + <==> b[n-1] < floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta) + {<= beta !}. + If yes, jump directly to the subtraction loop. + (Otherwise, r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] < beta + <==> floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta) = b[n-1] ) */ + if (r_ptr[j + b_len] > b_msd + || (c1 = r_ptr[j + b_len - 1] + b_msd) < b_msd) + /* r[j+n] >= b[n-1]+1 or + r[j+n] = b[n-1] and the addition r[j+n-1]+b[n-1] gives a + carry. */ + goto subtract; + } + /* q_star = q*, + c1 = (r[j+n]*beta+r[j+n-1]) - q* * b[n-1] (>=0, 0, decrease it by + b[n-1]*beta+b[n-2]. Because of b[n-1]*beta+b[n-2] >= beta^2/2 + this can happen only twice. */ + if (c3 > c2) + { + q_star = q_star - 1; /* q* := q* - 1 */ + if (c3 - c2 > b_msdd) + q_star = q_star - 1; /* q* := q* - 1 */ + } + } + if (q_star > 0) + subtract: + { + /* Subtract r := r - b * q* * beta^j. */ + mp_limb_t cr; + { + const mp_limb_t *sourceptr = b_ptr; + mp_limb_t *destptr = r_ptr + j; + mp_twolimb_t carry = 0; + size_t count; + for (count = b_len; count > 0; count--) + { + /* Here 0 <= carry <= q*. */ + carry = + carry + + (mp_twolimb_t) q_star * (mp_twolimb_t) *sourceptr++ + + (mp_limb_t) ~(*destptr); + /* Here 0 <= carry <= beta*q* + beta-1. */ + *destptr++ = ~(mp_limb_t) carry; + carry = carry >> GMP_LIMB_BITS; /* <= q* */ + } + cr = (mp_limb_t) carry; + } + /* Subtract cr from r_ptr[j + b_len], then forget about + r_ptr[j + b_len]. */ + if (cr > r_ptr[j + b_len]) + { + /* Subtraction gave a carry. */ + q_star = q_star - 1; /* q* := q* - 1 */ + /* Add b back. */ + { + const mp_limb_t *sourceptr = b_ptr; + mp_limb_t *destptr = r_ptr + j; + mp_limb_t carry = 0; + size_t count; + for (count = b_len; count > 0; count--) + { + mp_limb_t source1 = *sourceptr++; + mp_limb_t source2 = *destptr; + *destptr++ = source1 + source2 + carry; + carry = + (carry + ? source1 >= (mp_limb_t) ~source2 + : source1 > (mp_limb_t) ~source2); + } + } + /* Forget about the carry and about r[j+n]. */ + } + } + /* q* is determined. Store it as q[j]. */ + q_ptr[j] = q_star; + if (j == 0) + break; + j--; + } } r_len = b_len; /* Normalise q. */ if (q_ptr[q_len - 1] == 0) - q_len--; + q_len--; # if 0 /* Not needed here, since we need r only to compare it with b/2, and - b is shifted left by s bits. */ + b is shifted left by s bits. */ /* Shift r right by s bits. */ if (s > 0) - { - mp_limb_t ptr = r_ptr + r_len; - mp_twolimb_t accu = 0; - size_t count; - for (count = r_len; count > 0; count--) - { - accu = (mp_twolimb_t) (mp_limb_t) accu << GMP_LIMB_BITS; - accu += (mp_twolimb_t) *--ptr << (GMP_LIMB_BITS - s); - *ptr = (mp_limb_t) (accu >> GMP_LIMB_BITS); - } - } + { + mp_limb_t ptr = r_ptr + r_len; + mp_twolimb_t accu = 0; + size_t count; + for (count = r_len; count > 0; count--) + { + accu = (mp_twolimb_t) (mp_limb_t) accu << GMP_LIMB_BITS; + accu += (mp_twolimb_t) *--ptr << (GMP_LIMB_BITS - s); + *ptr = (mp_limb_t) (accu >> GMP_LIMB_BITS); + } + } # endif /* Normalise r. */ while (r_len > 0 && r_ptr[r_len - 1] == 0) - r_len--; + r_len--; } /* Compare r << 1 with b. */ if (r_len > b_len) @@ -765,17 +765,17 @@ divide (mpn_t a, mpn_t b, mpn_t *q) size_t i; for (i = b_len;;) { - mp_limb_t r_i = - (i <= r_len && i > 0 ? r_ptr[i - 1] >> (GMP_LIMB_BITS - 1) : 0) - | (i < r_len ? r_ptr[i] << 1 : 0); - mp_limb_t b_i = (i < b_len ? b_ptr[i] : 0); - if (r_i > b_i) - goto increment_q; - if (r_i < b_i) - goto keep_q; - if (i == 0) - break; - i--; + mp_limb_t r_i = + (i <= r_len && i > 0 ? r_ptr[i - 1] >> (GMP_LIMB_BITS - 1) : 0) + | (i < r_len ? r_ptr[i] << 1 : 0); + mp_limb_t b_i = (i < b_len ? b_ptr[i] : 0); + if (r_i > b_i) + goto increment_q; + if (r_i < b_i) + goto keep_q; + if (i == 0) + break; + i--; } } if (q_len > 0 && ((q_ptr[0] & 1) != 0)) @@ -784,8 +784,8 @@ divide (mpn_t a, mpn_t b, mpn_t *q) { size_t i; for (i = 0; i < q_len; i++) - if (++(q_ptr[i]) != 0) - goto keep_q; + if (++(q_ptr[i]) != 0) + goto keep_q; q_ptr[q_len++] = 1; } keep_q: @@ -814,36 +814,36 @@ convert_to_decimal (mpn_t a, size_t extra_zeroes) { char *d_ptr = c_ptr; for (; extra_zeroes > 0; extra_zeroes--) - *d_ptr++ = '0'; + *d_ptr++ = '0'; while (a_len > 0) - { - /* Divide a by 10^9, in-place. */ - mp_limb_t remainder = 0; - mp_limb_t *ptr = a_ptr + a_len; - size_t count; - for (count = a_len; count > 0; count--) - { - mp_twolimb_t num = - ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--ptr; - *ptr = num / 1000000000; - remainder = num % 1000000000; - } - /* Store the remainder as 9 decimal digits. */ - for (count = 9; count > 0; count--) - { - *d_ptr++ = '0' + (remainder % 10); - remainder = remainder / 10; - } - /* Normalize a. */ - if (a_ptr[a_len - 1] == 0) - a_len--; - } + { + /* Divide a by 10^9, in-place. */ + mp_limb_t remainder = 0; + mp_limb_t *ptr = a_ptr + a_len; + size_t count; + for (count = a_len; count > 0; count--) + { + mp_twolimb_t num = + ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--ptr; + *ptr = num / 1000000000; + remainder = num % 1000000000; + } + /* Store the remainder as 9 decimal digits. */ + for (count = 9; count > 0; count--) + { + *d_ptr++ = '0' + (remainder % 10); + remainder = remainder / 10; + } + /* Normalize a. */ + if (a_ptr[a_len - 1] == 0) + a_len--; + } /* Remove leading zeroes. */ while (d_ptr > c_ptr && d_ptr[-1] == '0') - d_ptr--; + d_ptr--; /* But keep at least one zero. */ if (d_ptr == c_ptr) - *d_ptr++ = '0'; + *d_ptr++ = '0'; /* Terminate the string. */ *d_ptr = '\0'; } @@ -888,12 +888,12 @@ decode_long_double (long double x, int *ep, mpn_t *mp) hi = (int) y; y -= hi; if (!(y >= 0.0L && y < 1.0L)) - abort (); + abort (); y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); lo = (int) y; y -= lo; if (!(y >= 0.0L && y < 1.0L)) - abort (); + abort (); m.limbs[LDBL_MANT_BIT / GMP_LIMB_BITS] = (hi << (GMP_LIMB_BITS / 2)) | lo; } # else @@ -903,7 +903,7 @@ decode_long_double (long double x, int *ep, mpn_t *mp) d = (int) y; y -= d; if (!(y >= 0.0L && y < 1.0L)) - abort (); + abort (); m.limbs[LDBL_MANT_BIT / GMP_LIMB_BITS] = d; } # endif @@ -915,12 +915,12 @@ decode_long_double (long double x, int *ep, mpn_t *mp) hi = (int) y; y -= hi; if (!(y >= 0.0L && y < 1.0L)) - abort (); + abort (); y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); lo = (int) y; y -= lo; if (!(y >= 0.0L && y < 1.0L)) - abort (); + abort (); m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo; } #if 0 /* On FreeBSD 6.1/x86, 'long double' numbers sometimes have excess @@ -976,12 +976,12 @@ decode_double (double x, int *ep, mpn_t *mp) hi = (int) y; y -= hi; if (!(y >= 0.0 && y < 1.0)) - abort (); + abort (); y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); lo = (int) y; y -= lo; if (!(y >= 0.0 && y < 1.0)) - abort (); + abort (); m.limbs[DBL_MANT_BIT / GMP_LIMB_BITS] = (hi << (GMP_LIMB_BITS / 2)) | lo; } # else @@ -991,7 +991,7 @@ decode_double (double x, int *ep, mpn_t *mp) d = (int) y; y -= d; if (!(y >= 0.0 && y < 1.0)) - abort (); + abort (); m.limbs[DBL_MANT_BIT / GMP_LIMB_BITS] = d; } # endif @@ -1003,12 +1003,12 @@ decode_double (double x, int *ep, mpn_t *mp) hi = (int) y; y -= hi; if (!(y >= 0.0 && y < 1.0)) - abort (); + abort (); y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2); lo = (int) y; y -= lo; if (!(y >= 0.0 && y < 1.0)) - abort (); + abort (); m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo; } if (!(y == 0.0)) @@ -1066,8 +1066,8 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n) abs_n = (n >= 0 ? n : -n); abs_s = (s >= 0 ? s : -s); pow5_ptr = (mp_limb_t *) malloc (((int)(abs_n * (2.322f / GMP_LIMB_BITS)) + 1 - + abs_s / GMP_LIMB_BITS + 1) - * sizeof (mp_limb_t)); + + abs_s / GMP_LIMB_BITS + 1) + * sizeof (mp_limb_t)); if (pow5_ptr == NULL) { free (memory); @@ -1080,26 +1080,26 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n) if (abs_n > 0) { static mp_limb_t const small_pow5[13 + 1] = - { - 1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, - 48828125, 244140625, 1220703125 - }; + { + 1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, + 48828125, 244140625, 1220703125 + }; unsigned int n13; for (n13 = 0; n13 <= abs_n; n13 += 13) - { - mp_limb_t digit1 = small_pow5[n13 + 13 <= abs_n ? 13 : abs_n - n13]; - size_t j; - mp_twolimb_t carry = 0; - for (j = 0; j < pow5_len; j++) - { - mp_limb_t digit2 = pow5_ptr[j]; - carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2; - pow5_ptr[j] = (mp_limb_t) carry; - carry = carry >> GMP_LIMB_BITS; - } - if (carry > 0) - pow5_ptr[pow5_len++] = (mp_limb_t) carry; - } + { + mp_limb_t digit1 = small_pow5[n13 + 13 <= abs_n ? 13 : abs_n - n13]; + size_t j; + mp_twolimb_t carry = 0; + for (j = 0; j < pow5_len; j++) + { + mp_limb_t digit2 = pow5_ptr[j]; + carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2; + pow5_ptr[j] = (mp_limb_t) carry; + carry = carry >> GMP_LIMB_BITS; + } + if (carry > 0) + pow5_ptr[pow5_len++] = (mp_limb_t) carry; + } } s_limbs = abs_s / GMP_LIMB_BITS; s_bits = abs_s % GMP_LIMB_BITS; @@ -1107,129 +1107,129 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n) { /* Multiply with 2^|s|. */ if (s_bits > 0) - { - mp_limb_t *ptr = pow5_ptr; - mp_twolimb_t accu = 0; - size_t count; - for (count = pow5_len; count > 0; count--) - { - accu += (mp_twolimb_t) *ptr << s_bits; - *ptr++ = (mp_limb_t) accu; - accu = accu >> GMP_LIMB_BITS; - } - if (accu > 0) - { - *ptr = (mp_limb_t) accu; - pow5_len++; - } - } + { + mp_limb_t *ptr = pow5_ptr; + mp_twolimb_t accu = 0; + size_t count; + for (count = pow5_len; count > 0; count--) + { + accu += (mp_twolimb_t) *ptr << s_bits; + *ptr++ = (mp_limb_t) accu; + accu = accu >> GMP_LIMB_BITS; + } + if (accu > 0) + { + *ptr = (mp_limb_t) accu; + pow5_len++; + } + } if (s_limbs > 0) - { - size_t count; - for (count = pow5_len; count > 0;) - { - count--; - pow5_ptr[s_limbs + count] = pow5_ptr[count]; - } - for (count = s_limbs; count > 0;) - { - count--; - pow5_ptr[count] = 0; - } - pow5_len += s_limbs; - } + { + size_t count; + for (count = pow5_len; count > 0;) + { + count--; + pow5_ptr[s_limbs + count] = pow5_ptr[count]; + } + for (count = s_limbs; count > 0;) + { + count--; + pow5_ptr[count] = 0; + } + pow5_len += s_limbs; + } pow5.limbs = pow5_ptr; pow5.nlimbs = pow5_len; if (n >= 0) - { - /* Multiply m with pow5. No division needed. */ - z_memory = multiply (m, pow5, &z); - } + { + /* Multiply m with pow5. No division needed. */ + z_memory = multiply (m, pow5, &z); + } else - { - /* Divide m by pow5 and round. */ - z_memory = divide (m, pow5, &z); - } + { + /* Divide m by pow5 and round. */ + z_memory = divide (m, pow5, &z); + } } else { pow5.limbs = pow5_ptr; pow5.nlimbs = pow5_len; if (n >= 0) - { - /* n >= 0, s < 0. - Multiply m with pow5, then divide by 2^|s|. */ - mpn_t numerator; - mpn_t denominator; - void *tmp_memory; - tmp_memory = multiply (m, pow5, &numerator); - if (tmp_memory == NULL) - { - free (pow5_ptr); - free (memory); - return NULL; - } - /* Construct 2^|s|. */ - { - mp_limb_t *ptr = pow5_ptr + pow5_len; - size_t i; - for (i = 0; i < s_limbs; i++) - ptr[i] = 0; - ptr[s_limbs] = (mp_limb_t) 1 << s_bits; - denominator.limbs = ptr; - denominator.nlimbs = s_limbs + 1; - } - z_memory = divide (numerator, denominator, &z); - free (tmp_memory); - } + { + /* n >= 0, s < 0. + Multiply m with pow5, then divide by 2^|s|. */ + mpn_t numerator; + mpn_t denominator; + void *tmp_memory; + tmp_memory = multiply (m, pow5, &numerator); + if (tmp_memory == NULL) + { + free (pow5_ptr); + free (memory); + return NULL; + } + /* Construct 2^|s|. */ + { + mp_limb_t *ptr = pow5_ptr + pow5_len; + size_t i; + for (i = 0; i < s_limbs; i++) + ptr[i] = 0; + ptr[s_limbs] = (mp_limb_t) 1 << s_bits; + denominator.limbs = ptr; + denominator.nlimbs = s_limbs + 1; + } + z_memory = divide (numerator, denominator, &z); + free (tmp_memory); + } else - { - /* n < 0, s > 0. - Multiply m with 2^s, then divide by pow5. */ - mpn_t numerator; - mp_limb_t *num_ptr; - num_ptr = (mp_limb_t *) malloc ((m.nlimbs + s_limbs + 1) - * sizeof (mp_limb_t)); - if (num_ptr == NULL) - { - free (pow5_ptr); - free (memory); - return NULL; - } - { - mp_limb_t *destptr = num_ptr; - { - size_t i; - for (i = 0; i < s_limbs; i++) - *destptr++ = 0; - } - if (s_bits > 0) - { - const mp_limb_t *sourceptr = m.limbs; - mp_twolimb_t accu = 0; - size_t count; - for (count = m.nlimbs; count > 0; count--) - { - accu += (mp_twolimb_t) *sourceptr++ << s_bits; - *destptr++ = (mp_limb_t) accu; - accu = accu >> GMP_LIMB_BITS; - } - if (accu > 0) - *destptr++ = (mp_limb_t) accu; - } - else - { - const mp_limb_t *sourceptr = m.limbs; - size_t count; - for (count = m.nlimbs; count > 0; count--) - *destptr++ = *sourceptr++; - } - numerator.limbs = num_ptr; - numerator.nlimbs = destptr - num_ptr; - } - z_memory = divide (numerator, pow5, &z); - free (num_ptr); - } + { + /* n < 0, s > 0. + Multiply m with 2^s, then divide by pow5. */ + mpn_t numerator; + mp_limb_t *num_ptr; + num_ptr = (mp_limb_t *) malloc ((m.nlimbs + s_limbs + 1) + * sizeof (mp_limb_t)); + if (num_ptr == NULL) + { + free (pow5_ptr); + free (memory); + return NULL; + } + { + mp_limb_t *destptr = num_ptr; + { + size_t i; + for (i = 0; i < s_limbs; i++) + *destptr++ = 0; + } + if (s_bits > 0) + { + const mp_limb_t *sourceptr = m.limbs; + mp_twolimb_t accu = 0; + size_t count; + for (count = m.nlimbs; count > 0; count--) + { + accu += (mp_twolimb_t) *sourceptr++ << s_bits; + *destptr++ = (mp_limb_t) accu; + accu = accu >> GMP_LIMB_BITS; + } + if (accu > 0) + *destptr++ = (mp_limb_t) accu; + } + else + { + const mp_limb_t *sourceptr = m.limbs; + size_t count; + for (count = m.nlimbs; count > 0; count--) + *destptr++ = *sourceptr++; + } + numerator.limbs = num_ptr; + numerator.nlimbs = destptr - num_ptr; + } + z_memory = divide (numerator, pow5, &z); + free (num_ptr); + } } free (pow5_ptr); free (memory); @@ -1301,35 +1301,35 @@ floorlog10l (long double x) if (y < 0.5L) { while (y < (1.0L / (1 << (GMP_LIMB_BITS / 2)) / (1 << (GMP_LIMB_BITS / 2)))) - { - y *= 1.0L * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2)); - exp -= GMP_LIMB_BITS; - } + { + y *= 1.0L * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2)); + exp -= GMP_LIMB_BITS; + } if (y < (1.0L / (1 << 16))) - { - y *= 1.0L * (1 << 16); - exp -= 16; - } + { + y *= 1.0L * (1 << 16); + exp -= 16; + } if (y < (1.0L / (1 << 8))) - { - y *= 1.0L * (1 << 8); - exp -= 8; - } + { + y *= 1.0L * (1 << 8); + exp -= 8; + } if (y < (1.0L / (1 << 4))) - { - y *= 1.0L * (1 << 4); - exp -= 4; - } + { + y *= 1.0L * (1 << 4); + exp -= 4; + } if (y < (1.0L / (1 << 2))) - { - y *= 1.0L * (1 << 2); - exp -= 2; - } + { + y *= 1.0L * (1 << 2); + exp -= 2; + } if (y < (1.0L / (1 << 1))) - { - y *= 1.0L * (1 << 1); - exp -= 1; - } + { + y *= 1.0L * (1 << 1); + exp -= 1; + } } if (!(y >= 0.5L && y < 1.0L)) abort (); @@ -1392,35 +1392,35 @@ floorlog10 (double x) if (y < 0.5) { while (y < (1.0 / (1 << (GMP_LIMB_BITS / 2)) / (1 << (GMP_LIMB_BITS / 2)))) - { - y *= 1.0 * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2)); - exp -= GMP_LIMB_BITS; - } + { + y *= 1.0 * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2)); + exp -= GMP_LIMB_BITS; + } if (y < (1.0 / (1 << 16))) - { - y *= 1.0 * (1 << 16); - exp -= 16; - } + { + y *= 1.0 * (1 << 16); + exp -= 16; + } if (y < (1.0 / (1 << 8))) - { - y *= 1.0 * (1 << 8); - exp -= 8; - } + { + y *= 1.0 * (1 << 8); + exp -= 8; + } if (y < (1.0 / (1 << 4))) - { - y *= 1.0 * (1 << 4); - exp -= 4; - } + { + y *= 1.0 * (1 << 4); + exp -= 4; + } if (y < (1.0 / (1 << 2))) - { - y *= 1.0 * (1 << 2); - exp -= 2; - } + { + y *= 1.0 * (1 << 2); + exp -= 2; + } if (y < (1.0 / (1 << 1))) - { - y *= 1.0 * (1 << 1); - exp -= 1; - } + { + y *= 1.0 * (1 << 1); + exp -= 1; + } } if (!(y >= 0.5 && y < 1.0)) abort (); @@ -1479,7 +1479,7 @@ is_borderline (const char *digits, size_t precision) DCHAR_T * VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, - const FCHAR_T *format, va_list args) + const FCHAR_T *format, va_list args) { DIRECTIVES d; arguments a; @@ -1489,8 +1489,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, return NULL; #define CLEANUP() \ - free (d.dir); \ - if (a.arg) \ + free (d.dir); \ + if (a.arg) \ free (a.arg); if (PRINTF_FETCHARGS (args, &a) < 0) @@ -1519,30 +1519,30 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, #if HAVE_ALLOCA if (buf_neededlength < 4000 / sizeof (TCHAR_T)) { - buf = (TCHAR_T *) alloca (buf_neededlength * sizeof (TCHAR_T)); - buf_malloced = NULL; + buf = (TCHAR_T *) alloca (buf_neededlength * sizeof (TCHAR_T)); + buf_malloced = NULL; } else #endif { - size_t buf_memsize = xtimes (buf_neededlength, sizeof (TCHAR_T)); - if (size_overflow_p (buf_memsize)) - goto out_of_memory_1; - buf = (TCHAR_T *) malloc (buf_memsize); - if (buf == NULL) - goto out_of_memory_1; - buf_malloced = buf; + size_t buf_memsize = xtimes (buf_neededlength, sizeof (TCHAR_T)); + if (size_overflow_p (buf_memsize)) + goto out_of_memory_1; + buf = (TCHAR_T *) malloc (buf_memsize); + if (buf == NULL) + goto out_of_memory_1; + buf_malloced = buf; } if (resultbuf != NULL) { - result = resultbuf; - allocated = *lengthp; + result = resultbuf; + allocated = *lengthp; } else { - result = NULL; - allocated = 0; + result = NULL; + allocated = 0; } length = 0; /* Invariants: @@ -1552,3881 +1552,3881 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, /* Ensures that allocated >= needed. Aborts through a jump to out_of_memory if needed is SIZE_MAX or otherwise too big. */ #define ENSURE_ALLOCATION(needed) \ - if ((needed) > allocated) \ - { \ - size_t memory_size; \ - DCHAR_T *memory; \ - \ - allocated = (allocated > 0 ? xtimes (allocated, 2) : 12); \ - if ((needed) > allocated) \ - allocated = (needed); \ - memory_size = xtimes (allocated, sizeof (DCHAR_T)); \ - if (size_overflow_p (memory_size)) \ - goto out_of_memory; \ - if (result == resultbuf || result == NULL) \ - memory = (DCHAR_T *) malloc (memory_size); \ - else \ - memory = (DCHAR_T *) realloc (result, memory_size); \ - if (memory == NULL) \ - goto out_of_memory; \ - if (result == resultbuf && length > 0) \ - DCHAR_CPY (memory, result, length); \ - result = memory; \ + if ((needed) > allocated) \ + { \ + size_t memory_size; \ + DCHAR_T *memory; \ + \ + allocated = (allocated > 0 ? xtimes (allocated, 2) : 12); \ + if ((needed) > allocated) \ + allocated = (needed); \ + memory_size = xtimes (allocated, sizeof (DCHAR_T)); \ + if (size_overflow_p (memory_size)) \ + goto out_of_memory; \ + if (result == resultbuf || result == NULL) \ + memory = (DCHAR_T *) malloc (memory_size); \ + else \ + memory = (DCHAR_T *) realloc (result, memory_size); \ + if (memory == NULL) \ + goto out_of_memory; \ + if (result == resultbuf && length > 0) \ + DCHAR_CPY (memory, result, length); \ + result = memory; \ } for (cp = format, i = 0, dp = &d.dir[0]; ; cp = dp->dir_end, i++, dp++) { - if (cp != dp->dir_start) - { - size_t n = dp->dir_start - cp; - size_t augmented_length = xsum (length, n); + if (cp != dp->dir_start) + { + size_t n = dp->dir_start - cp; + size_t augmented_length = xsum (length, n); - ENSURE_ALLOCATION (augmented_length); - /* This copies a piece of FCHAR_T[] into a DCHAR_T[]. Here we - need that the format string contains only ASCII characters - if FCHAR_T and DCHAR_T are not the same type. */ - if (sizeof (FCHAR_T) == sizeof (DCHAR_T)) - { - DCHAR_CPY (result + length, (const DCHAR_T *) cp, n); - length = augmented_length; - } - else - { - do - result[length++] = (unsigned char) *cp++; - while (--n > 0); - } - } - if (i == d.count) - break; + ENSURE_ALLOCATION (augmented_length); + /* This copies a piece of FCHAR_T[] into a DCHAR_T[]. Here we + need that the format string contains only ASCII characters + if FCHAR_T and DCHAR_T are not the same type. */ + if (sizeof (FCHAR_T) == sizeof (DCHAR_T)) + { + DCHAR_CPY (result + length, (const DCHAR_T *) cp, n); + length = augmented_length; + } + else + { + do + result[length++] = (unsigned char) *cp++; + while (--n > 0); + } + } + if (i == d.count) + break; - /* Execute a single directive. */ - if (dp->conversion == '%') - { - size_t augmented_length; + /* Execute a single directive. */ + if (dp->conversion == '%') + { + size_t augmented_length; - if (!(dp->arg_index == ARG_NONE)) - abort (); - augmented_length = xsum (length, 1); - ENSURE_ALLOCATION (augmented_length); - result[length] = '%'; - length = augmented_length; - } - else - { - if (!(dp->arg_index != ARG_NONE)) - abort (); + if (!(dp->arg_index == ARG_NONE)) + abort (); + augmented_length = xsum (length, 1); + ENSURE_ALLOCATION (augmented_length); + result[length] = '%'; + length = augmented_length; + } + else + { + if (!(dp->arg_index != ARG_NONE)) + abort (); - if (dp->conversion == 'n') - { - switch (a.arg[dp->arg_index].type) - { - case TYPE_COUNT_SCHAR_POINTER: - *a.arg[dp->arg_index].a.a_count_schar_pointer = length; - break; - case TYPE_COUNT_SHORT_POINTER: - *a.arg[dp->arg_index].a.a_count_short_pointer = length; - break; - case TYPE_COUNT_INT_POINTER: - *a.arg[dp->arg_index].a.a_count_int_pointer = length; - break; - case TYPE_COUNT_LONGINT_POINTER: - *a.arg[dp->arg_index].a.a_count_longint_pointer = length; - break; + if (dp->conversion == 'n') + { + switch (a.arg[dp->arg_index].type) + { + case TYPE_COUNT_SCHAR_POINTER: + *a.arg[dp->arg_index].a.a_count_schar_pointer = length; + break; + case TYPE_COUNT_SHORT_POINTER: + *a.arg[dp->arg_index].a.a_count_short_pointer = length; + break; + case TYPE_COUNT_INT_POINTER: + *a.arg[dp->arg_index].a.a_count_int_pointer = length; + break; + case TYPE_COUNT_LONGINT_POINTER: + *a.arg[dp->arg_index].a.a_count_longint_pointer = length; + break; #if HAVE_LONG_LONG_INT - case TYPE_COUNT_LONGLONGINT_POINTER: - *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length; - break; + case TYPE_COUNT_LONGLONGINT_POINTER: + *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length; + break; #endif - default: - abort (); - } - } + default: + abort (); + } + } #if ENABLE_UNISTDIO - /* The unistdio extensions. */ - else if (dp->conversion == 'U') - { - arg_type type = a.arg[dp->arg_index].type; - int flags = dp->flags; - int has_width; - size_t width; - int has_precision; - size_t precision; + /* The unistdio extensions. */ + else if (dp->conversion == 'U') + { + arg_type type = a.arg[dp->arg_index].type; + int flags = dp->flags; + int has_width; + size_t width; + int has_precision; + size_t precision; - has_width = 0; - width = 0; - if (dp->width_start != dp->width_end) - { - if (dp->width_arg_index != ARG_NONE) - { - int arg; + has_width = 0; + width = 0; + if (dp->width_start != dp->width_end) + { + if (dp->width_arg_index != ARG_NONE) + { + int arg; - if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) - abort (); - arg = a.arg[dp->width_arg_index].a.a_int; - if (arg < 0) - { - /* "A negative field width is taken as a '-' flag - followed by a positive field width." */ - flags |= FLAG_LEFT; - width = (unsigned int) (-arg); - } - else - width = arg; - } - else - { - const FCHAR_T *digitp = dp->width_start; + if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->width_arg_index].a.a_int; + if (arg < 0) + { + /* "A negative field width is taken as a '-' flag + followed by a positive field width." */ + flags |= FLAG_LEFT; + width = (unsigned int) (-arg); + } + else + width = arg; + } + else + { + const FCHAR_T *digitp = dp->width_start; - do - width = xsum (xtimes (width, 10), *digitp++ - '0'); - while (digitp != dp->width_end); - } - has_width = 1; - } + do + width = xsum (xtimes (width, 10), *digitp++ - '0'); + while (digitp != dp->width_end); + } + has_width = 1; + } - has_precision = 0; - precision = 0; - if (dp->precision_start != dp->precision_end) - { - if (dp->precision_arg_index != ARG_NONE) - { - int arg; + has_precision = 0; + precision = 0; + if (dp->precision_start != dp->precision_end) + { + if (dp->precision_arg_index != ARG_NONE) + { + int arg; - if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) - abort (); - arg = a.arg[dp->precision_arg_index].a.a_int; - /* "A negative precision is taken as if the precision - were omitted." */ - if (arg >= 0) - { - precision = arg; - has_precision = 1; - } - } - else - { - const FCHAR_T *digitp = dp->precision_start + 1; + if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->precision_arg_index].a.a_int; + /* "A negative precision is taken as if the precision + were omitted." */ + if (arg >= 0) + { + precision = arg; + has_precision = 1; + } + } + else + { + const FCHAR_T *digitp = dp->precision_start + 1; - precision = 0; - while (digitp != dp->precision_end) - precision = xsum (xtimes (precision, 10), *digitp++ - '0'); - has_precision = 1; - } - } + precision = 0; + while (digitp != dp->precision_end) + precision = xsum (xtimes (precision, 10), *digitp++ - '0'); + has_precision = 1; + } + } - switch (type) - { - case TYPE_U8_STRING: - { - const uint8_t *arg = a.arg[dp->arg_index].a.a_u8_string; - const uint8_t *arg_end; - size_t characters; + switch (type) + { + case TYPE_U8_STRING: + { + const uint8_t *arg = a.arg[dp->arg_index].a.a_u8_string; + const uint8_t *arg_end; + size_t characters; - if (has_precision) - { - /* Use only PRECISION characters, from the left. */ - arg_end = arg; - characters = 0; - for (; precision > 0; precision--) - { - int count = u8_strmblen (arg_end); - if (count == 0) - break; - if (count < 0) - { - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = EILSEQ; - return NULL; - } - arg_end += count; - characters++; - } - } - else if (has_width) - { - /* Use the entire string, and count the number of - characters. */ - arg_end = arg; - characters = 0; - for (;;) - { - int count = u8_strmblen (arg_end); - if (count == 0) - break; - if (count < 0) - { - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = EILSEQ; - return NULL; - } - arg_end += count; - characters++; - } - } - else - { - /* Use the entire string. */ - arg_end = arg + u8_strlen (arg); - /* The number of characters doesn't matter. */ - characters = 0; - } + if (has_precision) + { + /* Use only PRECISION characters, from the left. */ + arg_end = arg; + characters = 0; + for (; precision > 0; precision--) + { + int count = u8_strmblen (arg_end); + if (count == 0) + break; + if (count < 0) + { + if (!(result == resultbuf || result == NULL)) + free (result); + if (buf_malloced != NULL) + free (buf_malloced); + CLEANUP (); + errno = EILSEQ; + return NULL; + } + arg_end += count; + characters++; + } + } + else if (has_width) + { + /* Use the entire string, and count the number of + characters. */ + arg_end = arg; + characters = 0; + for (;;) + { + int count = u8_strmblen (arg_end); + if (count == 0) + break; + if (count < 0) + { + if (!(result == resultbuf || result == NULL)) + free (result); + if (buf_malloced != NULL) + free (buf_malloced); + CLEANUP (); + errno = EILSEQ; + return NULL; + } + arg_end += count; + characters++; + } + } + else + { + /* Use the entire string. */ + arg_end = arg + u8_strlen (arg); + /* The number of characters doesn't matter. */ + characters = 0; + } - if (has_width && width > characters - && !(dp->flags & FLAG_LEFT)) - { - size_t n = width - characters; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_SET (result + length, ' ', n); - length += n; - } + if (has_width && width > characters + && !(dp->flags & FLAG_LEFT)) + { + size_t n = width - characters; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } # if DCHAR_IS_UINT8_T - { - size_t n = arg_end - arg; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_CPY (result + length, arg, n); - length += n; - } + { + size_t n = arg_end - arg; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_CPY (result + length, arg, n); + length += n; + } # else - { /* Convert. */ - DCHAR_T *converted = result + length; - size_t converted_len = allocated - length; + { /* Convert. */ + DCHAR_T *converted = result + length; + size_t converted_len = allocated - length; # if DCHAR_IS_TCHAR - /* Convert from UTF-8 to locale encoding. */ - converted = - u8_conv_to_encoding (locale_charset (), - iconveh_question_mark, - arg, arg_end - arg, NULL, - converted, &converted_len); + /* Convert from UTF-8 to locale encoding. */ + converted = + u8_conv_to_encoding (locale_charset (), + iconveh_question_mark, + arg, arg_end - arg, NULL, + converted, &converted_len); # else - /* Convert from UTF-8 to UTF-16/UTF-32. */ - converted = - U8_TO_DCHAR (arg, arg_end - arg, - converted, &converted_len); + /* Convert from UTF-8 to UTF-16/UTF-32. */ + converted = + U8_TO_DCHAR (arg, arg_end - arg, + converted, &converted_len); # endif - if (converted == NULL) - { - int saved_errno = errno; - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = saved_errno; - return NULL; - } - if (converted != result + length) - { - ENSURE_ALLOCATION (xsum (length, converted_len)); - DCHAR_CPY (result + length, converted, converted_len); - free (converted); - } - length += converted_len; - } + if (converted == NULL) + { + int saved_errno = errno; + if (!(result == resultbuf || result == NULL)) + free (result); + if (buf_malloced != NULL) + free (buf_malloced); + CLEANUP (); + errno = saved_errno; + return NULL; + } + if (converted != result + length) + { + ENSURE_ALLOCATION (xsum (length, converted_len)); + DCHAR_CPY (result + length, converted, converted_len); + free (converted); + } + length += converted_len; + } # endif - if (has_width && width > characters - && (dp->flags & FLAG_LEFT)) - { - size_t n = width - characters; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_SET (result + length, ' ', n); - length += n; - } - } - break; + if (has_width && width > characters + && (dp->flags & FLAG_LEFT)) + { + size_t n = width - characters; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } + } + break; - case TYPE_U16_STRING: - { - const uint16_t *arg = a.arg[dp->arg_index].a.a_u16_string; - const uint16_t *arg_end; - size_t characters; + case TYPE_U16_STRING: + { + const uint16_t *arg = a.arg[dp->arg_index].a.a_u16_string; + const uint16_t *arg_end; + size_t characters; - if (has_precision) - { - /* Use only PRECISION characters, from the left. */ - arg_end = arg; - characters = 0; - for (; precision > 0; precision--) - { - int count = u16_strmblen (arg_end); - if (count == 0) - break; - if (count < 0) - { - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = EILSEQ; - return NULL; - } - arg_end += count; - characters++; - } - } - else if (has_width) - { - /* Use the entire string, and count the number of - characters. */ - arg_end = arg; - characters = 0; - for (;;) - { - int count = u16_strmblen (arg_end); - if (count == 0) - break; - if (count < 0) - { - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = EILSEQ; - return NULL; - } - arg_end += count; - characters++; - } - } - else - { - /* Use the entire string. */ - arg_end = arg + u16_strlen (arg); - /* The number of characters doesn't matter. */ - characters = 0; - } + if (has_precision) + { + /* Use only PRECISION characters, from the left. */ + arg_end = arg; + characters = 0; + for (; precision > 0; precision--) + { + int count = u16_strmblen (arg_end); + if (count == 0) + break; + if (count < 0) + { + if (!(result == resultbuf || result == NULL)) + free (result); + if (buf_malloced != NULL) + free (buf_malloced); + CLEANUP (); + errno = EILSEQ; + return NULL; + } + arg_end += count; + characters++; + } + } + else if (has_width) + { + /* Use the entire string, and count the number of + characters. */ + arg_end = arg; + characters = 0; + for (;;) + { + int count = u16_strmblen (arg_end); + if (count == 0) + break; + if (count < 0) + { + if (!(result == resultbuf || result == NULL)) + free (result); + if (buf_malloced != NULL) + free (buf_malloced); + CLEANUP (); + errno = EILSEQ; + return NULL; + } + arg_end += count; + characters++; + } + } + else + { + /* Use the entire string. */ + arg_end = arg + u16_strlen (arg); + /* The number of characters doesn't matter. */ + characters = 0; + } - if (has_width && width > characters - && !(dp->flags & FLAG_LEFT)) - { - size_t n = width - characters; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_SET (result + length, ' ', n); - length += n; - } + if (has_width && width > characters + && !(dp->flags & FLAG_LEFT)) + { + size_t n = width - characters; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } # if DCHAR_IS_UINT16_T - { - size_t n = arg_end - arg; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_CPY (result + length, arg, n); - length += n; - } + { + size_t n = arg_end - arg; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_CPY (result + length, arg, n); + length += n; + } # else - { /* Convert. */ - DCHAR_T *converted = result + length; - size_t converted_len = allocated - length; + { /* Convert. */ + DCHAR_T *converted = result + length; + size_t converted_len = allocated - length; # if DCHAR_IS_TCHAR - /* Convert from UTF-16 to locale encoding. */ - converted = - u16_conv_to_encoding (locale_charset (), - iconveh_question_mark, - arg, arg_end - arg, NULL, - converted, &converted_len); + /* Convert from UTF-16 to locale encoding. */ + converted = + u16_conv_to_encoding (locale_charset (), + iconveh_question_mark, + arg, arg_end - arg, NULL, + converted, &converted_len); # else - /* Convert from UTF-16 to UTF-8/UTF-32. */ - converted = - U16_TO_DCHAR (arg, arg_end - arg, - converted, &converted_len); + /* Convert from UTF-16 to UTF-8/UTF-32. */ + converted = + U16_TO_DCHAR (arg, arg_end - arg, + converted, &converted_len); # endif - if (converted == NULL) - { - int saved_errno = errno; - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = saved_errno; - return NULL; - } - if (converted != result + length) - { - ENSURE_ALLOCATION (xsum (length, converted_len)); - DCHAR_CPY (result + length, converted, converted_len); - free (converted); - } - length += converted_len; - } + if (converted == NULL) + { + int saved_errno = errno; + if (!(result == resultbuf || result == NULL)) + free (result); + if (buf_malloced != NULL) + free (buf_malloced); + CLEANUP (); + errno = saved_errno; + return NULL; + } + if (converted != result + length) + { + ENSURE_ALLOCATION (xsum (length, converted_len)); + DCHAR_CPY (result + length, converted, converted_len); + free (converted); + } + length += converted_len; + } # endif - if (has_width && width > characters - && (dp->flags & FLAG_LEFT)) - { - size_t n = width - characters; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_SET (result + length, ' ', n); - length += n; - } - } - break; + if (has_width && width > characters + && (dp->flags & FLAG_LEFT)) + { + size_t n = width - characters; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } + } + break; - case TYPE_U32_STRING: - { - const uint32_t *arg = a.arg[dp->arg_index].a.a_u32_string; - const uint32_t *arg_end; - size_t characters; + case TYPE_U32_STRING: + { + const uint32_t *arg = a.arg[dp->arg_index].a.a_u32_string; + const uint32_t *arg_end; + size_t characters; - if (has_precision) - { - /* Use only PRECISION characters, from the left. */ - arg_end = arg; - characters = 0; - for (; precision > 0; precision--) - { - int count = u32_strmblen (arg_end); - if (count == 0) - break; - if (count < 0) - { - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = EILSEQ; - return NULL; - } - arg_end += count; - characters++; - } - } - else if (has_width) - { - /* Use the entire string, and count the number of - characters. */ - arg_end = arg; - characters = 0; - for (;;) - { - int count = u32_strmblen (arg_end); - if (count == 0) - break; - if (count < 0) - { - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = EILSEQ; - return NULL; - } - arg_end += count; - characters++; - } - } - else - { - /* Use the entire string. */ - arg_end = arg + u32_strlen (arg); - /* The number of characters doesn't matter. */ - characters = 0; - } + if (has_precision) + { + /* Use only PRECISION characters, from the left. */ + arg_end = arg; + characters = 0; + for (; precision > 0; precision--) + { + int count = u32_strmblen (arg_end); + if (count == 0) + break; + if (count < 0) + { + if (!(result == resultbuf || result == NULL)) + free (result); + if (buf_malloced != NULL) + free (buf_malloced); + CLEANUP (); + errno = EILSEQ; + return NULL; + } + arg_end += count; + characters++; + } + } + else if (has_width) + { + /* Use the entire string, and count the number of + characters. */ + arg_end = arg; + characters = 0; + for (;;) + { + int count = u32_strmblen (arg_end); + if (count == 0) + break; + if (count < 0) + { + if (!(result == resultbuf || result == NULL)) + free (result); + if (buf_malloced != NULL) + free (buf_malloced); + CLEANUP (); + errno = EILSEQ; + return NULL; + } + arg_end += count; + characters++; + } + } + else + { + /* Use the entire string. */ + arg_end = arg + u32_strlen (arg); + /* The number of characters doesn't matter. */ + characters = 0; + } - if (has_width && width > characters - && !(dp->flags & FLAG_LEFT)) - { - size_t n = width - characters; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_SET (result + length, ' ', n); - length += n; - } + if (has_width && width > characters + && !(dp->flags & FLAG_LEFT)) + { + size_t n = width - characters; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } # if DCHAR_IS_UINT32_T - { - size_t n = arg_end - arg; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_CPY (result + length, arg, n); - length += n; - } + { + size_t n = arg_end - arg; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_CPY (result + length, arg, n); + length += n; + } # else - { /* Convert. */ - DCHAR_T *converted = result + length; - size_t converted_len = allocated - length; + { /* Convert. */ + DCHAR_T *converted = result + length; + size_t converted_len = allocated - length; # if DCHAR_IS_TCHAR - /* Convert from UTF-32 to locale encoding. */ - converted = - u32_conv_to_encoding (locale_charset (), - iconveh_question_mark, - arg, arg_end - arg, NULL, - converted, &converted_len); + /* Convert from UTF-32 to locale encoding. */ + converted = + u32_conv_to_encoding (locale_charset (), + iconveh_question_mark, + arg, arg_end - arg, NULL, + converted, &converted_len); # else - /* Convert from UTF-32 to UTF-8/UTF-16. */ - converted = - U32_TO_DCHAR (arg, arg_end - arg, - converted, &converted_len); + /* Convert from UTF-32 to UTF-8/UTF-16. */ + converted = + U32_TO_DCHAR (arg, arg_end - arg, + converted, &converted_len); # endif - if (converted == NULL) - { - int saved_errno = errno; - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = saved_errno; - return NULL; - } - if (converted != result + length) - { - ENSURE_ALLOCATION (xsum (length, converted_len)); - DCHAR_CPY (result + length, converted, converted_len); - free (converted); - } - length += converted_len; - } + if (converted == NULL) + { + int saved_errno = errno; + if (!(result == resultbuf || result == NULL)) + free (result); + if (buf_malloced != NULL) + free (buf_malloced); + CLEANUP (); + errno = saved_errno; + return NULL; + } + if (converted != result + length) + { + ENSURE_ALLOCATION (xsum (length, converted_len)); + DCHAR_CPY (result + length, converted, converted_len); + free (converted); + } + length += converted_len; + } # endif - if (has_width && width > characters - && (dp->flags & FLAG_LEFT)) - { - size_t n = width - characters; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_SET (result + length, ' ', n); - length += n; - } - } - break; + if (has_width && width > characters + && (dp->flags & FLAG_LEFT)) + { + size_t n = width - characters; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } + } + break; - default: - abort (); - } - } + default: + abort (); + } + } #endif #if (!USE_SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T - else if (dp->conversion == 's' + else if (dp->conversion == 's' # if WIDE_CHAR_VERSION - && a.arg[dp->arg_index].type != TYPE_WIDE_STRING + && a.arg[dp->arg_index].type != TYPE_WIDE_STRING # else - && a.arg[dp->arg_index].type == TYPE_WIDE_STRING + && a.arg[dp->arg_index].type == TYPE_WIDE_STRING # endif - ) - { - /* The normal handling of the 's' directive below requires - allocating a temporary buffer. The determination of its - length (tmp_length), in the case when a precision is - specified, below requires a conversion between a char[] - string and a wchar_t[] wide string. It could be done, but - we have no guarantee that the implementation of sprintf will - use the exactly same algorithm. Without this guarantee, it - is possible to have buffer overrun bugs. In order to avoid - such bugs, we implement the entire processing of the 's' - directive ourselves. */ - int flags = dp->flags; - int has_width; - size_t width; - int has_precision; - size_t precision; + ) + { + /* The normal handling of the 's' directive below requires + allocating a temporary buffer. The determination of its + length (tmp_length), in the case when a precision is + specified, below requires a conversion between a char[] + string and a wchar_t[] wide string. It could be done, but + we have no guarantee that the implementation of sprintf will + use the exactly same algorithm. Without this guarantee, it + is possible to have buffer overrun bugs. In order to avoid + such bugs, we implement the entire processing of the 's' + directive ourselves. */ + int flags = dp->flags; + int has_width; + size_t width; + int has_precision; + size_t precision; - has_width = 0; - width = 0; - if (dp->width_start != dp->width_end) - { - if (dp->width_arg_index != ARG_NONE) - { - int arg; + has_width = 0; + width = 0; + if (dp->width_start != dp->width_end) + { + if (dp->width_arg_index != ARG_NONE) + { + int arg; - if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) - abort (); - arg = a.arg[dp->width_arg_index].a.a_int; - if (arg < 0) - { - /* "A negative field width is taken as a '-' flag - followed by a positive field width." */ - flags |= FLAG_LEFT; - width = (unsigned int) (-arg); - } - else - width = arg; - } - else - { - const FCHAR_T *digitp = dp->width_start; + if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->width_arg_index].a.a_int; + if (arg < 0) + { + /* "A negative field width is taken as a '-' flag + followed by a positive field width." */ + flags |= FLAG_LEFT; + width = (unsigned int) (-arg); + } + else + width = arg; + } + else + { + const FCHAR_T *digitp = dp->width_start; - do - width = xsum (xtimes (width, 10), *digitp++ - '0'); - while (digitp != dp->width_end); - } - has_width = 1; - } + do + width = xsum (xtimes (width, 10), *digitp++ - '0'); + while (digitp != dp->width_end); + } + has_width = 1; + } - has_precision = 0; - precision = 6; - if (dp->precision_start != dp->precision_end) - { - if (dp->precision_arg_index != ARG_NONE) - { - int arg; + has_precision = 0; + precision = 6; + if (dp->precision_start != dp->precision_end) + { + if (dp->precision_arg_index != ARG_NONE) + { + int arg; - if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) - abort (); - arg = a.arg[dp->precision_arg_index].a.a_int; - /* "A negative precision is taken as if the precision - were omitted." */ - if (arg >= 0) - { - precision = arg; - has_precision = 1; - } - } - else - { - const FCHAR_T *digitp = dp->precision_start + 1; + if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->precision_arg_index].a.a_int; + /* "A negative precision is taken as if the precision + were omitted." */ + if (arg >= 0) + { + precision = arg; + has_precision = 1; + } + } + else + { + const FCHAR_T *digitp = dp->precision_start + 1; - precision = 0; - while (digitp != dp->precision_end) - precision = xsum (xtimes (precision, 10), *digitp++ - '0'); - has_precision = 1; - } - } + precision = 0; + while (digitp != dp->precision_end) + precision = xsum (xtimes (precision, 10), *digitp++ - '0'); + has_precision = 1; + } + } # if WIDE_CHAR_VERSION - /* %s in vasnwprintf. See the specification of fwprintf. */ - { - const char *arg = a.arg[dp->arg_index].a.a_string; - const char *arg_end; - size_t characters; + /* %s in vasnwprintf. See the specification of fwprintf. */ + { + const char *arg = a.arg[dp->arg_index].a.a_string; + const char *arg_end; + size_t characters; - if (has_precision) - { - /* Use only as many bytes as needed to produce PRECISION - wide characters, from the left. */ + if (has_precision) + { + /* Use only as many bytes as needed to produce PRECISION + wide characters, from the left. */ # if HAVE_MBRTOWC - mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + mbstate_t state; + memset (&state, '\0', sizeof (mbstate_t)); # endif - arg_end = arg; - characters = 0; - for (; precision > 0; precision--) - { - int count; + arg_end = arg; + characters = 0; + for (; precision > 0; precision--) + { + int count; # if HAVE_MBRTOWC - count = mbrlen (arg_end, MB_CUR_MAX, &state); + count = mbrlen (arg_end, MB_CUR_MAX, &state); # else - count = mblen (arg_end, MB_CUR_MAX); + count = mblen (arg_end, MB_CUR_MAX); # endif - if (count == 0) - /* Found the terminating NUL. */ - break; - if (count < 0) - { - /* Invalid or incomplete multibyte character. */ - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = EILSEQ; - return NULL; - } - arg_end += count; - characters++; - } - } - else if (has_width) - { - /* Use the entire string, and count the number of wide - characters. */ + if (count == 0) + /* Found the terminating NUL. */ + break; + if (count < 0) + { + /* Invalid or incomplete multibyte character. */ + if (!(result == resultbuf || result == NULL)) + free (result); + if (buf_malloced != NULL) + free (buf_malloced); + CLEANUP (); + errno = EILSEQ; + return NULL; + } + arg_end += count; + characters++; + } + } + else if (has_width) + { + /* Use the entire string, and count the number of wide + characters. */ # if HAVE_MBRTOWC - mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + mbstate_t state; + memset (&state, '\0', sizeof (mbstate_t)); # endif - arg_end = arg; - characters = 0; - for (;;) - { - int count; + arg_end = arg; + characters = 0; + for (;;) + { + int count; # if HAVE_MBRTOWC - count = mbrlen (arg_end, MB_CUR_MAX, &state); + count = mbrlen (arg_end, MB_CUR_MAX, &state); # else - count = mblen (arg_end, MB_CUR_MAX); + count = mblen (arg_end, MB_CUR_MAX); # endif - if (count == 0) - /* Found the terminating NUL. */ - break; - if (count < 0) - { - /* Invalid or incomplete multibyte character. */ - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = EILSEQ; - return NULL; - } - arg_end += count; - characters++; - } - } - else - { - /* Use the entire string. */ - arg_end = arg + strlen (arg); - /* The number of characters doesn't matter. */ - characters = 0; - } + if (count == 0) + /* Found the terminating NUL. */ + break; + if (count < 0) + { + /* Invalid or incomplete multibyte character. */ + if (!(result == resultbuf || result == NULL)) + free (result); + if (buf_malloced != NULL) + free (buf_malloced); + CLEANUP (); + errno = EILSEQ; + return NULL; + } + arg_end += count; + characters++; + } + } + else + { + /* Use the entire string. */ + arg_end = arg + strlen (arg); + /* The number of characters doesn't matter. */ + characters = 0; + } - if (has_width && width > characters - && !(dp->flags & FLAG_LEFT)) - { - size_t n = width - characters; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_SET (result + length, ' ', n); - length += n; - } + if (has_width && width > characters + && !(dp->flags & FLAG_LEFT)) + { + size_t n = width - characters; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } - if (has_precision || has_width) - { - /* We know the number of wide characters in advance. */ - size_t remaining; + if (has_precision || has_width) + { + /* We know the number of wide characters in advance. */ + size_t remaining; # if HAVE_MBRTOWC - mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + mbstate_t state; + memset (&state, '\0', sizeof (mbstate_t)); # endif - ENSURE_ALLOCATION (xsum (length, characters)); - for (remaining = characters; remaining > 0; remaining--) - { - wchar_t wc; - int count; + ENSURE_ALLOCATION (xsum (length, characters)); + for (remaining = characters; remaining > 0; remaining--) + { + wchar_t wc; + int count; # if HAVE_MBRTOWC - count = mbrtowc (&wc, arg, arg_end - arg, &state); + count = mbrtowc (&wc, arg, arg_end - arg, &state); # else - count = mbtowc (&wc, arg, arg_end - arg); + count = mbtowc (&wc, arg, arg_end - arg); # endif - if (count <= 0) - /* mbrtowc not consistent with mbrlen, or mbtowc - not consistent with mblen. */ - abort (); - result[length++] = wc; - arg += count; - } - if (!(arg == arg_end)) - abort (); - } - else - { + if (count <= 0) + /* mbrtowc not consistent with mbrlen, or mbtowc + not consistent with mblen. */ + abort (); + result[length++] = wc; + arg += count; + } + if (!(arg == arg_end)) + abort (); + } + else + { # if HAVE_MBRTOWC - mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + mbstate_t state; + memset (&state, '\0', sizeof (mbstate_t)); # endif - while (arg < arg_end) - { - wchar_t wc; - int count; + while (arg < arg_end) + { + wchar_t wc; + int count; # if HAVE_MBRTOWC - count = mbrtowc (&wc, arg, arg_end - arg, &state); + count = mbrtowc (&wc, arg, arg_end - arg, &state); # else - count = mbtowc (&wc, arg, arg_end - arg); + count = mbtowc (&wc, arg, arg_end - arg); # endif - if (count <= 0) - /* mbrtowc not consistent with mbrlen, or mbtowc - not consistent with mblen. */ - abort (); - ENSURE_ALLOCATION (xsum (length, 1)); - result[length++] = wc; - arg += count; - } - } + if (count <= 0) + /* mbrtowc not consistent with mbrlen, or mbtowc + not consistent with mblen. */ + abort (); + ENSURE_ALLOCATION (xsum (length, 1)); + result[length++] = wc; + arg += count; + } + } - if (has_width && width > characters - && (dp->flags & FLAG_LEFT)) - { - size_t n = width - characters; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_SET (result + length, ' ', n); - length += n; - } - } + if (has_width && width > characters + && (dp->flags & FLAG_LEFT)) + { + size_t n = width - characters; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } + } # else - /* %ls in vasnprintf. See the specification of fprintf. */ - { - const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string; - const wchar_t *arg_end; - size_t characters; + /* %ls in vasnprintf. See the specification of fprintf. */ + { + const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string; + const wchar_t *arg_end; + size_t characters; # if !DCHAR_IS_TCHAR - /* This code assumes that TCHAR_T is 'char'. */ - typedef int TCHAR_T_verify[2 * (sizeof (TCHAR_T) == 1) - 1]; - TCHAR_T *tmpsrc; - DCHAR_T *tmpdst; - size_t tmpdst_len; + /* This code assumes that TCHAR_T is 'char'. */ + typedef int TCHAR_T_verify[2 * (sizeof (TCHAR_T) == 1) - 1]; + TCHAR_T *tmpsrc; + DCHAR_T *tmpdst; + size_t tmpdst_len; # endif - size_t w; + size_t w; - if (has_precision) - { - /* Use only as many wide characters as needed to produce - at most PRECISION bytes, from the left. */ -# if HAVE_WCRTOMB - mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + if (has_precision) + { + /* Use only as many wide characters as needed to produce + at most PRECISION bytes, from the left. */ +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t + mbstate_t state; + memset (&state, '\0', sizeof (mbstate_t)); # endif - arg_end = arg; - characters = 0; - while (precision > 0) - { - char buf[64]; /* Assume MB_CUR_MAX <= 64. */ - int count; + arg_end = arg; + characters = 0; + while (precision > 0) + { + char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ + int count; - if (*arg_end == 0) - /* Found the terminating null wide character. */ - break; -# if HAVE_WCRTOMB - count = wcrtomb (buf, *arg_end, &state); + if (*arg_end == 0) + /* Found the terminating null wide character. */ + break; +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t + count = wcrtomb (cbuf, *arg_end, &state); # else - count = wctomb (buf, *arg_end); + count = wctomb (cbuf, *arg_end); # endif - if (count < 0) - { - /* Cannot convert. */ - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = EILSEQ; - return NULL; - } - if (precision < count) - break; - arg_end++; - characters += count; - precision -= count; - } - } + if (count < 0) + { + /* Cannot convert. */ + if (!(result == resultbuf || result == NULL)) + free (result); + if (buf_malloced != NULL) + free (buf_malloced); + CLEANUP (); + errno = EILSEQ; + return NULL; + } + if (precision < count) + break; + arg_end++; + characters += count; + precision -= count; + } + } # if DCHAR_IS_TCHAR - else if (has_width) + else if (has_width) # else - else + else # endif - { - /* Use the entire string, and count the number of - bytes. */ -# if HAVE_WCRTOMB - mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + { + /* Use the entire string, and count the number of + bytes. */ +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t + mbstate_t state; + memset (&state, '\0', sizeof (mbstate_t)); # endif - arg_end = arg; - characters = 0; - for (;;) - { - char buf[64]; /* Assume MB_CUR_MAX <= 64. */ - int count; + arg_end = arg; + characters = 0; + for (;;) + { + char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ + int count; - if (*arg_end == 0) - /* Found the terminating null wide character. */ - break; -# if HAVE_WCRTOMB - count = wcrtomb (buf, *arg_end, &state); + if (*arg_end == 0) + /* Found the terminating null wide character. */ + break; +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t + count = wcrtomb (cbuf, *arg_end, &state); # else - count = wctomb (buf, *arg_end); + count = wctomb (cbuf, *arg_end); # endif - if (count < 0) - { - /* Cannot convert. */ - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = EILSEQ; - return NULL; - } - arg_end++; - characters += count; - } - } + if (count < 0) + { + /* Cannot convert. */ + if (!(result == resultbuf || result == NULL)) + free (result); + if (buf_malloced != NULL) + free (buf_malloced); + CLEANUP (); + errno = EILSEQ; + return NULL; + } + arg_end++; + characters += count; + } + } # if DCHAR_IS_TCHAR - else - { - /* Use the entire string. */ - arg_end = arg + local_wcslen (arg); - /* The number of bytes doesn't matter. */ - characters = 0; - } + else + { + /* Use the entire string. */ + arg_end = arg + local_wcslen (arg); + /* The number of bytes doesn't matter. */ + characters = 0; + } # endif # if !DCHAR_IS_TCHAR - /* Convert the string into a piece of temporary memory. */ - tmpsrc = (TCHAR_T *) malloc (characters * sizeof (TCHAR_T)); - if (tmpsrc == NULL) - goto out_of_memory; - { - TCHAR_T *tmpptr = tmpsrc; - size_t remaining; -# if HAVE_WCRTOMB - mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + /* Convert the string into a piece of temporary memory. */ + tmpsrc = (TCHAR_T *) malloc (characters * sizeof (TCHAR_T)); + if (tmpsrc == NULL) + goto out_of_memory; + { + TCHAR_T *tmpptr = tmpsrc; + size_t remaining; +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t + mbstate_t state; + memset (&state, '\0', sizeof (mbstate_t)); # endif - for (remaining = characters; remaining > 0; ) - { - char buf[64]; /* Assume MB_CUR_MAX <= 64. */ - int count; + for (remaining = characters; remaining > 0; ) + { + char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ + int count; - if (*arg == 0) - abort (); -# if HAVE_WCRTOMB - count = wcrtomb (buf, *arg, &state); + if (*arg == 0) + abort (); +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t + count = wcrtomb (cbuf, *arg, &state); # else - count = wctomb (buf, *arg); + count = wctomb (cbuf, *arg); # endif - if (count <= 0) - /* Inconsistency. */ - abort (); - memcpy (tmpptr, buf, count); - tmpptr += count; - arg++; - remaining -= count; - } - if (!(arg == arg_end)) - abort (); - } + if (count <= 0) + /* Inconsistency. */ + abort (); + memcpy (tmpptr, cbuf, count); + tmpptr += count; + arg++; + remaining -= count; + } + if (!(arg == arg_end)) + abort (); + } - /* Convert from TCHAR_T[] to DCHAR_T[]. */ - tmpdst = - DCHAR_CONV_FROM_ENCODING (locale_charset (), - iconveh_question_mark, - tmpsrc, characters, - NULL, - NULL, &tmpdst_len); - if (tmpdst == NULL) - { - int saved_errno = errno; - free (tmpsrc); - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = saved_errno; - return NULL; - } - free (tmpsrc); + /* Convert from TCHAR_T[] to DCHAR_T[]. */ + tmpdst = + DCHAR_CONV_FROM_ENCODING (locale_charset (), + iconveh_question_mark, + tmpsrc, characters, + NULL, + NULL, &tmpdst_len); + if (tmpdst == NULL) + { + int saved_errno = errno; + free (tmpsrc); + if (!(result == resultbuf || result == NULL)) + free (result); + if (buf_malloced != NULL) + free (buf_malloced); + CLEANUP (); + errno = saved_errno; + return NULL; + } + free (tmpsrc); # endif - if (has_width) - { + if (has_width) + { # if ENABLE_UNISTDIO - /* Outside POSIX, it's preferrable to compare the width - against the number of _characters_ of the converted - value. */ - w = DCHAR_MBSNLEN (result + length, characters); + /* Outside POSIX, it's preferrable to compare the width + against the number of _characters_ of the converted + value. */ + w = DCHAR_MBSNLEN (result + length, characters); # else - /* The width is compared against the number of _bytes_ - of the converted value, says POSIX. */ - w = characters; + /* The width is compared against the number of _bytes_ + of the converted value, says POSIX. */ + w = characters; # endif - } - else - /* w doesn't matter. */ - w = 0; + } + else + /* w doesn't matter. */ + w = 0; - if (has_width && width > w - && !(dp->flags & FLAG_LEFT)) - { - size_t n = width - w; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_SET (result + length, ' ', n); - length += n; - } + if (has_width && width > w + && !(dp->flags & FLAG_LEFT)) + { + size_t n = width - w; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } # if DCHAR_IS_TCHAR - if (has_precision || has_width) - { - /* We know the number of bytes in advance. */ - size_t remaining; -# if HAVE_WCRTOMB - mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + if (has_precision || has_width) + { + /* We know the number of bytes in advance. */ + size_t remaining; +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t + mbstate_t state; + memset (&state, '\0', sizeof (mbstate_t)); # endif - ENSURE_ALLOCATION (xsum (length, characters)); - for (remaining = characters; remaining > 0; ) - { - char buf[64]; /* Assume MB_CUR_MAX <= 64. */ - int count; + ENSURE_ALLOCATION (xsum (length, characters)); + for (remaining = characters; remaining > 0; ) + { + char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ + int count; - if (*arg == 0) - abort (); -# if HAVE_WCRTOMB - count = wcrtomb (buf, *arg, &state); + if (*arg == 0) + abort (); +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t + count = wcrtomb (cbuf, *arg, &state); # else - count = wctomb (buf, *arg); + count = wctomb (cbuf, *arg); # endif - if (count <= 0) - /* Inconsistency. */ - abort (); - memcpy (result + length, buf, count); - length += count; - arg++; - remaining -= count; - } - if (!(arg == arg_end)) - abort (); - } - else - { -# if HAVE_WCRTOMB - mbstate_t state; - memset (&state, '\0', sizeof (mbstate_t)); + if (count <= 0) + /* Inconsistency. */ + abort (); + memcpy (result + length, cbuf, count); + length += count; + arg++; + remaining -= count; + } + if (!(arg == arg_end)) + abort (); + } + else + { +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t + mbstate_t state; + memset (&state, '\0', sizeof (mbstate_t)); # endif - while (arg < arg_end) - { - char buf[64]; /* Assume MB_CUR_MAX <= 64. */ - int count; + while (arg < arg_end) + { + char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */ + int count; - if (*arg == 0) - abort (); -# if HAVE_WCRTOMB - count = wcrtomb (buf, *arg, &state); + if (*arg == 0) + abort (); +# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t + count = wcrtomb (cbuf, *arg, &state); # else - count = wctomb (buf, *arg); + count = wctomb (cbuf, *arg); # endif - if (count <= 0) - /* Inconsistency. */ - abort (); - ENSURE_ALLOCATION (xsum (length, count)); - memcpy (result + length, buf, count); - length += count; - arg++; - } - } + if (count <= 0) + /* Inconsistency. */ + abort (); + ENSURE_ALLOCATION (xsum (length, count)); + memcpy (result + length, cbuf, count); + length += count; + arg++; + } + } # else - ENSURE_ALLOCATION (xsum (length, tmpdst_len)); - DCHAR_CPY (result + length, tmpdst, tmpdst_len); - free (tmpdst); - length += tmpdst_len; + ENSURE_ALLOCATION (xsum (length, tmpdst_len)); + DCHAR_CPY (result + length, tmpdst, tmpdst_len); + free (tmpdst); + length += tmpdst_len; # endif - if (has_width && width > w - && (dp->flags & FLAG_LEFT)) - { - size_t n = width - w; - ENSURE_ALLOCATION (xsum (length, n)); - DCHAR_SET (result + length, ' ', n); - length += n; - } - } - } + if (has_width && width > w + && (dp->flags & FLAG_LEFT)) + { + size_t n = width - w; + ENSURE_ALLOCATION (xsum (length, n)); + DCHAR_SET (result + length, ' ', n); + length += n; + } + } + } # endif #endif #if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL - else if ((dp->conversion == 'a' || dp->conversion == 'A') + else if ((dp->conversion == 'a' || dp->conversion == 'A') # if !(NEED_PRINTF_DIRECTIVE_A || (NEED_PRINTF_LONG_DOUBLE && NEED_PRINTF_DOUBLE)) - && (0 + && (0 # if NEED_PRINTF_DOUBLE - || a.arg[dp->arg_index].type == TYPE_DOUBLE + || a.arg[dp->arg_index].type == TYPE_DOUBLE # endif # if NEED_PRINTF_LONG_DOUBLE - || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE + || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE # endif - ) + ) # endif - ) - { - arg_type type = a.arg[dp->arg_index].type; - int flags = dp->flags; - int has_width; - size_t width; - int has_precision; - size_t precision; - size_t tmp_length; - DCHAR_T tmpbuf[700]; - DCHAR_T *tmp; - DCHAR_T *pad_ptr; - DCHAR_T *p; + ) + { + arg_type type = a.arg[dp->arg_index].type; + int flags = dp->flags; + int has_width; + size_t width; + int has_precision; + size_t precision; + size_t tmp_length; + DCHAR_T tmpbuf[700]; + DCHAR_T *tmp; + DCHAR_T *pad_ptr; + DCHAR_T *p; - has_width = 0; - width = 0; - if (dp->width_start != dp->width_end) - { - if (dp->width_arg_index != ARG_NONE) - { - int arg; + has_width = 0; + width = 0; + if (dp->width_start != dp->width_end) + { + if (dp->width_arg_index != ARG_NONE) + { + int arg; - if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) - abort (); - arg = a.arg[dp->width_arg_index].a.a_int; - if (arg < 0) - { - /* "A negative field width is taken as a '-' flag - followed by a positive field width." */ - flags |= FLAG_LEFT; - width = (unsigned int) (-arg); - } - else - width = arg; - } - else - { - const FCHAR_T *digitp = dp->width_start; + if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->width_arg_index].a.a_int; + if (arg < 0) + { + /* "A negative field width is taken as a '-' flag + followed by a positive field width." */ + flags |= FLAG_LEFT; + width = (unsigned int) (-arg); + } + else + width = arg; + } + else + { + const FCHAR_T *digitp = dp->width_start; - do - width = xsum (xtimes (width, 10), *digitp++ - '0'); - while (digitp != dp->width_end); - } - has_width = 1; - } + do + width = xsum (xtimes (width, 10), *digitp++ - '0'); + while (digitp != dp->width_end); + } + has_width = 1; + } - has_precision = 0; - precision = 0; - if (dp->precision_start != dp->precision_end) - { - if (dp->precision_arg_index != ARG_NONE) - { - int arg; + has_precision = 0; + precision = 0; + if (dp->precision_start != dp->precision_end) + { + if (dp->precision_arg_index != ARG_NONE) + { + int arg; - if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) - abort (); - arg = a.arg[dp->precision_arg_index].a.a_int; - /* "A negative precision is taken as if the precision - were omitted." */ - if (arg >= 0) - { - precision = arg; - has_precision = 1; - } - } - else - { - const FCHAR_T *digitp = dp->precision_start + 1; + if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->precision_arg_index].a.a_int; + /* "A negative precision is taken as if the precision + were omitted." */ + if (arg >= 0) + { + precision = arg; + has_precision = 1; + } + } + else + { + const FCHAR_T *digitp = dp->precision_start + 1; - precision = 0; - while (digitp != dp->precision_end) - precision = xsum (xtimes (precision, 10), *digitp++ - '0'); - has_precision = 1; - } - } + precision = 0; + while (digitp != dp->precision_end) + precision = xsum (xtimes (precision, 10), *digitp++ - '0'); + has_precision = 1; + } + } - /* Allocate a temporary buffer of sufficient size. */ - if (type == TYPE_LONGDOUBLE) - tmp_length = - (unsigned int) ((LDBL_DIG + 1) - * 0.831 /* decimal -> hexadecimal */ - ) - + 1; /* turn floor into ceil */ - else - tmp_length = - (unsigned int) ((DBL_DIG + 1) - * 0.831 /* decimal -> hexadecimal */ - ) - + 1; /* turn floor into ceil */ - if (tmp_length < precision) - tmp_length = precision; - /* Account for sign, decimal point etc. */ - tmp_length = xsum (tmp_length, 12); + /* Allocate a temporary buffer of sufficient size. */ + if (type == TYPE_LONGDOUBLE) + tmp_length = + (unsigned int) ((LDBL_DIG + 1) + * 0.831 /* decimal -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + else + tmp_length = + (unsigned int) ((DBL_DIG + 1) + * 0.831 /* decimal -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + if (tmp_length < precision) + tmp_length = precision; + /* Account for sign, decimal point etc. */ + tmp_length = xsum (tmp_length, 12); - if (tmp_length < width) - tmp_length = width; + if (tmp_length < width) + tmp_length = width; - tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ + tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ - if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T)) - tmp = tmpbuf; - else - { - size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T)); + if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T)) + tmp = tmpbuf; + else + { + size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T)); - if (size_overflow_p (tmp_memsize)) - /* Overflow, would lead to out of memory. */ - goto out_of_memory; - tmp = (DCHAR_T *) malloc (tmp_memsize); - if (tmp == NULL) - /* Out of memory. */ - goto out_of_memory; - } + if (size_overflow_p (tmp_memsize)) + /* Overflow, would lead to out of memory. */ + goto out_of_memory; + tmp = (DCHAR_T *) malloc (tmp_memsize); + if (tmp == NULL) + /* Out of memory. */ + goto out_of_memory; + } - pad_ptr = NULL; - p = tmp; - if (type == TYPE_LONGDOUBLE) - { + pad_ptr = NULL; + p = tmp; + if (type == TYPE_LONGDOUBLE) + { # if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE - long double arg = a.arg[dp->arg_index].a.a_longdouble; + long double arg = a.arg[dp->arg_index].a.a_longdouble; - if (isnanl (arg)) - { - if (dp->conversion == 'A') - { - *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; - } - else - { - *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; - } - } - else - { - int sign = 0; - DECL_LONG_DOUBLE_ROUNDING + if (isnanl (arg)) + { + if (dp->conversion == 'A') + { + *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; + } + else + { + *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; + } + } + else + { + int sign = 0; + DECL_LONG_DOUBLE_ROUNDING - BEGIN_LONG_DOUBLE_ROUNDING (); + BEGIN_LONG_DOUBLE_ROUNDING (); - if (signbit (arg)) /* arg < 0.0L or negative zero */ - { - sign = -1; - arg = -arg; - } + if (signbit (arg)) /* arg < 0.0L or negative zero */ + { + sign = -1; + arg = -arg; + } - if (sign < 0) - *p++ = '-'; - else if (flags & FLAG_SHOWSIGN) - *p++ = '+'; - else if (flags & FLAG_SPACE) - *p++ = ' '; + if (sign < 0) + *p++ = '-'; + else if (flags & FLAG_SHOWSIGN) + *p++ = '+'; + else if (flags & FLAG_SPACE) + *p++ = ' '; - if (arg > 0.0L && arg + arg == arg) - { - if (dp->conversion == 'A') - { - *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; - } - else - { - *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; - } - } - else - { - int exponent; - long double mantissa; + if (arg > 0.0L && arg + arg == arg) + { + if (dp->conversion == 'A') + { + *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; + } + else + { + *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; + } + } + else + { + int exponent; + long double mantissa; - if (arg > 0.0L) - mantissa = printf_frexpl (arg, &exponent); - else - { - exponent = 0; - mantissa = 0.0L; - } + if (arg > 0.0L) + mantissa = printf_frexpl (arg, &exponent); + else + { + exponent = 0; + mantissa = 0.0L; + } - if (has_precision - && precision < (unsigned int) ((LDBL_DIG + 1) * 0.831) + 1) - { - /* Round the mantissa. */ - long double tail = mantissa; - size_t q; + if (has_precision + && precision < (unsigned int) ((LDBL_DIG + 1) * 0.831) + 1) + { + /* Round the mantissa. */ + long double tail = mantissa; + size_t q; - for (q = precision; ; q--) - { - int digit = (int) tail; - tail -= digit; - if (q == 0) - { - if (digit & 1 ? tail >= 0.5L : tail > 0.5L) - tail = 1 - tail; - else - tail = - tail; - break; - } - tail *= 16.0L; - } - if (tail != 0.0L) - for (q = precision; q > 0; q--) - tail *= 0.0625L; - mantissa += tail; - } + for (q = precision; ; q--) + { + int digit = (int) tail; + tail -= digit; + if (q == 0) + { + if (digit & 1 ? tail >= 0.5L : tail > 0.5L) + tail = 1 - tail; + else + tail = - tail; + break; + } + tail *= 16.0L; + } + if (tail != 0.0L) + for (q = precision; q > 0; q--) + tail *= 0.0625L; + mantissa += tail; + } - *p++ = '0'; - *p++ = dp->conversion - 'A' + 'X'; - pad_ptr = p; - { - int digit; + *p++ = '0'; + *p++ = dp->conversion - 'A' + 'X'; + pad_ptr = p; + { + int digit; - digit = (int) mantissa; - mantissa -= digit; - *p++ = '0' + digit; - if ((flags & FLAG_ALT) - || mantissa > 0.0L || precision > 0) - { - *p++ = decimal_point_char (); - /* This loop terminates because we assume - that FLT_RADIX is a power of 2. */ - while (mantissa > 0.0L) - { - mantissa *= 16.0L; - digit = (int) mantissa; - mantissa -= digit; - *p++ = digit - + (digit < 10 - ? '0' - : dp->conversion - 10); - if (precision > 0) - precision--; - } - while (precision > 0) - { - *p++ = '0'; - precision--; - } - } - } - *p++ = dp->conversion - 'A' + 'P'; + digit = (int) mantissa; + mantissa -= digit; + *p++ = '0' + digit; + if ((flags & FLAG_ALT) + || mantissa > 0.0L || precision > 0) + { + *p++ = decimal_point_char (); + /* This loop terminates because we assume + that FLT_RADIX is a power of 2. */ + while (mantissa > 0.0L) + { + mantissa *= 16.0L; + digit = (int) mantissa; + mantissa -= digit; + *p++ = digit + + (digit < 10 + ? '0' + : dp->conversion - 10); + if (precision > 0) + precision--; + } + while (precision > 0) + { + *p++ = '0'; + precision--; + } + } + } + *p++ = dp->conversion - 'A' + 'P'; # if WIDE_CHAR_VERSION - { - static const wchar_t decimal_format[] = - { '%', '+', 'd', '\0' }; - SNPRINTF (p, 6 + 1, decimal_format, exponent); - } - while (*p != '\0') - p++; + { + static const wchar_t decimal_format[] = + { '%', '+', 'd', '\0' }; + SNPRINTF (p, 6 + 1, decimal_format, exponent); + } + while (*p != '\0') + p++; # else - if (sizeof (DCHAR_T) == 1) - { - sprintf ((char *) p, "%+d", exponent); - while (*p != '\0') - p++; - } - else - { - char expbuf[6 + 1]; - const char *ep; - sprintf (expbuf, "%+d", exponent); - for (ep = expbuf; (*p = *ep) != '\0'; ep++) - p++; - } + if (sizeof (DCHAR_T) == 1) + { + sprintf ((char *) p, "%+d", exponent); + while (*p != '\0') + p++; + } + else + { + char expbuf[6 + 1]; + const char *ep; + sprintf (expbuf, "%+d", exponent); + for (ep = expbuf; (*p = *ep) != '\0'; ep++) + p++; + } # endif - } + } - END_LONG_DOUBLE_ROUNDING (); - } + END_LONG_DOUBLE_ROUNDING (); + } # else - abort (); + abort (); # endif - } - else - { + } + else + { # if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE - double arg = a.arg[dp->arg_index].a.a_double; + double arg = a.arg[dp->arg_index].a.a_double; - if (isnand (arg)) - { - if (dp->conversion == 'A') - { - *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; - } - else - { - *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; - } - } - else - { - int sign = 0; + if (isnand (arg)) + { + if (dp->conversion == 'A') + { + *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; + } + else + { + *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; + } + } + else + { + int sign = 0; - if (signbit (arg)) /* arg < 0.0 or negative zero */ - { - sign = -1; - arg = -arg; - } + if (signbit (arg)) /* arg < 0.0 or negative zero */ + { + sign = -1; + arg = -arg; + } - if (sign < 0) - *p++ = '-'; - else if (flags & FLAG_SHOWSIGN) - *p++ = '+'; - else if (flags & FLAG_SPACE) - *p++ = ' '; + if (sign < 0) + *p++ = '-'; + else if (flags & FLAG_SHOWSIGN) + *p++ = '+'; + else if (flags & FLAG_SPACE) + *p++ = ' '; - if (arg > 0.0 && arg + arg == arg) - { - if (dp->conversion == 'A') - { - *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; - } - else - { - *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; - } - } - else - { - int exponent; - double mantissa; + if (arg > 0.0 && arg + arg == arg) + { + if (dp->conversion == 'A') + { + *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; + } + else + { + *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; + } + } + else + { + int exponent; + double mantissa; - if (arg > 0.0) - mantissa = printf_frexp (arg, &exponent); - else - { - exponent = 0; - mantissa = 0.0; - } + if (arg > 0.0) + mantissa = printf_frexp (arg, &exponent); + else + { + exponent = 0; + mantissa = 0.0; + } - if (has_precision - && precision < (unsigned int) ((DBL_DIG + 1) * 0.831) + 1) - { - /* Round the mantissa. */ - double tail = mantissa; - size_t q; + if (has_precision + && precision < (unsigned int) ((DBL_DIG + 1) * 0.831) + 1) + { + /* Round the mantissa. */ + double tail = mantissa; + size_t q; - for (q = precision; ; q--) - { - int digit = (int) tail; - tail -= digit; - if (q == 0) - { - if (digit & 1 ? tail >= 0.5 : tail > 0.5) - tail = 1 - tail; - else - tail = - tail; - break; - } - tail *= 16.0; - } - if (tail != 0.0) - for (q = precision; q > 0; q--) - tail *= 0.0625; - mantissa += tail; - } + for (q = precision; ; q--) + { + int digit = (int) tail; + tail -= digit; + if (q == 0) + { + if (digit & 1 ? tail >= 0.5 : tail > 0.5) + tail = 1 - tail; + else + tail = - tail; + break; + } + tail *= 16.0; + } + if (tail != 0.0) + for (q = precision; q > 0; q--) + tail *= 0.0625; + mantissa += tail; + } - *p++ = '0'; - *p++ = dp->conversion - 'A' + 'X'; - pad_ptr = p; - { - int digit; + *p++ = '0'; + *p++ = dp->conversion - 'A' + 'X'; + pad_ptr = p; + { + int digit; - digit = (int) mantissa; - mantissa -= digit; - *p++ = '0' + digit; - if ((flags & FLAG_ALT) - || mantissa > 0.0 || precision > 0) - { - *p++ = decimal_point_char (); - /* This loop terminates because we assume - that FLT_RADIX is a power of 2. */ - while (mantissa > 0.0) - { - mantissa *= 16.0; - digit = (int) mantissa; - mantissa -= digit; - *p++ = digit - + (digit < 10 - ? '0' - : dp->conversion - 10); - if (precision > 0) - precision--; - } - while (precision > 0) - { - *p++ = '0'; - precision--; - } - } - } - *p++ = dp->conversion - 'A' + 'P'; + digit = (int) mantissa; + mantissa -= digit; + *p++ = '0' + digit; + if ((flags & FLAG_ALT) + || mantissa > 0.0 || precision > 0) + { + *p++ = decimal_point_char (); + /* This loop terminates because we assume + that FLT_RADIX is a power of 2. */ + while (mantissa > 0.0) + { + mantissa *= 16.0; + digit = (int) mantissa; + mantissa -= digit; + *p++ = digit + + (digit < 10 + ? '0' + : dp->conversion - 10); + if (precision > 0) + precision--; + } + while (precision > 0) + { + *p++ = '0'; + precision--; + } + } + } + *p++ = dp->conversion - 'A' + 'P'; # if WIDE_CHAR_VERSION - { - static const wchar_t decimal_format[] = - { '%', '+', 'd', '\0' }; - SNPRINTF (p, 6 + 1, decimal_format, exponent); - } - while (*p != '\0') - p++; + { + static const wchar_t decimal_format[] = + { '%', '+', 'd', '\0' }; + SNPRINTF (p, 6 + 1, decimal_format, exponent); + } + while (*p != '\0') + p++; # else - if (sizeof (DCHAR_T) == 1) - { - sprintf ((char *) p, "%+d", exponent); - while (*p != '\0') - p++; - } - else - { - char expbuf[6 + 1]; - const char *ep; - sprintf (expbuf, "%+d", exponent); - for (ep = expbuf; (*p = *ep) != '\0'; ep++) - p++; - } + if (sizeof (DCHAR_T) == 1) + { + sprintf ((char *) p, "%+d", exponent); + while (*p != '\0') + p++; + } + else + { + char expbuf[6 + 1]; + const char *ep; + sprintf (expbuf, "%+d", exponent); + for (ep = expbuf; (*p = *ep) != '\0'; ep++) + p++; + } # endif - } - } + } + } # else - abort (); + abort (); # endif - } - /* The generated string now extends from tmp to p, with the - zero padding insertion point being at pad_ptr. */ - if (has_width && p - tmp < width) - { - size_t pad = width - (p - tmp); - DCHAR_T *end = p + pad; + } + /* The generated string now extends from tmp to p, with the + zero padding insertion point being at pad_ptr. */ + if (has_width && p - tmp < width) + { + size_t pad = width - (p - tmp); + DCHAR_T *end = p + pad; - if (flags & FLAG_LEFT) - { - /* Pad with spaces on the right. */ - for (; pad > 0; pad--) - *p++ = ' '; - } - else if ((flags & FLAG_ZERO) && pad_ptr != NULL) - { - /* Pad with zeroes. */ - DCHAR_T *q = end; + if (flags & FLAG_LEFT) + { + /* Pad with spaces on the right. */ + for (; pad > 0; pad--) + *p++ = ' '; + } + else if ((flags & FLAG_ZERO) && pad_ptr != NULL) + { + /* Pad with zeroes. */ + DCHAR_T *q = end; - while (p > pad_ptr) - *--q = *--p; - for (; pad > 0; pad--) - *p++ = '0'; - } - else - { - /* Pad with spaces on the left. */ - DCHAR_T *q = end; + while (p > pad_ptr) + *--q = *--p; + for (; pad > 0; pad--) + *p++ = '0'; + } + else + { + /* Pad with spaces on the left. */ + DCHAR_T *q = end; - while (p > tmp) - *--q = *--p; - for (; pad > 0; pad--) - *p++ = ' '; - } + while (p > tmp) + *--q = *--p; + for (; pad > 0; pad--) + *p++ = ' '; + } - p = end; - } + p = end; + } - { - size_t count = p - tmp; + { + size_t count = p - tmp; - if (count >= tmp_length) - /* tmp_length was incorrectly calculated - fix the - code above! */ - abort (); + if (count >= tmp_length) + /* tmp_length was incorrectly calculated - fix the + code above! */ + abort (); - /* Make room for the result. */ - if (count >= allocated - length) - { - size_t n = xsum (length, count); + /* Make room for the result. */ + if (count >= allocated - length) + { + size_t n = xsum (length, count); - ENSURE_ALLOCATION (n); - } + ENSURE_ALLOCATION (n); + } - /* Append the result. */ - memcpy (result + length, tmp, count * sizeof (DCHAR_T)); - if (tmp != tmpbuf) - free (tmp); - length += count; - } - } + /* Append the result. */ + memcpy (result + length, tmp, count * sizeof (DCHAR_T)); + if (tmp != tmpbuf) + free (tmp); + length += count; + } + } #endif #if (NEED_PRINTF_INFINITE_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL - else if ((dp->conversion == 'f' || dp->conversion == 'F' - || dp->conversion == 'e' || dp->conversion == 'E' - || dp->conversion == 'g' || dp->conversion == 'G' - || dp->conversion == 'a' || dp->conversion == 'A') - && (0 + else if ((dp->conversion == 'f' || dp->conversion == 'F' + || dp->conversion == 'e' || dp->conversion == 'E' + || dp->conversion == 'g' || dp->conversion == 'G' + || dp->conversion == 'a' || dp->conversion == 'A') + && (0 # if NEED_PRINTF_DOUBLE - || a.arg[dp->arg_index].type == TYPE_DOUBLE + || a.arg[dp->arg_index].type == TYPE_DOUBLE # elif NEED_PRINTF_INFINITE_DOUBLE - || (a.arg[dp->arg_index].type == TYPE_DOUBLE - /* The systems (mingw) which produce wrong output - for Inf, -Inf, and NaN also do so for -0.0. - Therefore we treat this case here as well. */ - && is_infinite_or_zero (a.arg[dp->arg_index].a.a_double)) + || (a.arg[dp->arg_index].type == TYPE_DOUBLE + /* The systems (mingw) which produce wrong output + for Inf, -Inf, and NaN also do so for -0.0. + Therefore we treat this case here as well. */ + && is_infinite_or_zero (a.arg[dp->arg_index].a.a_double)) # endif # if NEED_PRINTF_LONG_DOUBLE - || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE + || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE # elif NEED_PRINTF_INFINITE_LONG_DOUBLE - || (a.arg[dp->arg_index].type == TYPE_LONGDOUBLE - /* Some systems produce wrong output for Inf, - -Inf, and NaN. Some systems in this category - (IRIX 5.3) also do so for -0.0. Therefore we - treat this case here as well. */ - && is_infinite_or_zerol (a.arg[dp->arg_index].a.a_longdouble)) + || (a.arg[dp->arg_index].type == TYPE_LONGDOUBLE + /* Some systems produce wrong output for Inf, + -Inf, and NaN. Some systems in this category + (IRIX 5.3) also do so for -0.0. Therefore we + treat this case here as well. */ + && is_infinite_or_zerol (a.arg[dp->arg_index].a.a_longdouble)) # endif - )) - { + )) + { # if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE) - arg_type type = a.arg[dp->arg_index].type; + arg_type type = a.arg[dp->arg_index].type; # endif - int flags = dp->flags; - int has_width; - size_t width; - int has_precision; - size_t precision; - size_t tmp_length; - DCHAR_T tmpbuf[700]; - DCHAR_T *tmp; - DCHAR_T *pad_ptr; - DCHAR_T *p; + int flags = dp->flags; + int has_width; + size_t width; + int has_precision; + size_t precision; + size_t tmp_length; + DCHAR_T tmpbuf[700]; + DCHAR_T *tmp; + DCHAR_T *pad_ptr; + DCHAR_T *p; - has_width = 0; - width = 0; - if (dp->width_start != dp->width_end) - { - if (dp->width_arg_index != ARG_NONE) - { - int arg; + has_width = 0; + width = 0; + if (dp->width_start != dp->width_end) + { + if (dp->width_arg_index != ARG_NONE) + { + int arg; - if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) - abort (); - arg = a.arg[dp->width_arg_index].a.a_int; - if (arg < 0) - { - /* "A negative field width is taken as a '-' flag - followed by a positive field width." */ - flags |= FLAG_LEFT; - width = (unsigned int) (-arg); - } - else - width = arg; - } - else - { - const FCHAR_T *digitp = dp->width_start; + if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->width_arg_index].a.a_int; + if (arg < 0) + { + /* "A negative field width is taken as a '-' flag + followed by a positive field width." */ + flags |= FLAG_LEFT; + width = (unsigned int) (-arg); + } + else + width = arg; + } + else + { + const FCHAR_T *digitp = dp->width_start; - do - width = xsum (xtimes (width, 10), *digitp++ - '0'); - while (digitp != dp->width_end); - } - has_width = 1; - } + do + width = xsum (xtimes (width, 10), *digitp++ - '0'); + while (digitp != dp->width_end); + } + has_width = 1; + } - has_precision = 0; - precision = 0; - if (dp->precision_start != dp->precision_end) - { - if (dp->precision_arg_index != ARG_NONE) - { - int arg; + has_precision = 0; + precision = 0; + if (dp->precision_start != dp->precision_end) + { + if (dp->precision_arg_index != ARG_NONE) + { + int arg; - if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) - abort (); - arg = a.arg[dp->precision_arg_index].a.a_int; - /* "A negative precision is taken as if the precision - were omitted." */ - if (arg >= 0) - { - precision = arg; - has_precision = 1; - } - } - else - { - const FCHAR_T *digitp = dp->precision_start + 1; + if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->precision_arg_index].a.a_int; + /* "A negative precision is taken as if the precision + were omitted." */ + if (arg >= 0) + { + precision = arg; + has_precision = 1; + } + } + else + { + const FCHAR_T *digitp = dp->precision_start + 1; - precision = 0; - while (digitp != dp->precision_end) - precision = xsum (xtimes (precision, 10), *digitp++ - '0'); - has_precision = 1; - } - } + precision = 0; + while (digitp != dp->precision_end) + precision = xsum (xtimes (precision, 10), *digitp++ - '0'); + has_precision = 1; + } + } - /* POSIX specifies the default precision to be 6 for %f, %F, - %e, %E, but not for %g, %G. Implementations appear to use - the same default precision also for %g, %G. But for %a, %A, - the default precision is 0. */ - if (!has_precision) - if (!(dp->conversion == 'a' || dp->conversion == 'A')) - precision = 6; + /* POSIX specifies the default precision to be 6 for %f, %F, + %e, %E, but not for %g, %G. Implementations appear to use + the same default precision also for %g, %G. But for %a, %A, + the default precision is 0. */ + if (!has_precision) + if (!(dp->conversion == 'a' || dp->conversion == 'A')) + precision = 6; - /* Allocate a temporary buffer of sufficient size. */ + /* Allocate a temporary buffer of sufficient size. */ # if NEED_PRINTF_DOUBLE && NEED_PRINTF_LONG_DOUBLE - tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : DBL_DIG + 1); + tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : DBL_DIG + 1); # elif NEED_PRINTF_INFINITE_DOUBLE && NEED_PRINTF_LONG_DOUBLE - tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : 0); + tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : 0); # elif NEED_PRINTF_LONG_DOUBLE - tmp_length = LDBL_DIG + 1; + tmp_length = LDBL_DIG + 1; # elif NEED_PRINTF_DOUBLE - tmp_length = DBL_DIG + 1; + tmp_length = DBL_DIG + 1; # else - tmp_length = 0; + tmp_length = 0; # endif - if (tmp_length < precision) - tmp_length = precision; + if (tmp_length < precision) + tmp_length = precision; # if NEED_PRINTF_LONG_DOUBLE # if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE - if (type == TYPE_LONGDOUBLE) + if (type == TYPE_LONGDOUBLE) # endif - if (dp->conversion == 'f' || dp->conversion == 'F') - { - long double arg = a.arg[dp->arg_index].a.a_longdouble; - if (!(isnanl (arg) || arg + arg == arg)) - { - /* arg is finite and nonzero. */ - int exponent = floorlog10l (arg < 0 ? -arg : arg); - if (exponent >= 0 && tmp_length < exponent + precision) - tmp_length = exponent + precision; - } - } + if (dp->conversion == 'f' || dp->conversion == 'F') + { + long double arg = a.arg[dp->arg_index].a.a_longdouble; + if (!(isnanl (arg) || arg + arg == arg)) + { + /* arg is finite and nonzero. */ + int exponent = floorlog10l (arg < 0 ? -arg : arg); + if (exponent >= 0 && tmp_length < exponent + precision) + tmp_length = exponent + precision; + } + } # endif # if NEED_PRINTF_DOUBLE # if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE - if (type == TYPE_DOUBLE) + if (type == TYPE_DOUBLE) # endif - if (dp->conversion == 'f' || dp->conversion == 'F') - { - double arg = a.arg[dp->arg_index].a.a_double; - if (!(isnand (arg) || arg + arg == arg)) - { - /* arg is finite and nonzero. */ - int exponent = floorlog10 (arg < 0 ? -arg : arg); - if (exponent >= 0 && tmp_length < exponent + precision) - tmp_length = exponent + precision; - } - } + if (dp->conversion == 'f' || dp->conversion == 'F') + { + double arg = a.arg[dp->arg_index].a.a_double; + if (!(isnand (arg) || arg + arg == arg)) + { + /* arg is finite and nonzero. */ + int exponent = floorlog10 (arg < 0 ? -arg : arg); + if (exponent >= 0 && tmp_length < exponent + precision) + tmp_length = exponent + precision; + } + } # endif - /* Account for sign, decimal point etc. */ - tmp_length = xsum (tmp_length, 12); + /* Account for sign, decimal point etc. */ + tmp_length = xsum (tmp_length, 12); - if (tmp_length < width) - tmp_length = width; + if (tmp_length < width) + tmp_length = width; - tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ + tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ - if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T)) - tmp = tmpbuf; - else - { - size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T)); + if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T)) + tmp = tmpbuf; + else + { + size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T)); - if (size_overflow_p (tmp_memsize)) - /* Overflow, would lead to out of memory. */ - goto out_of_memory; - tmp = (DCHAR_T *) malloc (tmp_memsize); - if (tmp == NULL) - /* Out of memory. */ - goto out_of_memory; - } + if (size_overflow_p (tmp_memsize)) + /* Overflow, would lead to out of memory. */ + goto out_of_memory; + tmp = (DCHAR_T *) malloc (tmp_memsize); + if (tmp == NULL) + /* Out of memory. */ + goto out_of_memory; + } - pad_ptr = NULL; - p = tmp; + pad_ptr = NULL; + p = tmp; # if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE # if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE - if (type == TYPE_LONGDOUBLE) + if (type == TYPE_LONGDOUBLE) # endif - { - long double arg = a.arg[dp->arg_index].a.a_longdouble; + { + long double arg = a.arg[dp->arg_index].a.a_longdouble; - if (isnanl (arg)) - { - if (dp->conversion >= 'A' && dp->conversion <= 'Z') - { - *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; - } - else - { - *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; - } - } - else - { - int sign = 0; - DECL_LONG_DOUBLE_ROUNDING + if (isnanl (arg)) + { + if (dp->conversion >= 'A' && dp->conversion <= 'Z') + { + *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; + } + else + { + *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; + } + } + else + { + int sign = 0; + DECL_LONG_DOUBLE_ROUNDING - BEGIN_LONG_DOUBLE_ROUNDING (); + BEGIN_LONG_DOUBLE_ROUNDING (); - if (signbit (arg)) /* arg < 0.0L or negative zero */ - { - sign = -1; - arg = -arg; - } + if (signbit (arg)) /* arg < 0.0L or negative zero */ + { + sign = -1; + arg = -arg; + } - if (sign < 0) - *p++ = '-'; - else if (flags & FLAG_SHOWSIGN) - *p++ = '+'; - else if (flags & FLAG_SPACE) - *p++ = ' '; + if (sign < 0) + *p++ = '-'; + else if (flags & FLAG_SHOWSIGN) + *p++ = '+'; + else if (flags & FLAG_SPACE) + *p++ = ' '; - if (arg > 0.0L && arg + arg == arg) - { - if (dp->conversion >= 'A' && dp->conversion <= 'Z') - { - *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; - } - else - { - *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; - } - } - else - { + if (arg > 0.0L && arg + arg == arg) + { + if (dp->conversion >= 'A' && dp->conversion <= 'Z') + { + *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; + } + else + { + *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; + } + } + else + { # if NEED_PRINTF_LONG_DOUBLE - pad_ptr = p; + pad_ptr = p; - if (dp->conversion == 'f' || dp->conversion == 'F') - { - char *digits; - size_t ndigits; + if (dp->conversion == 'f' || dp->conversion == 'F') + { + char *digits; + size_t ndigits; - digits = - scale10_round_decimal_long_double (arg, precision); - if (digits == NULL) - { - END_LONG_DOUBLE_ROUNDING (); - goto out_of_memory; - } - ndigits = strlen (digits); + digits = + scale10_round_decimal_long_double (arg, precision); + if (digits == NULL) + { + END_LONG_DOUBLE_ROUNDING (); + goto out_of_memory; + } + ndigits = strlen (digits); - if (ndigits > precision) - do - { - --ndigits; - *p++ = digits[ndigits]; - } - while (ndigits > precision); - else - *p++ = '0'; - /* Here ndigits <= precision. */ - if ((flags & FLAG_ALT) || precision > 0) - { - *p++ = decimal_point_char (); - for (; precision > ndigits; precision--) - *p++ = '0'; - while (ndigits > 0) - { - --ndigits; - *p++ = digits[ndigits]; - } - } + if (ndigits > precision) + do + { + --ndigits; + *p++ = digits[ndigits]; + } + while (ndigits > precision); + else + *p++ = '0'; + /* Here ndigits <= precision. */ + if ((flags & FLAG_ALT) || precision > 0) + { + *p++ = decimal_point_char (); + for (; precision > ndigits; precision--) + *p++ = '0'; + while (ndigits > 0) + { + --ndigits; + *p++ = digits[ndigits]; + } + } - free (digits); - } - else if (dp->conversion == 'e' || dp->conversion == 'E') - { - int exponent; + free (digits); + } + else if (dp->conversion == 'e' || dp->conversion == 'E') + { + int exponent; - if (arg == 0.0L) - { - exponent = 0; - *p++ = '0'; - if ((flags & FLAG_ALT) || precision > 0) - { - *p++ = decimal_point_char (); - for (; precision > 0; precision--) - *p++ = '0'; - } - } - else - { - /* arg > 0.0L. */ - int adjusted; - char *digits; - size_t ndigits; + if (arg == 0.0L) + { + exponent = 0; + *p++ = '0'; + if ((flags & FLAG_ALT) || precision > 0) + { + *p++ = decimal_point_char (); + for (; precision > 0; precision--) + *p++ = '0'; + } + } + else + { + /* arg > 0.0L. */ + int adjusted; + char *digits; + size_t ndigits; - exponent = floorlog10l (arg); - adjusted = 0; - for (;;) - { - digits = - scale10_round_decimal_long_double (arg, - (int)precision - exponent); - if (digits == NULL) - { - END_LONG_DOUBLE_ROUNDING (); - goto out_of_memory; - } - ndigits = strlen (digits); + exponent = floorlog10l (arg); + adjusted = 0; + for (;;) + { + digits = + scale10_round_decimal_long_double (arg, + (int)precision - exponent); + if (digits == NULL) + { + END_LONG_DOUBLE_ROUNDING (); + goto out_of_memory; + } + ndigits = strlen (digits); - if (ndigits == precision + 1) - break; - if (ndigits < precision - || ndigits > precision + 2) - /* The exponent was not guessed - precisely enough. */ - abort (); - if (adjusted) - /* None of two values of exponent is - the right one. Prevent an endless - loop. */ - abort (); - free (digits); - if (ndigits == precision) - exponent -= 1; - else - exponent += 1; - adjusted = 1; - } - /* Here ndigits = precision+1. */ - if (is_borderline (digits, precision)) - { - /* Maybe the exponent guess was too high - and a smaller exponent can be reached - by turning a 10...0 into 9...9x. */ - char *digits2 = - scale10_round_decimal_long_double (arg, - (int)precision - exponent + 1); - if (digits2 == NULL) - { - free (digits); - END_LONG_DOUBLE_ROUNDING (); - goto out_of_memory; - } - if (strlen (digits2) == precision + 1) - { - free (digits); - digits = digits2; - exponent -= 1; - } - else - free (digits2); - } - /* Here ndigits = precision+1. */ + if (ndigits == precision + 1) + break; + if (ndigits < precision + || ndigits > precision + 2) + /* The exponent was not guessed + precisely enough. */ + abort (); + if (adjusted) + /* None of two values of exponent is + the right one. Prevent an endless + loop. */ + abort (); + free (digits); + if (ndigits == precision) + exponent -= 1; + else + exponent += 1; + adjusted = 1; + } + /* Here ndigits = precision+1. */ + if (is_borderline (digits, precision)) + { + /* Maybe the exponent guess was too high + and a smaller exponent can be reached + by turning a 10...0 into 9...9x. */ + char *digits2 = + scale10_round_decimal_long_double (arg, + (int)precision - exponent + 1); + if (digits2 == NULL) + { + free (digits); + END_LONG_DOUBLE_ROUNDING (); + goto out_of_memory; + } + if (strlen (digits2) == precision + 1) + { + free (digits); + digits = digits2; + exponent -= 1; + } + else + free (digits2); + } + /* Here ndigits = precision+1. */ - *p++ = digits[--ndigits]; - if ((flags & FLAG_ALT) || precision > 0) - { - *p++ = decimal_point_char (); - while (ndigits > 0) - { - --ndigits; - *p++ = digits[ndigits]; - } - } + *p++ = digits[--ndigits]; + if ((flags & FLAG_ALT) || precision > 0) + { + *p++ = decimal_point_char (); + while (ndigits > 0) + { + --ndigits; + *p++ = digits[ndigits]; + } + } - free (digits); - } + free (digits); + } - *p++ = dp->conversion; /* 'e' or 'E' */ + *p++ = dp->conversion; /* 'e' or 'E' */ # if WIDE_CHAR_VERSION - { - static const wchar_t decimal_format[] = - { '%', '+', '.', '2', 'd', '\0' }; - SNPRINTF (p, 6 + 1, decimal_format, exponent); - } - while (*p != '\0') - p++; + { + static const wchar_t decimal_format[] = + { '%', '+', '.', '2', 'd', '\0' }; + SNPRINTF (p, 6 + 1, decimal_format, exponent); + } + while (*p != '\0') + p++; # else - if (sizeof (DCHAR_T) == 1) - { - sprintf ((char *) p, "%+.2d", exponent); - while (*p != '\0') - p++; - } - else - { - char expbuf[6 + 1]; - const char *ep; - sprintf (expbuf, "%+.2d", exponent); - for (ep = expbuf; (*p = *ep) != '\0'; ep++) - p++; - } + if (sizeof (DCHAR_T) == 1) + { + sprintf ((char *) p, "%+.2d", exponent); + while (*p != '\0') + p++; + } + else + { + char expbuf[6 + 1]; + const char *ep; + sprintf (expbuf, "%+.2d", exponent); + for (ep = expbuf; (*p = *ep) != '\0'; ep++) + p++; + } # endif - } - else if (dp->conversion == 'g' || dp->conversion == 'G') - { - if (precision == 0) - precision = 1; - /* precision >= 1. */ + } + else if (dp->conversion == 'g' || dp->conversion == 'G') + { + if (precision == 0) + precision = 1; + /* precision >= 1. */ - if (arg == 0.0L) - /* The exponent is 0, >= -4, < precision. - Use fixed-point notation. */ - { - size_t ndigits = precision; - /* Number of trailing zeroes that have to be - dropped. */ - size_t nzeroes = - (flags & FLAG_ALT ? 0 : precision - 1); + if (arg == 0.0L) + /* The exponent is 0, >= -4, < precision. + Use fixed-point notation. */ + { + size_t ndigits = precision; + /* Number of trailing zeroes that have to be + dropped. */ + size_t nzeroes = + (flags & FLAG_ALT ? 0 : precision - 1); - --ndigits; - *p++ = '0'; - if ((flags & FLAG_ALT) || ndigits > nzeroes) - { - *p++ = decimal_point_char (); - while (ndigits > nzeroes) - { - --ndigits; - *p++ = '0'; - } - } - } - else - { - /* arg > 0.0L. */ - int exponent; - int adjusted; - char *digits; - size_t ndigits; - size_t nzeroes; + --ndigits; + *p++ = '0'; + if ((flags & FLAG_ALT) || ndigits > nzeroes) + { + *p++ = decimal_point_char (); + while (ndigits > nzeroes) + { + --ndigits; + *p++ = '0'; + } + } + } + else + { + /* arg > 0.0L. */ + int exponent; + int adjusted; + char *digits; + size_t ndigits; + size_t nzeroes; - exponent = floorlog10l (arg); - adjusted = 0; - for (;;) - { - digits = - scale10_round_decimal_long_double (arg, - (int)(precision - 1) - exponent); - if (digits == NULL) - { - END_LONG_DOUBLE_ROUNDING (); - goto out_of_memory; - } - ndigits = strlen (digits); + exponent = floorlog10l (arg); + adjusted = 0; + for (;;) + { + digits = + scale10_round_decimal_long_double (arg, + (int)(precision - 1) - exponent); + if (digits == NULL) + { + END_LONG_DOUBLE_ROUNDING (); + goto out_of_memory; + } + ndigits = strlen (digits); - if (ndigits == precision) - break; - if (ndigits < precision - 1 - || ndigits > precision + 1) - /* The exponent was not guessed - precisely enough. */ - abort (); - if (adjusted) - /* None of two values of exponent is - the right one. Prevent an endless - loop. */ - abort (); - free (digits); - if (ndigits < precision) - exponent -= 1; - else - exponent += 1; - adjusted = 1; - } - /* Here ndigits = precision. */ - if (is_borderline (digits, precision - 1)) - { - /* Maybe the exponent guess was too high - and a smaller exponent can be reached - by turning a 10...0 into 9...9x. */ - char *digits2 = - scale10_round_decimal_long_double (arg, - (int)(precision - 1) - exponent + 1); - if (digits2 == NULL) - { - free (digits); - END_LONG_DOUBLE_ROUNDING (); - goto out_of_memory; - } - if (strlen (digits2) == precision) - { - free (digits); - digits = digits2; - exponent -= 1; - } - else - free (digits2); - } - /* Here ndigits = precision. */ + if (ndigits == precision) + break; + if (ndigits < precision - 1 + || ndigits > precision + 1) + /* The exponent was not guessed + precisely enough. */ + abort (); + if (adjusted) + /* None of two values of exponent is + the right one. Prevent an endless + loop. */ + abort (); + free (digits); + if (ndigits < precision) + exponent -= 1; + else + exponent += 1; + adjusted = 1; + } + /* Here ndigits = precision. */ + if (is_borderline (digits, precision - 1)) + { + /* Maybe the exponent guess was too high + and a smaller exponent can be reached + by turning a 10...0 into 9...9x. */ + char *digits2 = + scale10_round_decimal_long_double (arg, + (int)(precision - 1) - exponent + 1); + if (digits2 == NULL) + { + free (digits); + END_LONG_DOUBLE_ROUNDING (); + goto out_of_memory; + } + if (strlen (digits2) == precision) + { + free (digits); + digits = digits2; + exponent -= 1; + } + else + free (digits2); + } + /* Here ndigits = precision. */ - /* Determine the number of trailing zeroes - that have to be dropped. */ - nzeroes = 0; - if ((flags & FLAG_ALT) == 0) - while (nzeroes < ndigits - && digits[nzeroes] == '0') - nzeroes++; + /* Determine the number of trailing zeroes + that have to be dropped. */ + nzeroes = 0; + if ((flags & FLAG_ALT) == 0) + while (nzeroes < ndigits + && digits[nzeroes] == '0') + nzeroes++; - /* The exponent is now determined. */ - if (exponent >= -4 - && exponent < (long)precision) - { - /* Fixed-point notation: - max(exponent,0)+1 digits, then the - decimal point, then the remaining - digits without trailing zeroes. */ - if (exponent >= 0) - { - size_t count = exponent + 1; - /* Note: count <= precision = ndigits. */ - for (; count > 0; count--) - *p++ = digits[--ndigits]; - if ((flags & FLAG_ALT) || ndigits > nzeroes) - { - *p++ = decimal_point_char (); - while (ndigits > nzeroes) - { - --ndigits; - *p++ = digits[ndigits]; - } - } - } - else - { - size_t count = -exponent - 1; - *p++ = '0'; - *p++ = decimal_point_char (); - for (; count > 0; count--) - *p++ = '0'; - while (ndigits > nzeroes) - { - --ndigits; - *p++ = digits[ndigits]; - } - } - } - else - { - /* Exponential notation. */ - *p++ = digits[--ndigits]; - if ((flags & FLAG_ALT) || ndigits > nzeroes) - { - *p++ = decimal_point_char (); - while (ndigits > nzeroes) - { - --ndigits; - *p++ = digits[ndigits]; - } - } - *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */ + /* The exponent is now determined. */ + if (exponent >= -4 + && exponent < (long)precision) + { + /* Fixed-point notation: + max(exponent,0)+1 digits, then the + decimal point, then the remaining + digits without trailing zeroes. */ + if (exponent >= 0) + { + size_t count = exponent + 1; + /* Note: count <= precision = ndigits. */ + for (; count > 0; count--) + *p++ = digits[--ndigits]; + if ((flags & FLAG_ALT) || ndigits > nzeroes) + { + *p++ = decimal_point_char (); + while (ndigits > nzeroes) + { + --ndigits; + *p++ = digits[ndigits]; + } + } + } + else + { + size_t count = -exponent - 1; + *p++ = '0'; + *p++ = decimal_point_char (); + for (; count > 0; count--) + *p++ = '0'; + while (ndigits > nzeroes) + { + --ndigits; + *p++ = digits[ndigits]; + } + } + } + else + { + /* Exponential notation. */ + *p++ = digits[--ndigits]; + if ((flags & FLAG_ALT) || ndigits > nzeroes) + { + *p++ = decimal_point_char (); + while (ndigits > nzeroes) + { + --ndigits; + *p++ = digits[ndigits]; + } + } + *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */ # if WIDE_CHAR_VERSION - { - static const wchar_t decimal_format[] = - { '%', '+', '.', '2', 'd', '\0' }; - SNPRINTF (p, 6 + 1, decimal_format, exponent); - } - while (*p != '\0') - p++; + { + static const wchar_t decimal_format[] = + { '%', '+', '.', '2', 'd', '\0' }; + SNPRINTF (p, 6 + 1, decimal_format, exponent); + } + while (*p != '\0') + p++; # else - if (sizeof (DCHAR_T) == 1) - { - sprintf ((char *) p, "%+.2d", exponent); - while (*p != '\0') - p++; - } - else - { - char expbuf[6 + 1]; - const char *ep; - sprintf (expbuf, "%+.2d", exponent); - for (ep = expbuf; (*p = *ep) != '\0'; ep++) - p++; - } + if (sizeof (DCHAR_T) == 1) + { + sprintf ((char *) p, "%+.2d", exponent); + while (*p != '\0') + p++; + } + else + { + char expbuf[6 + 1]; + const char *ep; + sprintf (expbuf, "%+.2d", exponent); + for (ep = expbuf; (*p = *ep) != '\0'; ep++) + p++; + } # endif - } + } - free (digits); - } - } - else - abort (); + free (digits); + } + } + else + abort (); # else - /* arg is finite. */ - if (!(arg == 0.0L)) - abort (); + /* arg is finite. */ + if (!(arg == 0.0L)) + abort (); - pad_ptr = p; + pad_ptr = p; - if (dp->conversion == 'f' || dp->conversion == 'F') - { - *p++ = '0'; - if ((flags & FLAG_ALT) || precision > 0) - { - *p++ = decimal_point_char (); - for (; precision > 0; precision--) - *p++ = '0'; - } - } - else if (dp->conversion == 'e' || dp->conversion == 'E') - { - *p++ = '0'; - if ((flags & FLAG_ALT) || precision > 0) - { - *p++ = decimal_point_char (); - for (; precision > 0; precision--) - *p++ = '0'; - } - *p++ = dp->conversion; /* 'e' or 'E' */ - *p++ = '+'; - *p++ = '0'; - *p++ = '0'; - } - else if (dp->conversion == 'g' || dp->conversion == 'G') - { - *p++ = '0'; - if (flags & FLAG_ALT) - { - size_t ndigits = - (precision > 0 ? precision - 1 : 0); - *p++ = decimal_point_char (); - for (; ndigits > 0; --ndigits) - *p++ = '0'; - } - } - else if (dp->conversion == 'a' || dp->conversion == 'A') - { - *p++ = '0'; - *p++ = dp->conversion - 'A' + 'X'; - pad_ptr = p; - *p++ = '0'; - if ((flags & FLAG_ALT) || precision > 0) - { - *p++ = decimal_point_char (); - for (; precision > 0; precision--) - *p++ = '0'; - } - *p++ = dp->conversion - 'A' + 'P'; - *p++ = '+'; - *p++ = '0'; - } - else - abort (); + if (dp->conversion == 'f' || dp->conversion == 'F') + { + *p++ = '0'; + if ((flags & FLAG_ALT) || precision > 0) + { + *p++ = decimal_point_char (); + for (; precision > 0; precision--) + *p++ = '0'; + } + } + else if (dp->conversion == 'e' || dp->conversion == 'E') + { + *p++ = '0'; + if ((flags & FLAG_ALT) || precision > 0) + { + *p++ = decimal_point_char (); + for (; precision > 0; precision--) + *p++ = '0'; + } + *p++ = dp->conversion; /* 'e' or 'E' */ + *p++ = '+'; + *p++ = '0'; + *p++ = '0'; + } + else if (dp->conversion == 'g' || dp->conversion == 'G') + { + *p++ = '0'; + if (flags & FLAG_ALT) + { + size_t ndigits = + (precision > 0 ? precision - 1 : 0); + *p++ = decimal_point_char (); + for (; ndigits > 0; --ndigits) + *p++ = '0'; + } + } + else if (dp->conversion == 'a' || dp->conversion == 'A') + { + *p++ = '0'; + *p++ = dp->conversion - 'A' + 'X'; + pad_ptr = p; + *p++ = '0'; + if ((flags & FLAG_ALT) || precision > 0) + { + *p++ = decimal_point_char (); + for (; precision > 0; precision--) + *p++ = '0'; + } + *p++ = dp->conversion - 'A' + 'P'; + *p++ = '+'; + *p++ = '0'; + } + else + abort (); # endif - } + } - END_LONG_DOUBLE_ROUNDING (); - } - } + END_LONG_DOUBLE_ROUNDING (); + } + } # if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE - else + else # endif # endif # if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE - { - double arg = a.arg[dp->arg_index].a.a_double; + { + double arg = a.arg[dp->arg_index].a.a_double; - if (isnand (arg)) - { - if (dp->conversion >= 'A' && dp->conversion <= 'Z') - { - *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; - } - else - { - *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; - } - } - else - { - int sign = 0; + if (isnand (arg)) + { + if (dp->conversion >= 'A' && dp->conversion <= 'Z') + { + *p++ = 'N'; *p++ = 'A'; *p++ = 'N'; + } + else + { + *p++ = 'n'; *p++ = 'a'; *p++ = 'n'; + } + } + else + { + int sign = 0; - if (signbit (arg)) /* arg < 0.0 or negative zero */ - { - sign = -1; - arg = -arg; - } + if (signbit (arg)) /* arg < 0.0 or negative zero */ + { + sign = -1; + arg = -arg; + } - if (sign < 0) - *p++ = '-'; - else if (flags & FLAG_SHOWSIGN) - *p++ = '+'; - else if (flags & FLAG_SPACE) - *p++ = ' '; + if (sign < 0) + *p++ = '-'; + else if (flags & FLAG_SHOWSIGN) + *p++ = '+'; + else if (flags & FLAG_SPACE) + *p++ = ' '; - if (arg > 0.0 && arg + arg == arg) - { - if (dp->conversion >= 'A' && dp->conversion <= 'Z') - { - *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; - } - else - { - *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; - } - } - else - { + if (arg > 0.0 && arg + arg == arg) + { + if (dp->conversion >= 'A' && dp->conversion <= 'Z') + { + *p++ = 'I'; *p++ = 'N'; *p++ = 'F'; + } + else + { + *p++ = 'i'; *p++ = 'n'; *p++ = 'f'; + } + } + else + { # if NEED_PRINTF_DOUBLE - pad_ptr = p; + pad_ptr = p; - if (dp->conversion == 'f' || dp->conversion == 'F') - { - char *digits; - size_t ndigits; + if (dp->conversion == 'f' || dp->conversion == 'F') + { + char *digits; + size_t ndigits; - digits = - scale10_round_decimal_double (arg, precision); - if (digits == NULL) - goto out_of_memory; - ndigits = strlen (digits); + digits = + scale10_round_decimal_double (arg, precision); + if (digits == NULL) + goto out_of_memory; + ndigits = strlen (digits); - if (ndigits > precision) - do - { - --ndigits; - *p++ = digits[ndigits]; - } - while (ndigits > precision); - else - *p++ = '0'; - /* Here ndigits <= precision. */ - if ((flags & FLAG_ALT) || precision > 0) - { - *p++ = decimal_point_char (); - for (; precision > ndigits; precision--) - *p++ = '0'; - while (ndigits > 0) - { - --ndigits; - *p++ = digits[ndigits]; - } - } + if (ndigits > precision) + do + { + --ndigits; + *p++ = digits[ndigits]; + } + while (ndigits > precision); + else + *p++ = '0'; + /* Here ndigits <= precision. */ + if ((flags & FLAG_ALT) || precision > 0) + { + *p++ = decimal_point_char (); + for (; precision > ndigits; precision--) + *p++ = '0'; + while (ndigits > 0) + { + --ndigits; + *p++ = digits[ndigits]; + } + } - free (digits); - } - else if (dp->conversion == 'e' || dp->conversion == 'E') - { - int exponent; + free (digits); + } + else if (dp->conversion == 'e' || dp->conversion == 'E') + { + int exponent; - if (arg == 0.0) - { - exponent = 0; - *p++ = '0'; - if ((flags & FLAG_ALT) || precision > 0) - { - *p++ = decimal_point_char (); - for (; precision > 0; precision--) - *p++ = '0'; - } - } - else - { - /* arg > 0.0. */ - int adjusted; - char *digits; - size_t ndigits; + if (arg == 0.0) + { + exponent = 0; + *p++ = '0'; + if ((flags & FLAG_ALT) || precision > 0) + { + *p++ = decimal_point_char (); + for (; precision > 0; precision--) + *p++ = '0'; + } + } + else + { + /* arg > 0.0. */ + int adjusted; + char *digits; + size_t ndigits; - exponent = floorlog10 (arg); - adjusted = 0; - for (;;) - { - digits = - scale10_round_decimal_double (arg, - (int)precision - exponent); - if (digits == NULL) - goto out_of_memory; - ndigits = strlen (digits); + exponent = floorlog10 (arg); + adjusted = 0; + for (;;) + { + digits = + scale10_round_decimal_double (arg, + (int)precision - exponent); + if (digits == NULL) + goto out_of_memory; + ndigits = strlen (digits); - if (ndigits == precision + 1) - break; - if (ndigits < precision - || ndigits > precision + 2) - /* The exponent was not guessed - precisely enough. */ - abort (); - if (adjusted) - /* None of two values of exponent is - the right one. Prevent an endless - loop. */ - abort (); - free (digits); - if (ndigits == precision) - exponent -= 1; - else - exponent += 1; - adjusted = 1; - } - /* Here ndigits = precision+1. */ - if (is_borderline (digits, precision)) - { - /* Maybe the exponent guess was too high - and a smaller exponent can be reached - by turning a 10...0 into 9...9x. */ - char *digits2 = - scale10_round_decimal_double (arg, - (int)precision - exponent + 1); - if (digits2 == NULL) - { - free (digits); - goto out_of_memory; - } - if (strlen (digits2) == precision + 1) - { - free (digits); - digits = digits2; - exponent -= 1; - } - else - free (digits2); - } - /* Here ndigits = precision+1. */ + if (ndigits == precision + 1) + break; + if (ndigits < precision + || ndigits > precision + 2) + /* The exponent was not guessed + precisely enough. */ + abort (); + if (adjusted) + /* None of two values of exponent is + the right one. Prevent an endless + loop. */ + abort (); + free (digits); + if (ndigits == precision) + exponent -= 1; + else + exponent += 1; + adjusted = 1; + } + /* Here ndigits = precision+1. */ + if (is_borderline (digits, precision)) + { + /* Maybe the exponent guess was too high + and a smaller exponent can be reached + by turning a 10...0 into 9...9x. */ + char *digits2 = + scale10_round_decimal_double (arg, + (int)precision - exponent + 1); + if (digits2 == NULL) + { + free (digits); + goto out_of_memory; + } + if (strlen (digits2) == precision + 1) + { + free (digits); + digits = digits2; + exponent -= 1; + } + else + free (digits2); + } + /* Here ndigits = precision+1. */ - *p++ = digits[--ndigits]; - if ((flags & FLAG_ALT) || precision > 0) - { - *p++ = decimal_point_char (); - while (ndigits > 0) - { - --ndigits; - *p++ = digits[ndigits]; - } - } + *p++ = digits[--ndigits]; + if ((flags & FLAG_ALT) || precision > 0) + { + *p++ = decimal_point_char (); + while (ndigits > 0) + { + --ndigits; + *p++ = digits[ndigits]; + } + } - free (digits); - } + free (digits); + } - *p++ = dp->conversion; /* 'e' or 'E' */ + *p++ = dp->conversion; /* 'e' or 'E' */ # if WIDE_CHAR_VERSION - { - static const wchar_t decimal_format[] = - /* Produce the same number of exponent digits - as the native printf implementation. */ + { + static const wchar_t decimal_format[] = + /* Produce the same number of exponent digits + as the native printf implementation. */ # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - { '%', '+', '.', '3', 'd', '\0' }; + { '%', '+', '.', '3', 'd', '\0' }; # else - { '%', '+', '.', '2', 'd', '\0' }; + { '%', '+', '.', '2', 'd', '\0' }; # endif - SNPRINTF (p, 6 + 1, decimal_format, exponent); - } - while (*p != '\0') - p++; + SNPRINTF (p, 6 + 1, decimal_format, exponent); + } + while (*p != '\0') + p++; # else - { - static const char decimal_format[] = - /* Produce the same number of exponent digits - as the native printf implementation. */ + { + static const char decimal_format[] = + /* Produce the same number of exponent digits + as the native printf implementation. */ # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - "%+.3d"; + "%+.3d"; # else - "%+.2d"; + "%+.2d"; # endif - if (sizeof (DCHAR_T) == 1) - { - sprintf ((char *) p, decimal_format, exponent); - while (*p != '\0') - p++; - } - else - { - char expbuf[6 + 1]; - const char *ep; - sprintf (expbuf, decimal_format, exponent); - for (ep = expbuf; (*p = *ep) != '\0'; ep++) - p++; - } - } + if (sizeof (DCHAR_T) == 1) + { + sprintf ((char *) p, decimal_format, exponent); + while (*p != '\0') + p++; + } + else + { + char expbuf[6 + 1]; + const char *ep; + sprintf (expbuf, decimal_format, exponent); + for (ep = expbuf; (*p = *ep) != '\0'; ep++) + p++; + } + } # endif - } - else if (dp->conversion == 'g' || dp->conversion == 'G') - { - if (precision == 0) - precision = 1; - /* precision >= 1. */ + } + else if (dp->conversion == 'g' || dp->conversion == 'G') + { + if (precision == 0) + precision = 1; + /* precision >= 1. */ - if (arg == 0.0) - /* The exponent is 0, >= -4, < precision. - Use fixed-point notation. */ - { - size_t ndigits = precision; - /* Number of trailing zeroes that have to be - dropped. */ - size_t nzeroes = - (flags & FLAG_ALT ? 0 : precision - 1); + if (arg == 0.0) + /* The exponent is 0, >= -4, < precision. + Use fixed-point notation. */ + { + size_t ndigits = precision; + /* Number of trailing zeroes that have to be + dropped. */ + size_t nzeroes = + (flags & FLAG_ALT ? 0 : precision - 1); - --ndigits; - *p++ = '0'; - if ((flags & FLAG_ALT) || ndigits > nzeroes) - { - *p++ = decimal_point_char (); - while (ndigits > nzeroes) - { - --ndigits; - *p++ = '0'; - } - } - } - else - { - /* arg > 0.0. */ - int exponent; - int adjusted; - char *digits; - size_t ndigits; - size_t nzeroes; + --ndigits; + *p++ = '0'; + if ((flags & FLAG_ALT) || ndigits > nzeroes) + { + *p++ = decimal_point_char (); + while (ndigits > nzeroes) + { + --ndigits; + *p++ = '0'; + } + } + } + else + { + /* arg > 0.0. */ + int exponent; + int adjusted; + char *digits; + size_t ndigits; + size_t nzeroes; - exponent = floorlog10 (arg); - adjusted = 0; - for (;;) - { - digits = - scale10_round_decimal_double (arg, - (int)(precision - 1) - exponent); - if (digits == NULL) - goto out_of_memory; - ndigits = strlen (digits); + exponent = floorlog10 (arg); + adjusted = 0; + for (;;) + { + digits = + scale10_round_decimal_double (arg, + (int)(precision - 1) - exponent); + if (digits == NULL) + goto out_of_memory; + ndigits = strlen (digits); - if (ndigits == precision) - break; - if (ndigits < precision - 1 - || ndigits > precision + 1) - /* The exponent was not guessed - precisely enough. */ - abort (); - if (adjusted) - /* None of two values of exponent is - the right one. Prevent an endless - loop. */ - abort (); - free (digits); - if (ndigits < precision) - exponent -= 1; - else - exponent += 1; - adjusted = 1; - } - /* Here ndigits = precision. */ - if (is_borderline (digits, precision - 1)) - { - /* Maybe the exponent guess was too high - and a smaller exponent can be reached - by turning a 10...0 into 9...9x. */ - char *digits2 = - scale10_round_decimal_double (arg, - (int)(precision - 1) - exponent + 1); - if (digits2 == NULL) - { - free (digits); - goto out_of_memory; - } - if (strlen (digits2) == precision) - { - free (digits); - digits = digits2; - exponent -= 1; - } - else - free (digits2); - } - /* Here ndigits = precision. */ + if (ndigits == precision) + break; + if (ndigits < precision - 1 + || ndigits > precision + 1) + /* The exponent was not guessed + precisely enough. */ + abort (); + if (adjusted) + /* None of two values of exponent is + the right one. Prevent an endless + loop. */ + abort (); + free (digits); + if (ndigits < precision) + exponent -= 1; + else + exponent += 1; + adjusted = 1; + } + /* Here ndigits = precision. */ + if (is_borderline (digits, precision - 1)) + { + /* Maybe the exponent guess was too high + and a smaller exponent can be reached + by turning a 10...0 into 9...9x. */ + char *digits2 = + scale10_round_decimal_double (arg, + (int)(precision - 1) - exponent + 1); + if (digits2 == NULL) + { + free (digits); + goto out_of_memory; + } + if (strlen (digits2) == precision) + { + free (digits); + digits = digits2; + exponent -= 1; + } + else + free (digits2); + } + /* Here ndigits = precision. */ - /* Determine the number of trailing zeroes - that have to be dropped. */ - nzeroes = 0; - if ((flags & FLAG_ALT) == 0) - while (nzeroes < ndigits - && digits[nzeroes] == '0') - nzeroes++; + /* Determine the number of trailing zeroes + that have to be dropped. */ + nzeroes = 0; + if ((flags & FLAG_ALT) == 0) + while (nzeroes < ndigits + && digits[nzeroes] == '0') + nzeroes++; - /* The exponent is now determined. */ - if (exponent >= -4 - && exponent < (long)precision) - { - /* Fixed-point notation: - max(exponent,0)+1 digits, then the - decimal point, then the remaining - digits without trailing zeroes. */ - if (exponent >= 0) - { - size_t count = exponent + 1; - /* Note: count <= precision = ndigits. */ - for (; count > 0; count--) - *p++ = digits[--ndigits]; - if ((flags & FLAG_ALT) || ndigits > nzeroes) - { - *p++ = decimal_point_char (); - while (ndigits > nzeroes) - { - --ndigits; - *p++ = digits[ndigits]; - } - } - } - else - { - size_t count = -exponent - 1; - *p++ = '0'; - *p++ = decimal_point_char (); - for (; count > 0; count--) - *p++ = '0'; - while (ndigits > nzeroes) - { - --ndigits; - *p++ = digits[ndigits]; - } - } - } - else - { - /* Exponential notation. */ - *p++ = digits[--ndigits]; - if ((flags & FLAG_ALT) || ndigits > nzeroes) - { - *p++ = decimal_point_char (); - while (ndigits > nzeroes) - { - --ndigits; - *p++ = digits[ndigits]; - } - } - *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */ + /* The exponent is now determined. */ + if (exponent >= -4 + && exponent < (long)precision) + { + /* Fixed-point notation: + max(exponent,0)+1 digits, then the + decimal point, then the remaining + digits without trailing zeroes. */ + if (exponent >= 0) + { + size_t count = exponent + 1; + /* Note: count <= precision = ndigits. */ + for (; count > 0; count--) + *p++ = digits[--ndigits]; + if ((flags & FLAG_ALT) || ndigits > nzeroes) + { + *p++ = decimal_point_char (); + while (ndigits > nzeroes) + { + --ndigits; + *p++ = digits[ndigits]; + } + } + } + else + { + size_t count = -exponent - 1; + *p++ = '0'; + *p++ = decimal_point_char (); + for (; count > 0; count--) + *p++ = '0'; + while (ndigits > nzeroes) + { + --ndigits; + *p++ = digits[ndigits]; + } + } + } + else + { + /* Exponential notation. */ + *p++ = digits[--ndigits]; + if ((flags & FLAG_ALT) || ndigits > nzeroes) + { + *p++ = decimal_point_char (); + while (ndigits > nzeroes) + { + --ndigits; + *p++ = digits[ndigits]; + } + } + *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */ # if WIDE_CHAR_VERSION - { - static const wchar_t decimal_format[] = - /* Produce the same number of exponent digits - as the native printf implementation. */ + { + static const wchar_t decimal_format[] = + /* Produce the same number of exponent digits + as the native printf implementation. */ # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - { '%', '+', '.', '3', 'd', '\0' }; + { '%', '+', '.', '3', 'd', '\0' }; # else - { '%', '+', '.', '2', 'd', '\0' }; + { '%', '+', '.', '2', 'd', '\0' }; # endif - SNPRINTF (p, 6 + 1, decimal_format, exponent); - } - while (*p != '\0') - p++; + SNPRINTF (p, 6 + 1, decimal_format, exponent); + } + while (*p != '\0') + p++; # else - { - static const char decimal_format[] = - /* Produce the same number of exponent digits - as the native printf implementation. */ + { + static const char decimal_format[] = + /* Produce the same number of exponent digits + as the native printf implementation. */ # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - "%+.3d"; + "%+.3d"; # else - "%+.2d"; + "%+.2d"; # endif - if (sizeof (DCHAR_T) == 1) - { - sprintf ((char *) p, decimal_format, exponent); - while (*p != '\0') - p++; - } - else - { - char expbuf[6 + 1]; - const char *ep; - sprintf (expbuf, decimal_format, exponent); - for (ep = expbuf; (*p = *ep) != '\0'; ep++) - p++; - } - } + if (sizeof (DCHAR_T) == 1) + { + sprintf ((char *) p, decimal_format, exponent); + while (*p != '\0') + p++; + } + else + { + char expbuf[6 + 1]; + const char *ep; + sprintf (expbuf, decimal_format, exponent); + for (ep = expbuf; (*p = *ep) != '\0'; ep++) + p++; + } + } # endif - } + } - free (digits); - } - } - else - abort (); + free (digits); + } + } + else + abort (); # else - /* arg is finite. */ - if (!(arg == 0.0)) - abort (); + /* arg is finite. */ + if (!(arg == 0.0)) + abort (); - pad_ptr = p; + pad_ptr = p; - if (dp->conversion == 'f' || dp->conversion == 'F') - { - *p++ = '0'; - if ((flags & FLAG_ALT) || precision > 0) - { - *p++ = decimal_point_char (); - for (; precision > 0; precision--) - *p++ = '0'; - } - } - else if (dp->conversion == 'e' || dp->conversion == 'E') - { - *p++ = '0'; - if ((flags & FLAG_ALT) || precision > 0) - { - *p++ = decimal_point_char (); - for (; precision > 0; precision--) - *p++ = '0'; - } - *p++ = dp->conversion; /* 'e' or 'E' */ - *p++ = '+'; - /* Produce the same number of exponent digits as - the native printf implementation. */ + if (dp->conversion == 'f' || dp->conversion == 'F') + { + *p++ = '0'; + if ((flags & FLAG_ALT) || precision > 0) + { + *p++ = decimal_point_char (); + for (; precision > 0; precision--) + *p++ = '0'; + } + } + else if (dp->conversion == 'e' || dp->conversion == 'E') + { + *p++ = '0'; + if ((flags & FLAG_ALT) || precision > 0) + { + *p++ = decimal_point_char (); + for (; precision > 0; precision--) + *p++ = '0'; + } + *p++ = dp->conversion; /* 'e' or 'E' */ + *p++ = '+'; + /* Produce the same number of exponent digits as + the native printf implementation. */ # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - *p++ = '0'; + *p++ = '0'; # endif - *p++ = '0'; - *p++ = '0'; - } - else if (dp->conversion == 'g' || dp->conversion == 'G') - { - *p++ = '0'; - if (flags & FLAG_ALT) - { - size_t ndigits = - (precision > 0 ? precision - 1 : 0); - *p++ = decimal_point_char (); - for (; ndigits > 0; --ndigits) - *p++ = '0'; - } - } - else - abort (); + *p++ = '0'; + *p++ = '0'; + } + else if (dp->conversion == 'g' || dp->conversion == 'G') + { + *p++ = '0'; + if (flags & FLAG_ALT) + { + size_t ndigits = + (precision > 0 ? precision - 1 : 0); + *p++ = decimal_point_char (); + for (; ndigits > 0; --ndigits) + *p++ = '0'; + } + } + else + abort (); # endif - } - } - } + } + } + } # endif - /* The generated string now extends from tmp to p, with the - zero padding insertion point being at pad_ptr. */ - if (has_width && p - tmp < width) - { - size_t pad = width - (p - tmp); - DCHAR_T *end = p + pad; + /* The generated string now extends from tmp to p, with the + zero padding insertion point being at pad_ptr. */ + if (has_width && p - tmp < width) + { + size_t pad = width - (p - tmp); + DCHAR_T *end = p + pad; - if (flags & FLAG_LEFT) - { - /* Pad with spaces on the right. */ - for (; pad > 0; pad--) - *p++ = ' '; - } - else if ((flags & FLAG_ZERO) && pad_ptr != NULL) - { - /* Pad with zeroes. */ - DCHAR_T *q = end; + if (flags & FLAG_LEFT) + { + /* Pad with spaces on the right. */ + for (; pad > 0; pad--) + *p++ = ' '; + } + else if ((flags & FLAG_ZERO) && pad_ptr != NULL) + { + /* Pad with zeroes. */ + DCHAR_T *q = end; - while (p > pad_ptr) - *--q = *--p; - for (; pad > 0; pad--) - *p++ = '0'; - } - else - { - /* Pad with spaces on the left. */ - DCHAR_T *q = end; + while (p > pad_ptr) + *--q = *--p; + for (; pad > 0; pad--) + *p++ = '0'; + } + else + { + /* Pad with spaces on the left. */ + DCHAR_T *q = end; - while (p > tmp) - *--q = *--p; - for (; pad > 0; pad--) - *p++ = ' '; - } + while (p > tmp) + *--q = *--p; + for (; pad > 0; pad--) + *p++ = ' '; + } - p = end; - } + p = end; + } - { - size_t count = p - tmp; + { + size_t count = p - tmp; - if (count >= tmp_length) - /* tmp_length was incorrectly calculated - fix the - code above! */ - abort (); + if (count >= tmp_length) + /* tmp_length was incorrectly calculated - fix the + code above! */ + abort (); - /* Make room for the result. */ - if (count >= allocated - length) - { - size_t n = xsum (length, count); + /* Make room for the result. */ + if (count >= allocated - length) + { + size_t n = xsum (length, count); - ENSURE_ALLOCATION (n); - } + ENSURE_ALLOCATION (n); + } - /* Append the result. */ - memcpy (result + length, tmp, count * sizeof (DCHAR_T)); - if (tmp != tmpbuf) - free (tmp); - length += count; - } - } + /* Append the result. */ + memcpy (result + length, tmp, count * sizeof (DCHAR_T)); + if (tmp != tmpbuf) + free (tmp); + length += count; + } + } #endif - else - { - arg_type type = a.arg[dp->arg_index].type; - int flags = dp->flags; + else + { + arg_type type = a.arg[dp->arg_index].type; + int flags = dp->flags; #if !USE_SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION - int has_width; - size_t width; + int has_width; + size_t width; #endif #if !USE_SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION - int has_precision; - size_t precision; + int has_precision; + size_t precision; #endif #if NEED_PRINTF_UNBOUNDED_PRECISION - int prec_ourselves; + int prec_ourselves; #else -# define prec_ourselves 0 +# define prec_ourselves 0 #endif #if NEED_PRINTF_FLAG_LEFTADJUST -# define pad_ourselves 1 +# define pad_ourselves 1 #elif !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION - int pad_ourselves; + int pad_ourselves; #else -# define pad_ourselves 0 +# define pad_ourselves 0 #endif - TCHAR_T *fbp; - unsigned int prefix_count; - int prefixes[2] IF_LINT (= { 0 }); + TCHAR_T *fbp; + unsigned int prefix_count; + int prefixes[2] IF_LINT (= { 0 }); #if !USE_SNPRINTF - size_t tmp_length; - TCHAR_T tmpbuf[700]; - TCHAR_T *tmp; + size_t tmp_length; + TCHAR_T tmpbuf[700]; + TCHAR_T *tmp; #endif #if !USE_SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION - has_width = 0; - width = 0; - if (dp->width_start != dp->width_end) - { - if (dp->width_arg_index != ARG_NONE) - { - int arg; + has_width = 0; + width = 0; + if (dp->width_start != dp->width_end) + { + if (dp->width_arg_index != ARG_NONE) + { + int arg; - if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) - abort (); - arg = a.arg[dp->width_arg_index].a.a_int; - if (arg < 0) - { - /* "A negative field width is taken as a '-' flag - followed by a positive field width." */ - flags |= FLAG_LEFT; - width = (unsigned int) (-arg); - } - else - width = arg; - } - else - { - const FCHAR_T *digitp = dp->width_start; + if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->width_arg_index].a.a_int; + if (arg < 0) + { + /* "A negative field width is taken as a '-' flag + followed by a positive field width." */ + flags |= FLAG_LEFT; + width = (unsigned int) (-arg); + } + else + width = arg; + } + else + { + const FCHAR_T *digitp = dp->width_start; - do - width = xsum (xtimes (width, 10), *digitp++ - '0'); - while (digitp != dp->width_end); - } - has_width = 1; - } + do + width = xsum (xtimes (width, 10), *digitp++ - '0'); + while (digitp != dp->width_end); + } + has_width = 1; + } #endif #if !USE_SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION - has_precision = 0; - precision = 6; - if (dp->precision_start != dp->precision_end) - { - if (dp->precision_arg_index != ARG_NONE) - { - int arg; + has_precision = 0; + precision = 6; + if (dp->precision_start != dp->precision_end) + { + if (dp->precision_arg_index != ARG_NONE) + { + int arg; - if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) - abort (); - arg = a.arg[dp->precision_arg_index].a.a_int; - /* "A negative precision is taken as if the precision - were omitted." */ - if (arg >= 0) - { - precision = arg; - has_precision = 1; - } - } - else - { - const FCHAR_T *digitp = dp->precision_start + 1; + if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) + abort (); + arg = a.arg[dp->precision_arg_index].a.a_int; + /* "A negative precision is taken as if the precision + were omitted." */ + if (arg >= 0) + { + precision = arg; + has_precision = 1; + } + } + else + { + const FCHAR_T *digitp = dp->precision_start + 1; - precision = 0; - while (digitp != dp->precision_end) - precision = xsum (xtimes (precision, 10), *digitp++ - '0'); - has_precision = 1; - } - } + precision = 0; + while (digitp != dp->precision_end) + precision = xsum (xtimes (precision, 10), *digitp++ - '0'); + has_precision = 1; + } + } #endif - /* Decide whether to handle the precision ourselves. */ + /* Decide whether to handle the precision ourselves. */ #if NEED_PRINTF_UNBOUNDED_PRECISION - switch (dp->conversion) - { - case 'd': case 'i': case 'u': - case 'o': - case 'x': case 'X': case 'p': - prec_ourselves = has_precision && (precision > 0); - break; - default: - prec_ourselves = 0; - break; - } + switch (dp->conversion) + { + case 'd': case 'i': case 'u': + case 'o': + case 'x': case 'X': case 'p': + prec_ourselves = has_precision && (precision > 0); + break; + default: + prec_ourselves = 0; + break; + } #endif - /* Decide whether to perform the padding ourselves. */ + /* Decide whether to perform the padding ourselves. */ #if !NEED_PRINTF_FLAG_LEFTADJUST && (!DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION) - switch (dp->conversion) - { + switch (dp->conversion) + { # if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO - /* If we need conversion from TCHAR_T[] to DCHAR_T[], we need - to perform the padding after this conversion. Functions - with unistdio extensions perform the padding based on - character count rather than element count. */ - case 'c': case 's': + /* If we need conversion from TCHAR_T[] to DCHAR_T[], we need + to perform the padding after this conversion. Functions + with unistdio extensions perform the padding based on + character count rather than element count. */ + case 'c': case 's': # endif # if NEED_PRINTF_FLAG_ZERO - case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': - case 'a': case 'A': + case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': + case 'a': case 'A': # endif - pad_ourselves = 1; - break; - default: - pad_ourselves = prec_ourselves; - break; - } + pad_ourselves = 1; + break; + default: + pad_ourselves = prec_ourselves; + break; + } #endif #if !USE_SNPRINTF - /* Allocate a temporary buffer of sufficient size for calling - sprintf. */ - { - switch (dp->conversion) - { + /* Allocate a temporary buffer of sufficient size for calling + sprintf. */ + { + switch (dp->conversion) + { - case 'd': case 'i': case 'u': + case 'd': case 'i': case 'u': # if HAVE_LONG_LONG_INT - if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long long) * CHAR_BIT - * 0.30103 /* binary -> decimal */ - ) - + 1; /* turn floor into ceil */ - else + if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) + tmp_length = + (unsigned int) (sizeof (unsigned long long) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + else # endif - if (type == TYPE_LONGINT || type == TYPE_ULONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long) * CHAR_BIT - * 0.30103 /* binary -> decimal */ - ) - + 1; /* turn floor into ceil */ - else - tmp_length = - (unsigned int) (sizeof (unsigned int) * CHAR_BIT - * 0.30103 /* binary -> decimal */ - ) - + 1; /* turn floor into ceil */ - if (tmp_length < precision) - tmp_length = precision; - /* Multiply by 2, as an estimate for FLAG_GROUP. */ - tmp_length = xsum (tmp_length, tmp_length); - /* Add 1, to account for a leading sign. */ - tmp_length = xsum (tmp_length, 1); - break; + if (type == TYPE_LONGINT || type == TYPE_ULONGINT) + tmp_length = + (unsigned int) (sizeof (unsigned long) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + else + tmp_length = + (unsigned int) (sizeof (unsigned int) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + if (tmp_length < precision) + tmp_length = precision; + /* Multiply by 2, as an estimate for FLAG_GROUP. */ + tmp_length = xsum (tmp_length, tmp_length); + /* Add 1, to account for a leading sign. */ + tmp_length = xsum (tmp_length, 1); + break; - case 'o': + case 'o': # if HAVE_LONG_LONG_INT - if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long long) * CHAR_BIT - * 0.333334 /* binary -> octal */ - ) - + 1; /* turn floor into ceil */ - else + if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) + tmp_length = + (unsigned int) (sizeof (unsigned long long) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + else # endif - if (type == TYPE_LONGINT || type == TYPE_ULONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long) * CHAR_BIT - * 0.333334 /* binary -> octal */ - ) - + 1; /* turn floor into ceil */ - else - tmp_length = - (unsigned int) (sizeof (unsigned int) * CHAR_BIT - * 0.333334 /* binary -> octal */ - ) - + 1; /* turn floor into ceil */ - if (tmp_length < precision) - tmp_length = precision; - /* Add 1, to account for a leading sign. */ - tmp_length = xsum (tmp_length, 1); - break; + if (type == TYPE_LONGINT || type == TYPE_ULONGINT) + tmp_length = + (unsigned int) (sizeof (unsigned long) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + else + tmp_length = + (unsigned int) (sizeof (unsigned int) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + if (tmp_length < precision) + tmp_length = precision; + /* Add 1, to account for a leading sign. */ + tmp_length = xsum (tmp_length, 1); + break; - case 'x': case 'X': + case 'x': case 'X': # if HAVE_LONG_LONG_INT - if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long long) * CHAR_BIT - * 0.25 /* binary -> hexadecimal */ - ) - + 1; /* turn floor into ceil */ - else + if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) + tmp_length = + (unsigned int) (sizeof (unsigned long long) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + else # endif - if (type == TYPE_LONGINT || type == TYPE_ULONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long) * CHAR_BIT - * 0.25 /* binary -> hexadecimal */ - ) - + 1; /* turn floor into ceil */ - else - tmp_length = - (unsigned int) (sizeof (unsigned int) * CHAR_BIT - * 0.25 /* binary -> hexadecimal */ - ) - + 1; /* turn floor into ceil */ - if (tmp_length < precision) - tmp_length = precision; - /* Add 2, to account for a leading sign or alternate form. */ - tmp_length = xsum (tmp_length, 2); - break; + if (type == TYPE_LONGINT || type == TYPE_ULONGINT) + tmp_length = + (unsigned int) (sizeof (unsigned long) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + else + tmp_length = + (unsigned int) (sizeof (unsigned int) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + if (tmp_length < precision) + tmp_length = precision; + /* Add 2, to account for a leading sign or alternate form. */ + tmp_length = xsum (tmp_length, 2); + break; - case 'f': case 'F': - if (type == TYPE_LONGDOUBLE) - tmp_length = - (unsigned int) (LDBL_MAX_EXP - * 0.30103 /* binary -> decimal */ - * 2 /* estimate for FLAG_GROUP */ - ) - + 1 /* turn floor into ceil */ - + 10; /* sign, decimal point etc. */ - else - tmp_length = - (unsigned int) (DBL_MAX_EXP - * 0.30103 /* binary -> decimal */ - * 2 /* estimate for FLAG_GROUP */ - ) - + 1 /* turn floor into ceil */ - + 10; /* sign, decimal point etc. */ - tmp_length = xsum (tmp_length, precision); - break; + case 'f': case 'F': + if (type == TYPE_LONGDOUBLE) + tmp_length = + (unsigned int) (LDBL_MAX_EXP + * 0.30103 /* binary -> decimal */ + * 2 /* estimate for FLAG_GROUP */ + ) + + 1 /* turn floor into ceil */ + + 10; /* sign, decimal point etc. */ + else + tmp_length = + (unsigned int) (DBL_MAX_EXP + * 0.30103 /* binary -> decimal */ + * 2 /* estimate for FLAG_GROUP */ + ) + + 1 /* turn floor into ceil */ + + 10; /* sign, decimal point etc. */ + tmp_length = xsum (tmp_length, precision); + break; - case 'e': case 'E': case 'g': case 'G': - tmp_length = - 12; /* sign, decimal point, exponent etc. */ - tmp_length = xsum (tmp_length, precision); - break; + case 'e': case 'E': case 'g': case 'G': + tmp_length = + 12; /* sign, decimal point, exponent etc. */ + tmp_length = xsum (tmp_length, precision); + break; - case 'a': case 'A': - if (type == TYPE_LONGDOUBLE) - tmp_length = - (unsigned int) (LDBL_DIG - * 0.831 /* decimal -> hexadecimal */ - ) - + 1; /* turn floor into ceil */ - else - tmp_length = - (unsigned int) (DBL_DIG - * 0.831 /* decimal -> hexadecimal */ - ) - + 1; /* turn floor into ceil */ - if (tmp_length < precision) - tmp_length = precision; - /* Account for sign, decimal point etc. */ - tmp_length = xsum (tmp_length, 12); - break; + case 'a': case 'A': + if (type == TYPE_LONGDOUBLE) + tmp_length = + (unsigned int) (LDBL_DIG + * 0.831 /* decimal -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + else + tmp_length = + (unsigned int) (DBL_DIG + * 0.831 /* decimal -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + if (tmp_length < precision) + tmp_length = precision; + /* Account for sign, decimal point etc. */ + tmp_length = xsum (tmp_length, 12); + break; - case 'c': + case 'c': # if HAVE_WINT_T && !WIDE_CHAR_VERSION - if (type == TYPE_WIDE_CHAR) - tmp_length = MB_CUR_MAX; - else + if (type == TYPE_WIDE_CHAR) + tmp_length = MB_CUR_MAX; + else # endif - tmp_length = 1; - break; + tmp_length = 1; + break; - case 's': + case 's': # if HAVE_WCHAR_T - if (type == TYPE_WIDE_STRING) - { + if (type == TYPE_WIDE_STRING) + { # if WIDE_CHAR_VERSION - /* ISO C says about %ls in fwprintf: - "If the precision is not specified or is greater - than the size of the array, the array shall - contain a null wide character." - So if there is a precision, we must not use - wcslen. */ - const wchar_t *arg = - a.arg[dp->arg_index].a.a_wide_string; + /* ISO C says about %ls in fwprintf: + "If the precision is not specified or is greater + than the size of the array, the array shall + contain a null wide character." + So if there is a precision, we must not use + wcslen. */ + const wchar_t *arg = + a.arg[dp->arg_index].a.a_wide_string; - if (has_precision) - tmp_length = local_wcsnlen (arg, precision); - else - tmp_length = local_wcslen (arg); + if (has_precision) + tmp_length = local_wcsnlen (arg, precision); + else + tmp_length = local_wcslen (arg); # else - /* ISO C says about %ls in fprintf: - "If a precision is specified, no more than that - many bytes are written (including shift - sequences, if any), and the array shall contain - a null wide character if, to equal the - multibyte character sequence length given by - the precision, the function would need to - access a wide character one past the end of the - array." - So if there is a precision, we must not use - wcslen. */ - /* This case has already been handled above. */ - abort (); + /* ISO C says about %ls in fprintf: + "If a precision is specified, no more than that + many bytes are written (including shift + sequences, if any), and the array shall contain + a null wide character if, to equal the + multibyte character sequence length given by + the precision, the function would need to + access a wide character one past the end of the + array." + So if there is a precision, we must not use + wcslen. */ + /* This case has already been handled above. */ + abort (); # endif - } - else + } + else # endif - { + { # if WIDE_CHAR_VERSION - /* ISO C says about %s in fwprintf: - "If the precision is not specified or is greater - than the size of the converted array, the - converted array shall contain a null wide - character." - So if there is a precision, we must not use - strlen. */ - /* This case has already been handled above. */ - abort (); + /* ISO C says about %s in fwprintf: + "If the precision is not specified or is greater + than the size of the converted array, the + converted array shall contain a null wide + character." + So if there is a precision, we must not use + strlen. */ + /* This case has already been handled above. */ + abort (); # else - /* ISO C says about %s in fprintf: - "If the precision is not specified or greater - than the size of the array, the array shall - contain a null character." - So if there is a precision, we must not use - strlen. */ - const char *arg = a.arg[dp->arg_index].a.a_string; + /* ISO C says about %s in fprintf: + "If the precision is not specified or greater + than the size of the array, the array shall + contain a null character." + So if there is a precision, we must not use + strlen. */ + const char *arg = a.arg[dp->arg_index].a.a_string; - if (has_precision) - tmp_length = local_strnlen (arg, precision); - else - tmp_length = strlen (arg); + if (has_precision) + tmp_length = local_strnlen (arg, precision); + else + tmp_length = strlen (arg); # endif - } - break; + } + break; - case 'p': - tmp_length = - (unsigned int) (sizeof (void *) * CHAR_BIT - * 0.25 /* binary -> hexadecimal */ - ) - + 1 /* turn floor into ceil */ - + 2; /* account for leading 0x */ - break; + case 'p': + tmp_length = + (unsigned int) (sizeof (void *) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1 /* turn floor into ceil */ + + 2; /* account for leading 0x */ + break; - default: - abort (); - } + default: + abort (); + } - if (!pad_ourselves) - { + if (!pad_ourselves) + { # if ENABLE_UNISTDIO - /* Padding considers the number of characters, therefore - the number of elements after padding may be - > max (tmp_length, width) - but is certainly - <= tmp_length + width. */ - tmp_length = xsum (tmp_length, width); + /* Padding considers the number of characters, therefore + the number of elements after padding may be + > max (tmp_length, width) + but is certainly + <= tmp_length + width. */ + tmp_length = xsum (tmp_length, width); # else - /* Padding considers the number of elements, - says POSIX. */ - if (tmp_length < width) - tmp_length = width; + /* Padding considers the number of elements, + says POSIX. */ + if (tmp_length < width) + tmp_length = width; # endif - } + } - tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ - } + tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ + } - if (tmp_length <= sizeof (tmpbuf) / sizeof (TCHAR_T)) - tmp = tmpbuf; - else - { - size_t tmp_memsize = xtimes (tmp_length, sizeof (TCHAR_T)); + if (tmp_length <= sizeof (tmpbuf) / sizeof (TCHAR_T)) + tmp = tmpbuf; + else + { + size_t tmp_memsize = xtimes (tmp_length, sizeof (TCHAR_T)); - if (size_overflow_p (tmp_memsize)) - /* Overflow, would lead to out of memory. */ - goto out_of_memory; - tmp = (TCHAR_T *) malloc (tmp_memsize); - if (tmp == NULL) - /* Out of memory. */ - goto out_of_memory; - } + if (size_overflow_p (tmp_memsize)) + /* Overflow, would lead to out of memory. */ + goto out_of_memory; + tmp = (TCHAR_T *) malloc (tmp_memsize); + if (tmp == NULL) + /* Out of memory. */ + goto out_of_memory; + } #endif - /* Construct the format string for calling snprintf or - sprintf. */ - fbp = buf; - *fbp++ = '%'; + /* Construct the format string for calling snprintf or + sprintf. */ + fbp = buf; + *fbp++ = '%'; #if NEED_PRINTF_FLAG_GROUPING - /* The underlying implementation doesn't support the ' flag. - Produce no grouping characters in this case; this is - acceptable because the grouping is locale dependent. */ + /* The underlying implementation doesn't support the ' flag. + Produce no grouping characters in this case; this is + acceptable because the grouping is locale dependent. */ #else - if (flags & FLAG_GROUP) - *fbp++ = '\''; + if (flags & FLAG_GROUP) + *fbp++ = '\''; #endif - if (flags & FLAG_LEFT) - *fbp++ = '-'; - if (flags & FLAG_SHOWSIGN) - *fbp++ = '+'; - if (flags & FLAG_SPACE) - *fbp++ = ' '; - if (flags & FLAG_ALT) - *fbp++ = '#'; - if (!pad_ourselves) - { - if (flags & FLAG_ZERO) - *fbp++ = '0'; - if (dp->width_start != dp->width_end) - { - size_t n = dp->width_end - dp->width_start; - /* The width specification is known to consist only - of standard ASCII characters. */ - if (sizeof (FCHAR_T) == sizeof (TCHAR_T)) - { - memcpy (fbp, dp->width_start, n * sizeof (TCHAR_T)); - fbp += n; - } - else - { - const FCHAR_T *mp = dp->width_start; - do - *fbp++ = (unsigned char) *mp++; - while (--n > 0); - } - } - } - if (!prec_ourselves) - { - if (dp->precision_start != dp->precision_end) - { - size_t n = dp->precision_end - dp->precision_start; - /* The precision specification is known to consist only - of standard ASCII characters. */ - if (sizeof (FCHAR_T) == sizeof (TCHAR_T)) - { - memcpy (fbp, dp->precision_start, n * sizeof (TCHAR_T)); - fbp += n; - } - else - { - const FCHAR_T *mp = dp->precision_start; - do - *fbp++ = (unsigned char) *mp++; - while (--n > 0); - } - } - } + if (flags & FLAG_LEFT) + *fbp++ = '-'; + if (flags & FLAG_SHOWSIGN) + *fbp++ = '+'; + if (flags & FLAG_SPACE) + *fbp++ = ' '; + if (flags & FLAG_ALT) + *fbp++ = '#'; + if (!pad_ourselves) + { + if (flags & FLAG_ZERO) + *fbp++ = '0'; + if (dp->width_start != dp->width_end) + { + size_t n = dp->width_end - dp->width_start; + /* The width specification is known to consist only + of standard ASCII characters. */ + if (sizeof (FCHAR_T) == sizeof (TCHAR_T)) + { + memcpy (fbp, dp->width_start, n * sizeof (TCHAR_T)); + fbp += n; + } + else + { + const FCHAR_T *mp = dp->width_start; + do + *fbp++ = (unsigned char) *mp++; + while (--n > 0); + } + } + } + if (!prec_ourselves) + { + if (dp->precision_start != dp->precision_end) + { + size_t n = dp->precision_end - dp->precision_start; + /* The precision specification is known to consist only + of standard ASCII characters. */ + if (sizeof (FCHAR_T) == sizeof (TCHAR_T)) + { + memcpy (fbp, dp->precision_start, n * sizeof (TCHAR_T)); + fbp += n; + } + else + { + const FCHAR_T *mp = dp->precision_start; + do + *fbp++ = (unsigned char) *mp++; + while (--n > 0); + } + } + } - switch (type) - { + switch (type) + { #if HAVE_LONG_LONG_INT - case TYPE_LONGLONGINT: - case TYPE_ULONGLONGINT: + case TYPE_LONGLONGINT: + case TYPE_ULONGLONGINT: # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - *fbp++ = 'I'; - *fbp++ = '6'; - *fbp++ = '4'; - break; + *fbp++ = 'I'; + *fbp++ = '6'; + *fbp++ = '4'; + break; # else - *fbp++ = 'l'; - /*FALLTHROUGH*/ + *fbp++ = 'l'; + /*FALLTHROUGH*/ # endif #endif - case TYPE_LONGINT: - case TYPE_ULONGINT: + case TYPE_LONGINT: + case TYPE_ULONGINT: #if HAVE_WINT_T - case TYPE_WIDE_CHAR: + case TYPE_WIDE_CHAR: #endif #if HAVE_WCHAR_T - case TYPE_WIDE_STRING: + case TYPE_WIDE_STRING: #endif - *fbp++ = 'l'; - break; - case TYPE_LONGDOUBLE: - *fbp++ = 'L'; - break; - default: - break; - } + *fbp++ = 'l'; + break; + case TYPE_LONGDOUBLE: + *fbp++ = 'L'; + break; + default: + break; + } #if NEED_PRINTF_DIRECTIVE_F - if (dp->conversion == 'F') - *fbp = 'f'; - else + if (dp->conversion == 'F') + *fbp = 'f'; + else #endif - *fbp = dp->conversion; + *fbp = dp->conversion; #if USE_SNPRINTF # if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) - fbp[1] = '%'; - fbp[2] = 'n'; - fbp[3] = '\0'; + fbp[1] = '%'; + fbp[2] = 'n'; + fbp[3] = '\0'; # else - /* On glibc2 systems from glibc >= 2.3 - probably also older - ones - we know that snprintf's returns value conforms to - ISO C 99: the gl_SNPRINTF_DIRECTIVE_N test passes. - Therefore we can avoid using %n in this situation. - On glibc2 systems from 2004-10-18 or newer, the use of %n - in format strings in writable memory may crash the program - (if compiled with _FORTIFY_SOURCE=2), so we should avoid it - in this situation. */ - /* On native Win32 systems (such as mingw), we can avoid using - %n because: - - Although the gl_SNPRINTF_TRUNCATION_C99 test fails, - snprintf does not write more than the specified number - of bytes. (snprintf (buf, 3, "%d %d", 4567, 89) writes - '4', '5', '6' into buf, not '4', '5', '\0'.) - - Although the gl_SNPRINTF_RETVAL_C99 test fails, snprintf - allows us to recognize the case of an insufficient - buffer size: it returns -1 in this case. - On native Win32 systems (such as mingw) where the OS is - Windows Vista, the use of %n in format strings by default - crashes the program. See - and - - So we should avoid %n in this situation. */ - fbp[1] = '\0'; + /* On glibc2 systems from glibc >= 2.3 - probably also older + ones - we know that snprintf's returns value conforms to + ISO C 99: the gl_SNPRINTF_DIRECTIVE_N test passes. + Therefore we can avoid using %n in this situation. + On glibc2 systems from 2004-10-18 or newer, the use of %n + in format strings in writable memory may crash the program + (if compiled with _FORTIFY_SOURCE=2), so we should avoid it + in this situation. */ + /* On native Win32 systems (such as mingw), we can avoid using + %n because: + - Although the gl_SNPRINTF_TRUNCATION_C99 test fails, + snprintf does not write more than the specified number + of bytes. (snprintf (buf, 3, "%d %d", 4567, 89) writes + '4', '5', '6' into buf, not '4', '5', '\0'.) + - Although the gl_SNPRINTF_RETVAL_C99 test fails, snprintf + allows us to recognize the case of an insufficient + buffer size: it returns -1 in this case. + On native Win32 systems (such as mingw) where the OS is + Windows Vista, the use of %n in format strings by default + crashes the program. See + and + + So we should avoid %n in this situation. */ + fbp[1] = '\0'; # endif #else - fbp[1] = '\0'; + fbp[1] = '\0'; #endif - /* Construct the arguments for calling snprintf or sprintf. */ - prefix_count = 0; - if (!pad_ourselves && dp->width_arg_index != ARG_NONE) - { - if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) - abort (); - prefixes[prefix_count++] = a.arg[dp->width_arg_index].a.a_int; - } - if (!prec_ourselves && dp->precision_arg_index != ARG_NONE) - { - if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) - abort (); - prefixes[prefix_count++] = a.arg[dp->precision_arg_index].a.a_int; - } + /* Construct the arguments for calling snprintf or sprintf. */ + prefix_count = 0; + if (!pad_ourselves && dp->width_arg_index != ARG_NONE) + { + if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) + abort (); + prefixes[prefix_count++] = a.arg[dp->width_arg_index].a.a_int; + } + if (!prec_ourselves && dp->precision_arg_index != ARG_NONE) + { + if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) + abort (); + prefixes[prefix_count++] = a.arg[dp->precision_arg_index].a.a_int; + } #if USE_SNPRINTF - /* The SNPRINTF result is appended after result[0..length]. - The latter is an array of DCHAR_T; SNPRINTF appends an - array of TCHAR_T to it. This is possible because - sizeof (TCHAR_T) divides sizeof (DCHAR_T) and - alignof (TCHAR_T) <= alignof (DCHAR_T). */ + /* The SNPRINTF result is appended after result[0..length]. + The latter is an array of DCHAR_T; SNPRINTF appends an + array of TCHAR_T to it. This is possible because + sizeof (TCHAR_T) divides sizeof (DCHAR_T) and + alignof (TCHAR_T) <= alignof (DCHAR_T). */ # define TCHARS_PER_DCHAR (sizeof (DCHAR_T) / sizeof (TCHAR_T)) - /* Ensure that maxlen below will be >= 2. Needed on BeOS, - where an snprintf() with maxlen==1 acts like sprintf(). */ - ENSURE_ALLOCATION (xsum (length, - (2 + TCHARS_PER_DCHAR - 1) - / TCHARS_PER_DCHAR)); - /* Prepare checking whether snprintf returns the count - via %n. */ - *(TCHAR_T *) (result + length) = '\0'; + /* Ensure that maxlen below will be >= 2. Needed on BeOS, + where an snprintf() with maxlen==1 acts like sprintf(). */ + ENSURE_ALLOCATION (xsum (length, + (2 + TCHARS_PER_DCHAR - 1) + / TCHARS_PER_DCHAR)); + /* Prepare checking whether snprintf returns the count + via %n. */ + *(TCHAR_T *) (result + length) = '\0'; #endif - for (;;) - { - int count = -1; + for (;;) + { + int count = -1; #if USE_SNPRINTF - int retcount = 0; - size_t maxlen = allocated - length; - /* SNPRINTF can fail if its second argument is - > INT_MAX. */ - if (maxlen > INT_MAX / TCHARS_PER_DCHAR) - maxlen = INT_MAX / TCHARS_PER_DCHAR; - maxlen = maxlen * TCHARS_PER_DCHAR; + int retcount = 0; + size_t maxlen = allocated - length; + /* SNPRINTF can fail if its second argument is + > INT_MAX. */ + if (maxlen > INT_MAX / TCHARS_PER_DCHAR) + maxlen = INT_MAX / TCHARS_PER_DCHAR; + maxlen = maxlen * TCHARS_PER_DCHAR; # define SNPRINTF_BUF(arg) \ - switch (prefix_count) \ - { \ - case 0: \ - retcount = SNPRINTF ((TCHAR_T *) (result + length), \ - maxlen, buf, \ - arg, &count); \ - break; \ - case 1: \ - retcount = SNPRINTF ((TCHAR_T *) (result + length), \ - maxlen, buf, \ - prefixes[0], arg, &count); \ - break; \ - case 2: \ - retcount = SNPRINTF ((TCHAR_T *) (result + length), \ - maxlen, buf, \ - prefixes[0], prefixes[1], arg, \ - &count); \ - break; \ - default: \ - abort (); \ - } + switch (prefix_count) \ + { \ + case 0: \ + retcount = SNPRINTF ((TCHAR_T *) (result + length), \ + maxlen, buf, \ + arg, &count); \ + break; \ + case 1: \ + retcount = SNPRINTF ((TCHAR_T *) (result + length), \ + maxlen, buf, \ + prefixes[0], arg, &count); \ + break; \ + case 2: \ + retcount = SNPRINTF ((TCHAR_T *) (result + length), \ + maxlen, buf, \ + prefixes[0], prefixes[1], arg, \ + &count); \ + break; \ + default: \ + abort (); \ + } #else # define SNPRINTF_BUF(arg) \ - switch (prefix_count) \ - { \ - case 0: \ - count = sprintf (tmp, buf, arg); \ - break; \ - case 1: \ - count = sprintf (tmp, buf, prefixes[0], arg); \ - break; \ - case 2: \ - count = sprintf (tmp, buf, prefixes[0], prefixes[1],\ - arg); \ - break; \ - default: \ - abort (); \ - } + switch (prefix_count) \ + { \ + case 0: \ + count = sprintf (tmp, buf, arg); \ + break; \ + case 1: \ + count = sprintf (tmp, buf, prefixes[0], arg); \ + break; \ + case 2: \ + count = sprintf (tmp, buf, prefixes[0], prefixes[1],\ + arg); \ + break; \ + default: \ + abort (); \ + } #endif - switch (type) - { - case TYPE_SCHAR: - { - int arg = a.arg[dp->arg_index].a.a_schar; - SNPRINTF_BUF (arg); - } - break; - case TYPE_UCHAR: - { - unsigned int arg = a.arg[dp->arg_index].a.a_uchar; - SNPRINTF_BUF (arg); - } - break; - case TYPE_SHORT: - { - int arg = a.arg[dp->arg_index].a.a_short; - SNPRINTF_BUF (arg); - } - break; - case TYPE_USHORT: - { - unsigned int arg = a.arg[dp->arg_index].a.a_ushort; - SNPRINTF_BUF (arg); - } - break; - case TYPE_INT: - { - int arg = a.arg[dp->arg_index].a.a_int; - SNPRINTF_BUF (arg); - } - break; - case TYPE_UINT: - { - unsigned int arg = a.arg[dp->arg_index].a.a_uint; - SNPRINTF_BUF (arg); - } - break; - case TYPE_LONGINT: - { - long int arg = a.arg[dp->arg_index].a.a_longint; - SNPRINTF_BUF (arg); - } - break; - case TYPE_ULONGINT: - { - unsigned long int arg = a.arg[dp->arg_index].a.a_ulongint; - SNPRINTF_BUF (arg); - } - break; + switch (type) + { + case TYPE_SCHAR: + { + int arg = a.arg[dp->arg_index].a.a_schar; + SNPRINTF_BUF (arg); + } + break; + case TYPE_UCHAR: + { + unsigned int arg = a.arg[dp->arg_index].a.a_uchar; + SNPRINTF_BUF (arg); + } + break; + case TYPE_SHORT: + { + int arg = a.arg[dp->arg_index].a.a_short; + SNPRINTF_BUF (arg); + } + break; + case TYPE_USHORT: + { + unsigned int arg = a.arg[dp->arg_index].a.a_ushort; + SNPRINTF_BUF (arg); + } + break; + case TYPE_INT: + { + int arg = a.arg[dp->arg_index].a.a_int; + SNPRINTF_BUF (arg); + } + break; + case TYPE_UINT: + { + unsigned int arg = a.arg[dp->arg_index].a.a_uint; + SNPRINTF_BUF (arg); + } + break; + case TYPE_LONGINT: + { + long int arg = a.arg[dp->arg_index].a.a_longint; + SNPRINTF_BUF (arg); + } + break; + case TYPE_ULONGINT: + { + unsigned long int arg = a.arg[dp->arg_index].a.a_ulongint; + SNPRINTF_BUF (arg); + } + break; #if HAVE_LONG_LONG_INT - case TYPE_LONGLONGINT: - { - long long int arg = a.arg[dp->arg_index].a.a_longlongint; - SNPRINTF_BUF (arg); - } - break; - case TYPE_ULONGLONGINT: - { - unsigned long long int arg = a.arg[dp->arg_index].a.a_ulonglongint; - SNPRINTF_BUF (arg); - } - break; + case TYPE_LONGLONGINT: + { + long long int arg = a.arg[dp->arg_index].a.a_longlongint; + SNPRINTF_BUF (arg); + } + break; + case TYPE_ULONGLONGINT: + { + unsigned long long int arg = a.arg[dp->arg_index].a.a_ulonglongint; + SNPRINTF_BUF (arg); + } + break; #endif - case TYPE_DOUBLE: - { - double arg = a.arg[dp->arg_index].a.a_double; - SNPRINTF_BUF (arg); - } - break; - case TYPE_LONGDOUBLE: - { - long double arg = a.arg[dp->arg_index].a.a_longdouble; - SNPRINTF_BUF (arg); - } - break; - case TYPE_CHAR: - { - int arg = a.arg[dp->arg_index].a.a_char; - SNPRINTF_BUF (arg); - } - break; + case TYPE_DOUBLE: + { + double arg = a.arg[dp->arg_index].a.a_double; + SNPRINTF_BUF (arg); + } + break; + case TYPE_LONGDOUBLE: + { + long double arg = a.arg[dp->arg_index].a.a_longdouble; + SNPRINTF_BUF (arg); + } + break; + case TYPE_CHAR: + { + int arg = a.arg[dp->arg_index].a.a_char; + SNPRINTF_BUF (arg); + } + break; #if HAVE_WINT_T - case TYPE_WIDE_CHAR: - { - wint_t arg = a.arg[dp->arg_index].a.a_wide_char; - SNPRINTF_BUF (arg); - } - break; + case TYPE_WIDE_CHAR: + { + wint_t arg = a.arg[dp->arg_index].a.a_wide_char; + SNPRINTF_BUF (arg); + } + break; #endif - case TYPE_STRING: - { - const char *arg = a.arg[dp->arg_index].a.a_string; - SNPRINTF_BUF (arg); - } - break; + case TYPE_STRING: + { + const char *arg = a.arg[dp->arg_index].a.a_string; + SNPRINTF_BUF (arg); + } + break; #if HAVE_WCHAR_T - case TYPE_WIDE_STRING: - { - const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string; - SNPRINTF_BUF (arg); - } - break; + case TYPE_WIDE_STRING: + { + const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string; + SNPRINTF_BUF (arg); + } + break; #endif - case TYPE_POINTER: - { - void *arg = a.arg[dp->arg_index].a.a_pointer; - SNPRINTF_BUF (arg); - } - break; - default: - abort (); - } + case TYPE_POINTER: + { + void *arg = a.arg[dp->arg_index].a.a_pointer; + SNPRINTF_BUF (arg); + } + break; + default: + abort (); + } #if USE_SNPRINTF - /* Portability: Not all implementations of snprintf() - are ISO C 99 compliant. Determine the number of - bytes that snprintf() has produced or would have - produced. */ - if (count >= 0) - { - /* Verify that snprintf() has NUL-terminated its - result. */ - if (count < maxlen - && ((TCHAR_T *) (result + length)) [count] != '\0') - abort (); - /* Portability hack. */ - if (retcount > count) - count = retcount; - } - else - { - /* snprintf() doesn't understand the '%n' - directive. */ - if (fbp[1] != '\0') - { - /* Don't use the '%n' directive; instead, look - at the snprintf() return value. */ - fbp[1] = '\0'; - continue; - } - else - { - /* Look at the snprintf() return value. */ - if (retcount < 0) - { - /* HP-UX 10.20 snprintf() is doubly deficient: - It doesn't understand the '%n' directive, - *and* it returns -1 (rather than the length - that would have been required) when the - buffer is too small. */ - size_t bigger_need = - xsum (xtimes (allocated, 2), 12); - ENSURE_ALLOCATION (bigger_need); - continue; - } - else - count = retcount; - } - } + /* Portability: Not all implementations of snprintf() + are ISO C 99 compliant. Determine the number of + bytes that snprintf() has produced or would have + produced. */ + if (count >= 0) + { + /* Verify that snprintf() has NUL-terminated its + result. */ + if (count < maxlen + && ((TCHAR_T *) (result + length)) [count] != '\0') + abort (); + /* Portability hack. */ + if (retcount > count) + count = retcount; + } + else + { + /* snprintf() doesn't understand the '%n' + directive. */ + if (fbp[1] != '\0') + { + /* Don't use the '%n' directive; instead, look + at the snprintf() return value. */ + fbp[1] = '\0'; + continue; + } + else + { + /* Look at the snprintf() return value. */ + if (retcount < 0) + { + /* HP-UX 10.20 snprintf() is doubly deficient: + It doesn't understand the '%n' directive, + *and* it returns -1 (rather than the length + that would have been required) when the + buffer is too small. */ + size_t bigger_need = + xsum (xtimes (allocated, 2), 12); + ENSURE_ALLOCATION (bigger_need); + continue; + } + else + count = retcount; + } + } #endif - /* Attempt to handle failure. */ - if (count < 0) - { - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = EINVAL; - return NULL; - } + /* Attempt to handle failure. */ + if (count < 0) + { + if (!(result == resultbuf || result == NULL)) + free (result); + if (buf_malloced != NULL) + free (buf_malloced); + CLEANUP (); + errno = EINVAL; + return NULL; + } #if USE_SNPRINTF - /* Handle overflow of the allocated buffer. - If such an overflow occurs, a C99 compliant snprintf() - returns a count >= maxlen. However, a non-compliant - snprintf() function returns only count = maxlen - 1. To - cover both cases, test whether count >= maxlen - 1. */ - if ((unsigned int) count + 1 >= maxlen) - { - /* If maxlen already has attained its allowed maximum, - allocating more memory will not increase maxlen. - Instead of looping, bail out. */ - if (maxlen == INT_MAX / TCHARS_PER_DCHAR) - goto overflow; - else - { - /* Need at least (count + 1) * sizeof (TCHAR_T) - bytes. (The +1 is for the trailing NUL.) - But ask for (count + 2) * sizeof (TCHAR_T) - bytes, so that in the next round, we likely get - maxlen > (unsigned int) count + 1 - and so we don't get here again. - And allocate proportionally, to avoid looping - eternally if snprintf() reports a too small - count. */ - size_t n = - xmax (xsum (length, - ((unsigned int) count + 2 - + TCHARS_PER_DCHAR - 1) - / TCHARS_PER_DCHAR), - xtimes (allocated, 2)); + /* Handle overflow of the allocated buffer. + If such an overflow occurs, a C99 compliant snprintf() + returns a count >= maxlen. However, a non-compliant + snprintf() function returns only count = maxlen - 1. To + cover both cases, test whether count >= maxlen - 1. */ + if ((unsigned int) count + 1 >= maxlen) + { + /* If maxlen already has attained its allowed maximum, + allocating more memory will not increase maxlen. + Instead of looping, bail out. */ + if (maxlen == INT_MAX / TCHARS_PER_DCHAR) + goto overflow; + else + { + /* Need at least (count + 1) * sizeof (TCHAR_T) + bytes. (The +1 is for the trailing NUL.) + But ask for (count + 2) * sizeof (TCHAR_T) + bytes, so that in the next round, we likely get + maxlen > (unsigned int) count + 1 + and so we don't get here again. + And allocate proportionally, to avoid looping + eternally if snprintf() reports a too small + count. */ + size_t n = + xmax (xsum (length, + ((unsigned int) count + 2 + + TCHARS_PER_DCHAR - 1) + / TCHARS_PER_DCHAR), + xtimes (allocated, 2)); - ENSURE_ALLOCATION (n); - continue; - } - } + ENSURE_ALLOCATION (n); + continue; + } + } #endif #if NEED_PRINTF_UNBOUNDED_PRECISION - if (prec_ourselves) - { - /* Handle the precision. */ - TCHAR_T *prec_ptr = + if (prec_ourselves) + { + /* Handle the precision. */ + TCHAR_T *prec_ptr = # if USE_SNPRINTF - (TCHAR_T *) (result + length); + (TCHAR_T *) (result + length); # else - tmp; + tmp; # endif - size_t prefix_count; - size_t move; + size_t prefix_count; + size_t move; - prefix_count = 0; - /* Put the additional zeroes after the sign. */ - if (count >= 1 - && (*prec_ptr == '-' || *prec_ptr == '+' - || *prec_ptr == ' ')) - prefix_count = 1; - /* Put the additional zeroes after the 0x prefix if - (flags & FLAG_ALT) || (dp->conversion == 'p'). */ - else if (count >= 2 - && prec_ptr[0] == '0' - && (prec_ptr[1] == 'x' || prec_ptr[1] == 'X')) - prefix_count = 2; + prefix_count = 0; + /* Put the additional zeroes after the sign. */ + if (count >= 1 + && (*prec_ptr == '-' || *prec_ptr == '+' + || *prec_ptr == ' ')) + prefix_count = 1; + /* Put the additional zeroes after the 0x prefix if + (flags & FLAG_ALT) || (dp->conversion == 'p'). */ + else if (count >= 2 + && prec_ptr[0] == '0' + && (prec_ptr[1] == 'x' || prec_ptr[1] == 'X')) + prefix_count = 2; - move = count - prefix_count; - if (precision > move) - { - /* Insert zeroes. */ - size_t insert = precision - move; - TCHAR_T *prec_end; + move = count - prefix_count; + if (precision > move) + { + /* Insert zeroes. */ + size_t insert = precision - move; + TCHAR_T *prec_end; # if USE_SNPRINTF - size_t n = - xsum (length, - (count + insert + TCHARS_PER_DCHAR - 1) - / TCHARS_PER_DCHAR); - length += (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR; - ENSURE_ALLOCATION (n); - length -= (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR; - prec_ptr = (TCHAR_T *) (result + length); + size_t n = + xsum (length, + (count + insert + TCHARS_PER_DCHAR - 1) + / TCHARS_PER_DCHAR); + length += (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR; + ENSURE_ALLOCATION (n); + length -= (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR; + prec_ptr = (TCHAR_T *) (result + length); # endif - prec_end = prec_ptr + count; - prec_ptr += prefix_count; + prec_end = prec_ptr + count; + prec_ptr += prefix_count; - while (prec_end > prec_ptr) - { - prec_end--; - prec_end[insert] = prec_end[0]; - } + while (prec_end > prec_ptr) + { + prec_end--; + prec_end[insert] = prec_end[0]; + } - prec_end += insert; - do - *--prec_end = '0'; - while (prec_end > prec_ptr); + prec_end += insert; + do + *--prec_end = '0'; + while (prec_end > prec_ptr); - count += insert; - } - } + count += insert; + } + } #endif #if !USE_SNPRINTF - if (count >= tmp_length) - /* tmp_length was incorrectly calculated - fix the - code above! */ - abort (); + if (count >= tmp_length) + /* tmp_length was incorrectly calculated - fix the + code above! */ + abort (); #endif #if !DCHAR_IS_TCHAR - /* Convert from TCHAR_T[] to DCHAR_T[]. */ - if (dp->conversion == 'c' || dp->conversion == 's') - { - /* type = TYPE_CHAR or TYPE_WIDE_CHAR or TYPE_STRING - TYPE_WIDE_STRING. - The result string is not certainly ASCII. */ - const TCHAR_T *tmpsrc; - DCHAR_T *tmpdst; - size_t tmpdst_len; - /* This code assumes that TCHAR_T is 'char'. */ - typedef int TCHAR_T_verify - [2 * (sizeof (TCHAR_T) == 1) - 1]; + /* Convert from TCHAR_T[] to DCHAR_T[]. */ + if (dp->conversion == 'c' || dp->conversion == 's') + { + /* type = TYPE_CHAR or TYPE_WIDE_CHAR or TYPE_STRING + TYPE_WIDE_STRING. + The result string is not certainly ASCII. */ + const TCHAR_T *tmpsrc; + DCHAR_T *tmpdst; + size_t tmpdst_len; + /* This code assumes that TCHAR_T is 'char'. */ + typedef int TCHAR_T_verify + [2 * (sizeof (TCHAR_T) == 1) - 1]; # if USE_SNPRINTF - tmpsrc = (TCHAR_T *) (result + length); + tmpsrc = (TCHAR_T *) (result + length); # else - tmpsrc = tmp; + tmpsrc = tmp; # endif - tmpdst = - DCHAR_CONV_FROM_ENCODING (locale_charset (), - iconveh_question_mark, - tmpsrc, count, - NULL, - NULL, &tmpdst_len); - if (tmpdst == NULL) - { - int saved_errno = errno; - if (!(result == resultbuf || result == NULL)) - free (result); - if (buf_malloced != NULL) - free (buf_malloced); - CLEANUP (); - errno = saved_errno; - return NULL; - } - ENSURE_ALLOCATION (xsum (length, tmpdst_len)); - DCHAR_CPY (result + length, tmpdst, tmpdst_len); - free (tmpdst); - count = tmpdst_len; - } - else - { - /* The result string is ASCII. - Simple 1:1 conversion. */ + tmpdst = + DCHAR_CONV_FROM_ENCODING (locale_charset (), + iconveh_question_mark, + tmpsrc, count, + NULL, + NULL, &tmpdst_len); + if (tmpdst == NULL) + { + int saved_errno = errno; + if (!(result == resultbuf || result == NULL)) + free (result); + if (buf_malloced != NULL) + free (buf_malloced); + CLEANUP (); + errno = saved_errno; + return NULL; + } + ENSURE_ALLOCATION (xsum (length, tmpdst_len)); + DCHAR_CPY (result + length, tmpdst, tmpdst_len); + free (tmpdst); + count = tmpdst_len; + } + else + { + /* The result string is ASCII. + Simple 1:1 conversion. */ # if USE_SNPRINTF - /* If sizeof (DCHAR_T) == sizeof (TCHAR_T), it's a - no-op conversion, in-place on the array starting - at (result + length). */ - if (sizeof (DCHAR_T) != sizeof (TCHAR_T)) + /* If sizeof (DCHAR_T) == sizeof (TCHAR_T), it's a + no-op conversion, in-place on the array starting + at (result + length). */ + if (sizeof (DCHAR_T) != sizeof (TCHAR_T)) # endif - { - const TCHAR_T *tmpsrc; - DCHAR_T *tmpdst; - size_t n; + { + const TCHAR_T *tmpsrc; + DCHAR_T *tmpdst; + size_t n; # if USE_SNPRINTF - if (result == resultbuf) - { - tmpsrc = (TCHAR_T *) (result + length); - /* ENSURE_ALLOCATION will not move tmpsrc - (because it's part of resultbuf). */ - ENSURE_ALLOCATION (xsum (length, count)); - } - else - { - /* ENSURE_ALLOCATION will move the array - (because it uses realloc(). */ - ENSURE_ALLOCATION (xsum (length, count)); - tmpsrc = (TCHAR_T *) (result + length); - } + if (result == resultbuf) + { + tmpsrc = (TCHAR_T *) (result + length); + /* ENSURE_ALLOCATION will not move tmpsrc + (because it's part of resultbuf). */ + ENSURE_ALLOCATION (xsum (length, count)); + } + else + { + /* ENSURE_ALLOCATION will move the array + (because it uses realloc(). */ + ENSURE_ALLOCATION (xsum (length, count)); + tmpsrc = (TCHAR_T *) (result + length); + } # else - tmpsrc = tmp; - ENSURE_ALLOCATION (xsum (length, count)); + tmpsrc = tmp; + ENSURE_ALLOCATION (xsum (length, count)); # endif - tmpdst = result + length; - /* Copy backwards, because of overlapping. */ - tmpsrc += count; - tmpdst += count; - for (n = count; n > 0; n--) - *--tmpdst = (unsigned char) *--tmpsrc; - } - } + tmpdst = result + length; + /* Copy backwards, because of overlapping. */ + tmpsrc += count; + tmpdst += count; + for (n = count; n > 0; n--) + *--tmpdst = (unsigned char) *--tmpsrc; + } + } #endif #if DCHAR_IS_TCHAR && !USE_SNPRINTF - /* Make room for the result. */ - if (count > allocated - length) - { - /* Need at least count elements. But allocate - proportionally. */ - size_t n = - xmax (xsum (length, count), xtimes (allocated, 2)); + /* Make room for the result. */ + if (count > allocated - length) + { + /* Need at least count elements. But allocate + proportionally. */ + size_t n = + xmax (xsum (length, count), xtimes (allocated, 2)); - ENSURE_ALLOCATION (n); - } + ENSURE_ALLOCATION (n); + } #endif - /* Here count <= allocated - length. */ + /* Here count <= allocated - length. */ - /* Perform padding. */ + /* Perform padding. */ #if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION - if (pad_ourselves && has_width) - { - size_t w; + if (pad_ourselves && has_width) + { + size_t w; # if ENABLE_UNISTDIO - /* Outside POSIX, it's preferrable to compare the width - against the number of _characters_ of the converted - value. */ - w = DCHAR_MBSNLEN (result + length, count); + /* Outside POSIX, it's preferrable to compare the width + against the number of _characters_ of the converted + value. */ + w = DCHAR_MBSNLEN (result + length, count); # else - /* The width is compared against the number of _bytes_ - of the converted value, says POSIX. */ - w = count; + /* The width is compared against the number of _bytes_ + of the converted value, says POSIX. */ + w = count; # endif - if (w < width) - { - size_t pad = width - w; + if (w < width) + { + size_t pad = width - w; - /* Make room for the result. */ - if (xsum (count, pad) > allocated - length) - { - /* Need at least count + pad elements. But - allocate proportionally. */ - size_t n = - xmax (xsum3 (length, count, pad), - xtimes (allocated, 2)); + /* Make room for the result. */ + if (xsum (count, pad) > allocated - length) + { + /* Need at least count + pad elements. But + allocate proportionally. */ + size_t n = + xmax (xsum3 (length, count, pad), + xtimes (allocated, 2)); # if USE_SNPRINTF - length += count; - ENSURE_ALLOCATION (n); - length -= count; + length += count; + ENSURE_ALLOCATION (n); + length -= count; # else - ENSURE_ALLOCATION (n); + ENSURE_ALLOCATION (n); # endif - } - /* Here count + pad <= allocated - length. */ + } + /* Here count + pad <= allocated - length. */ - { + { # if !DCHAR_IS_TCHAR || USE_SNPRINTF - DCHAR_T * const rp = result + length; + DCHAR_T * const rp = result + length; # else - DCHAR_T * const rp = tmp; + DCHAR_T * const rp = tmp; # endif - DCHAR_T *p = rp + count; - DCHAR_T *end = p + pad; - DCHAR_T *pad_ptr; + DCHAR_T *p = rp + count; + DCHAR_T *end = p + pad; + DCHAR_T *pad_ptr; # if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO - if (dp->conversion == 'c' - || dp->conversion == 's') - /* No zero-padding for string directives. */ - pad_ptr = NULL; - else + if (dp->conversion == 'c' + || dp->conversion == 's') + /* No zero-padding for string directives. */ + pad_ptr = NULL; + else # endif - { - pad_ptr = (*rp == '-' ? rp + 1 : rp); - /* No zero-padding of "inf" and "nan". */ - if ((*pad_ptr >= 'A' && *pad_ptr <= 'Z') - || (*pad_ptr >= 'a' && *pad_ptr <= 'z')) - pad_ptr = NULL; - } - /* The generated string now extends from rp to p, - with the zero padding insertion point being at - pad_ptr. */ + { + pad_ptr = (*rp == '-' ? rp + 1 : rp); + /* No zero-padding of "inf" and "nan". */ + if ((*pad_ptr >= 'A' && *pad_ptr <= 'Z') + || (*pad_ptr >= 'a' && *pad_ptr <= 'z')) + pad_ptr = NULL; + } + /* The generated string now extends from rp to p, + with the zero padding insertion point being at + pad_ptr. */ - count = count + pad; /* = end - rp */ + count = count + pad; /* = end - rp */ - if (flags & FLAG_LEFT) - { - /* Pad with spaces on the right. */ - for (; pad > 0; pad--) - *p++ = ' '; - } - else if ((flags & FLAG_ZERO) && pad_ptr != NULL) - { - /* Pad with zeroes. */ - DCHAR_T *q = end; + if (flags & FLAG_LEFT) + { + /* Pad with spaces on the right. */ + for (; pad > 0; pad--) + *p++ = ' '; + } + else if ((flags & FLAG_ZERO) && pad_ptr != NULL) + { + /* Pad with zeroes. */ + DCHAR_T *q = end; - while (p > pad_ptr) - *--q = *--p; - for (; pad > 0; pad--) - *p++ = '0'; - } - else - { - /* Pad with spaces on the left. */ - DCHAR_T *q = end; + while (p > pad_ptr) + *--q = *--p; + for (; pad > 0; pad--) + *p++ = '0'; + } + else + { + /* Pad with spaces on the left. */ + DCHAR_T *q = end; - while (p > rp) - *--q = *--p; - for (; pad > 0; pad--) - *p++ = ' '; - } - } - } - } + while (p > rp) + *--q = *--p; + for (; pad > 0; pad--) + *p++ = ' '; + } + } + } + } #endif - /* Here still count <= allocated - length. */ + /* Here still count <= allocated - length. */ #if !DCHAR_IS_TCHAR || USE_SNPRINTF - /* The snprintf() result did fit. */ + /* The snprintf() result did fit. */ #else - /* Append the sprintf() result. */ - memcpy (result + length, tmp, count * sizeof (DCHAR_T)); + /* Append the sprintf() result. */ + memcpy (result + length, tmp, count * sizeof (DCHAR_T)); #endif #if !USE_SNPRINTF - if (tmp != tmpbuf) - free (tmp); + if (tmp != tmpbuf) + free (tmp); #endif #if NEED_PRINTF_DIRECTIVE_F - if (dp->conversion == 'F') - { - /* Convert the %f result to upper case for %F. */ - DCHAR_T *rp = result + length; - size_t rc; - for (rc = count; rc > 0; rc--, rp++) - if (*rp >= 'a' && *rp <= 'z') - *rp = *rp - 'a' + 'A'; - } + if (dp->conversion == 'F') + { + /* Convert the %f result to upper case for %F. */ + DCHAR_T *rp = result + length; + size_t rc; + for (rc = count; rc > 0; rc--, rp++) + if (*rp >= 'a' && *rp <= 'z') + *rp = *rp - 'a' + 'A'; + } #endif - length += count; - break; - } - } - } + length += count; + break; + } + } + } } /* Add the final NUL. */ @@ -5435,12 +5435,12 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, if (result != resultbuf && length + 1 < allocated) { - /* Shrink the allocated memory if possible. */ - DCHAR_T *memory; + /* Shrink the allocated memory if possible. */ + DCHAR_T *memory; - memory = (DCHAR_T *) realloc (result, (length + 1) * sizeof (DCHAR_T)); - if (memory != NULL) - result = memory; + memory = (DCHAR_T *) realloc (result, (length + 1) * sizeof (DCHAR_T)); + if (memory != NULL) + result = memory; } if (buf_malloced != NULL) diff --git a/src/bin/coreutils/lib/vasnprintf.h b/src/bin/coreutils/lib/vasnprintf.h index d3e86d9121..4a178c7b2a 100644 --- a/src/bin/coreutils/lib/vasnprintf.h +++ b/src/bin/coreutils/lib/vasnprintf.h @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* vsprintf with automatic memory allocation. - Copyright (C) 2002-2004, 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2002-2004, 2007-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/vasprintf.c b/src/bin/coreutils/lib/vasprintf.c index 292ec538f1..0b4071fd19 100644 --- a/src/bin/coreutils/lib/vasprintf.c +++ b/src/bin/coreutils/lib/vasprintf.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Formatted output to strings. - Copyright (C) 1999, 2002, 2006-2008 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/verify.h b/src/bin/coreutils/lib/verify.h index fac53f6fc4..bcd3f5a09d 100644 --- a/src/bin/coreutils/lib/verify.h +++ b/src/bin/coreutils/lib/verify.h @@ -1,6 +1,6 @@ /* Compile-time assert-like macros. - Copyright (C) 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -110,8 +110,8 @@ #if 4 <= __GNUC__ # define verify(R) \ - extern int (* verify_function__ (void)) \ - [__builtin_constant_p (R) && (R) ? 1 : -1] + extern int (* verify_function__ (void)) \ + [__builtin_constant_p (R) && (R) ? 1 : -1] #endif * In C++, any struct definition inside sizeof is invalid. diff --git a/src/bin/coreutils/lib/verror.c b/src/bin/coreutils/lib/verror.c index 0a7981ea27..62b7fc462d 100644 --- a/src/bin/coreutils/lib/verror.c +++ b/src/bin/coreutils/lib/verror.c @@ -1,5 +1,5 @@ /* va_list error handler for noninteractive utilities - Copyright (C) 2006-2007 Free Software Foundation, Inc. + Copyright (C) 2006-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -59,8 +59,8 @@ verror_at_line (int status, int errnum, const char *file, if (message) { /* Until http://sourceware.org/bugzilla/show_bug.cgi?id=2997 is fixed, - glibc violates GNU Coding Standards when the file argument to - error_at_line is NULL. */ + glibc violates GNU Coding Standards when the file argument to + error_at_line is NULL. */ if (file) error_at_line (status, errnum, file, line_number, "%s", message); else diff --git a/src/bin/coreutils/lib/verror.h b/src/bin/coreutils/lib/verror.h index 4d3b7ce657..f0553e8698 100644 --- a/src/bin/coreutils/lib/verror.h +++ b/src/bin/coreutils/lib/verror.h @@ -1,5 +1,5 @@ /* Declaration for va_list error-reporting function - Copyright (C) 2006-2007 Free Software Foundation, Inc. + Copyright (C) 2006-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/version-etc-fsf.c b/src/bin/coreutils/lib/version-etc-fsf.c index 4c0d174d63..fc837a895d 100644 --- a/src/bin/coreutils/lib/version-etc-fsf.c +++ b/src/bin/coreutils/lib/version-etc-fsf.c @@ -1,5 +1,5 @@ /* Variable with FSF copyright information, for version-etc. - Copyright (C) 1999-2006 Free Software Foundation, Inc. + Copyright (C) 1999-2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/version-etc.c b/src/bin/coreutils/lib/version-etc.c index a580140c45..19c873d016 100644 --- a/src/bin/coreutils/lib/version-etc.c +++ b/src/bin/coreutils/lib/version-etc.c @@ -1,5 +1,5 @@ /* Print --version and bug-reporting information in a consistent format. - Copyright (C) 1999-2009 Free Software Foundation, Inc. + Copyright (C) 1999-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -32,7 +32,13 @@ #include "gettext.h" #define _(msgid) gettext (msgid) -enum { COPYRIGHT_YEAR = 2009 }; +/* If you use AM_INIT_AUTOMAKE's no-define option, + PACKAGE is not defined. Use PACKAGE_TARNAME instead. */ +#if ! defined PACKAGE && defined PACKAGE_TARNAME +# define PACKAGE PACKAGE_TARNAME +#endif + +enum { COPYRIGHT_YEAR = 2010 }; /* The three functions below display the --version information the standard way. @@ -54,9 +60,9 @@ enum { COPYRIGHT_YEAR = 2009 }; number of elements in the array. */ void version_etc_arn (FILE *stream, - const char *command_name, const char *package, - const char *version, - const char * const * authors, size_t n_authors) + const char *command_name, const char *package, + const char *version, + const char * const * authors, size_t n_authors) { if (command_name) fprintf (stream, "%s (%s) %s\n", command_name, package, version); @@ -66,7 +72,7 @@ version_etc_arn (FILE *stream, #ifdef PACKAGE_PACKAGER # ifdef PACKAGE_PACKAGER_VERSION fprintf (stream, _("Packaged by %s (%s)\n"), PACKAGE_PACKAGER, - PACKAGE_PACKAGER_VERSION); + PACKAGE_PACKAGER_VERSION); # else fprintf (stream, _("Packaged by %s\n"), PACKAGE_PACKAGER); # endif @@ -84,7 +90,7 @@ This is free software: you are free to change and redistribute it.\n\ There is NO WARRANTY, to the extent permitted by law.\n\ \n\ "), - stream); + stream); switch (n_authors) { @@ -102,66 +108,66 @@ There is NO WARRANTY, to the extent permitted by law.\n\ case 3: /* TRANSLATORS: Each %s denotes an author name. */ fprintf (stream, _("Written by %s, %s, and %s.\n"), - authors[0], authors[1], authors[2]); + authors[0], authors[1], authors[2]); break; case 4: /* TRANSLATORS: Each %s denotes an author name. - You can use line breaks, estimating that each author name occupies - ca. 16 screen columns and that a screen line has ca. 80 columns. */ + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ fprintf (stream, _("Written by %s, %s, %s,\nand %s.\n"), - authors[0], authors[1], authors[2], authors[3]); + authors[0], authors[1], authors[2], authors[3]); break; case 5: /* TRANSLATORS: Each %s denotes an author name. - You can use line breaks, estimating that each author name occupies - ca. 16 screen columns and that a screen line has ca. 80 columns. */ + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ fprintf (stream, _("Written by %s, %s, %s,\n%s, and %s.\n"), - authors[0], authors[1], authors[2], authors[3], authors[4]); + authors[0], authors[1], authors[2], authors[3], authors[4]); break; case 6: /* TRANSLATORS: Each %s denotes an author name. - You can use line breaks, estimating that each author name occupies - ca. 16 screen columns and that a screen line has ca. 80 columns. */ + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ fprintf (stream, _("Written by %s, %s, %s,\n%s, %s, and %s.\n"), - authors[0], authors[1], authors[2], authors[3], authors[4], - authors[5]); + authors[0], authors[1], authors[2], authors[3], authors[4], + authors[5]); break; case 7: /* TRANSLATORS: Each %s denotes an author name. - You can use line breaks, estimating that each author name occupies - ca. 16 screen columns and that a screen line has ca. 80 columns. */ + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ fprintf (stream, _("Written by %s, %s, %s,\n%s, %s, %s, and %s.\n"), - authors[0], authors[1], authors[2], authors[3], authors[4], - authors[5], authors[6]); + authors[0], authors[1], authors[2], authors[3], authors[4], + authors[5], authors[6]); break; case 8: /* TRANSLATORS: Each %s denotes an author name. - You can use line breaks, estimating that each author name occupies - ca. 16 screen columns and that a screen line has ca. 80 columns. */ + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ fprintf (stream, _("\ Written by %s, %s, %s,\n%s, %s, %s, %s,\nand %s.\n"), - authors[0], authors[1], authors[2], authors[3], authors[4], - authors[5], authors[6], authors[7]); + authors[0], authors[1], authors[2], authors[3], authors[4], + authors[5], authors[6], authors[7]); break; case 9: /* TRANSLATORS: Each %s denotes an author name. - You can use line breaks, estimating that each author name occupies - ca. 16 screen columns and that a screen line has ca. 80 columns. */ + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ fprintf (stream, _("\ Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, and %s.\n"), - authors[0], authors[1], authors[2], authors[3], authors[4], - authors[5], authors[6], authors[7], authors[8]); + authors[0], authors[1], authors[2], authors[3], authors[4], + authors[5], authors[6], authors[7], authors[8]); break; default: /* 10 or more authors. Use an abbreviation, since the human reader - will probably not want to read the entire list anyway. */ + will probably not want to read the entire list anyway. */ /* TRANSLATORS: Each %s denotes an author name. - You can use line breaks, estimating that each author name occupies - ca. 16 screen columns and that a screen line has ca. 80 columns. */ + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ fprintf (stream, _("\ Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, %s, and others.\n"), - authors[0], authors[1], authors[2], authors[3], authors[4], - authors[5], authors[6], authors[7], authors[8]); + authors[0], authors[1], authors[2], authors[3], authors[4], + authors[5], authors[6], authors[7], authors[8]); break; } } @@ -172,8 +178,8 @@ Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, %s, and others.\n"), Author names are given in the NULL-terminated array AUTHORS. */ void version_etc_ar (FILE *stream, - const char *command_name, const char *package, - const char *version, const char * const * authors) + const char *command_name, const char *package, + const char *version, const char * const * authors) { size_t n_authors; @@ -188,19 +194,19 @@ version_etc_ar (FILE *stream, Author names are given in the NULL-terminated va_list AUTHORS. */ void version_etc_va (FILE *stream, - const char *command_name, const char *package, - const char *version, va_list authors) + const char *command_name, const char *package, + const char *version, va_list authors) { size_t n_authors; const char *authtab[10]; for (n_authors = 0; n_authors < 10 - && (authtab[n_authors] = va_arg (authors, const char *)) != NULL; + && (authtab[n_authors] = va_arg (authors, const char *)) != NULL; n_authors++) ; version_etc_arn (stream, command_name, package, version, - authtab, n_authors); + authtab, n_authors); } @@ -219,8 +225,8 @@ version_etc_va (FILE *stream, NULL argument at the end. */ void version_etc (FILE *stream, - const char *command_name, const char *package, - const char *version, /* const char *author1, ...*/ ...) + const char *command_name, const char *package, + const char *version, /* const char *author1, ...*/ ...) { va_list authors; @@ -236,13 +242,17 @@ emit_bug_reporting_address (void) for this package. Please add _another line_ saying "Report translation bugs to <...>\n" with the address for translation bugs (typically your translation team's web or email address). */ - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + printf (_("\nReport bugs to: %s\n"), PACKAGE_BUGREPORT); #ifdef PACKAGE_PACKAGER_BUG_REPORTS - printf (_("Report %s bugs to <%s>.\n"), PACKAGE_PACKAGER, - PACKAGE_PACKAGER_BUG_REPORTS); + printf (_("Report %s bugs to: %s\n"), PACKAGE_PACKAGER, + PACKAGE_PACKAGER_BUG_REPORTS); #endif - printf (_("%s home page: .\n"), - PACKAGE_NAME, PACKAGE); - fputs (_("General help using GNU software: .\n"), - stdout); +#ifdef PACKAGE_URL + printf (_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL); +#else + printf (_("%s home page: \n"), + PACKAGE_NAME, PACKAGE); +#endif + fputs (_("General help using GNU software: \n"), + stdout); } diff --git a/src/bin/coreutils/lib/version-etc.h b/src/bin/coreutils/lib/version-etc.h index 8ce02fecb8..629fe83013 100644 --- a/src/bin/coreutils/lib/version-etc.h +++ b/src/bin/coreutils/lib/version-etc.h @@ -1,5 +1,5 @@ /* Print --version and bug-reporting information in a consistent format. - Copyright (C) 1999, 2003, 2005, 2009 Free Software Foundation, Inc. + Copyright (C) 1999, 2003, 2005, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -50,26 +50,26 @@ extern const char version_etc_copyright[]; /* N_AUTHORS names are supplied in array AUTHORS. */ extern void version_etc_arn (FILE *stream, - const char *command_name, const char *package, - const char *version, - const char * const * authors, size_t n_authors); + const char *command_name, const char *package, + const char *version, + const char * const * authors, size_t n_authors); /* Names are passed in the NULL-terminated array AUTHORS. */ extern void version_etc_ar (FILE *stream, - const char *command_name, const char *package, - const char *version, const char * const * authors); + const char *command_name, const char *package, + const char *version, const char * const * authors); /* Names are passed in the NULL-terminated va_list. */ extern void version_etc_va (FILE *stream, - const char *command_name, const char *package, - const char *version, va_list authors); + const char *command_name, const char *package, + const char *version, va_list authors); /* Names are passed as separate arguments, with an additional NULL argument at the end. */ extern void version_etc (FILE *stream, - const char *command_name, const char *package, - const char *version, - /* const char *author1, ..., NULL */ ...) + const char *command_name, const char *package, + const char *version, + /* const char *author1, ..., NULL */ ...) ATTRIBUTE_SENTINEL; /* Display the usual `Report bugs to' stanza */ diff --git a/src/bin/coreutils/lib/version.c b/src/bin/coreutils/lib/version.c index 8e23134a35..80c38f4c52 100644 --- a/src/bin/coreutils/lib/version.c +++ b/src/bin/coreutils/lib/version.c @@ -1,2 +1,2 @@ #include -char const *Version = "7.6"; +char const *Version = "8.4"; diff --git a/src/bin/coreutils/lib/vfprintf.c b/src/bin/coreutils/lib/vfprintf.c index 225466a458..36f84e94c9 100644 --- a/src/bin/coreutils/lib/vfprintf.c +++ b/src/bin/coreutils/lib/vfprintf.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Formatted output to a stream. - Copyright (C) 2004, 2006-2008 Free Software Foundation, Inc. + Copyright (C) 2004, 2006-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -55,14 +55,17 @@ vfprintf (FILE *fp, const char *format, va_list args) if (fwrite (output, 1, len, fp) < len) { if (output != buf) - { - int saved_errno = errno; - free (output); - errno = saved_errno; - } + { + int saved_errno = errno; + free (output); + errno = saved_errno; + } return -1; } + if (output != buf) + free (output); + if (len > INT_MAX) { errno = EOVERFLOW; diff --git a/src/bin/coreutils/lib/vprintf.c b/src/bin/coreutils/lib/vprintf.c index ab57d9b550..8e767cbce0 100644 --- a/src/bin/coreutils/lib/vprintf.c +++ b/src/bin/coreutils/lib/vprintf.c @@ -2,7 +2,7 @@ /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ #line 1 /* Formatted output to a stream. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/w32sock.h b/src/bin/coreutils/lib/w32sock.h index 0622985b81..b472bd0501 100644 --- a/src/bin/coreutils/lib/w32sock.h +++ b/src/bin/coreutils/lib/w32sock.h @@ -1,6 +1,6 @@ /* w32sock.h --- internal auxilliary functions for Windows socket functions - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -32,7 +32,6 @@ static inline void set_winsock_errno (void) { int err = WSAGetLastError (); - WSASetLastError (0); /* Map some WSAE* errors to the runtime library's error codes. */ switch (err) diff --git a/src/bin/coreutils/lib/warn-on-use.h b/src/bin/coreutils/lib/warn-on-use.h new file mode 100644 index 0000000000..acfa4112ee --- /dev/null +++ b/src/bin/coreutils/lib/warn-on-use.h @@ -0,0 +1,12 @@ +#ifndef _GL_WARN_ON_USE + +# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) +/* A compiler attribute is available in gcc versions 4.3.0 and later. */ +# define _GL_WARN_ON_USE(function, message) \ +extern __typeof__ (function) function __attribute__ ((__warning__ (message))) + +# else /* Unsupported. */ +# define _GL_WARN_ON_USE(function, message) \ +extern int _gl_warn_on_use +# endif +#endif diff --git a/src/bin/coreutils/lib/wchar.h b/src/bin/coreutils/lib/wchar.h new file mode 100644 index 0000000000..9a3b2f5b0c --- /dev/null +++ b/src/bin/coreutils/lib/wchar.h @@ -0,0 +1,361 @@ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +/* -*- buffer-read-only: t -*- vi: set ro: */ +/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ +#line 1 +/* A substitute for ISO C99 , for platforms that have issues. + + Copyright (C) 2007-2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Eric Blake. */ + +/* + * ISO C 99 for platforms that have issues. + * + * + * For now, this just ensures proper prerequisite inclusion order and + * the declaration of wcwidth(). + */ + +#if __GNUC__ >= 3 +#pragma GCC system_header +#endif + +#if defined __need_mbstate_t || defined __need_wint_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H +/* Special invocation convention: + - Inside glibc and uClibc header files. + - On HP-UX 11.00 we have a sequence of nested includes + -> -> , and the latter includes , + once indirectly -> -> -> + and once directly. In both situations 'wint_t' is not yet defined, + therefore we cannot provide the function overrides; instead include only + the system's . + - On IRIX 6.5, similarly, we have an include -> , and + the latter includes . But here, we have no way to detect whether + is completely included or is still being included. */ + +#include_next + +#else +/* Normal invocation convention. */ + +#ifndef _GL_WCHAR_H + +#define _GL_ALREADY_INCLUDING_WCHAR_H + +/* Tru64 with Desktop Toolkit C has a bug: must be included before + . + BSD/OS 4.0.1 has a bug: , and must be + included before . + But avoid namespace pollution on glibc systems. */ +#ifndef __GLIBC__ +# include +# include +# include +#endif + +/* Include the original if it exists. + Some builds of uClibc lack it. */ +/* The include_next requires a split double-inclusion guard. */ +#if 1 +# include_next +#endif + +#undef _GL_ALREADY_INCLUDING_WCHAR_H + +#ifndef _GL_WCHAR_H +#define _GL_WCHAR_H + +/* The definition of GL_LINK_WARNING is copied here. */ +/* GL_LINK_WARNING("literal string") arranges to emit the literal string as + a linker warning on most glibc systems. + We use a linker warning rather than a preprocessor warning, because + #warning cannot be used inside macros. */ +#ifndef GL_LINK_WARNING + /* This works on platforms with GNU ld and ELF object format. + Testing __GLIBC__ is sufficient for asserting that GNU ld is in use. + Testing __ELF__ guarantees the ELF object format. + Testing __GNUC__ is necessary for the compound expression syntax. */ +# if defined __GLIBC__ && defined __ELF__ && defined __GNUC__ +# define GL_LINK_WARNING(message) \ + GL_LINK_WARNING1 (__FILE__, __LINE__, message) +# define GL_LINK_WARNING1(file, line, message) \ + GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */ +# define GL_LINK_WARNING2(file, line, message) \ + GL_LINK_WARNING3 (file ":" #line ": warning: " message) +# define GL_LINK_WARNING3(message) \ + ({ static const char warning[sizeof (message)] \ + __attribute__ ((__unused__, \ + __section__ (".gnu.warning"), \ + __aligned__ (1))) \ + = message "\n"; \ + (void)0; \ + }) +# else +# define GL_LINK_WARNING(message) ((void) 0) +# endif +#endif + +/* The definition of _GL_ARG_NONNULL is copied here. */ +/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools + that the values passed as arguments n, ..., m must be non-NULL pointers. + n = 1 stands for the first argument, n = 2 for the second argument etc. */ +#ifndef _GL_ARG_NONNULL +# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 +# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) +# else +# define _GL_ARG_NONNULL(params) +# endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Define wint_t. (Also done in wctype.in.h.) */ +#if !1 && !defined wint_t +# define wint_t int +# ifndef WEOF +# define WEOF -1 +# endif +#endif + + +/* Override mbstate_t if it is too small. + On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for + implementing mbrtowc for encodings like UTF-8. */ +#if !(1 && 1) || 0 +typedef int rpl_mbstate_t; +# undef mbstate_t +# define mbstate_t rpl_mbstate_t +# define GNULIB_defined_mbstate_t 1 +#endif + + +/* Convert a single-byte character to a wide character. */ +#if 1 +# if 0 +# undef btowc +# define btowc rpl_btowc +# endif +# if !1 || 0 +extern wint_t btowc (int c); +# endif +#elif defined GNULIB_POSIXCHECK +# undef btowc +# define btowc(c) \ + (GL_LINK_WARNING ("btowc is unportable - " \ + "use gnulib module btowc for portability"), \ + btowc (c)) +#endif + + +/* Convert a wide character to a single-byte character. */ +#if 1 +# if 0 +# undef wctob +# define wctob rpl_wctob +# endif +# if (!defined wctob && !1) || 0 +/* wctob is provided by gnulib, or wctob exists but is not declared. */ +extern int wctob (wint_t wc); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wctob +# define wctob(w) \ + (GL_LINK_WARNING ("wctob is unportable - " \ + "use gnulib module wctob for portability"), \ + wctob (w)) +#endif + + +/* Test whether *PS is in the initial state. */ +#if 1 +# if 0 +# undef mbsinit +# define mbsinit rpl_mbsinit +# endif +# if !1 || 0 +extern int mbsinit (const mbstate_t *ps); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mbsinit +# define mbsinit(p) \ + (GL_LINK_WARNING ("mbsinit is unportable - " \ + "use gnulib module mbsinit for portability"), \ + mbsinit (p)) +#endif + + +/* Convert a multibyte character to a wide character. */ +#if 1 +# if 0 +# undef mbrtowc +# define mbrtowc rpl_mbrtowc +# endif +# if !1 || 0 +extern size_t mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mbrtowc +# define mbrtowc(w,s,n,p) \ + (GL_LINK_WARNING ("mbrtowc is unportable - " \ + "use gnulib module mbrtowc for portability"), \ + mbrtowc (w, s, n, p)) +#endif + + +/* Recognize a multibyte character. */ +#if 1 +# if 0 +# undef mbrlen +# define mbrlen rpl_mbrlen +# endif +# if !1 || 0 +extern size_t mbrlen (const char *s, size_t n, mbstate_t *ps); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mbrlen +# define mbrlen(s,n,p) \ + (GL_LINK_WARNING ("mbrlen is unportable - " \ + "use gnulib module mbrlen for portability"), \ + mbrlen (s, n, p)) +#endif + + +/* Convert a string to a wide string. */ +#if 1 +# if 0 +# undef mbsrtowcs +# define mbsrtowcs rpl_mbsrtowcs +# endif +# if !1 || 0 +extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps) + _GL_ARG_NONNULL ((2)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mbsrtowcs +# define mbsrtowcs(d,s,l,p) \ + (GL_LINK_WARNING ("mbsrtowcs is unportable - " \ + "use gnulib module mbsrtowcs for portability"), \ + mbsrtowcs (d, s, l, p)) +#endif + + +/* Convert a string to a wide string. */ +#if 0 +# if 0 +# undef mbsnrtowcs +# define mbsnrtowcs rpl_mbsnrtowcs +# endif +# if !1 || 0 +extern size_t mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps) + _GL_ARG_NONNULL ((2)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef mbsnrtowcs +# define mbsnrtowcs(d,s,n,l,p) \ + (GL_LINK_WARNING ("mbsnrtowcs is unportable - " \ + "use gnulib module mbsnrtowcs for portability"), \ + mbsnrtowcs (d, s, n, l, p)) +#endif + + +/* Convert a wide character to a multibyte character. */ +#if 1 +# if 0 +# undef wcrtomb +# define wcrtomb rpl_wcrtomb +# endif +# if !1 || 0 +extern size_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcrtomb +# define wcrtomb(s,w,p) \ + (GL_LINK_WARNING ("wcrtomb is unportable - " \ + "use gnulib module wcrtomb for portability"), \ + wcrtomb (s, w, p)) +#endif + + +/* Convert a wide string to a string. */ +#if 0 +# if 0 +# undef wcsrtombs +# define wcsrtombs rpl_wcsrtombs +# endif +# if !1 || 0 +extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps) + _GL_ARG_NONNULL ((2)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcsrtombs +# define wcsrtombs(d,s,l,p) \ + (GL_LINK_WARNING ("wcsrtombs is unportable - " \ + "use gnulib module wcsrtombs for portability"), \ + wcsrtombs (d, s, l, p)) +#endif + + +/* Convert a wide string to a string. */ +#if 0 +# if 0 +# undef wcsnrtombs +# define wcsnrtombs rpl_wcsnrtombs +# endif +# if !1 || 0 +extern size_t wcsnrtombs (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps) + _GL_ARG_NONNULL ((2)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcsnrtombs +# define wcsnrtombs(d,s,n,l,p) \ + (GL_LINK_WARNING ("wcsnrtombs is unportable - " \ + "use gnulib module wcsnrtombs for portability"), \ + wcsnrtombs (d, s, n, l, p)) +#endif + + +/* Return the number of screen columns needed for WC. */ +#if 1 +# if 0 +# undef wcwidth +# define wcwidth rpl_wcwidth +extern int wcwidth (wchar_t); +# else +# if !defined wcwidth && !1 +/* wcwidth exists but is not declared. */ +extern int wcwidth (int /* actually wchar_t */); +# endif +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcwidth +# define wcwidth(w) \ + (GL_LINK_WARNING ("wcwidth is unportable - " \ + "use gnulib module wcwidth for portability"), \ + wcwidth (w)) +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* _GL_WCHAR_H */ +#endif /* _GL_WCHAR_H */ +#endif diff --git a/src/bin/coreutils/lib/wchar.in.h b/src/bin/coreutils/lib/wchar.in.h index 6c812bebfb..d00343990a 100644 --- a/src/bin/coreutils/lib/wchar.in.h +++ b/src/bin/coreutils/lib/wchar.in.h @@ -3,7 +3,7 @@ #line 1 /* A substitute for ISO C99 , for platforms that have issues. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,9 +33,9 @@ @PRAGMA_SYSTEM_HEADER@ #endif -#if defined __need_mbstate_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H +#if defined __need_mbstate_t || defined __need_wint_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H /* Special invocation convention: - - Inside uClibc header files. + - Inside glibc and uClibc header files. - On HP-UX 11.00 we have a sequence of nested includes -> -> , and the latter includes , once indirectly -> -> -> @@ -58,10 +58,13 @@ /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#include -#include -#include + included before . + But avoid namespace pollution on glibc systems. */ +#ifndef __GLIBC__ +# include +# include +# include +#endif /* Include the original if it exists. Some builds of uClibc lack it. */ @@ -77,6 +80,8 @@ /* The definition of GL_LINK_WARNING is copied here. */ +/* The definition of _GL_ARG_NONNULL is copied here. */ + #ifdef __cplusplus extern "C" { #endif @@ -200,7 +205,8 @@ extern size_t mbrlen (const char *s, size_t n, mbstate_t *ps); # define mbsrtowcs rpl_mbsrtowcs # endif # if !@HAVE_MBSRTOWCS@ || @REPLACE_MBSRTOWCS@ -extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps); +extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps) + _GL_ARG_NONNULL ((2)); # endif #elif defined GNULIB_POSIXCHECK # undef mbsrtowcs @@ -218,7 +224,8 @@ extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t # define mbsnrtowcs rpl_mbsnrtowcs # endif # if !@HAVE_MBSNRTOWCS@ || @REPLACE_MBSNRTOWCS@ -extern size_t mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps); +extern size_t mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps) + _GL_ARG_NONNULL ((2)); # endif #elif defined GNULIB_POSIXCHECK # undef mbsnrtowcs @@ -254,7 +261,8 @@ extern size_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps); # define wcsrtombs rpl_wcsrtombs # endif # if !@HAVE_WCSRTOMBS@ || @REPLACE_WCSRTOMBS@ -extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps); +extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps) + _GL_ARG_NONNULL ((2)); # endif #elif defined GNULIB_POSIXCHECK # undef wcsrtombs @@ -272,7 +280,8 @@ extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t # define wcsnrtombs rpl_wcsnrtombs # endif # if !@HAVE_WCSNRTOMBS@ || @REPLACE_WCSNRTOMBS@ -extern size_t wcsnrtombs (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps); +extern size_t wcsnrtombs (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps) + _GL_ARG_NONNULL ((2)); # endif #elif defined GNULIB_POSIXCHECK # undef wcsnrtombs diff --git a/src/bin/coreutils/lib/wcrtomb.c b/src/bin/coreutils/lib/wcrtomb.c index 79df99f235..e7345f698f 100644 --- a/src/bin/coreutils/lib/wcrtomb.c +++ b/src/bin/coreutils/lib/wcrtomb.c @@ -1,5 +1,5 @@ /* Convert wide character to multibyte character. - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. Written by Bruno Haible , 2008. This program is free software: you can redistribute it and/or modify @@ -43,11 +43,11 @@ wcrtomb (char *s, wchar_t wc, mbstate_t *ps) int ret = wctomb (s, wc); if (ret >= 0) - return ret; + return ret; else - { - errno = EILSEQ; - return (size_t)(-1); - } + { + errno = EILSEQ; + return (size_t)(-1); + } } } diff --git a/src/bin/coreutils/lib/wctype.in.h b/src/bin/coreutils/lib/wctype.in.h index 1f0db00512..4d41a73feb 100644 --- a/src/bin/coreutils/lib/wctype.in.h +++ b/src/bin/coreutils/lib/wctype.in.h @@ -3,7 +3,7 @@ #line 1 /* A substitute for ISO C99 , for platforms that lack it. - Copyright (C) 2006-2009 Free Software Foundation, Inc. + Copyright (C) 2006-2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -65,6 +65,10 @@ # endif #endif +#ifdef __cplusplus +extern "C" { +#endif + /* FreeBSD 4.4 to 4.11 has but lacks the functions. Linux libc5 has and the functions but they are broken. Assume all 12 functions are implemented the same way, or not at all. */ @@ -75,44 +79,44 @@ refer to system functions like _iswctype that are not in the standard C library. Rather than try to get ancient buggy implementations like this to work, just disable them. */ -# undef iswalnum -# undef iswalpha -# undef iswblank -# undef iswcntrl -# undef iswdigit -# undef iswgraph -# undef iswlower -# undef iswprint -# undef iswpunct -# undef iswspace -# undef iswupper -# undef iswxdigit -# undef towlower -# undef towupper +# undef iswalnum +# undef iswalpha +# undef iswblank +# undef iswcntrl +# undef iswdigit +# undef iswgraph +# undef iswlower +# undef iswprint +# undef iswpunct +# undef iswspace +# undef iswupper +# undef iswxdigit +# undef towlower +# undef towupper /* Linux libc5 has and the functions but they are broken. */ -# if @REPLACE_ISWCNTRL@ -# define iswalnum rpl_iswalnum -# define iswalpha rpl_iswalpha -# define iswblank rpl_iswblank -# define iswcntrl rpl_iswcntrl -# define iswdigit rpl_iswdigit -# define iswgraph rpl_iswgraph -# define iswlower rpl_iswlower -# define iswprint rpl_iswprint -# define iswpunct rpl_iswpunct -# define iswspace rpl_iswspace -# define iswupper rpl_iswupper -# define iswxdigit rpl_iswxdigit -# define towlower rpl_towlower -# define towupper rpl_towupper -# endif +# if @REPLACE_ISWCNTRL@ +# define iswalnum rpl_iswalnum +# define iswalpha rpl_iswalpha +# define iswblank rpl_iswblank +# define iswcntrl rpl_iswcntrl +# define iswdigit rpl_iswdigit +# define iswgraph rpl_iswgraph +# define iswlower rpl_iswlower +# define iswprint rpl_iswprint +# define iswpunct rpl_iswpunct +# define iswspace rpl_iswspace +# define iswupper rpl_iswupper +# define iswxdigit rpl_iswxdigit +# define towlower rpl_towlower +# define towupper rpl_towupper +# endif static inline int iswalnum (wint_t wc) { return ((wc >= '0' && wc <= '9') - || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')); + || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')); } static inline int @@ -161,15 +165,15 @@ static inline int iswpunct (wint_t wc) { return (wc >= '!' && wc <= '~' - && !((wc >= '0' && wc <= '9') - || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'))); + && !((wc >= '0' && wc <= '9') + || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'))); } static inline int iswspace (wint_t wc) { return (wc == ' ' || wc == '\t' - || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r'); + || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r'); } static inline int @@ -182,7 +186,7 @@ static inline int iswxdigit (wint_t wc) { return ((wc >= '0' && wc <= '9') - || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F')); + || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F')); } static inline wint_t @@ -197,9 +201,9 @@ towupper (wint_t wc) return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc); } -# endif /* ! HAVE_ISWCNTRL */ +#endif /* ! HAVE_ISWCNTRL || REPLACE_ISWCNTRL */ -# if defined __MINGW32__ +#if defined __MINGW32__ /* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t. The functions towlower and towupper are implemented in the MSVCRT library @@ -219,16 +223,20 @@ rpl_towlower (wint_t wc) { return (wint_t) (wchar_t) towlower (wc); } -# define towlower rpl_towlower +# define towlower rpl_towlower static inline wint_t rpl_towupper (wint_t wc) { return (wint_t) (wchar_t) towupper (wc); } -# define towupper rpl_towupper +# define towupper rpl_towupper -# endif +#endif /* __MINGW32__ */ + +#ifdef __cplusplus +} +#endif #endif /* _GL_WCTYPE_H */ #endif /* _GL_WCTYPE_H */ diff --git a/src/bin/coreutils/lib/wcwidth.c b/src/bin/coreutils/lib/wcwidth.c index 4885071d06..7341b66c67 100644 --- a/src/bin/coreutils/lib/wcwidth.c +++ b/src/bin/coreutils/lib/wcwidth.c @@ -1,5 +1,5 @@ /* Determine the number of screen columns needed for a character. - Copyright (C) 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2006, 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -36,7 +36,7 @@ rpl_wcwidth (wchar_t wc) if (STREQ (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0 ,0)) { /* We assume that in a UTF-8 locale, a wide character is the same as a - Unicode character. */ + Unicode character. */ return uc_width (wc, encoding); } else diff --git a/src/bin/coreutils/lib/write-any-file.c b/src/bin/coreutils/lib/write-any-file.c index 26db765fa6..2a26b2fab4 100644 --- a/src/bin/coreutils/lib/write-any-file.c +++ b/src/bin/coreutils/lib/write-any-file.c @@ -1,6 +1,6 @@ /* Determine whether we can write any file. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/write.c b/src/bin/coreutils/lib/write.c index 5f0131d17a..3a98f24f94 100644 --- a/src/bin/coreutils/lib/write.c +++ b/src/bin/coreutils/lib/write.c @@ -1,5 +1,5 @@ /* POSIX compatible write() function. - Copyright (C) 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. Written by Bruno Haible , 2008. This program is free software: you can redistribute it and/or modify @@ -46,14 +46,14 @@ rpl_write (int fd, const void *buf, size_t count) if (ret < 0) { if (GetLastError () == ERROR_NO_DATA - && GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE) - { - /* Try to raise signal SIGPIPE. */ - raise (SIGPIPE); - /* If it is currently blocked or ignored, change errno from EINVAL - to EPIPE. */ - errno = EPIPE; - } + && GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE) + { + /* Try to raise signal SIGPIPE. */ + raise (SIGPIPE); + /* If it is currently blocked or ignored, change errno from EINVAL + to EPIPE. */ + errno = EPIPE; + } } return ret; } diff --git a/src/bin/coreutils/lib/xalloc-die.c b/src/bin/coreutils/lib/xalloc-die.c index 0a0694fcfe..4b220403b0 100644 --- a/src/bin/coreutils/lib/xalloc-die.c +++ b/src/bin/coreutils/lib/xalloc-die.c @@ -1,7 +1,7 @@ /* Report a memory allocation failure and exit. - Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2006 Free - Software Foundation, Inc. + Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2006, 2009, 2010 + Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/xalloc.h b/src/bin/coreutils/lib/xalloc.h index 57a13e0afa..6122cc58b0 100644 --- a/src/bin/coreutils/lib/xalloc.h +++ b/src/bin/coreutils/lib/xalloc.h @@ -1,7 +1,8 @@ /* xalloc.h -- malloc with out-of-memory checking - Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, + 2000, 2003, 2004, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -105,10 +106,10 @@ char *xstrdup (char const *str) ATTRIBUTE_MALLOC; # if HAVE_INLINE # define static_inline static inline # else - void *xnmalloc (size_t n, size_t s) ATTRIBUTE_MALLOC; - void *xnrealloc (void *p, size_t n, size_t s); - void *x2nrealloc (void *p, size_t *pn, size_t s); - char *xcharalloc (size_t n) ATTRIBUTE_MALLOC; +void *xnmalloc (size_t n, size_t s) ATTRIBUTE_MALLOC; +void *xnrealloc (void *p, size_t n, size_t s); +void *x2nrealloc (void *p, size_t *pn, size_t s); +char *xcharalloc (size_t n) ATTRIBUTE_MALLOC; # endif # ifdef static_inline @@ -161,9 +162,9 @@ xnrealloc (void *p, size_t n, size_t s) void append_int (int value) { - if (used == allocated) - p = x2nrealloc (p, &allocated, sizeof *p); - p[used++] = value; + if (used == allocated) + p = x2nrealloc (p, &allocated, sizeof *p); + p[used++] = value; } This causes x2nrealloc to allocate a block of some nonzero size the @@ -181,12 +182,12 @@ xnrealloc (void *p, size_t n, size_t s) void append_int (int value) { - if (used == allocated) - { - p = x2nrealloc (p, &allocated1, sizeof *p); - allocated = allocated1; - } - p[used++] = value; + if (used == allocated) + { + p = x2nrealloc (p, &allocated1, sizeof *p); + allocated = allocated1; + } + p[used++] = value; } */ @@ -199,25 +200,25 @@ x2nrealloc (void *p, size_t *pn, size_t s) if (! p) { if (! n) - { - /* The approximate size to use for initial small allocation - requests, when the invoking code specifies an old size of - zero. 64 bytes is the largest "small" request for the - GNU C library malloc. */ - enum { DEFAULT_MXFAST = 64 }; + { + /* The approximate size to use for initial small allocation + requests, when the invoking code specifies an old size of + zero. 64 bytes is the largest "small" request for the + GNU C library malloc. */ + enum { DEFAULT_MXFAST = 64 }; - n = DEFAULT_MXFAST / s; - n += !n; - } + n = DEFAULT_MXFAST / s; + n += !n; + } } else { /* Set N = ceil (1.5 * N) so that progress is made if N == 1. - Check for overflow, so that N * S stays in size_t range. - The check is slightly conservative, but an exact check isn't - worth the trouble. */ + Check for overflow, so that N * S stays in size_t range. + The check is slightly conservative, but an exact check isn't + worth the trouble. */ if ((size_t) -1 / 3 * 2 / s <= n) - xalloc_die (); + xalloc_die (); n += (n + 1) / 2; } diff --git a/src/bin/coreutils/lib/xasprintf.c b/src/bin/coreutils/lib/xasprintf.c index 5b4f0c0bea..0fcff254af 100644 --- a/src/bin/coreutils/lib/xasprintf.c +++ b/src/bin/coreutils/lib/xasprintf.c @@ -1,5 +1,6 @@ /* vasprintf and asprintf with out-of-memory checking. - Copyright (C) 1999, 2002-2004, 2006 Free Software Foundation, Inc. + Copyright (C) 1999, 2002-2004, 2006, 2009-2010 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/xfreopen.c b/src/bin/coreutils/lib/xfreopen.c index 61091694bb..297bda4e0f 100644 --- a/src/bin/coreutils/lib/xfreopen.c +++ b/src/bin/coreutils/lib/xfreopen.c @@ -1,5 +1,5 @@ /* a wrapper for frepoen - Copyright (C) 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,6 +21,7 @@ #include "error.h" #include "exitfail.h" #include "quote.h" +#include "stdio--.h" #include "gettext.h" #define _(msgid) gettext (msgid) diff --git a/src/bin/coreutils/lib/xfts.c b/src/bin/coreutils/lib/xfts.c index 5994a5fef3..7dd7da3f5c 100644 --- a/src/bin/coreutils/lib/xfts.c +++ b/src/bin/coreutils/lib/xfts.c @@ -1,6 +1,6 @@ /* xfts.c -- a wrapper for fts_open - Copyright (C) 2003, 2005-2007, 2009 Free Software Foundation, Inc. + Copyright (C) 2003, 2005-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,13 +21,9 @@ #include #include +#include +#include -#include "error.h" - -#include "gettext.h" -#define _(msgid) gettext (msgid) - -#include "quote.h" #include "xalloc.h" #include "xfts.h" @@ -40,24 +36,30 @@ xfts_open (char * const *argv, int options, FTS *fts = fts_open (argv, options | FTS_CWDFD, compar); if (fts == NULL) { - /* This can fail in three ways: out of memory, invalid bit_flags, - and one or more of the FILES is an empty string. We could try - to decipher that errno==EINVAL means invalid bit_flags and - errno==ENOENT means there's an empty string, but that seems wrong. - Ideally, fts_open would return a proper error indicator. For now, - we'll presume that the bit_flags are valid and just check for - empty strings. */ - bool invalid_arg = false; - for (; *argv; ++argv) - { - if (**argv == '\0') - invalid_arg = true; - } - if (invalid_arg) - error (EXIT_FAILURE, 0, _("invalid argument: %s"), quote ("")); - else - xalloc_die (); + /* This can fail in two ways: out of memory or with errno==EINVAL, + which indicates it was called with invalid bit_flags. */ + assert (errno != EINVAL); + xalloc_die (); } return fts; } + +/* When fts_read returns FTS_DC to indicate a directory cycle, + it may or may not indicate a real problem. When a program like + chgrp performs a recursive traversal that requires traversing + symbolic links, it is *not* a problem. However, when invoked + with "-P -R", it deserves a warning. The fts_options member + records the options that control this aspect of fts's behavior, + so test that. */ +bool +cycle_warning_required (FTS const *fts, FTSENT const *ent) +{ +#define ISSET(Fts,Opt) ((Fts)->fts_options & (Opt)) + /* When dereferencing no symlinks, or when dereferencing only + those listed on the command line and we're not processing + a command-line argument, then a cycle is a serious problem. */ + return ((ISSET (fts, FTS_PHYSICAL) && !ISSET (fts, FTS_COMFOLLOW)) + || (ISSET (fts, FTS_PHYSICAL) && ISSET (fts, FTS_COMFOLLOW) + && ent->fts_level != FTS_ROOTLEVEL)); +} diff --git a/src/bin/coreutils/lib/xfts.h b/src/bin/coreutils/lib/xfts.h index 27ddb5d48e..fc3ba9010d 100644 --- a/src/bin/coreutils/lib/xfts.h +++ b/src/bin/coreutils/lib/xfts.h @@ -1,5 +1,9 @@ +#include #include "fts_.h" FTS * xfts_open (char * const *, int options, int (*) (const FTSENT **, const FTSENT **)); + +bool +cycle_warning_required (FTS const *fts, FTSENT const *ent); diff --git a/src/bin/coreutils/lib/xgetcwd.c b/src/bin/coreutils/lib/xgetcwd.c index 6787b4653c..8b78aa2854 100644 --- a/src/bin/coreutils/lib/xgetcwd.c +++ b/src/bin/coreutils/lib/xgetcwd.c @@ -1,6 +1,7 @@ /* xgetcwd.c -- return current directory with unlimited length - Copyright (C) 2001, 2003, 2004, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2001, 2003-2004, 2006-2007, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/xgetcwd.h b/src/bin/coreutils/lib/xgetcwd.h index 3d966de967..ad427e8b40 100644 --- a/src/bin/coreutils/lib/xgetcwd.h +++ b/src/bin/coreutils/lib/xgetcwd.h @@ -1,5 +1,5 @@ /* prototype for xgetcwd - Copyright (C) 1995, 2001, 2003 Free Software Foundation, Inc. + Copyright (C) 1995, 2001, 2003, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/xgethostname.c b/src/bin/coreutils/lib/xgethostname.c index d649b8dcff..8d24d4042d 100644 --- a/src/bin/coreutils/lib/xgethostname.c +++ b/src/bin/coreutils/lib/xgethostname.c @@ -1,7 +1,7 @@ /* xgethostname.c -- return current hostname with unlimited length - Copyright (C) 1992, 1996, 2000, 2001, 2003, 2004, 2005, 2006, 2009 - Free Software Foundation, Inc. + Copyright (C) 1992, 1996, 2000-2001, 2003-2006, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -45,8 +45,8 @@ xgethostname (void) while (1) { /* Use SIZE_1 here rather than SIZE to work around the bug in - SunOS 5.5's gethostname whereby it NUL-terminates HOSTNAME - even when the name is as long as the supplied buffer. */ + SunOS 5.5's gethostname whereby it NUL-terminates HOSTNAME + even when the name is as long as the supplied buffer. */ size_t size_1; hostname = x2realloc (hostname, &size); @@ -55,19 +55,19 @@ xgethostname (void) errno = 0; if (gethostname (hostname, size_1) == 0) - { - if (! hostname[size_1 - 1]) - break; - } + { + if (! hostname[size_1 - 1]) + break; + } else if (errno != 0 && errno != ENAMETOOLONG && errno != EINVAL - /* OSX/Darwin does this when the buffer is not large enough */ - && errno != ENOMEM) - { - int saved_errno = errno; - free (hostname); - errno = saved_errno; - return NULL; - } + /* OSX/Darwin does this when the buffer is not large enough */ + && errno != ENOMEM) + { + int saved_errno = errno; + free (hostname); + errno = saved_errno; + return NULL; + } } return hostname; diff --git a/src/bin/coreutils/lib/xmalloc.c b/src/bin/coreutils/lib/xmalloc.c index 585fb4b1e8..ecce529690 100644 --- a/src/bin/coreutils/lib/xmalloc.c +++ b/src/bin/coreutils/lib/xmalloc.c @@ -1,8 +1,8 @@ /* xmalloc.c -- malloc with out of memory checking - Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2008-2009 Free Software Foundation, - Inc. + Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, + 2000, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/xmemcoll.c b/src/bin/coreutils/lib/xmemcoll.c index 393e6d50a4..84bbd8ced3 100644 --- a/src/bin/coreutils/lib/xmemcoll.c +++ b/src/bin/coreutils/lib/xmemcoll.c @@ -1,6 +1,6 @@ /* Locale-specific memory comparison. - Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2002-2004, 2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -48,9 +48,9 @@ xmemcoll (char *s1, size_t s1len, char *s2, size_t s2len) error (0, collation_errno, _("string comparison failed")); error (0, 0, _("Set LC_ALL='C' to work around the problem.")); error (exit_failure, 0, - _("The strings compared were %s and %s."), - quotearg_n_style_mem (0, locale_quoting_style, s1, s1len), - quotearg_n_style_mem (1, locale_quoting_style, s2, s2len)); + _("The strings compared were %s and %s."), + quotearg_n_style_mem (0, locale_quoting_style, s1, s1len), + quotearg_n_style_mem (1, locale_quoting_style, s2, s2len)); } return diff; diff --git a/src/bin/coreutils/lib/xmemxfrm.c b/src/bin/coreutils/lib/xmemxfrm.c index bfbf658abd..9cdda9833c 100644 --- a/src/bin/coreutils/lib/xmemxfrm.c +++ b/src/bin/coreutils/lib/xmemxfrm.c @@ -1,6 +1,6 @@ /* Locale-specific memory transformation - Copyright (C) 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/xnanosleep.c b/src/bin/coreutils/lib/xnanosleep.c index 1c7de6241c..b4dbdc1cf0 100644 --- a/src/bin/coreutils/lib/xnanosleep.c +++ b/src/bin/coreutils/lib/xnanosleep.c @@ -1,7 +1,6 @@ /* xnanosleep.c -- a more convenient interface to nanosleep - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software - Foundation, Inc. + Copyright (C) 2002-2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -57,10 +56,10 @@ xnanosleep (double seconds) in some rare (perhaps theoretical) cases but that is better than undefined behavior. */ bool overflow = ((time_t) ((double) TIME_T_MAX / 2) == TIME_T_MAX / 2 - ? TIME_T_MAX < seconds - : (time_t) ((long double) TIME_T_MAX / 2) == TIME_T_MAX / 2 - ? TIME_T_MAX < (long double) seconds - : TIME_T_MAX <= (long double) seconds); + ? TIME_T_MAX < seconds + : (time_t) ((long double) TIME_T_MAX / 2) == TIME_T_MAX / 2 + ? TIME_T_MAX < (long double) seconds + : TIME_T_MAX <= (long double) seconds); struct timespec ts_sleep; @@ -74,45 +73,45 @@ xnanosleep (double seconds) ts_sleep.tv_sec = floor_seconds; /* Round up to the next whole number, if necessary, so that we - always sleep for at least the requested amount of time. Assuming - the default rounding mode, we don't have to worry about the - rounding error when computing 'ns' above, since the error won't - cause 'ns' to drop below an integer boundary. */ + always sleep for at least the requested amount of time. Assuming + the default rounding mode, we don't have to worry about the + rounding error when computing 'ns' above, since the error won't + cause 'ns' to drop below an integer boundary. */ ts_sleep.tv_nsec = ns; ts_sleep.tv_nsec += (ts_sleep.tv_nsec < ns); /* Normalize the interval length. nanosleep requires this. */ if (BILLION <= ts_sleep.tv_nsec) - { - if (ts_sleep.tv_sec == TIME_T_MAX) - overflow = true; - else - { - ts_sleep.tv_sec++; - ts_sleep.tv_nsec -= BILLION; - } - } + { + if (ts_sleep.tv_sec == TIME_T_MAX) + overflow = true; + else + { + ts_sleep.tv_sec++; + ts_sleep.tv_nsec -= BILLION; + } + } } for (;;) { if (overflow) - { - ts_sleep.tv_sec = TIME_T_MAX; - ts_sleep.tv_nsec = BILLION - 1; - } + { + ts_sleep.tv_sec = TIME_T_MAX; + ts_sleep.tv_nsec = BILLION - 1; + } /* Linux-2.6.8.1's nanosleep returns -1, but doesn't set errno - when resumed after being suspended. Earlier versions would - set errno to EINTR. nanosleep from linux-2.6.10, as well as - implementations by (all?) other vendors, doesn't return -1 - in that case; either it continues sleeping (if time remains) - or it returns zero (if the wake-up time has passed). */ + when resumed after being suspended. Earlier versions would + set errno to EINTR. nanosleep from linux-2.6.10, as well as + implementations by (all?) other vendors, doesn't return -1 + in that case; either it continues sleeping (if time remains) + or it returns zero (if the wake-up time has passed). */ errno = 0; if (nanosleep (&ts_sleep, NULL) == 0) - break; + break; if (errno != EINTR && errno != 0) - return -1; + return -1; } return 0; diff --git a/src/bin/coreutils/lib/xprintf.c b/src/bin/coreutils/lib/xprintf.c index 8f279faf41..f04503007f 100644 --- a/src/bin/coreutils/lib/xprintf.c +++ b/src/bin/coreutils/lib/xprintf.c @@ -1,5 +1,5 @@ /* printf wrappers that fail immediately for non-file-related errors - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/xprintf.h b/src/bin/coreutils/lib/xprintf.h index d11e270e98..d313d64fad 100644 --- a/src/bin/coreutils/lib/xprintf.h +++ b/src/bin/coreutils/lib/xprintf.h @@ -1,5 +1,5 @@ /* printf wrappers that fail immediately for non-file-related errors - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ #ifndef __attribute__ /* This feature is available in gcc versions 2.5 and later. */ # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) -# define __attribute__(Spec) /* empty */ +# define __attribute__(Spec) /* empty */ # endif /* The __-protected variants of `format' and `printf' attributes are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ @@ -40,7 +40,7 @@ extern int xvprintf (char const *restrict format, va_list args) extern int xfprintf (FILE *restrict stream, char const *restrict format, ...) __attribute__ ((__format__ (__printf__, 2, 3))); extern int xvfprintf (FILE *restrict stream, char const *restrict format, - va_list args) + va_list args) __attribute__ ((__format__ (__printf__, 2, 0))); #endif diff --git a/src/bin/coreutils/lib/xreadlink.c b/src/bin/coreutils/lib/xreadlink.c new file mode 100644 index 0000000000..4fdcafb56c --- /dev/null +++ b/src/bin/coreutils/lib/xreadlink.c @@ -0,0 +1,44 @@ +/* xreadlink.c -- readlink wrapper to return the link name in malloc'd storage + + Copyright (C) 2001, 2003-2007, 2009-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Jim Meyering + and Bruno Haible . */ + +#include + +/* Specification. */ +#include "xreadlink.h" + +#include + +#include "areadlink.h" +#include "xalloc.h" + +/* Call readlink to get the symbolic link value of FILENAME. + Return a pointer to that NUL-terminated string in malloc'd storage. + If readlink fails, return NULL and set errno. + If realloc fails, or if the link value is longer than SIZE_MAX :-), + give a diagnostic and exit. */ + +char * +xreadlink (char const *filename) +{ + char *result = areadlink (filename); + if (result == NULL && errno == ENOMEM) + xalloc_die (); + return result; +} diff --git a/src/bin/coreutils/lib/unlinkdir.h b/src/bin/coreutils/lib/xreadlink.h similarity index 66% rename from src/bin/coreutils/lib/unlinkdir.h rename to src/bin/coreutils/lib/xreadlink.h index 10c4e5f656..022bc80429 100644 --- a/src/bin/coreutils/lib/unlinkdir.h +++ b/src/bin/coreutils/lib/xreadlink.h @@ -1,6 +1,7 @@ -/* unlinkdir.h - determine (and maybe change) whether we can unlink directories +/* Reading symbolic links without size limitation. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2001, 2003-2004, 2007, 2009-2010 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,12 +16,12 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -/* Written by Paul Eggert and Jim Meyering. */ +/* Written by Jim Meyering */ -#include +#include -#if UNLINK_CANNOT_UNLINK_DIR -# define cannot_unlink_dir() true -#else -bool cannot_unlink_dir (void); +extern char *xreadlink (char const *filename); + +#if GNULIB_XREADLINKAT +extern char *xreadlinkat (int fd, char const *filename); #endif diff --git a/src/bin/coreutils/lib/xsize.h b/src/bin/coreutils/lib/xsize.h index 60a311a790..36e1a9f802 100644 --- a/src/bin/coreutils/lib/xsize.h +++ b/src/bin/coreutils/lib/xsize.h @@ -3,7 +3,7 @@ #line 1 /* xsize.h -- Checked size_t computations. - Copyright (C) 2003, 2008 Free Software Foundation, Inc. + Copyright (C) 2003, 2008, 2009, 2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/xstriconv.c b/src/bin/coreutils/lib/xstriconv.c index 14d8775cbf..7c8c142149 100644 --- a/src/bin/coreutils/lib/xstriconv.c +++ b/src/bin/coreutils/lib/xstriconv.c @@ -1,5 +1,5 @@ /* Charset conversion with out-of-memory checking. - Copyright (C) 2001-2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2006, 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible. This program is free software: you can redistribute it and/or modify @@ -30,7 +30,7 @@ int xmem_cd_iconv (const char *src, size_t srclen, iconv_t cd, - char **resultp, size_t *lengthp) + char **resultp, size_t *lengthp) { int retval = mem_cd_iconv (src, srclen, cd, resultp, lengthp); diff --git a/src/bin/coreutils/lib/xstriconv.h b/src/bin/coreutils/lib/xstriconv.h index a8a197102a..72b2aa370c 100644 --- a/src/bin/coreutils/lib/xstriconv.h +++ b/src/bin/coreutils/lib/xstriconv.h @@ -1,5 +1,5 @@ /* Charset conversion with out-of-memory checking. - Copyright (C) 2001-2004, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2006-2007, 2009-2010 Free Software Foundation, Inc. Written by Bruno Haible and Simon Josefsson. This program is free software: you can redistribute it and/or modify @@ -43,7 +43,7 @@ extern "C" { in *LENGTHP. *RESULTP is set to a freshly allocated memory block, or is unchanged if no dynamic memory allocation was necessary. */ extern int xmem_cd_iconv (const char *src, size_t srclen, iconv_t cd, - char **resultp, size_t *lengthp); + char **resultp, size_t *lengthp); /* Convert an entire string from one encoding to another, using iconv. The original string is the NUL-terminated string starting at SRC. @@ -67,7 +67,7 @@ extern char * xstr_cd_iconv (const char *src, iconv_t cd); Return value: the freshly allocated resulting NUL-terminated string if successful, otherwise NULL and errno set. */ extern char * xstr_iconv (const char *src, - const char *from_codeset, const char *to_codeset); + const char *from_codeset, const char *to_codeset); #ifdef __cplusplus diff --git a/src/bin/coreutils/lib/xstrndup.c b/src/bin/coreutils/lib/xstrndup.c index 37488cd99d..414f9f4f95 100644 --- a/src/bin/coreutils/lib/xstrndup.c +++ b/src/bin/coreutils/lib/xstrndup.c @@ -1,6 +1,6 @@ /* Duplicate a bounded initial segment of a string, with out-of-memory checking. - Copyright (C) 2003, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2003, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/xstrndup.h b/src/bin/coreutils/lib/xstrndup.h index 4882e39475..009fdb0864 100644 --- a/src/bin/coreutils/lib/xstrndup.h +++ b/src/bin/coreutils/lib/xstrndup.h @@ -1,6 +1,6 @@ /* Duplicate a bounded initial segment of a string, with out-of-memory checking. - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2003, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/xstrtod.c b/src/bin/coreutils/lib/xstrtod.c index 8b4a72c8b7..ef4d5bee09 100644 --- a/src/bin/coreutils/lib/xstrtod.c +++ b/src/bin/coreutils/lib/xstrtod.c @@ -1,7 +1,7 @@ /* error-checking interface to strtod-like functions - Copyright (C) 1996, 1999, 2000, 2003, 2004, 2005, 2006 Free - Software Foundation, Inc. + Copyright (C) 1996, 1999-2000, 2003-2006, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -43,7 +43,7 @@ bool XSTRTOD (char const *str, char const **ptr, DOUBLE *result, - DOUBLE (*convert) (char const *, char **)) + DOUBLE (*convert) (char const *, char **)) { DOUBLE val; char *terminator; @@ -58,9 +58,9 @@ XSTRTOD (char const *str, char const **ptr, DOUBLE *result, else { /* Allow underflow (in which case CONVERT returns zero), - but flag overflow as an error. */ + but flag overflow as an error. */ if (val != 0 && errno == ERANGE) - ok = false; + ok = false; } if (ptr != NULL) diff --git a/src/bin/coreutils/lib/xstrtod.h b/src/bin/coreutils/lib/xstrtod.h index 949d6d469e..572d8a721d 100644 --- a/src/bin/coreutils/lib/xstrtod.h +++ b/src/bin/coreutils/lib/xstrtod.h @@ -1,6 +1,7 @@ /* Error-checking interface to strtod-like functions. - Copyright (C) 1996, 1998, 2003, 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 1996, 1998, 2003-2004, 2006, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,8 +24,8 @@ # include bool xstrtod (const char *str, const char **ptr, double *result, - double (*convert) (char const *, char **)); + double (*convert) (char const *, char **)); bool xstrtold (const char *str, const char **ptr, long double *result, - long double (*convert) (char const *, char **)); + long double (*convert) (char const *, char **)); #endif /* not XSTRTOD_H */ diff --git a/src/bin/coreutils/lib/xstrtol-error.c b/src/bin/coreutils/lib/xstrtol-error.c index 67b5bf065b..014fc1c570 100644 --- a/src/bin/coreutils/lib/xstrtol-error.c +++ b/src/bin/coreutils/lib/xstrtol-error.c @@ -1,7 +1,7 @@ /* A more useful interface to strtol. - Copyright (C) 1995, 1996, 1998, 1999, 2001-2004, 2006-2008 - Free Software Foundation, Inc. + Copyright (C) 1995-1996, 1998-1999, 2001-2004, 2006-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -45,9 +45,9 @@ static void xstrtol_error (enum strtol_error err, - int opt_idx, char c, struct option const *long_options, - char const *arg, - int exit_status) + int opt_idx, char c, struct option const *long_options, + char const *arg, + int exit_status) { char const *hyphens = "--"; char const *msgid; @@ -90,8 +90,8 @@ xstrtol_error (enum strtol_error err, void xstrtol_fatal (enum strtol_error err, - int opt_idx, char c, struct option const *long_options, - char const *arg) + int opt_idx, char c, struct option const *long_options, + char const *arg) { xstrtol_error (err, opt_idx, c, long_options, arg, exit_failure); abort (); diff --git a/src/bin/coreutils/lib/xstrtol.c b/src/bin/coreutils/lib/xstrtol.c index 1804fe5866..43f5ada719 100644 --- a/src/bin/coreutils/lib/xstrtol.c +++ b/src/bin/coreutils/lib/xstrtol.c @@ -1,7 +1,7 @@ /* A more useful interface to strtol. - Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2003, 2004, 2005, - 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 1995-1996, 1998-2001, 2003-2007, 2009-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -73,7 +73,7 @@ bkm_scale_by_power (__strtol_t *x, int base, int power) strtol_error __xstrtol (const char *s, char **ptr, int strtol_base, - __strtol_t *val, const char *valid_suffixes) + __strtol_t *val, const char *valid_suffixes) { char *t_ptr; char **p; @@ -89,9 +89,9 @@ __xstrtol (const char *s, char **ptr, int strtol_base, const char *q = s; unsigned char ch = *q; while (isspace (ch)) - ch = *++q; + ch = *++q; if (ch == '-') - return LONGINT_INVALID; + return LONGINT_INVALID; } errno = 0; @@ -100,16 +100,16 @@ __xstrtol (const char *s, char **ptr, int strtol_base, if (*p == s) { /* If there is no number but there is a valid suffix, assume the - number is 1. The string is invalid otherwise. */ + number is 1. The string is invalid otherwise. */ if (valid_suffixes && **p && strchr (valid_suffixes, **p)) - tmp = 1; + tmp = 1; else - return LONGINT_INVALID; + return LONGINT_INVALID; } else if (errno != 0) { if (errno != ERANGE) - return LONGINT_INVALID; + return LONGINT_INVALID; err = LONGINT_OVERFLOW; } @@ -129,98 +129,98 @@ __xstrtol (const char *s, char **ptr, int strtol_base, strtol_error overflow; if (!strchr (valid_suffixes, **p)) - { - *val = tmp; - return err | LONGINT_INVALID_SUFFIX_CHAR; - } + { + *val = tmp; + return err | LONGINT_INVALID_SUFFIX_CHAR; + } if (strchr (valid_suffixes, '0')) - { - /* The ``valid suffix'' '0' is a special flag meaning that - an optional second suffix is allowed, which can change - the base. A suffix "B" (e.g. "100MB") stands for a power - of 1000, whereas a suffix "iB" (e.g. "100MiB") stands for - a power of 1024. If no suffix (e.g. "100M"), assume - power-of-1024. */ + { + /* The ``valid suffix'' '0' is a special flag meaning that + an optional second suffix is allowed, which can change + the base. A suffix "B" (e.g. "100MB") stands for a power + of 1000, whereas a suffix "iB" (e.g. "100MiB") stands for + a power of 1024. If no suffix (e.g. "100M"), assume + power-of-1024. */ - switch (p[0][1]) - { - case 'i': - if (p[0][2] == 'B') - suffixes += 2; - break; + switch (p[0][1]) + { + case 'i': + if (p[0][2] == 'B') + suffixes += 2; + break; - case 'B': - case 'D': /* 'D' is obsolescent */ - base = 1000; - suffixes++; - break; - } - } + case 'B': + case 'D': /* 'D' is obsolescent */ + base = 1000; + suffixes++; + break; + } + } switch (**p) - { - case 'b': - overflow = bkm_scale (&tmp, 512); - break; + { + case 'b': + overflow = bkm_scale (&tmp, 512); + break; - case 'B': - overflow = bkm_scale (&tmp, 1024); - break; + case 'B': + overflow = bkm_scale (&tmp, 1024); + break; - case 'c': - overflow = 0; - break; + case 'c': + overflow = 0; + break; - case 'E': /* exa or exbi */ - overflow = bkm_scale_by_power (&tmp, base, 6); - break; + case 'E': /* exa or exbi */ + overflow = bkm_scale_by_power (&tmp, base, 6); + break; - case 'G': /* giga or gibi */ - case 'g': /* 'g' is undocumented; for compatibility only */ - overflow = bkm_scale_by_power (&tmp, base, 3); - break; + case 'G': /* giga or gibi */ + case 'g': /* 'g' is undocumented; for compatibility only */ + overflow = bkm_scale_by_power (&tmp, base, 3); + break; - case 'k': /* kilo */ - case 'K': /* kibi */ - overflow = bkm_scale_by_power (&tmp, base, 1); - break; + case 'k': /* kilo */ + case 'K': /* kibi */ + overflow = bkm_scale_by_power (&tmp, base, 1); + break; - case 'M': /* mega or mebi */ - case 'm': /* 'm' is undocumented; for compatibility only */ - overflow = bkm_scale_by_power (&tmp, base, 2); - break; + case 'M': /* mega or mebi */ + case 'm': /* 'm' is undocumented; for compatibility only */ + overflow = bkm_scale_by_power (&tmp, base, 2); + break; - case 'P': /* peta or pebi */ - overflow = bkm_scale_by_power (&tmp, base, 5); - break; + case 'P': /* peta or pebi */ + overflow = bkm_scale_by_power (&tmp, base, 5); + break; - case 'T': /* tera or tebi */ - case 't': /* 't' is undocumented; for compatibility only */ - overflow = bkm_scale_by_power (&tmp, base, 4); - break; + case 'T': /* tera or tebi */ + case 't': /* 't' is undocumented; for compatibility only */ + overflow = bkm_scale_by_power (&tmp, base, 4); + break; - case 'w': - overflow = bkm_scale (&tmp, 2); - break; + case 'w': + overflow = bkm_scale (&tmp, 2); + break; - case 'Y': /* yotta or 2**80 */ - overflow = bkm_scale_by_power (&tmp, base, 8); - break; + case 'Y': /* yotta or 2**80 */ + overflow = bkm_scale_by_power (&tmp, base, 8); + break; - case 'Z': /* zetta or 2**70 */ - overflow = bkm_scale_by_power (&tmp, base, 7); - break; + case 'Z': /* zetta or 2**70 */ + overflow = bkm_scale_by_power (&tmp, base, 7); + break; - default: - *val = tmp; - return err | LONGINT_INVALID_SUFFIX_CHAR; - } + default: + *val = tmp; + return err | LONGINT_INVALID_SUFFIX_CHAR; + } err |= overflow; *p += suffixes; if (**p) - err |= LONGINT_INVALID_SUFFIX_CHAR; + err |= LONGINT_INVALID_SUFFIX_CHAR; } *val = tmp; diff --git a/src/bin/coreutils/lib/xstrtol.h b/src/bin/coreutils/lib/xstrtol.h index 9ac168bf38..95475f0594 100644 --- a/src/bin/coreutils/lib/xstrtol.h +++ b/src/bin/coreutils/lib/xstrtol.h @@ -1,7 +1,7 @@ /* A more useful interface to strtol. - Copyright (C) 1995, 1996, 1998, 1999, 2001, 2002, 2003, 2004, 2006, 2007, - 2008 Free Software Foundation, Inc. + Copyright (C) 1995-1996, 1998-1999, 2001-2004, 2006-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,7 +33,7 @@ enum strtol_error LONGINT_INVALID_SUFFIX_CHAR = 2, LONGINT_INVALID_SUFFIX_CHAR_WITH_OVERFLOW = (LONGINT_INVALID_SUFFIX_CHAR - | LONGINT_OVERFLOW), + | LONGINT_OVERFLOW), LONGINT_INVALID = 4 }; typedef enum strtol_error strtol_error; @@ -72,7 +72,7 @@ _DECLARE_XSTRTOL (xstrtoumax, uintmax_t) After reporting an error, exit with a failure status. */ void xstrtol_fatal (enum strtol_error, - int, char, struct option const *, - char const *) ATTRIBUTE_NORETURN; + int, char, struct option const *, + char const *) ATTRIBUTE_NORETURN; #endif /* not XSTRTOL_H_ */ diff --git a/src/bin/coreutils/lib/xtime.h b/src/bin/coreutils/lib/xtime.h index 1be9ad7681..9060956c0e 100644 --- a/src/bin/coreutils/lib/xtime.h +++ b/src/bin/coreutils/lib/xtime.h @@ -1,6 +1,6 @@ /* xtime -- extended-resolution integer time stamps - Copyright (C) 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -60,10 +60,10 @@ static inline xtime_t xtime_sec (xtime_t t) { return (XTIME_PRECISION == 1 - ? t - : t < 0 - ? (t + XTIME_PRECISION - 1) / XTIME_PRECISION - 1 - : xtime_nonnegative_sec (t)); + ? t + : t < 0 + ? (t + XTIME_PRECISION - 1) / XTIME_PRECISION - 1 + : xtime_nonnegative_sec (t)); } /* Return the number of nanoseconds in T, which must be nonnegative. */ diff --git a/src/bin/coreutils/lib/xvasprintf.c b/src/bin/coreutils/lib/xvasprintf.c index fd7f21b101..6a8bac4a88 100644 --- a/src/bin/coreutils/lib/xvasprintf.c +++ b/src/bin/coreutils/lib/xvasprintf.c @@ -1,5 +1,5 @@ /* vasprintf and asprintf with out-of-memory checking. - Copyright (C) 1999, 2002-2004, 2006-2008 Free Software Foundation, Inc. + Copyright (C) 1999, 2002-2004, 2006-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -86,23 +86,23 @@ xvasprintf (const char *format, va_list args) for (f = format;;) { - if (*f == '\0') - /* Recognized the special case of string concatenation. */ - return xstrcat (argcount, args); - if (*f != '%') - break; - f++; - if (*f != 's') - break; - f++; - argcount++; + if (*f == '\0') + /* Recognized the special case of string concatenation. */ + return xstrcat (argcount, args); + if (*f != '%') + break; + f++; + if (*f != 's') + break; + f++; + argcount++; } } if (vasprintf (&result, format, args) < 0) { if (errno == ENOMEM) - xalloc_die (); + xalloc_die (); return NULL; } diff --git a/src/bin/coreutils/lib/xvasprintf.h b/src/bin/coreutils/lib/xvasprintf.h index 42b032a487..acea805636 100644 --- a/src/bin/coreutils/lib/xvasprintf.h +++ b/src/bin/coreutils/lib/xvasprintf.h @@ -1,5 +1,5 @@ /* vasprintf and asprintf with out-of-memory checking. - Copyright (C) 2002-2004, 2006-2008 Free Software Foundation, Inc. + Copyright (C) 2002-2004, 2006-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/yesno.c b/src/bin/coreutils/lib/yesno.c index 139ab93114..fb5ef36611 100644 --- a/src/bin/coreutils/lib/yesno.c +++ b/src/bin/coreutils/lib/yesno.c @@ -1,6 +1,6 @@ /* yesno.c -- read a yes/no response from stdin - Copyright (C) 1990, 1998, 2001, 2003-2008 Free Software Foundation, Inc. + Copyright (C) 1990, 1998, 2001, 2003-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/lib/yesno.h b/src/bin/coreutils/lib/yesno.h index 633c274a64..8be630091b 100644 --- a/src/bin/coreutils/lib/yesno.h +++ b/src/bin/coreutils/lib/yesno.h @@ -1,5 +1,5 @@ /* declare yesno - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/man/Jamfile b/src/bin/coreutils/man/Jamfile index 5d5bf56efe..c83ca61273 100644 --- a/src/bin/coreutils/man/Jamfile +++ b/src/bin/coreutils/man/Jamfile @@ -30,7 +30,6 @@ fold.1 groups.1 head.1 hostid.1 -hostname.1 id.1 install.1 join.1 @@ -67,7 +66,6 @@ sort.1 split.1 #stat.1 stty.1 -su.1 sum.1 sync.1 tac.1 diff --git a/src/bin/coreutils/man/Makefile.am b/src/bin/coreutils/man/Makefile.am index b56db94fe6..904b302d04 100644 --- a/src/bin/coreutils/man/Makefile.am +++ b/src/bin/coreutils/man/Makefile.am @@ -1,6 +1,6 @@ # Make coreutils man pages. -*-Makefile-*- -# Copyright (C) 2002-2009 Free Software Foundation, Inc. +# Copyright (C) 2002-2010 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -80,6 +80,7 @@ mv.1: $(common_dep) $(srcdir)/mv.x ../src/mv.c nice.1: $(common_dep) $(srcdir)/nice.x ../src/nice.c nl.1: $(common_dep) $(srcdir)/nl.x ../src/nl.c nohup.1: $(common_dep) $(srcdir)/nohup.x ../src/nohup.c +nproc.1: $(common_dep) $(srcdir)/nproc.x ../src/nproc.c od.1: $(common_dep) $(srcdir)/od.x ../src/od.c paste.1: $(common_dep) $(srcdir)/paste.x ../src/paste.c pathchk.1: $(common_dep) $(srcdir)/pathchk.x ../src/pathchk.c diff --git a/src/bin/coreutils/man/Makefile.in b/src/bin/coreutils/man/Makefile.in index b0f0eab1c0..9cffd9f22a 100644 --- a/src/bin/coreutils/man/Makefile.in +++ b/src/bin/coreutils/man/Makefile.in @@ -17,7 +17,7 @@ # Make coreutils man pages. -*-Makefile-*- -# Copyright (C) 2002-2009 Free Software Foundation, Inc. +# Copyright (C) 2002-2010 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -69,35 +69,40 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/cloexec.m4 $(top_srcdir)/m4/close-stream.m4 \ $(top_srcdir)/m4/close.m4 $(top_srcdir)/m4/closein.m4 \ $(top_srcdir)/m4/closeout.m4 $(top_srcdir)/m4/codeset.m4 \ - $(top_srcdir)/m4/config-h.m4 $(top_srcdir)/m4/cycle-check.m4 \ - $(top_srcdir)/m4/d-ino.m4 $(top_srcdir)/m4/d-type.m4 \ - $(top_srcdir)/m4/dirent-safer.m4 $(top_srcdir)/m4/dirent_h.m4 \ - $(top_srcdir)/m4/dirfd.m4 $(top_srcdir)/m4/dirname.m4 \ - $(top_srcdir)/m4/dos.m4 $(top_srcdir)/m4/double-slash-root.m4 \ - $(top_srcdir)/m4/dup2.m4 $(top_srcdir)/m4/eealloc.m4 \ - $(top_srcdir)/m4/environ.m4 $(top_srcdir)/m4/errno_h.m4 \ - $(top_srcdir)/m4/error.m4 $(top_srcdir)/m4/euidaccess-stat.m4 \ + $(top_srcdir)/m4/config-h.m4 $(top_srcdir)/m4/ctype.m4 \ + $(top_srcdir)/m4/cycle-check.m4 $(top_srcdir)/m4/d-ino.m4 \ + $(top_srcdir)/m4/d-type.m4 $(top_srcdir)/m4/dirent-safer.m4 \ + $(top_srcdir)/m4/dirent_h.m4 $(top_srcdir)/m4/dirfd.m4 \ + $(top_srcdir)/m4/dirname.m4 $(top_srcdir)/m4/dos.m4 \ + $(top_srcdir)/m4/double-slash-root.m4 $(top_srcdir)/m4/dup2.m4 \ + $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/environ.m4 \ + $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/error.m4 \ + $(top_srcdir)/m4/euidaccess-stat.m4 \ $(top_srcdir)/m4/euidaccess.m4 $(top_srcdir)/m4/exclude.m4 \ $(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/exponentd.m4 \ $(top_srcdir)/m4/exponentf.m4 $(top_srcdir)/m4/exponentl.m4 \ - $(top_srcdir)/m4/extensions.m4 $(top_srcdir)/m4/fchdir.m4 \ - $(top_srcdir)/m4/fclose.m4 $(top_srcdir)/m4/fcntl-safer.m4 \ - $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/fd-reopen.m4 \ - $(top_srcdir)/m4/fdopendir.m4 $(top_srcdir)/m4/fflush.m4 \ - $(top_srcdir)/m4/file-type.m4 $(top_srcdir)/m4/fileblocks.m4 \ - $(top_srcdir)/m4/filemode.m4 $(top_srcdir)/m4/filenamecat.m4 \ - $(top_srcdir)/m4/flexmember.m4 $(top_srcdir)/m4/float_h.m4 \ - $(top_srcdir)/m4/fnmatch.m4 $(top_srcdir)/m4/fopen.m4 \ - $(top_srcdir)/m4/fpending.m4 $(top_srcdir)/m4/fpieee.m4 \ - $(top_srcdir)/m4/fprintftime.m4 $(top_srcdir)/m4/fpurge.m4 \ - $(top_srcdir)/m4/freading.m4 $(top_srcdir)/m4/frexp.m4 \ + $(top_srcdir)/m4/extensions.m4 $(top_srcdir)/m4/faccessat.m4 \ + $(top_srcdir)/m4/fchdir.m4 $(top_srcdir)/m4/fclose.m4 \ + $(top_srcdir)/m4/fcntl-o.m4 $(top_srcdir)/m4/fcntl-safer.m4 \ + $(top_srcdir)/m4/fcntl.m4 $(top_srcdir)/m4/fcntl_h.m4 \ + $(top_srcdir)/m4/fd-reopen.m4 $(top_srcdir)/m4/fdopendir.m4 \ + $(top_srcdir)/m4/fflush.m4 $(top_srcdir)/m4/file-type.m4 \ + $(top_srcdir)/m4/fileblocks.m4 $(top_srcdir)/m4/filemode.m4 \ + $(top_srcdir)/m4/filenamecat.m4 $(top_srcdir)/m4/flexmember.m4 \ + $(top_srcdir)/m4/float_h.m4 $(top_srcdir)/m4/fnmatch.m4 \ + $(top_srcdir)/m4/fopen.m4 $(top_srcdir)/m4/fpending.m4 \ + $(top_srcdir)/m4/fpieee.m4 $(top_srcdir)/m4/fprintftime.m4 \ + $(top_srcdir)/m4/fpurge.m4 $(top_srcdir)/m4/freading.m4 \ + $(top_srcdir)/m4/freopen.m4 $(top_srcdir)/m4/frexp.m4 \ $(top_srcdir)/m4/frexpl.m4 $(top_srcdir)/m4/fseeko.m4 \ $(top_srcdir)/m4/fstypename.m4 $(top_srcdir)/m4/fsusage.m4 \ - $(top_srcdir)/m4/ftello.m4 $(top_srcdir)/m4/ftruncate.m4 \ - $(top_srcdir)/m4/fts.m4 $(top_srcdir)/m4/getaddrinfo.m4 \ + $(top_srcdir)/m4/fsync.m4 $(top_srcdir)/m4/ftello.m4 \ + $(top_srcdir)/m4/ftruncate.m4 $(top_srcdir)/m4/fts.m4 \ + $(top_srcdir)/m4/getaddrinfo.m4 \ $(top_srcdir)/m4/getcwd-abort-bug.m4 \ $(top_srcdir)/m4/getcwd-path-max.m4 $(top_srcdir)/m4/getcwd.m4 \ $(top_srcdir)/m4/getdate.m4 $(top_srcdir)/m4/getdelim.m4 \ + $(top_srcdir)/m4/getdtablesize.m4 \ $(top_srcdir)/m4/getgroups.m4 $(top_srcdir)/m4/gethostname.m4 \ $(top_srcdir)/m4/gethrxtime.m4 $(top_srcdir)/m4/getline.m4 \ $(top_srcdir)/m4/getloadavg.m4 $(top_srcdir)/m4/getndelim2.m4 \ @@ -121,24 +126,27 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intmax_t.m4 \ $(top_srcdir)/m4/inttostr.m4 $(top_srcdir)/m4/inttypes-pri.m4 \ $(top_srcdir)/m4/inttypes.m4 $(top_srcdir)/m4/inttypes_h.m4 \ - $(top_srcdir)/m4/isapipe.m4 $(top_srcdir)/m4/isnand.m4 \ - $(top_srcdir)/m4/isnanf.m4 $(top_srcdir)/m4/isnanl.m4 \ - $(top_srcdir)/m4/jm-macros.m4 $(top_srcdir)/m4/jm-winsz1.m4 \ - $(top_srcdir)/m4/jm-winsz2.m4 $(top_srcdir)/m4/lchmod.m4 \ + $(top_srcdir)/m4/isapipe.m4 $(top_srcdir)/m4/isblank.m4 \ + $(top_srcdir)/m4/isnand.m4 $(top_srcdir)/m4/isnanf.m4 \ + $(top_srcdir)/m4/isnanl.m4 $(top_srcdir)/m4/jm-macros.m4 \ + $(top_srcdir)/m4/jm-winsz1.m4 $(top_srcdir)/m4/jm-winsz2.m4 \ + $(top_srcdir)/m4/langinfo_h.m4 $(top_srcdir)/m4/lchmod.m4 \ $(top_srcdir)/m4/lchown.m4 $(top_srcdir)/m4/ldexpl.m4 \ $(top_srcdir)/m4/lib-check.m4 $(top_srcdir)/m4/lib-ignore.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/link-follow.m4 \ - $(top_srcdir)/m4/link.m4 $(top_srcdir)/m4/localcharset.m4 \ - $(top_srcdir)/m4/locale-fr.m4 $(top_srcdir)/m4/locale-ja.m4 \ - $(top_srcdir)/m4/locale-tr.m4 $(top_srcdir)/m4/locale-zh.m4 \ - $(top_srcdir)/m4/long-options.m4 $(top_srcdir)/m4/longlong.m4 \ - $(top_srcdir)/m4/ls-mntd-fs.m4 $(top_srcdir)/m4/lseek.m4 \ - $(top_srcdir)/m4/lstat.m4 $(top_srcdir)/m4/malloc.m4 \ - $(top_srcdir)/m4/malloca.m4 $(top_srcdir)/m4/manywarnings.m4 \ - $(top_srcdir)/m4/math_h.m4 $(top_srcdir)/m4/mbchar.m4 \ - $(top_srcdir)/m4/mbiter.m4 $(top_srcdir)/m4/mbrlen.m4 \ - $(top_srcdir)/m4/mbrtowc.m4 $(top_srcdir)/m4/mbsinit.m4 \ + $(top_srcdir)/m4/link.m4 $(top_srcdir)/m4/linkat.m4 \ + $(top_srcdir)/m4/localcharset.m4 $(top_srcdir)/m4/locale-fr.m4 \ + $(top_srcdir)/m4/locale-ja.m4 $(top_srcdir)/m4/locale-tr.m4 \ + $(top_srcdir)/m4/locale-zh.m4 $(top_srcdir)/m4/locale_h.m4 \ + $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/long-options.m4 \ + $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ls-mntd-fs.m4 \ + $(top_srcdir)/m4/lseek.m4 $(top_srcdir)/m4/lstat.m4 \ + $(top_srcdir)/m4/malloc.m4 $(top_srcdir)/m4/malloca.m4 \ + $(top_srcdir)/m4/manywarnings.m4 $(top_srcdir)/m4/math_h.m4 \ + $(top_srcdir)/m4/mbchar.m4 $(top_srcdir)/m4/mbiter.m4 \ + $(top_srcdir)/m4/mbrlen.m4 $(top_srcdir)/m4/mbrtowc.m4 \ + $(top_srcdir)/m4/mbsinit.m4 $(top_srcdir)/m4/mbslen.m4 \ $(top_srcdir)/m4/mbsrtowcs.m4 $(top_srcdir)/m4/mbstate_t.m4 \ $(top_srcdir)/m4/mbswidth.m4 $(top_srcdir)/m4/md5.m4 \ $(top_srcdir)/m4/memcasecmp.m4 $(top_srcdir)/m4/memchr.m4 \ @@ -147,34 +155,34 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/mempcpy.m4 $(top_srcdir)/m4/memrchr.m4 \ $(top_srcdir)/m4/memset.m4 $(top_srcdir)/m4/memxfrm.m4 \ $(top_srcdir)/m4/mgetgroups.m4 $(top_srcdir)/m4/mkancesdirs.m4 \ - $(top_srcdir)/m4/mkdir-p.m4 $(top_srcdir)/m4/mkdir-slash.m4 \ + $(top_srcdir)/m4/mkdir-p.m4 $(top_srcdir)/m4/mkdir.m4 \ $(top_srcdir)/m4/mkstemp.m4 $(top_srcdir)/m4/mktime.m4 \ $(top_srcdir)/m4/mmap-anon.m4 $(top_srcdir)/m4/mode_t.m4 \ $(top_srcdir)/m4/modechange.m4 $(top_srcdir)/m4/mountlist.m4 \ $(top_srcdir)/m4/mpsort.m4 $(top_srcdir)/m4/multiarch.m4 \ $(top_srcdir)/m4/nanosleep.m4 $(top_srcdir)/m4/netdb_h.m4 \ - $(top_srcdir)/m4/netinet_in_h.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/open.m4 \ - $(top_srcdir)/m4/openat.m4 $(top_srcdir)/m4/pathmax.m4 \ - $(top_srcdir)/m4/perl.m4 $(top_srcdir)/m4/perror.m4 \ - $(top_srcdir)/m4/physmem.m4 $(top_srcdir)/m4/po.m4 \ - $(top_srcdir)/m4/posix-shell.m4 $(top_srcdir)/m4/posixtm.m4 \ - $(top_srcdir)/m4/posixver.m4 $(top_srcdir)/m4/prereq.m4 \ - $(top_srcdir)/m4/printf-frexp.m4 \ + $(top_srcdir)/m4/netinet_in_h.m4 \ + $(top_srcdir)/m4/nl_langinfo.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/nproc.m4 \ + $(top_srcdir)/m4/open.m4 $(top_srcdir)/m4/openat.m4 \ + $(top_srcdir)/m4/pathmax.m4 $(top_srcdir)/m4/perl.m4 \ + $(top_srcdir)/m4/perror.m4 $(top_srcdir)/m4/physmem.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/posix-shell.m4 \ + $(top_srcdir)/m4/posixtm.m4 $(top_srcdir)/m4/posixver.m4 \ + $(top_srcdir)/m4/prereq.m4 $(top_srcdir)/m4/printf-frexp.m4 \ $(top_srcdir)/m4/printf-frexpl.m4 $(top_srcdir)/m4/printf.m4 \ $(top_srcdir)/m4/priv-set.m4 $(top_srcdir)/m4/progtest.m4 \ $(top_srcdir)/m4/putenv.m4 $(top_srcdir)/m4/quote.m4 \ $(top_srcdir)/m4/quotearg.m4 $(top_srcdir)/m4/read-file.m4 \ $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/readtokens.m4 \ $(top_srcdir)/m4/readutmp.m4 $(top_srcdir)/m4/realloc.m4 \ - $(top_srcdir)/m4/regex.m4 \ - $(top_srcdir)/m4/rename-dest-slash.m4 \ - $(top_srcdir)/m4/rename.m4 $(top_srcdir)/m4/rmdir-errno.m4 \ - $(top_srcdir)/m4/rmdir.m4 $(top_srcdir)/m4/root-dev-ino.m4 \ - $(top_srcdir)/m4/rpmatch.m4 $(top_srcdir)/m4/safe-read.m4 \ - $(top_srcdir)/m4/safe-write.m4 $(top_srcdir)/m4/same.m4 \ - $(top_srcdir)/m4/save-cwd.m4 $(top_srcdir)/m4/savedir.m4 \ - $(top_srcdir)/m4/savewd.m4 $(top_srcdir)/m4/select.m4 \ + $(top_srcdir)/m4/regex.m4 $(top_srcdir)/m4/remove.m4 \ + $(top_srcdir)/m4/rename.m4 $(top_srcdir)/m4/rmdir.m4 \ + $(top_srcdir)/m4/root-dev-ino.m4 $(top_srcdir)/m4/rpmatch.m4 \ + $(top_srcdir)/m4/safe-read.m4 $(top_srcdir)/m4/safe-write.m4 \ + $(top_srcdir)/m4/same.m4 $(top_srcdir)/m4/save-cwd.m4 \ + $(top_srcdir)/m4/savedir.m4 $(top_srcdir)/m4/savewd.m4 \ + $(top_srcdir)/m4/select.m4 \ $(top_srcdir)/m4/selinux-context-h.m4 \ $(top_srcdir)/m4/selinux-selinux-h.m4 \ $(top_srcdir)/m4/servent.m4 $(top_srcdir)/m4/setenv.m4 \ @@ -188,38 +196,45 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/socklen.m4 $(top_srcdir)/m4/sockpfaf.m4 \ $(top_srcdir)/m4/ssize_t.m4 $(top_srcdir)/m4/st_dm_mode.m4 \ $(top_srcdir)/m4/stat-prog.m4 $(top_srcdir)/m4/stat-time.m4 \ - $(top_srcdir)/m4/stdarg.m4 $(top_srcdir)/m4/stdbool.m4 \ - $(top_srcdir)/m4/stddef_h.m4 $(top_srcdir)/m4/stdint.m4 \ - $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/stdio-safer.m4 \ - $(top_srcdir)/m4/stdio_h.m4 $(top_srcdir)/m4/stdlib-safer.m4 \ - $(top_srcdir)/m4/stdlib_h.m4 $(top_srcdir)/m4/stpcpy.m4 \ - $(top_srcdir)/m4/stpncpy.m4 $(top_srcdir)/m4/strcspn.m4 \ - $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \ - $(top_srcdir)/m4/strftime.m4 $(top_srcdir)/m4/string_h.m4 \ - $(top_srcdir)/m4/strndup.m4 $(top_srcdir)/m4/strnlen.m4 \ - $(top_srcdir)/m4/strnumcmp.m4 $(top_srcdir)/m4/strpbrk.m4 \ + $(top_srcdir)/m4/stat.m4 $(top_srcdir)/m4/stdarg.m4 \ + $(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stddef_h.m4 \ + $(top_srcdir)/m4/stdint.m4 $(top_srcdir)/m4/stdint_h.m4 \ + $(top_srcdir)/m4/stdio-safer.m4 $(top_srcdir)/m4/stdio_h.m4 \ + $(top_srcdir)/m4/stdlib-safer.m4 $(top_srcdir)/m4/stdlib_h.m4 \ + $(top_srcdir)/m4/stpcpy.m4 $(top_srcdir)/m4/stpncpy.m4 \ + $(top_srcdir)/m4/strcspn.m4 $(top_srcdir)/m4/strdup.m4 \ + $(top_srcdir)/m4/strerror.m4 $(top_srcdir)/m4/strftime.m4 \ + $(top_srcdir)/m4/string_h.m4 $(top_srcdir)/m4/strndup.m4 \ + $(top_srcdir)/m4/strnlen.m4 $(top_srcdir)/m4/strnumcmp.m4 \ + $(top_srcdir)/m4/strpbrk.m4 $(top_srcdir)/m4/strsignal.m4 \ $(top_srcdir)/m4/strstr.m4 $(top_srcdir)/m4/strtod.m4 \ $(top_srcdir)/m4/strtoimax.m4 $(top_srcdir)/m4/strtol.m4 \ $(top_srcdir)/m4/strtoll.m4 $(top_srcdir)/m4/strtoul.m4 \ $(top_srcdir)/m4/strtoull.m4 $(top_srcdir)/m4/strtoumax.m4 \ - $(top_srcdir)/m4/strverscmp.m4 $(top_srcdir)/m4/sys_ioctl_h.m4 \ + $(top_srcdir)/m4/symlink.m4 $(top_srcdir)/m4/symlinkat.m4 \ + $(top_srcdir)/m4/sys_ioctl_h.m4 \ $(top_srcdir)/m4/sys_select_h.m4 \ $(top_srcdir)/m4/sys_socket_h.m4 \ $(top_srcdir)/m4/sys_stat_h.m4 $(top_srcdir)/m4/sys_time_h.m4 \ - $(top_srcdir)/m4/tempname.m4 $(top_srcdir)/m4/time_h.m4 \ - $(top_srcdir)/m4/time_r.m4 $(top_srcdir)/m4/timespec.m4 \ + $(top_srcdir)/m4/sys_utsname_h.m4 $(top_srcdir)/m4/tempname.m4 \ + $(top_srcdir)/m4/thread.m4 $(top_srcdir)/m4/threadlib.m4 \ + $(top_srcdir)/m4/time_h.m4 $(top_srcdir)/m4/time_r.m4 \ + $(top_srcdir)/m4/timespec.m4 $(top_srcdir)/m4/tls.m4 \ $(top_srcdir)/m4/tm_gmtoff.m4 $(top_srcdir)/m4/tzset.m4 \ - $(top_srcdir)/m4/ungetc.m4 $(top_srcdir)/m4/unicodeio.m4 \ - $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/unistd_h.m4 \ - $(top_srcdir)/m4/unlink-busy.m4 $(top_srcdir)/m4/unlinkdir.m4 \ + $(top_srcdir)/m4/uname.m4 $(top_srcdir)/m4/ungetc.m4 \ + $(top_srcdir)/m4/unicodeio.m4 $(top_srcdir)/m4/unistd-safer.m4 \ + $(top_srcdir)/m4/unistd_h.m4 $(top_srcdir)/m4/unlink-busy.m4 \ + $(top_srcdir)/m4/unlink.m4 $(top_srcdir)/m4/unlinkdir.m4 \ $(top_srcdir)/m4/unlocked-io.m4 $(top_srcdir)/m4/uptime.m4 \ - $(top_srcdir)/m4/userspec.m4 $(top_srcdir)/m4/utimbuf.m4 \ - $(top_srcdir)/m4/utimecmp.m4 $(top_srcdir)/m4/utimens.m4 \ - $(top_srcdir)/m4/utimes.m4 $(top_srcdir)/m4/vasnprintf.m4 \ + $(top_srcdir)/m4/userspec.m4 $(top_srcdir)/m4/usleep.m4 \ + $(top_srcdir)/m4/utimbuf.m4 $(top_srcdir)/m4/utimecmp.m4 \ + $(top_srcdir)/m4/utimens.m4 $(top_srcdir)/m4/utimes.m4 \ + $(top_srcdir)/m4/vasnprintf.m4 \ $(top_srcdir)/m4/vasprintf-posix.m4 \ $(top_srcdir)/m4/vasprintf.m4 $(top_srcdir)/m4/version-etc.m4 \ $(top_srcdir)/m4/vfprintf-posix.m4 \ - $(top_srcdir)/m4/vprintf-posix.m4 $(top_srcdir)/m4/warnings.m4 \ + $(top_srcdir)/m4/vprintf-posix.m4 \ + $(top_srcdir)/m4/warn-on-use.m4 $(top_srcdir)/m4/warnings.m4 \ $(top_srcdir)/m4/wchar.m4 $(top_srcdir)/m4/wchar_t.m4 \ $(top_srcdir)/m4/wcrtomb.m4 $(top_srcdir)/m4/wctob.m4 \ $(top_srcdir)/m4/wctype.m4 $(top_srcdir)/m4/wcwidth.m4 \ @@ -230,7 +245,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/m4/xstrndup.m4 \ $(top_srcdir)/m4/xstrtod.m4 $(top_srcdir)/m4/xstrtol.m4 \ $(top_srcdir)/m4/xvasprintf.m4 $(top_srcdir)/m4/yesno.m4 \ - $(top_srcdir)/configure.ac + $(top_srcdir)/m4/yield.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d @@ -239,7 +254,7 @@ CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) -am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_0 = @echo " GEN " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ @@ -277,7 +292,6 @@ ALLOCA_H = @ALLOCA_H@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@ -ARPA_INET_H = @ARPA_INET_H@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -297,7 +311,6 @@ CYGPATH_W = @CYGPATH_W@ DEFAULT_POSIX2_VERSION = @DEFAULT_POSIX2_VERSION@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ -DIRENT_H = @DIRENT_H@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ @@ -310,7 +323,6 @@ EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@ EOVERFLOW_VALUE = @EOVERFLOW_VALUE@ ERRNO_H = @ERRNO_H@ EXEEXT = @EXEEXT@ -FCNTL_H = @FCNTL_H@ FLOAT_H = @FLOAT_H@ FNMATCH_H = @FNMATCH_H@ GETADDRINFO_LIB = @GETADDRINFO_LIB@ @@ -328,6 +340,7 @@ GNULIB_ATOLL = @GNULIB_ATOLL@ GNULIB_BIND = @GNULIB_BIND@ GNULIB_BTOWC = @GNULIB_BTOWC@ GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@ +GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@ GNULIB_CEILF = @GNULIB_CEILF@ GNULIB_CEILL = @GNULIB_CEILL@ GNULIB_CHOWN = @GNULIB_CHOWN@ @@ -337,6 +350,7 @@ GNULIB_DIRFD = @GNULIB_DIRFD@ GNULIB_DPRINTF = @GNULIB_DPRINTF@ GNULIB_DUP2 = @GNULIB_DUP2@ GNULIB_DUP3 = @GNULIB_DUP3@ +GNULIB_DUPLOCALE = @GNULIB_DUPLOCALE@ GNULIB_ENVIRON = @GNULIB_ENVIRON@ GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@ GNULIB_FACCESSAT = @GNULIB_FACCESSAT@ @@ -344,6 +358,7 @@ GNULIB_FCHDIR = @GNULIB_FCHDIR@ GNULIB_FCHMODAT = @GNULIB_FCHMODAT@ GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@ GNULIB_FCLOSE = @GNULIB_FCLOSE@ +GNULIB_FCNTL = @GNULIB_FCNTL@ GNULIB_FDOPENDIR = @GNULIB_FDOPENDIR@ GNULIB_FFLUSH = @GNULIB_FFLUSH@ GNULIB_FLOORF = @GNULIB_FLOORF@ @@ -364,15 +379,18 @@ GNULIB_FSYNC = @GNULIB_FSYNC@ GNULIB_FTELL = @GNULIB_FTELL@ GNULIB_FTELLO = @GNULIB_FTELLO@ GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@ +GNULIB_FUTIMENS = @GNULIB_FUTIMENS@ GNULIB_FWRITE = @GNULIB_FWRITE@ GNULIB_GETADDRINFO = @GNULIB_GETADDRINFO@ GNULIB_GETCWD = @GNULIB_GETCWD@ GNULIB_GETDELIM = @GNULIB_GETDELIM@ GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@ GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@ +GNULIB_GETGROUPS = @GNULIB_GETGROUPS@ GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@ GNULIB_GETLINE = @GNULIB_GETLINE@ GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@ +GNULIB_GETLOGIN = @GNULIB_GETLOGIN@ GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@ GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@ GNULIB_GETPEERNAME = @GNULIB_GETPEERNAME@ @@ -385,6 +403,7 @@ GNULIB_IMAXDIV = @GNULIB_IMAXDIV@ GNULIB_INET_NTOP = @GNULIB_INET_NTOP@ GNULIB_INET_PTON = @GNULIB_INET_PTON@ GNULIB_IOCTL = @GNULIB_IOCTL@ +GNULIB_ISBLANK = @GNULIB_ISBLANK@ GNULIB_ISFINITE = @GNULIB_ISFINITE@ GNULIB_ISINF = @GNULIB_ISINF@ GNULIB_ISNAN = @GNULIB_ISNAN@ @@ -395,6 +414,7 @@ GNULIB_LCHMOD = @GNULIB_LCHMOD@ GNULIB_LCHOWN = @GNULIB_LCHOWN@ GNULIB_LDEXPL = @GNULIB_LDEXPL@ GNULIB_LINK = @GNULIB_LINK@ +GNULIB_LINKAT = @GNULIB_LINKAT@ GNULIB_LISTEN = @GNULIB_LISTEN@ GNULIB_LSEEK = @GNULIB_LSEEK@ GNULIB_LSTAT = @GNULIB_LSTAT@ @@ -425,10 +445,15 @@ GNULIB_MEMPCPY = @GNULIB_MEMPCPY@ GNULIB_MEMRCHR = @GNULIB_MEMRCHR@ GNULIB_MKDIRAT = @GNULIB_MKDIRAT@ GNULIB_MKDTEMP = @GNULIB_MKDTEMP@ +GNULIB_MKFIFO = @GNULIB_MKFIFO@ GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@ +GNULIB_MKNOD = @GNULIB_MKNOD@ GNULIB_MKNODAT = @GNULIB_MKNODAT@ GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@ +GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@ GNULIB_MKSTEMP = @GNULIB_MKSTEMP@ +GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@ +GNULIB_NL_LANGINFO = @GNULIB_NL_LANGINFO@ GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@ GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@ GNULIB_OPEN = @GNULIB_OPEN@ @@ -436,6 +461,7 @@ GNULIB_OPENAT = @GNULIB_OPENAT@ GNULIB_PERROR = @GNULIB_PERROR@ GNULIB_PIPE2 = @GNULIB_PIPE2@ GNULIB_POPEN = @GNULIB_POPEN@ +GNULIB_PREAD = @GNULIB_PREAD@ GNULIB_PRINTF = @GNULIB_PRINTF@ GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@ GNULIB_PUTC = @GNULIB_PUTC@ @@ -447,9 +473,13 @@ GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@ GNULIB_READLINK = @GNULIB_READLINK@ GNULIB_READLINKAT = @GNULIB_READLINKAT@ GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@ +GNULIB_REALPATH = @GNULIB_REALPATH@ GNULIB_RECV = @GNULIB_RECV@ GNULIB_RECVFROM = @GNULIB_RECVFROM@ +GNULIB_REMOVE = @GNULIB_REMOVE@ GNULIB_RENAME = @GNULIB_RENAME@ +GNULIB_RENAMEAT = @GNULIB_RENAMEAT@ +GNULIB_RMDIR = @GNULIB_RMDIR@ GNULIB_ROUND = @GNULIB_ROUND@ GNULIB_ROUNDF = @GNULIB_ROUNDF@ GNULIB_ROUNDL = @GNULIB_ROUNDL@ @@ -469,6 +499,7 @@ GNULIB_SLEEP = @GNULIB_SLEEP@ GNULIB_SNPRINTF = @GNULIB_SNPRINTF@ GNULIB_SOCKET = @GNULIB_SOCKET@ GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@ +GNULIB_STAT = @GNULIB_STAT@ GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@ GNULIB_STPCPY = @GNULIB_STPCPY@ GNULIB_STPNCPY = @GNULIB_STPNCPY@ @@ -489,14 +520,19 @@ GNULIB_STRTOLL = @GNULIB_STRTOLL@ GNULIB_STRTOULL = @GNULIB_STRTOULL@ GNULIB_STRTOUMAX = @GNULIB_STRTOUMAX@ GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@ +GNULIB_SYMLINK = @GNULIB_SYMLINK@ GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@ GNULIB_TRUNC = @GNULIB_TRUNC@ GNULIB_TRUNCF = @GNULIB_TRUNCF@ GNULIB_TRUNCL = @GNULIB_TRUNCL@ +GNULIB_UNAME = @GNULIB_UNAME@ GNULIB_UNISTD_H_GETOPT = @GNULIB_UNISTD_H_GETOPT@ GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@ +GNULIB_UNLINK = @GNULIB_UNLINK@ GNULIB_UNLINKAT = @GNULIB_UNLINKAT@ GNULIB_UNSETENV = @GNULIB_UNSETENV@ +GNULIB_USLEEP = @GNULIB_USLEEP@ +GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@ GNULIB_VASPRINTF = @GNULIB_VASPRINTF@ GNULIB_VDPRINTF = @GNULIB_VDPRINTF@ GNULIB_VFPRINTF = @GNULIB_VFPRINTF@ @@ -505,6 +541,7 @@ GNULIB_VPRINTF = @GNULIB_VPRINTF@ GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@ GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@ GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@ +GNULIB_WARN_CFLAGS = @GNULIB_WARN_CFLAGS@ GNULIB_WCRTOMB = @GNULIB_WCRTOMB@ GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@ GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@ @@ -518,6 +555,8 @@ HAVE_ARPA_INET_H = @HAVE_ARPA_INET_H@ HAVE_ATOLL = @HAVE_ATOLL@ HAVE_BTOWC = @HAVE_BTOWC@ HAVE_CALLOC_POSIX = @HAVE_CALLOC_POSIX@ +HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@ +HAVE_CHOWN = @HAVE_CHOWN@ HAVE_DECL_ACOSL = @HAVE_DECL_ACOSL@ HAVE_DECL_ASINL = @HAVE_DECL_ASINL@ HAVE_DECL_ATANL = @HAVE_DECL_ATANL@ @@ -568,51 +607,69 @@ HAVE_EUIDACCESS = @HAVE_EUIDACCESS@ HAVE_FACCESSAT = @HAVE_FACCESSAT@ HAVE_FCHMODAT = @HAVE_FCHMODAT@ HAVE_FCHOWNAT = @HAVE_FCHOWNAT@ +HAVE_FCNTL = @HAVE_FCNTL@ HAVE_FDOPENDIR = @HAVE_FDOPENDIR@ -HAVE_FSEEKO = @HAVE_FSEEKO@ HAVE_FSTATAT = @HAVE_FSTATAT@ HAVE_FSYNC = @HAVE_FSYNC@ -HAVE_FTELLO = @HAVE_FTELLO@ HAVE_FTRUNCATE = @HAVE_FTRUNCATE@ +HAVE_FUTIMENS = @HAVE_FUTIMENS@ HAVE_GETDOMAINNAME = @HAVE_GETDOMAINNAME@ HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@ +HAVE_GETGROUPS = @HAVE_GETGROUPS@ HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@ +HAVE_GETLOGIN = @HAVE_GETLOGIN@ +HAVE_GETOPT_H = @HAVE_GETOPT_H@ HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@ HAVE_GETSUBOPT = @HAVE_GETSUBOPT@ HAVE_GETUSERSHELL = @HAVE_GETUSERSHELL@ HAVE_INTTYPES_H = @HAVE_INTTYPES_H@ +HAVE_ISBLANK = @HAVE_ISBLANK@ HAVE_ISNAND = @HAVE_ISNAND@ HAVE_ISNANF = @HAVE_ISNANF@ HAVE_ISNANL = @HAVE_ISNANL@ HAVE_ISWCNTRL = @HAVE_ISWCNTRL@ +HAVE_LANGINFO_CODESET = @HAVE_LANGINFO_CODESET@ +HAVE_LANGINFO_ERA = @HAVE_LANGINFO_ERA@ +HAVE_LANGINFO_H = @HAVE_LANGINFO_H@ HAVE_LCHMOD = @HAVE_LCHMOD@ +HAVE_LCHOWN = @HAVE_LCHOWN@ HAVE_LINK = @HAVE_LINK@ +HAVE_LINKAT = @HAVE_LINKAT@ HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@ HAVE_LSTAT = @HAVE_LSTAT@ HAVE_MALLOC_POSIX = @HAVE_MALLOC_POSIX@ HAVE_MBRLEN = @HAVE_MBRLEN@ HAVE_MBRTOWC = @HAVE_MBRTOWC@ HAVE_MBSINIT = @HAVE_MBSINIT@ +HAVE_MBSLEN = @HAVE_MBSLEN@ HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@ HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@ HAVE_MEMPCPY = @HAVE_MEMPCPY@ HAVE_MKDIRAT = @HAVE_MKDIRAT@ HAVE_MKDTEMP = @HAVE_MKDTEMP@ +HAVE_MKFIFO = @HAVE_MKFIFO@ HAVE_MKFIFOAT = @HAVE_MKFIFOAT@ +HAVE_MKNOD = @HAVE_MKNOD@ HAVE_MKNODAT = @HAVE_MKNODAT@ HAVE_MKOSTEMP = @HAVE_MKOSTEMP@ +HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@ +HAVE_MKSTEMPS = @HAVE_MKSTEMPS@ HAVE_NETDB_H = @HAVE_NETDB_H@ HAVE_NETINET_IN_H = @HAVE_NETINET_IN_H@ +HAVE_NL_LANGINFO = @HAVE_NL_LANGINFO@ HAVE_OPENAT = @HAVE_OPENAT@ HAVE_OS_H = @HAVE_OS_H@ HAVE_PIPE2 = @HAVE_PIPE2@ HAVE_POSIX_SIGNALBLOCKING = @HAVE_POSIX_SIGNALBLOCKING@ +HAVE_PREAD = @HAVE_PREAD@ HAVE_RANDOM_H = @HAVE_RANDOM_H@ HAVE_RANDOM_R = @HAVE_RANDOM_R@ HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@ HAVE_READLINK = @HAVE_READLINK@ HAVE_READLINKAT = @HAVE_READLINKAT@ HAVE_REALLOC_POSIX = @HAVE_REALLOC_POSIX@ +HAVE_REALPATH = @HAVE_REALPATH@ +HAVE_RENAMEAT = @HAVE_RENAMEAT@ HAVE_RPMATCH = @HAVE_RPMATCH@ HAVE_SA_FAMILY_T = @HAVE_SA_FAMILY_T@ HAVE_SCANDIR = @HAVE_SCANDIR@ @@ -639,6 +696,7 @@ HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@ HAVE_STRUCT_SIGACTION_SA_SIGACTION = @HAVE_STRUCT_SIGACTION_SA_SIGACTION@ HAVE_STRUCT_SOCKADDR_STORAGE = @HAVE_STRUCT_SOCKADDR_STORAGE@ HAVE_STRUCT_TIMEVAL = @HAVE_STRUCT_TIMEVAL@ +HAVE_STRUCT_UTSNAME = @HAVE_STRUCT_UTSNAME@ HAVE_STRVERSCMP = @HAVE_STRVERSCMP@ HAVE_SYMLINK = @HAVE_SYMLINK@ HAVE_SYMLINKAT = @HAVE_SYMLINKAT@ @@ -651,11 +709,15 @@ HAVE_SYS_SELECT_H = @HAVE_SYS_SELECT_H@ HAVE_SYS_SOCKET_H = @HAVE_SYS_SOCKET_H@ HAVE_SYS_TIME_H = @HAVE_SYS_TIME_H@ HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@ +HAVE_SYS_UTSNAME_H = @HAVE_SYS_UTSNAME_H@ HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@ +HAVE_UNAME = @HAVE_UNAME@ HAVE_UNISTD_H = @HAVE_UNISTD_H@ HAVE_UNLINKAT = @HAVE_UNLINKAT@ HAVE_UNSETENV = @HAVE_UNSETENV@ HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@ +HAVE_USLEEP = @HAVE_USLEEP@ +HAVE_UTIMENSAT = @HAVE_UTIMENSAT@ HAVE_VASPRINTF = @HAVE_VASPRINTF@ HAVE_VDPRINTF = @HAVE_VDPRINTF@ HAVE_WCHAR_H = @HAVE_WCHAR_H@ @@ -667,12 +729,15 @@ HAVE_WCTYPE_H = @HAVE_WCTYPE_H@ HAVE_WINSOCK2_H = @HAVE_WINSOCK2_H@ HAVE_WINT_T = @HAVE_WINT_T@ HAVE_WS2TCPIP_H = @HAVE_WS2TCPIP_H@ +HAVE_XLOCALE_H = @HAVE_XLOCALE_H@ HAVE__BOOL = @HAVE__BOOL@ HELP2MAN = @HELP2MAN@ HOSTENT_LIB = @HOSTENT_LIB@ ICONV_H = @ICONV_H@ INCLUDE_NEXT = @INCLUDE_NEXT@ INCLUDE_NEXT_AS_FIRST_DIRECTIVE = @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ +INET_NTOP_LIB = @INET_NTOP_LIB@ +INET_PTON_LIB = @INET_PTON_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ @@ -683,17 +748,20 @@ INT32_MAX_LT_INTMAX_MAX = @INT32_MAX_LT_INTMAX_MAX@ INT64_MAX_EQ_LONG_MAX = @INT64_MAX_EQ_LONG_MAX@ INTLLIBS = @INTLLIBS@ INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTTYPES_H = @INTTYPES_H@ KMEM_GROUP = @KMEM_GROUP@ LDFLAGS = @LDFLAGS@ LIBCOREUTILS_LIBDEPS = @LIBCOREUTILS_LIBDEPS@ LIBCOREUTILS_LTLIBDEPS = @LIBCOREUTILS_LTLIBDEPS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ +LIBMULTITHREAD = @LIBMULTITHREAD@ LIBOBJS = @LIBOBJS@ +LIBPTH = @LIBPTH@ +LIBPTH_PREFIX = @LIBPTH_PREFIX@ LIBS = @LIBS@ LIBSOCKET = @LIBSOCKET@ LIBTESTS_LIBDEPS = @LIBTESTS_LIBDEPS@ +LIBTHREAD = @LIBTHREAD@ LIB_ACL = @LIB_ACL@ LIB_CAP = @LIB_CAP@ LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@ @@ -714,7 +782,10 @@ LOCALE_TR_UTF8 = @LOCALE_TR_UTF8@ LOCALE_ZH_CN = @LOCALE_ZH_CN@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ +LTLIBMULTITHREAD = @LTLIBMULTITHREAD@ LTLIBOBJS = @LTLIBOBJS@ +LTLIBPTH = @LTLIBPTH@ +LTLIBTHREAD = @LTLIBTHREAD@ MAKEINFO = @MAKEINFO@ MAN = @MAN@ MKDIR_P = @MKDIR_P@ @@ -726,15 +797,20 @@ NETDB_H = @NETDB_H@ NETINET_IN_H = @NETINET_IN_H@ NEXT_ARPA_INET_H = @NEXT_ARPA_INET_H@ NEXT_AS_FIRST_DIRECTIVE_ARPA_INET_H = @NEXT_AS_FIRST_DIRECTIVE_ARPA_INET_H@ +NEXT_AS_FIRST_DIRECTIVE_CTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_CTYPE_H@ NEXT_AS_FIRST_DIRECTIVE_DIRENT_H = @NEXT_AS_FIRST_DIRECTIVE_DIRENT_H@ NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@ NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@ NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@ +NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@ NEXT_AS_FIRST_DIRECTIVE_ICONV_H = @NEXT_AS_FIRST_DIRECTIVE_ICONV_H@ NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H = @NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H@ +NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H = @NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H@ +NEXT_AS_FIRST_DIRECTIVE_LOCALE_H = @NEXT_AS_FIRST_DIRECTIVE_LOCALE_H@ NEXT_AS_FIRST_DIRECTIVE_MATH_H = @NEXT_AS_FIRST_DIRECTIVE_MATH_H@ NEXT_AS_FIRST_DIRECTIVE_NETDB_H = @NEXT_AS_FIRST_DIRECTIVE_NETDB_H@ NEXT_AS_FIRST_DIRECTIVE_NETINET_IN_H = @NEXT_AS_FIRST_DIRECTIVE_NETINET_IN_H@ +NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H = @NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H@ NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H = @NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H@ NEXT_AS_FIRST_DIRECTIVE_STDARG_H = @NEXT_AS_FIRST_DIRECTIVE_STDARG_H@ NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@ @@ -747,19 +823,25 @@ NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H@ +NEXT_AS_FIRST_DIRECTIVE_SYS_UTSNAME_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_UTSNAME_H@ NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@ NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@ NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@ NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@ +NEXT_CTYPE_H = @NEXT_CTYPE_H@ NEXT_DIRENT_H = @NEXT_DIRENT_H@ NEXT_ERRNO_H = @NEXT_ERRNO_H@ NEXT_FCNTL_H = @NEXT_FCNTL_H@ NEXT_FLOAT_H = @NEXT_FLOAT_H@ +NEXT_GETOPT_H = @NEXT_GETOPT_H@ NEXT_ICONV_H = @NEXT_ICONV_H@ NEXT_INTTYPES_H = @NEXT_INTTYPES_H@ +NEXT_LANGINFO_H = @NEXT_LANGINFO_H@ +NEXT_LOCALE_H = @NEXT_LOCALE_H@ NEXT_MATH_H = @NEXT_MATH_H@ NEXT_NETDB_H = @NEXT_NETDB_H@ NEXT_NETINET_IN_H = @NEXT_NETINET_IN_H@ +NEXT_SELINUX_SELINUX_H = @NEXT_SELINUX_SELINUX_H@ NEXT_SIGNAL_H = @NEXT_SIGNAL_H@ NEXT_STDARG_H = @NEXT_STDARG_H@ NEXT_STDDEF_H = @NEXT_STDDEF_H@ @@ -772,6 +854,7 @@ NEXT_SYS_SELECT_H = @NEXT_SYS_SELECT_H@ NEXT_SYS_SOCKET_H = @NEXT_SYS_SOCKET_H@ NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@ NEXT_SYS_TIME_H = @NEXT_SYS_TIME_H@ +NEXT_SYS_UTSNAME_H = @NEXT_SYS_UTSNAME_H@ NEXT_TIME_H = @NEXT_TIME_H@ NEXT_UNISTD_H = @NEXT_UNISTD_H@ NEXT_WCHAR_H = @NEXT_WCHAR_H@ @@ -799,15 +882,21 @@ PRI_MACROS_BROKEN = @PRI_MACROS_BROKEN@ PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@ RANLIB = @RANLIB@ REPLACE_BTOWC = @REPLACE_BTOWC@ +REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@ REPLACE_CEILF = @REPLACE_CEILF@ REPLACE_CEILL = @REPLACE_CEILL@ REPLACE_CHOWN = @REPLACE_CHOWN@ REPLACE_CLOSE = @REPLACE_CLOSE@ +REPLACE_CLOSEDIR = @REPLACE_CLOSEDIR@ REPLACE_DPRINTF = @REPLACE_DPRINTF@ +REPLACE_DUP = @REPLACE_DUP@ REPLACE_DUP2 = @REPLACE_DUP2@ +REPLACE_DUPLOCALE = @REPLACE_DUPLOCALE@ REPLACE_FCHDIR = @REPLACE_FCHDIR@ REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@ REPLACE_FCLOSE = @REPLACE_FCLOSE@ +REPLACE_FCNTL = @REPLACE_FCNTL@ +REPLACE_FDOPENDIR = @REPLACE_FDOPENDIR@ REPLACE_FFLUSH = @REPLACE_FFLUSH@ REPLACE_FLOORF = @REPLACE_FLOORF@ REPLACE_FLOORL = @REPLACE_FLOORL@ @@ -819,10 +908,13 @@ REPLACE_FREXP = @REPLACE_FREXP@ REPLACE_FREXPL = @REPLACE_FREXPL@ REPLACE_FSEEK = @REPLACE_FSEEK@ REPLACE_FSEEKO = @REPLACE_FSEEKO@ +REPLACE_FSTAT = @REPLACE_FSTAT@ REPLACE_FSTATAT = @REPLACE_FSTATAT@ REPLACE_FTELL = @REPLACE_FTELL@ REPLACE_FTELLO = @REPLACE_FTELLO@ +REPLACE_FUTIMENS = @REPLACE_FUTIMENS@ REPLACE_GETCWD = @REPLACE_GETCWD@ +REPLACE_GETGROUPS = @REPLACE_GETGROUPS@ REPLACE_GETLINE = @REPLACE_GETLINE@ REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@ REPLACE_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@ @@ -837,6 +929,7 @@ REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@ REPLACE_LCHOWN = @REPLACE_LCHOWN@ REPLACE_LDEXPL = @REPLACE_LDEXPL@ REPLACE_LINK = @REPLACE_LINK@ +REPLACE_LINKAT = @REPLACE_LINKAT@ REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@ REPLACE_LSEEK = @REPLACE_LSEEK@ REPLACE_LSTAT = @REPLACE_LSTAT@ @@ -849,26 +942,40 @@ REPLACE_MBSTATE_T = @REPLACE_MBSTATE_T@ REPLACE_MEMCHR = @REPLACE_MEMCHR@ REPLACE_MEMMEM = @REPLACE_MEMMEM@ REPLACE_MKDIR = @REPLACE_MKDIR@ +REPLACE_MKFIFO = @REPLACE_MKFIFO@ +REPLACE_MKNOD = @REPLACE_MKNOD@ REPLACE_MKSTEMP = @REPLACE_MKSTEMP@ REPLACE_MKTIME = @REPLACE_MKTIME@ REPLACE_NAN = @REPLACE_NAN@ REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@ +REPLACE_NL_LANGINFO = @REPLACE_NL_LANGINFO@ REPLACE_NULL = @REPLACE_NULL@ REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@ REPLACE_OPEN = @REPLACE_OPEN@ +REPLACE_OPENAT = @REPLACE_OPENAT@ +REPLACE_OPENDIR = @REPLACE_OPENDIR@ REPLACE_PERROR = @REPLACE_PERROR@ REPLACE_POPEN = @REPLACE_POPEN@ +REPLACE_PREAD = @REPLACE_PREAD@ REPLACE_PRINTF = @REPLACE_PRINTF@ REPLACE_PUTENV = @REPLACE_PUTENV@ +REPLACE_READLINK = @REPLACE_READLINK@ +REPLACE_REALPATH = @REPLACE_REALPATH@ +REPLACE_REMOVE = @REPLACE_REMOVE@ REPLACE_RENAME = @REPLACE_RENAME@ +REPLACE_RENAMEAT = @REPLACE_RENAMEAT@ +REPLACE_RMDIR = @REPLACE_RMDIR@ REPLACE_ROUND = @REPLACE_ROUND@ REPLACE_ROUNDF = @REPLACE_ROUNDF@ REPLACE_ROUNDL = @REPLACE_ROUNDL@ REPLACE_SELECT = @REPLACE_SELECT@ +REPLACE_SETENV = @REPLACE_SETENV@ REPLACE_SIGNBIT = @REPLACE_SIGNBIT@ REPLACE_SIGNBIT_USING_GCC = @REPLACE_SIGNBIT_USING_GCC@ +REPLACE_SLEEP = @REPLACE_SLEEP@ REPLACE_SNPRINTF = @REPLACE_SNPRINTF@ REPLACE_SPRINTF = @REPLACE_SPRINTF@ +REPLACE_STAT = @REPLACE_STAT@ REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@ REPLACE_STRCASESTR = @REPLACE_STRCASESTR@ REPLACE_STRDUP = @REPLACE_STRDUP@ @@ -879,8 +986,14 @@ REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@ REPLACE_STRSTR = @REPLACE_STRSTR@ REPLACE_STRTOD = @REPLACE_STRTOD@ REPLACE_STRTOK_R = @REPLACE_STRTOK_R@ +REPLACE_SYMLINK = @REPLACE_SYMLINK@ REPLACE_TIMEGM = @REPLACE_TIMEGM@ REPLACE_TRUNCL = @REPLACE_TRUNCL@ +REPLACE_UNLINK = @REPLACE_UNLINK@ +REPLACE_UNLINKAT = @REPLACE_UNLINKAT@ +REPLACE_UNSETENV = @REPLACE_UNSETENV@ +REPLACE_USLEEP = @REPLACE_USLEEP@ +REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@ REPLACE_VASPRINTF = @REPLACE_VASPRINTF@ REPLACE_VDPRINTF = @REPLACE_VDPRINTF@ REPLACE_VFPRINTF = @REPLACE_VFPRINTF@ @@ -894,7 +1007,6 @@ REPLACE_WCTOB = @REPLACE_WCTOB@ REPLACE_WCWIDTH = @REPLACE_WCWIDTH@ REPLACE_WRITE = @REPLACE_WRITE@ SELINUX_CONTEXT_H = @SELINUX_CONTEXT_H@ -SELINUX_SELINUX_H = @SELINUX_SELINUX_H@ SEQ_LIBM = @SEQ_LIBM@ SERVENT_LIB = @SERVENT_LIB@ SET_MAKE = @SET_MAKE@ @@ -906,10 +1018,8 @@ STDBOOL_H = @STDBOOL_H@ STDDEF_H = @STDDEF_H@ STDINT_H = @STDINT_H@ STRIP = @STRIP@ -SYS_IOCTL_H = @SYS_IOCTL_H@ SYS_IOCTL_H_HAVE_WINSOCK2_H = @SYS_IOCTL_H_HAVE_WINSOCK2_H@ SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ -SYS_SELECT_H = @SYS_SELECT_H@ SYS_SOCKET_H = @SYS_SOCKET_H@ SYS_TIME_H = @SYS_TIME_H@ SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ @@ -923,9 +1033,7 @@ UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOC USE_ACL = @USE_ACL@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ -VOID_UNSETENV = @VOID_UNSETENV@ WARN_CFLAGS = @WARN_CFLAGS@ -WCHAR_H = @WCHAR_H@ WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@ WCTYPE_H = @WCTYPE_H@ WERROR_CFLAGS = @WERROR_CFLAGS@ @@ -935,6 +1043,7 @@ XGETTEXT_015 = @XGETTEXT_015@ XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ YACC = @YACC@ YFLAGS = @YFLAGS@ +YIELD_LIB = @YIELD_LIB@ abs_aux_dir = @abs_aux_dir@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ @@ -1087,6 +1196,8 @@ TAGS: ctags: CTAGS CTAGS: +cscope cscopelist: + distdir: $(DISTFILES) @list='$(MANS)'; if test -n "$$list"; then \ @@ -1301,6 +1412,7 @@ mv.1: $(common_dep) $(srcdir)/mv.x ../src/mv.c nice.1: $(common_dep) $(srcdir)/nice.x ../src/nice.c nl.1: $(common_dep) $(srcdir)/nl.x ../src/nl.c nohup.1: $(common_dep) $(srcdir)/nohup.x ../src/nohup.c +nproc.1: $(common_dep) $(srcdir)/nproc.x ../src/nproc.c od.1: $(common_dep) $(srcdir)/od.x ../src/od.c paste.1: $(common_dep) $(srcdir)/paste.x ../src/paste.c pathchk.1: $(common_dep) $(srcdir)/pathchk.x ../src/pathchk.c diff --git a/src/bin/coreutils/man/base64.1 b/src/bin/coreutils/man/base64.1 index 1fcc2c58d3..052c2a2236 100644 --- a/src/bin/coreutils/man/base64.1 +++ b/src/bin/coreutils/man/base64.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH BASE64 "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH BASE64 "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME base64 \- base64 encode/decode data and print to standard output .SH SYNOPSIS @@ -21,10 +21,10 @@ Decode data. When decoding, ignore non\-alphabet characters. .TP \fB\-\-help\fR -Display this help and exit. +display this help and exit .TP \fB\-\-version\fR -Output version information and exit. +output version information and exit .PP With no FILE, or when FILE is \-, read standard input. .PP @@ -40,8 +40,10 @@ Report base64 bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report base64 translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/basename.1 b/src/bin/coreutils/man/basename.1 index 6062d4a635..50a84fd9b6 100644 --- a/src/bin/coreutils/man/basename.1 +++ b/src/bin/coreutils/man/basename.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH BASENAME "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH BASENAME "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME basename \- strip directory and suffix from filenames .SH SYNOPSIS @@ -34,8 +34,10 @@ Report basename bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report basename translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/cat.1 b/src/bin/coreutils/man/cat.1 index 3bc61df380..89f9157b42 100644 --- a/src/bin/coreutils/man/cat.1 +++ b/src/bin/coreutils/man/cat.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH CAT "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH CAT "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME cat \- concatenate files and print on the standard output .SH SYNOPSIS @@ -62,8 +62,10 @@ Report cat bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report cat translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/chcon.1 b/src/bin/coreutils/man/chcon.1 index f5d1e7bfd6..d45f10ef3e 100644 --- a/src/bin/coreutils/man/chcon.1 +++ b/src/bin/coreutils/man/chcon.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH CHCON "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH CHCON "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME chcon \- change file security context .SH SYNOPSIS @@ -70,8 +70,10 @@ Report chcon bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report chcon translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/chgrp.1 b/src/bin/coreutils/man/chgrp.1 index 186a41635f..b230037d10 100644 --- a/src/bin/coreutils/man/chgrp.1 +++ b/src/bin/coreutils/man/chgrp.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH CHGRP "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH CHGRP "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME chgrp \- change group ownership .SH SYNOPSIS @@ -80,8 +80,10 @@ Report chgrp bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report chgrp translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/chmod.1 b/src/bin/coreutils/man/chmod.1 index 09d62174fb..9a1f587acd 100644 --- a/src/bin/coreutils/man/chmod.1 +++ b/src/bin/coreutils/man/chmod.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH CHMOD "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH CHMOD "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME chmod \- change file mode bits .SH SYNOPSIS @@ -152,8 +152,10 @@ Report chmod bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report chmod translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/chmod.x b/src/bin/coreutils/man/chmod.x index 3bd229fb6a..684d46f5ac 100644 --- a/src/bin/coreutils/man/chmod.x +++ b/src/bin/coreutils/man/chmod.x @@ -1,4 +1,5 @@ -'\" Copyright (C) 1998, 1999, 2001, 2006, 2007, 2009 Free Software Foundation, Inc. +'\" Copyright (C) 1998-1999, 2001, 2006-2007, 2009-2010 Free Software +'\" Foundation, Inc. '\" '\" This is free software. You may redistribute copies of it under the terms '\" of the GNU General Public License . diff --git a/src/bin/coreutils/man/chown.1 b/src/bin/coreutils/man/chown.1 index 8dfb7a50aa..e6b0ccc5a8 100644 --- a/src/bin/coreutils/man/chown.1 +++ b/src/bin/coreutils/man/chown.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH CHOWN "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH CHOWN "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME chown \- change file owner and group .SH SYNOPSIS @@ -112,8 +112,10 @@ Report chown bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report chown translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/chown.x b/src/bin/coreutils/man/chown.x index 05129636ff..787abc0bdf 100644 --- a/src/bin/coreutils/man/chown.x +++ b/src/bin/coreutils/man/chown.x @@ -1,4 +1,5 @@ -'\" Copyright (C) 1998, 1999, 2001, 2006, 2009 Free Software Foundation, Inc. +'\" Copyright (C) 1998-1999, 2001, 2006, 2009-2010 Free Software Foundation, +'\" Inc. '\" '\" This is free software. You may redistribute copies of it under the terms '\" of the GNU General Public License . diff --git a/src/bin/coreutils/man/chroot.1 b/src/bin/coreutils/man/chroot.1 index 56474d67fe..4e80ae268b 100644 --- a/src/bin/coreutils/man/chroot.1 +++ b/src/bin/coreutils/man/chroot.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH CHROOT "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH CHROOT "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME chroot \- run command or interactive shell with special root directory .SH SYNOPSIS @@ -34,8 +34,10 @@ Report chroot bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report chroot translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/cksum.1 b/src/bin/coreutils/man/cksum.1 index 98f08e008b..6e458b93e2 100644 --- a/src/bin/coreutils/man/cksum.1 +++ b/src/bin/coreutils/man/cksum.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH CKSUM "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH CKSUM "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME cksum \- checksum and count the bytes in a file .SH SYNOPSIS @@ -26,8 +26,10 @@ Report cksum bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report cksum translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/comm.1 b/src/bin/coreutils/man/comm.1 index 11f3632056..2ed05da75a 100644 --- a/src/bin/coreutils/man/comm.1 +++ b/src/bin/coreutils/man/comm.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH COMM "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH COMM "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME comm \- compare two sorted files line by line .SH SYNOPSIS @@ -55,8 +55,10 @@ Report comm bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report comm translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/cp.1 b/src/bin/coreutils/man/cp.1 index 0b0d99bbf4..3ad450616f 100644 --- a/src/bin/coreutils/man/cp.1 +++ b/src/bin/coreutils/man/cp.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH CP "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH CP "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME cp \- copy files and directories .SH SYNOPSIS @@ -156,8 +156,10 @@ Report cp bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report cp translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/csplit.1 b/src/bin/coreutils/man/csplit.1 index e55c3044eb..5893ccae87 100644 --- a/src/bin/coreutils/man/csplit.1 +++ b/src/bin/coreutils/man/csplit.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH CSPLIT "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH CSPLIT "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME csplit \- split a file into sections determined by context lines .SH SYNOPSIS @@ -63,8 +63,10 @@ Report csplit bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report csplit translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/cut.1 b/src/bin/coreutils/man/cut.1 index d7e755b586..56f4ee5448 100644 --- a/src/bin/coreutils/man/cut.1 +++ b/src/bin/coreutils/man/cut.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH CUT "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH CUT "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME cut \- remove sections from each line of files .SH SYNOPSIS @@ -72,8 +72,10 @@ Report cut bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report cut translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/date.1 b/src/bin/coreutils/man/date.1 index 55f485cc9b..d3acc480d8 100644 --- a/src/bin/coreutils/man/date.1 +++ b/src/bin/coreutils/man/date.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH DATE "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH DATE "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME date \- print or set the system date and time .SH SYNOPSIS @@ -221,8 +221,10 @@ Report date bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report date translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/dd.1 b/src/bin/coreutils/man/dd.1 index f6abea59a3..8f5a963c72 100644 --- a/src/bin/coreutils/man/dd.1 +++ b/src/bin/coreutils/man/dd.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH DD "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH DD "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME dd \- convert and copy a file .SH SYNOPSIS @@ -162,8 +162,10 @@ Report dd bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report dd translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/df.1 b/src/bin/coreutils/man/df.1 index a60bdb53eb..2ae5778389 100644 --- a/src/bin/coreutils/man/df.1 +++ b/src/bin/coreutils/man/df.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH DF "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH DF "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME df \- report file system disk space usage .SH SYNOPSIS @@ -99,8 +99,10 @@ Report df bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report df translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/df.x b/src/bin/coreutils/man/df.x index 9e83a994d4..8c83d0d34b 100644 --- a/src/bin/coreutils/man/df.x +++ b/src/bin/coreutils/man/df.x @@ -1,4 +1,4 @@ -'\" Copyright (C) 1998, 1999, 2004, 2009 Free Software Foundation, Inc. +'\" Copyright (C) 1998-1999, 2004, 2009-2010 Free Software Foundation, Inc. '\" '\" This is free software. You may redistribute copies of it under the terms '\" of the GNU General Public License . diff --git a/src/bin/coreutils/man/dir.1 b/src/bin/coreutils/man/dir.1 index f43bd5f50d..ac34fa6c98 100644 --- a/src/bin/coreutils/man/dir.1 +++ b/src/bin/coreutils/man/dir.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH DIR "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH DIR "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME dir \- list directory contents .SH SYNOPSIS @@ -41,8 +41,8 @@ otherwise: sort by ctime list entries by columns .TP \fB\-\-color\fR[=\fIWHEN\fR] -control whether color is used to distinguish file -types. WHEN may be `never', `always', or `auto' +colorize the output. WHEN defaults to `always' +or can be `never' or `auto'. More info below .TP \fB\-d\fR, \fB\-\-directory\fR list directory entries instead of contents, @@ -221,12 +221,10 @@ output version information and exit SIZE may be (or may be an integer optionally followed by) one of following: KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. .PP -By default, color is not used to distinguish types of files. That is -equivalent to using \fB\-\-color\fR=\fInone\fR. Using the \fB\-\-color\fR option without the -optional WHEN argument is equivalent to using \fB\-\-color\fR=\fIalways\fR. With -\fB\-\-color\fR=\fIauto\fR, color codes are output only if standard output is connected -to a terminal (tty). The environment variable LS_COLORS can influence the -colors, and can be set easily by the dircolors command. +Using color to distinguish file types is disabled both by default and +with \fB\-\-color\fR=\fInever\fR. With \fB\-\-color\fR=\fIauto\fR, ls emits color codes only when +standard output is connected to a terminal. The LS_COLORS environment +variable can change the settings. Use the dircolors command to set it. .SS "Exit status:" .TP 0 @@ -245,8 +243,10 @@ Report dir bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report dir translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/dircolors.1 b/src/bin/coreutils/man/dircolors.1 index a809bec585..20d94401d2 100644 --- a/src/bin/coreutils/man/dircolors.1 +++ b/src/bin/coreutils/man/dircolors.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH DIRCOLORS "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH DIRCOLORS "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME dircolors \- color setup for ls .SH SYNOPSIS @@ -37,8 +37,10 @@ Report dircolors bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report dircolors translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/dirname.1 b/src/bin/coreutils/man/dirname.1 index c932f7a90a..5d04ee29c6 100644 --- a/src/bin/coreutils/man/dirname.1 +++ b/src/bin/coreutils/man/dirname.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH DIRNAME "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH DIRNAME "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME dirname \- strip non-directory suffix from file name .SH SYNOPSIS @@ -34,8 +34,10 @@ Report dirname bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report dirname translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/du.1 b/src/bin/coreutils/man/du.1 index 07dd84e65d..f126825506 100644 --- a/src/bin/coreutils/man/du.1 +++ b/src/bin/coreutils/man/du.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH DU "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH DU "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME du \- estimate file space usage .SH SYNOPSIS @@ -143,8 +143,10 @@ Report du bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report du translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/du.x b/src/bin/coreutils/man/du.x index 08f135127d..2bdfbefc57 100644 --- a/src/bin/coreutils/man/du.x +++ b/src/bin/coreutils/man/du.x @@ -1,4 +1,4 @@ -'\" Copyright (C) 1998, 1999, 2000, 2002, 2009 Free Software Foundation, Inc. +'\" Copyright (C) 1998-2000, 2002, 2009-2010 Free Software Foundation, Inc. '\" '\" This is free software. You may redistribute copies of it under the terms '\" of the GNU General Public License . diff --git a/src/bin/coreutils/man/echo.1 b/src/bin/coreutils/man/echo.1 index 09116a4d1e..b7290dfa64 100644 --- a/src/bin/coreutils/man/echo.1 +++ b/src/bin/coreutils/man/echo.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH ECHO "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH ECHO "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME echo \- display a line of text .SH SYNOPSIS @@ -30,9 +30,6 @@ output version information and exit .PP If \fB\-e\fR is in effect, the following sequences are recognized: .TP -\e0NNN -the character whose ASCII code is NNN (octal) -.TP \e\e backslash .TP @@ -45,6 +42,9 @@ backspace \ec produce no further output .TP +\ee +escape +.TP \ef form feed .TP @@ -59,6 +59,12 @@ horizontal tab .TP \ev vertical tab +.TP +\e0NNN +byte with octal value NNN (1 to 3 digits) +.TP +\exHH +byte with hexadecimal value HH (1 to 2 digits) .PP NOTE: your shell may have its own version of echo, which usually supersedes the version described here. Please refer to your shell's documentation @@ -71,8 +77,10 @@ Report echo bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report echo translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/env.1 b/src/bin/coreutils/man/env.1 index 968f2416d0..fc679e2851 100644 --- a/src/bin/coreutils/man/env.1 +++ b/src/bin/coreutils/man/env.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH ENV "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH ENV "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME env \- run a program in a modified environment .SH SYNOPSIS @@ -13,6 +13,9 @@ Set each NAME to VALUE in the environment and run COMMAND. \fB\-i\fR, \fB\-\-ignore\-environment\fR start with an empty environment .TP +\fB\-0\fR, \fB\-\-null\fR +end each output line with 0 byte rather than newline +.TP \fB\-u\fR, \fB\-\-unset\fR=\fINAME\fR remove variable from the environment .TP @@ -31,8 +34,10 @@ Report env bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report env translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/expand.1 b/src/bin/coreutils/man/expand.1 index c23ddca735..c21e1bcf68 100644 --- a/src/bin/coreutils/man/expand.1 +++ b/src/bin/coreutils/man/expand.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH EXPAND "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH EXPAND "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME expand \- convert tabs to spaces .SH SYNOPSIS @@ -35,8 +35,10 @@ Report expand bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report expand translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/expr.1 b/src/bin/coreutils/man/expr.1 index 60a521a85d..920b979536 100644 --- a/src/bin/coreutils/man/expr.1 +++ b/src/bin/coreutils/man/expr.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH EXPR "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH EXPR "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME expr \- evaluate expressions .SH SYNOPSIS @@ -97,8 +97,10 @@ Report expr bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report expr translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/factor.1 b/src/bin/coreutils/man/factor.1 index 46ec988181..3b7ef4e4f6 100644 --- a/src/bin/coreutils/man/factor.1 +++ b/src/bin/coreutils/man/factor.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH FACTOR "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH FACTOR "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME factor \- factor numbers .SH SYNOPSIS @@ -27,8 +27,10 @@ Report factor bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report factor translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/false.1 b/src/bin/coreutils/man/false.1 index 6f0414aefc..cfd2b98735 100644 --- a/src/bin/coreutils/man/false.1 +++ b/src/bin/coreutils/man/false.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH FALSE "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH FALSE "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME false \- do nothing, unsuccessfully .SH SYNOPSIS @@ -30,8 +30,10 @@ Report false bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report false translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/fmt.1 b/src/bin/coreutils/man/fmt.1 index 13fc3fae80..25e3d2d1d8 100644 --- a/src/bin/coreutils/man/fmt.1 +++ b/src/bin/coreutils/man/fmt.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH FMT "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH FMT "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME fmt \- simple optimal text formatter .SH SYNOPSIS @@ -47,8 +47,10 @@ Report fmt bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report fmt translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/fold.1 b/src/bin/coreutils/man/fold.1 index 34bbfee02a..aab3047e30 100644 --- a/src/bin/coreutils/man/fold.1 +++ b/src/bin/coreutils/man/fold.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH FOLD "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH FOLD "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME fold \- wrap each input line to fit in specified width .SH SYNOPSIS @@ -35,8 +35,10 @@ Report fold bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report fold translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/groups.1 b/src/bin/coreutils/man/groups.1 index 37495096c1..297b97dd0c 100644 --- a/src/bin/coreutils/man/groups.1 +++ b/src/bin/coreutils/man/groups.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH GROUPS "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH GROUPS "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME groups \- print the groups a user is in .SH SYNOPSIS @@ -24,8 +24,10 @@ Report groups bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report groups translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/head.1 b/src/bin/coreutils/man/head.1 index 1aae44e475..89596a2924 100644 --- a/src/bin/coreutils/man/head.1 +++ b/src/bin/coreutils/man/head.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH HEAD "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH HEAD "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME head \- output the first part of files .SH SYNOPSIS @@ -47,8 +47,10 @@ Report head bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report head translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/help2man b/src/bin/coreutils/man/help2man index 7b7ce7a4b0..8e42f3cd11 100755 --- a/src/bin/coreutils/man/help2man +++ b/src/bin/coreutils/man/help2man @@ -1,8 +1,7 @@ #!/usr/bin/perl -w # Generate a short man page from --help and --version output. -# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2008, 2009 -# Free Software Foundation, Inc. +# Copyright (C) 1997-2004, 2008-2010 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -373,6 +372,7 @@ my $PAT_AUTHOR = _('Written +by'); my $PAT_OPTIONS = _('Options'); my $PAT_EXAMPLES = _('Examples'); my $PAT_FREE_SOFTWARE = _('This +is +free +software'); +my $PAT_INFO = _('For +complete +documentation'); # Start a new paragraph (if required) for these. s/([^\n])\n($PAT_BUGS|$PAT_AUTHOR)/$1\n\n$2/og; @@ -392,6 +392,11 @@ while (length) $sect = _('EXAMPLES'); next; } + # Skip any texinfo reference as that's handled separately + if (s/($PAT_INFO).*\n//o) + { + next; + } # Copyright section if (/^Copyright +[(\xa9]/) diff --git a/src/bin/coreutils/man/hostid.1 b/src/bin/coreutils/man/hostid.1 index 2bdfa2bf63..0899beee4a 100644 --- a/src/bin/coreutils/man/hostid.1 +++ b/src/bin/coreutils/man/hostid.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH HOSTID "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH HOSTID "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME hostid \- print the numeric identifier for the current host .SH SYNOPSIS @@ -23,8 +23,10 @@ Report hostid bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report hostid translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/id.1 b/src/bin/coreutils/man/id.1 index 9828ec11e6..f6993d4a91 100644 --- a/src/bin/coreutils/man/id.1 +++ b/src/bin/coreutils/man/id.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH ID "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH ID "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME id \- print real and effective user and group IDs .SH SYNOPSIS @@ -47,8 +47,10 @@ Report id bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report id translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/install.1 b/src/bin/coreutils/man/install.1 index 01f3c774f8..6a5af27336 100644 --- a/src/bin/coreutils/man/install.1 +++ b/src/bin/coreutils/man/install.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH INSTALL "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH INSTALL "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME install \- copy files and set attributes .SH SYNOPSIS @@ -115,8 +115,10 @@ Report install bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report install translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/join.1 b/src/bin/coreutils/man/join.1 index 17892c27f7..9fbc725c14 100644 --- a/src/bin/coreutils/man/join.1 +++ b/src/bin/coreutils/man/join.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH JOIN "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH JOIN "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME join \- join lines of two files on a common field .SH SYNOPSIS @@ -73,8 +73,10 @@ Report join bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report join translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/kill.1 b/src/bin/coreutils/man/kill.1 index df84fab3d3..af2fe5cf6c 100644 --- a/src/bin/coreutils/man/kill.1 +++ b/src/bin/coreutils/man/kill.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH KILL "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH KILL "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME kill \- send signals to processes, or list signals .SH SYNOPSIS @@ -49,8 +49,10 @@ Report kill bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report kill translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/link.1 b/src/bin/coreutils/man/link.1 index 3cd7291b97..61169a8ce6 100644 --- a/src/bin/coreutils/man/link.1 +++ b/src/bin/coreutils/man/link.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH LINK "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH LINK "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME link \- call the link function to create a link to a file .SH SYNOPSIS @@ -26,8 +26,10 @@ Report link bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report link translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/ln.1 b/src/bin/coreutils/man/ln.1 index e0d5c6d572..ab65c8bb3a 100644 --- a/src/bin/coreutils/man/ln.1 +++ b/src/bin/coreutils/man/ln.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH LN "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH LN "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME ln \- make links between files .SH SYNOPSIS @@ -41,12 +41,18 @@ system restrictions, even for the superuser) \fB\-f\fR, \fB\-\-force\fR remove existing destination files .TP +\fB\-i\fR, \fB\-\-interactive\fR +prompt whether to remove destinations +.TP +\fB\-L\fR, \fB\-\-logical\fR +make hard links to symbolic link references +.TP \fB\-n\fR, \fB\-\-no\-dereference\fR treat destination that is a symlink to a directory as if it were a normal file .TP -\fB\-i\fR, \fB\-\-interactive\fR -prompt whether to remove destinations +\fB\-P\fR, \fB\-\-physical\fR +make hard links directly to symbolic links .TP \fB\-s\fR, \fB\-\-symbolic\fR make symbolic links instead of hard links @@ -73,6 +79,9 @@ output version information and exit The backup suffix is `~', unless set with \fB\-\-suffix\fR or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the \fB\-\-backup\fR option or through the VERSION_CONTROL environment variable. Here are the values: +.PP +Using \fB\-s\fR ignores \fB\-L\fR and \fB\-P\fR. Otherwise, the last option specified controls +behavior when the source is a symbolic link, defaulting to \fB\-P\fR. .TP none, off never make backups (even if \fB\-\-backup\fR is given) @@ -93,8 +102,10 @@ Report ln bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report ln translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/logname.1 b/src/bin/coreutils/man/logname.1 index a96a9756a9..ed1597ad2b 100644 --- a/src/bin/coreutils/man/logname.1 +++ b/src/bin/coreutils/man/logname.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH LOGNAME "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH LOGNAME "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME logname \- print user\'s login name .SH SYNOPSIS @@ -23,8 +23,10 @@ Report logname bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report logname translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/ls.1 b/src/bin/coreutils/man/ls.1 index d24e1892ef..22b9012620 100644 --- a/src/bin/coreutils/man/ls.1 +++ b/src/bin/coreutils/man/ls.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH LS "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH LS "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME ls \- list directory contents .SH SYNOPSIS @@ -41,8 +41,8 @@ otherwise: sort by ctime list entries by columns .TP \fB\-\-color\fR[=\fIWHEN\fR] -control whether color is used to distinguish file -types. WHEN may be `never', `always', or `auto' +colorize the output. WHEN defaults to `always' +or can be `never' or `auto'. More info below .TP \fB\-d\fR, \fB\-\-directory\fR list directory entries instead of contents, @@ -221,12 +221,10 @@ output version information and exit SIZE may be (or may be an integer optionally followed by) one of following: KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. .PP -By default, color is not used to distinguish types of files. That is -equivalent to using \fB\-\-color\fR=\fInone\fR. Using the \fB\-\-color\fR option without the -optional WHEN argument is equivalent to using \fB\-\-color\fR=\fIalways\fR. With -\fB\-\-color\fR=\fIauto\fR, color codes are output only if standard output is connected -to a terminal (tty). The environment variable LS_COLORS can influence the -colors, and can be set easily by the dircolors command. +Using color to distinguish file types is disabled both by default and +with \fB\-\-color\fR=\fInever\fR. With \fB\-\-color\fR=\fIauto\fR, ls emits color codes only when +standard output is connected to a terminal. The LS_COLORS environment +variable can change the settings. Use the dircolors command to set it. .SS "Exit status:" .TP 0 @@ -245,8 +243,10 @@ Report ls bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report ls translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/md5sum.1 b/src/bin/coreutils/man/md5sum.1 index 61cdbe5999..2a3b0a25dd 100644 --- a/src/bin/coreutils/man/md5sum.1 +++ b/src/bin/coreutils/man/md5sum.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH MD5SUM "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH MD5SUM "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME md5sum \- compute and check MD5 message digest .SH SYNOPSIS @@ -48,8 +48,10 @@ Report md5sum bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report md5sum translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/mkdir.1 b/src/bin/coreutils/man/mkdir.1 index cd19ae0875..96626e1807 100644 --- a/src/bin/coreutils/man/mkdir.1 +++ b/src/bin/coreutils/man/mkdir.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH MKDIR "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH MKDIR "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME mkdir \- make directories .SH SYNOPSIS @@ -38,8 +38,10 @@ Report mkdir bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report mkdir translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/mkfifo.1 b/src/bin/coreutils/man/mkfifo.1 index d86c1651d8..341a48dee9 100644 --- a/src/bin/coreutils/man/mkfifo.1 +++ b/src/bin/coreutils/man/mkfifo.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH MKFIFO "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH MKFIFO "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME mkfifo \- make FIFOs (named pipes) .SH SYNOPSIS @@ -31,8 +31,10 @@ Report mkfifo bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report mkfifo translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/mknod.1 b/src/bin/coreutils/man/mknod.1 index 1ebf8dea7a..f54fa6ef67 100644 --- a/src/bin/coreutils/man/mknod.1 +++ b/src/bin/coreutils/man/mknod.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH MKNOD "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH MKNOD "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME mknod \- make block or character special files .SH SYNOPSIS @@ -49,8 +49,10 @@ Report mknod bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report mknod translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/mktemp.1 b/src/bin/coreutils/man/mktemp.1 index 9ec1b6299e..e3f4b652e0 100644 --- a/src/bin/coreutils/man/mktemp.1 +++ b/src/bin/coreutils/man/mktemp.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH MKTEMP "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH MKTEMP "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME mktemp \- create a temporary file or directory .SH SYNOPSIS @@ -9,23 +9,28 @@ mktemp \- create a temporary file or directory .\" Add any additional description here .PP Create a temporary file or directory, safely, and print its name. -If TEMPLATE is not specified, use tmp.XXXXXXXXXX. +TEMPLATE must contain at least 3 consecutive `X's in last component. +If TEMPLATE is not specified, use tmp.XXXXXXXXXX, and \fB\-\-tmpdir\fR is implied. .TP \fB\-d\fR, \fB\-\-directory\fR create a directory, not a file .TP -\fB\-q\fR, \fB\-\-quiet\fR -suppress diagnostics about file/dir\-creation failure -.TP \fB\-u\fR, \fB\-\-dry\-run\fR do not create anything; merely print a name (unsafe) .TP +\fB\-q\fR, \fB\-\-quiet\fR +suppress diagnostics about file/dir\-creation failure +.TP +\fB\-\-suffix\fR=\fISUFF\fR +append SUFF to TEMPLATE. SUFF must not contain slash. +This option is implied if TEMPLATE does not end in X. +.TP \fB\-\-tmpdir\fR[=\fIDIR\fR] -interpret TEMPLATE relative to DIR. If DIR is -not specified, use $TMPDIR if set, else /tmp. -With this option, TEMPLATE must not be an absolute name. -Unlike with \fB\-t\fR, TEMPLATE may contain slashes, but even -here, mktemp still creates only the final component. +interpret TEMPLATE relative to DIR. If DIR is not +specified, use $TMPDIR if set, else /tmp. With +this option, TEMPLATE must not be an absolute name. +Unlike with \fB\-t\fR, TEMPLATE may contain slashes, but +mktemp creates only the final component. .TP \fB\-p\fR DIR use DIR as a prefix; implies \fB\-t\fR [deprecated] @@ -41,15 +46,17 @@ display this help and exit \fB\-\-version\fR output version information and exit .SH AUTHOR -Written by Jim Meyering. +Written by Jim Meyering and Eric Blake. .SH "REPORTING BUGS" Report mktemp bugs to bug\-coreutils@gnu.org .br GNU coreutils home page: .br General help using GNU software: +.br +Report mktemp translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/mv.1 b/src/bin/coreutils/man/mv.1 index 59e67c5964..22650224db 100644 --- a/src/bin/coreutils/man/mv.1 +++ b/src/bin/coreutils/man/mv.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH MV "1" "September 2009" "GNU coreutils 7.6" "User Commands" +.TH MV "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME mv \- move (rename) files .SH SYNOPSIS @@ -85,8 +85,10 @@ Report mv bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report mv translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/nice.1 b/src/bin/coreutils/man/nice.1 index 88713994bd..05dffa362b 100644 --- a/src/bin/coreutils/man/nice.1 +++ b/src/bin/coreutils/man/nice.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH NICE "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH NICE "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME nice \- run a program with modified scheduling priority .SH SYNOPSIS @@ -32,8 +32,10 @@ Report nice bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report nice translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/nl.1 b/src/bin/coreutils/man/nl.1 index b59eb1a7af..aa80fe5920 100644 --- a/src/bin/coreutils/man/nl.1 +++ b/src/bin/coreutils/man/nl.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH NL "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH NL "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME nl \- number lines of files .SH SYNOPSIS @@ -87,8 +87,10 @@ Report nl bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report nl translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/nohup.1 b/src/bin/coreutils/man/nohup.1 index 26cca3fed2..377de6a2bd 100644 --- a/src/bin/coreutils/man/nohup.1 +++ b/src/bin/coreutils/man/nohup.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH NOHUP "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH NOHUP "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME nohup \- run a command immune to hangups, with output to a non-tty .SH SYNOPSIS @@ -36,8 +36,10 @@ Report nohup bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report nohup translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/nproc.1 b/src/bin/coreutils/man/nproc.1 new file mode 100644 index 0000000000..62e0bae89d --- /dev/null +++ b/src/bin/coreutils/man/nproc.1 @@ -0,0 +1,52 @@ +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. +.TH NPROC "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" +.SH NAME +nproc \- print the number of processing units available +.SH SYNOPSIS +.B nproc +[\fIOPTION\fR]... +.SH DESCRIPTION +.\" Add any additional description here +.PP +Print the number of processing units available to the current process, +which may be less than the number of online processors +.TP +\fB\-\-all\fR +print the number of installed processors +.TP +\fB\-\-ignore\fR=\fIN\fR +if possible, exclude N processing units +.TP +\fB\-\-help\fR +display this help and exit +.TP +\fB\-\-version\fR +output version information and exit +.SH AUTHOR +Written by Giuseppe Scrivano. +.SH "REPORTING BUGS" +Report nproc bugs to bug\-coreutils@gnu.org +.br +GNU coreutils home page: +.br +General help using GNU software: +.br +Report nproc translation bugs to +.SH COPYRIGHT +Copyright \(co 2010 Free Software Foundation, Inc. +License GPLv3+: GNU GPL version 3 or later . +.br +This is free software: you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law. +.SH "SEE ALSO" +The full documentation for +.B nproc +is maintained as a Texinfo manual. If the +.B info +and +.B nproc +programs are properly installed at your site, the command +.IP +.B info coreutils \(aqnproc invocation\(aq +.PP +should give you access to the complete manual. diff --git a/src/bin/coreutils/man/nproc.x b/src/bin/coreutils/man/nproc.x new file mode 100644 index 0000000000..870d6bd454 --- /dev/null +++ b/src/bin/coreutils/man/nproc.x @@ -0,0 +1,4 @@ +[NAME] +nproc \- print the number of processing units available +[DESCRIPTION] +.\" Add any additional description here diff --git a/src/bin/coreutils/man/od.1 b/src/bin/coreutils/man/od.1 index b484db1291..d842292391 100644 --- a/src/bin/coreutils/man/od.1 +++ b/src/bin/coreutils/man/od.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH OD "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH OD "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME od \- dump files in octal and other formats .SH SYNOPSIS @@ -133,8 +133,10 @@ Report od bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report od translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/paste.1 b/src/bin/coreutils/man/paste.1 index 60875fdb2a..43224a1ba3 100644 --- a/src/bin/coreutils/man/paste.1 +++ b/src/bin/coreutils/man/paste.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH PASTE "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH PASTE "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME paste \- merge lines of files .SH SYNOPSIS @@ -33,8 +33,10 @@ Report paste bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report paste translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/pathchk.1 b/src/bin/coreutils/man/pathchk.1 index b3fc4c250a..14d96bedaa 100644 --- a/src/bin/coreutils/man/pathchk.1 +++ b/src/bin/coreutils/man/pathchk.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH PATHCHK "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH PATHCHK "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME pathchk \- check whether file names are valid or portable .SH SYNOPSIS @@ -32,8 +32,10 @@ Report pathchk bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report pathchk translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/pinky.1 b/src/bin/coreutils/man/pinky.1 index b02ad79cbb..90d2ca27f1 100644 --- a/src/bin/coreutils/man/pinky.1 +++ b/src/bin/coreutils/man/pinky.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH PINKY "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH PINKY "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME pinky \- lightweight finger .SH SYNOPSIS @@ -52,8 +52,10 @@ Report pinky bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report pinky translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/pr.1 b/src/bin/coreutils/man/pr.1 index 1fde89fb23..e390e9c097 100644 --- a/src/bin/coreutils/man/pr.1 +++ b/src/bin/coreutils/man/pr.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH PR "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH PR "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME pr \- convert text files for printing .SH SYNOPSIS @@ -75,7 +75,7 @@ affect \fB\-w\fR or \fB\-W\fR, MARGIN will be added to PAGE_WIDTH \fB\-r\fR, \fB\-\-no\-file\-warnings\fR omit warning when a file cannot be opened .TP -\fB\-s[CHAR]\fR,\-\-separator[=CHAR] +\fB\-s[CHAR]\fR, \fB\-\-separator\fR[=\fICHAR\fR] separate columns by a single character, default for CHAR is the character without \fB\-w\fR and 'no char' with \fB\-w\fR \fB\-s[CHAR]\fR turns off line truncation of all 3 column @@ -111,8 +111,8 @@ display this help and exit \fB\-\-version\fR output version information and exit .PP -\fB\-t\fR is implied if PAGE_LENGTH <= 10. With no FILE, or when -FILE is \-, read standard input. +\fB\-t\fR is implied if PAGE_LENGTH <= 10. With no FILE, or when FILE is \-, read +standard input. .SH AUTHOR Written by Pete TerMaat and Roland Huebner. .SH "REPORTING BUGS" @@ -121,8 +121,10 @@ Report pr bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report pr translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/printenv.1 b/src/bin/coreutils/man/printenv.1 index d5e8ff81ee..86bed36055 100644 --- a/src/bin/coreutils/man/printenv.1 +++ b/src/bin/coreutils/man/printenv.1 @@ -1,19 +1,19 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH PRINTENV "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH PRINTENV "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME printenv \- print all or part of environment .SH SYNOPSIS .B printenv -[\fIVARIABLE\fR]... -.br -.B printenv -\fIOPTION\fR +[\fIOPTION\fR]... [\fIVARIABLE\fR]... .SH DESCRIPTION .\" Add any additional description here .PP Print the values of the specified environment VARIABLE(s). If no VARIABLE is specified, print name and value pairs for them all. .TP +\fB\-0\fR, \fB\-\-null\fR +end each output line with 0 byte rather than newline +.TP \fB\-\-help\fR display this help and exit .TP @@ -31,8 +31,10 @@ Report printenv bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report printenv translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/printf.1 b/src/bin/coreutils/man/printf.1 index 402ed4f13d..51054cefd8 100644 --- a/src/bin/coreutils/man/printf.1 +++ b/src/bin/coreutils/man/printf.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH PRINTF "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH PRINTF "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME printf \- format and print data .SH SYNOPSIS @@ -24,9 +24,6 @@ FORMAT controls the output as in C printf. Interpreted sequences are: \e" double quote .TP -\eNNN -character with octal value NNN (1 to 3 digits) -.TP \e\e backslash .TP @@ -39,6 +36,9 @@ backspace \ec produce no further output .TP +\ee +escape +.TP \ef form feed .TP @@ -54,6 +54,9 @@ horizontal tab \ev vertical tab .TP +\eNNN +byte with octal value NNN (1 to 3 digits) +.TP \exHH byte with hexadecimal value HH (1 to 2 digits) .TP @@ -84,8 +87,10 @@ Report printf bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report printf translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/ptx.1 b/src/bin/coreutils/man/ptx.1 index 97336989ea..dd96ef2cc3 100644 --- a/src/bin/coreutils/man/ptx.1 +++ b/src/bin/coreutils/man/ptx.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH PTX "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH PTX "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME ptx \- produce a permuted index of file contents .SH SYNOPSIS @@ -80,8 +80,10 @@ Report ptx bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report ptx translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/pwd.1 b/src/bin/coreutils/man/pwd.1 index 0b48063ead..e2b5b186da 100644 --- a/src/bin/coreutils/man/pwd.1 +++ b/src/bin/coreutils/man/pwd.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH PWD "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH PWD "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME pwd \- print name of current/working directory .SH SYNOPSIS @@ -33,8 +33,10 @@ Report pwd bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report pwd translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/readlink.1 b/src/bin/coreutils/man/readlink.1 index afefcc5a21..750b6231d4 100644 --- a/src/bin/coreutils/man/readlink.1 +++ b/src/bin/coreutils/man/readlink.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH READLINK "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH READLINK "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME readlink \- print value of a symbolic link or canonical file name .SH SYNOPSIS @@ -49,8 +49,10 @@ Report readlink bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report readlink translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/rm.1 b/src/bin/coreutils/man/rm.1 index bf545d6e5b..8b71e47453 100644 --- a/src/bin/coreutils/man/rm.1 +++ b/src/bin/coreutils/man/rm.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH RM "1" "September 2009" "GNU coreutils 7.6" "User Commands" +.TH RM "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME rm \- remove files or directories .SH SYNOPSIS @@ -90,8 +90,10 @@ Report rm bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report rm translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/rm.x b/src/bin/coreutils/man/rm.x index f9146954a4..d7df0e932d 100644 --- a/src/bin/coreutils/man/rm.x +++ b/src/bin/coreutils/man/rm.x @@ -1,5 +1,5 @@ -'\" Copyright (C) 1998, 1999, 2001, 2003, 2004, -'\" 2006, 2009 Free Software Foundation, Inc. +'\" Copyright (C) 1998-1999, 2001, 2003-2004, 2006, 2009-2010 Free Software +'\" Foundation, Inc. '\" '\" This is free software. You may redistribute copies of it under the terms '\" of the GNU General Public License . diff --git a/src/bin/coreutils/man/rmdir.1 b/src/bin/coreutils/man/rmdir.1 index 0389e98ec0..6978bd1948 100644 --- a/src/bin/coreutils/man/rmdir.1 +++ b/src/bin/coreutils/man/rmdir.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH RMDIR "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH RMDIR "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME rmdir \- remove empty directories .SH SYNOPSIS @@ -36,8 +36,10 @@ Report rmdir bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report rmdir translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/runcon.1 b/src/bin/coreutils/man/runcon.1 index 1dd05c2f43..ad51770db2 100644 --- a/src/bin/coreutils/man/runcon.1 +++ b/src/bin/coreutils/man/runcon.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH RUNCON "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH RUNCON "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME runcon \- run command with specified security context .SH SYNOPSIS @@ -55,8 +55,10 @@ Report runcon bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report runcon translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/seq.1 b/src/bin/coreutils/man/seq.1 index 6fcc8a24a1..4d0ff404a1 100644 --- a/src/bin/coreutils/man/seq.1 +++ b/src/bin/coreutils/man/seq.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SEQ "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH SEQ "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME seq \- print a sequence of numbers .SH SYNOPSIS @@ -47,8 +47,10 @@ Report seq bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report seq translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/sha1sum.1 b/src/bin/coreutils/man/sha1sum.1 index 7b749c1264..6325a3519d 100644 --- a/src/bin/coreutils/man/sha1sum.1 +++ b/src/bin/coreutils/man/sha1sum.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SHA1SUM "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH SHA1SUM "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME sha1sum \- compute and check SHA1 message digest .SH SYNOPSIS @@ -48,8 +48,10 @@ Report sha1sum bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report sha1sum translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/sha224sum.1 b/src/bin/coreutils/man/sha224sum.1 index bf0b12b17e..90e3f6a723 100644 --- a/src/bin/coreutils/man/sha224sum.1 +++ b/src/bin/coreutils/man/sha224sum.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SHA224SUM "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH SHA224SUM "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME sha224sum \- compute and check SHA224 message digest .SH SYNOPSIS @@ -48,8 +48,10 @@ Report sha224sum bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report sha224sum translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/sha256sum.1 b/src/bin/coreutils/man/sha256sum.1 index 4b405fcb1f..9036a8b7be 100644 --- a/src/bin/coreutils/man/sha256sum.1 +++ b/src/bin/coreutils/man/sha256sum.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SHA256SUM "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH SHA256SUM "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME sha256sum \- compute and check SHA256 message digest .SH SYNOPSIS @@ -48,8 +48,10 @@ Report sha256sum bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report sha256sum translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/sha384sum.1 b/src/bin/coreutils/man/sha384sum.1 index 59f8e1f0f0..6f262a7172 100644 --- a/src/bin/coreutils/man/sha384sum.1 +++ b/src/bin/coreutils/man/sha384sum.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SHA384SUM "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH SHA384SUM "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME sha384sum \- compute and check SHA384 message digest .SH SYNOPSIS @@ -48,8 +48,10 @@ Report sha384sum bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report sha384sum translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/sha512sum.1 b/src/bin/coreutils/man/sha512sum.1 index b643551ad1..6d6fee4c96 100644 --- a/src/bin/coreutils/man/sha512sum.1 +++ b/src/bin/coreutils/man/sha512sum.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SHA512SUM "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH SHA512SUM "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME sha512sum \- compute and check SHA512 message digest .SH SYNOPSIS @@ -48,8 +48,10 @@ Report sha512sum bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report sha512sum translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/shred.1 b/src/bin/coreutils/man/shred.1 index e05015e8ba..24079879bf 100644 --- a/src/bin/coreutils/man/shred.1 +++ b/src/bin/coreutils/man/shred.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SHRED "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH SHRED "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME shred \- overwrite a file to hide its contents, and optionally delete it .SH SYNOPSIS @@ -90,8 +90,10 @@ Report shred bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report shred translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/shuf.1 b/src/bin/coreutils/man/shuf.1 index 5e31584855..d1021d625f 100644 --- a/src/bin/coreutils/man/shuf.1 +++ b/src/bin/coreutils/man/shuf.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SHUF "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH SHUF "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME shuf \- generate random permutations .SH SYNOPSIS @@ -51,8 +51,10 @@ Report shuf bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report shuf translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/sleep.1 b/src/bin/coreutils/man/sleep.1 index b08123e43d..f67b7dcc7a 100644 --- a/src/bin/coreutils/man/sleep.1 +++ b/src/bin/coreutils/man/sleep.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SLEEP "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH SLEEP "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME sleep \- delay for a specified amount of time .SH SYNOPSIS @@ -30,8 +30,10 @@ Report sleep bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report sleep translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/sort.1 b/src/bin/coreutils/man/sort.1 index b990929dcf..4b65b5dcba 100644 --- a/src/bin/coreutils/man/sort.1 +++ b/src/bin/coreutils/man/sort.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SORT "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH SORT "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME sort \- sort lines of text files .SH SYNOPSIS @@ -137,8 +137,10 @@ Report sort bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report sort translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/split.1 b/src/bin/coreutils/man/split.1 index 2a0870b6ea..9799517d7f 100644 --- a/src/bin/coreutils/man/split.1 +++ b/src/bin/coreutils/man/split.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SPLIT "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH SPLIT "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME split \- split a file into pieces .SH SYNOPSIS @@ -49,8 +49,10 @@ Report split bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report split translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/stat.1 b/src/bin/coreutils/man/stat.1 index 280e6b17d1..71ddee883b 100644 --- a/src/bin/coreutils/man/stat.1 +++ b/src/bin/coreutils/man/stat.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH STAT "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH STAT "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME stat \- display file or file system status .SH SYNOPSIS @@ -169,8 +169,10 @@ Report stat bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report stat translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/stdbuf.1 b/src/bin/coreutils/man/stdbuf.1 index ae9d862a2e..3f029deabe 100644 --- a/src/bin/coreutils/man/stdbuf.1 +++ b/src/bin/coreutils/man/stdbuf.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH STDBUF "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH STDBUF "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME stdbuf \- Run COMMAND, with modified buffering operations for its standard streams. .SH SYNOPSIS @@ -56,8 +56,10 @@ Report stdbuf bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report stdbuf translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/stdbuf.x b/src/bin/coreutils/man/stdbuf.x index 93f0b8e4b7..1ef2d9e43a 100644 --- a/src/bin/coreutils/man/stdbuf.x +++ b/src/bin/coreutils/man/stdbuf.x @@ -1,4 +1,4 @@ -'\" Copyright (C) 2009 Free Software Foundation, Inc. +'\" Copyright (C) 2009-2010 Free Software Foundation, Inc. '\" '\" This is free software. You may redistribute copies of it under the terms '\" of the GNU General Public License . diff --git a/src/bin/coreutils/man/stty.1 b/src/bin/coreutils/man/stty.1 index 39479e38d4..af65962e8d 100644 --- a/src/bin/coreutils/man/stty.1 +++ b/src/bin/coreutils/man/stty.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH STTY "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH STTY "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME stty \- change and print terminal line settings .SH SYNOPSIS @@ -389,8 +389,10 @@ Report stty bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report stty translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/sum.1 b/src/bin/coreutils/man/sum.1 index 89c2619592..ea7852bfd9 100644 --- a/src/bin/coreutils/man/sum.1 +++ b/src/bin/coreutils/man/sum.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SUM "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH SUM "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME sum \- checksum and count the blocks in a file .SH SYNOPSIS @@ -31,8 +31,10 @@ Report sum bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report sum translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/sync.1 b/src/bin/coreutils/man/sync.1 index af8b707852..ac699123fa 100644 --- a/src/bin/coreutils/man/sync.1 +++ b/src/bin/coreutils/man/sync.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH SYNC "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH SYNC "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME sync \- flush file system buffers .SH SYNOPSIS @@ -23,8 +23,10 @@ Report sync bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report sync translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/tac.1 b/src/bin/coreutils/man/tac.1 index 744a7655be..b488ce8b95 100644 --- a/src/bin/coreutils/man/tac.1 +++ b/src/bin/coreutils/man/tac.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH TAC "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH TAC "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME tac \- concatenate and print files in reverse .SH SYNOPSIS @@ -35,8 +35,10 @@ Report tac bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report tac translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/tail.1 b/src/bin/coreutils/man/tail.1 index 2e11a4865e..3d1838000f 100644 --- a/src/bin/coreutils/man/tail.1 +++ b/src/bin/coreutils/man/tail.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH TAIL "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH TAIL "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME tail \- output the last part of files .SH SYNOPSIS @@ -15,8 +15,8 @@ With no FILE, or when FILE is \-, read standard input. Mandatory arguments to long options are mandatory for short options too. .TP \fB\-c\fR, \fB\-\-bytes\fR=\fIK\fR -output the last K bytes; alternatively, use +K to -output bytes starting with the Kth of each file +output the last K bytes; alternatively, use \fB\-c\fR +K +to output bytes starting with the Kth of each file .TP \fB\-f\fR, \fB\-\-follow[=\fR{name|descriptor}] output appended data as the file grows; @@ -28,7 +28,7 @@ same as \fB\-\-follow\fR=\fIname\fR \fB\-\-retry\fR .TP \fB\-n\fR, \fB\-\-lines\fR=\fIK\fR output the last K lines, instead of the last 10; -or use +K to output lines starting with the Kth +or use \fB\-n\fR +K to output lines starting with the Kth .TP \fB\-\-max\-unchanged\-stats\fR=\fIN\fR with \fB\-\-follow\fR=\fIname\fR, reopen a FILE which has not @@ -71,8 +71,7 @@ means that even if a tail'ed file is renamed, tail will continue to track its end. This default behavior is not desirable when you really want to track the actual name of the file, not the file descriptor (e.g., log rotation). Use \fB\-\-follow\fR=\fIname\fR in that case. That causes tail to track the -named file by reopening it periodically to see if it has been removed and -recreated by some other program. +named file in a way that accommodates renaming, removal and creation. .SH AUTHOR Written by Paul Rubin, David MacKenzie, Ian Lance Taylor, and Jim Meyering. @@ -82,8 +81,10 @@ Report tail bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report tail translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/tee.1 b/src/bin/coreutils/man/tee.1 index 39e8879f89..ce53a9ffe0 100644 --- a/src/bin/coreutils/man/tee.1 +++ b/src/bin/coreutils/man/tee.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH TEE "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH TEE "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME tee \- read from standard input and write to standard output and files .SH SYNOPSIS @@ -31,8 +31,10 @@ Report tee bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report tee translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/test.1 b/src/bin/coreutils/man/test.1 index 4736c97c7f..3569a4dd8d 100644 --- a/src/bin/coreutils/man/test.1 +++ b/src/bin/coreutils/man/test.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH TEST "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH TEST "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME test \- check file types and compare values .SH SYNOPSIS @@ -160,8 +160,10 @@ Report test bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report test translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/timeout.1 b/src/bin/coreutils/man/timeout.1 index 0442eadc9c..d2424c24cc 100644 --- a/src/bin/coreutils/man/timeout.1 +++ b/src/bin/coreutils/man/timeout.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH TIMEOUT "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH TIMEOUT "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME timeout \- run a command with a time limit .SH SYNOPSIS @@ -29,12 +29,11 @@ display this help and exit \fB\-\-version\fR output version information and exit .PP -If the command times out, then we exit with status 124, -otherwise the normal exit status of the command is returned. -If no signal is specified, the TERM signal is sent. The TERM signal -will kill processes which do not catch this signal. For other processes, -it may be necessary to use the KILL (9) signal, since this signal cannot -be caught. +If the command times out, then exit with status 124. Otherwise, exit +with the status of COMMAND. If no signal is specified, send the TERM +signal upon timeout. The TERM signal kills any process that does not +block or catch that signal. For other processes, it may be necessary to +use the KILL (9) signal, since this signal cannot be caught. .SH AUTHOR Written by Padraig Brady. .SH "REPORTING BUGS" @@ -43,8 +42,10 @@ Report timeout bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report timeout translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/touch.1 b/src/bin/coreutils/man/touch.1 index 13bde42366..3c8b140a84 100644 --- a/src/bin/coreutils/man/touch.1 +++ b/src/bin/coreutils/man/touch.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH TOUCH "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH TOUCH "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME touch \- change file timestamps .SH SYNOPSIS @@ -10,7 +10,8 @@ touch \- change file timestamps .PP Update the access and modification times of each FILE to the current time. .PP -A FILE argument that does not exist is created empty. +A FILE argument that does not exist is created empty, unless \fB\-c\fR or \fB\-h\fR +is supplied. .PP A FILE argument string of \- is handled specially and causes touch to change the times of the file associated with standard output. @@ -29,6 +30,11 @@ parse STRING and use it instead of current time \fB\-f\fR (ignored) .TP +\fB\-h\fR, \fB\-\-no\-dereference\fR +affect each symbolic link instead of any referenced +file (useful only on systems that can change the +timestamps of a symlink) +.TP \fB\-m\fR change only the modification time .TP @@ -68,8 +74,10 @@ Report touch bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report touch translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/tr.1 b/src/bin/coreutils/man/tr.1 index 831178623c..637303defc 100644 --- a/src/bin/coreutils/man/tr.1 +++ b/src/bin/coreutils/man/tr.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH TR "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH TR "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME tr \- translate or delete characters .SH SYNOPSIS @@ -125,8 +125,10 @@ Report tr bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report tr translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/true.1 b/src/bin/coreutils/man/true.1 index 5f9a205b67..95ef052dec 100644 --- a/src/bin/coreutils/man/true.1 +++ b/src/bin/coreutils/man/true.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH TRUE "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH TRUE "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME true \- do nothing, successfully .SH SYNOPSIS @@ -30,8 +30,10 @@ Report true bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report true translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/truncate.1 b/src/bin/coreutils/man/truncate.1 index d0d1c1a487..ed57fed530 100644 --- a/src/bin/coreutils/man/truncate.1 +++ b/src/bin/coreutils/man/truncate.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH TRUNCATE "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH TRUNCATE "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME truncate \- shrink or extend the size of a file to the specified size .SH SYNOPSIS @@ -52,8 +52,10 @@ Report truncate bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report truncate translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/tsort.1 b/src/bin/coreutils/man/tsort.1 index f83d94ebf7..92594ecd02 100644 --- a/src/bin/coreutils/man/tsort.1 +++ b/src/bin/coreutils/man/tsort.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH TSORT "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH TSORT "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME tsort \- perform topological sort .SH SYNOPSIS @@ -24,8 +24,10 @@ Report tsort bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report tsort translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/tty.1 b/src/bin/coreutils/man/tty.1 index b34f5076e0..3100e17777 100644 --- a/src/bin/coreutils/man/tty.1 +++ b/src/bin/coreutils/man/tty.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH TTY "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH TTY "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME tty \- print the file name of the terminal connected to standard input .SH SYNOPSIS @@ -26,8 +26,10 @@ Report tty bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report tty translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/uname.1 b/src/bin/coreutils/man/uname.1 index a879de7eb5..254611e885 100644 --- a/src/bin/coreutils/man/uname.1 +++ b/src/bin/coreutils/man/uname.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH UNAME "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH UNAME "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME uname \- print system information .SH SYNOPSIS @@ -51,8 +51,10 @@ Report uname bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report uname translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/unexpand.1 b/src/bin/coreutils/man/unexpand.1 index bc63e0dfb2..4c35cfecc6 100644 --- a/src/bin/coreutils/man/unexpand.1 +++ b/src/bin/coreutils/man/unexpand.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH UNEXPAND "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH UNEXPAND "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME unexpand \- convert spaces to tabs .SH SYNOPSIS @@ -38,8 +38,10 @@ Report unexpand bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report unexpand translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/uniq.1 b/src/bin/coreutils/man/uniq.1 index c28d92e040..5b4b59a865 100644 --- a/src/bin/coreutils/man/uniq.1 +++ b/src/bin/coreutils/man/uniq.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH UNIQ "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH UNIQ "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME uniq \- report or omit repeated lines .SH SYNOPSIS @@ -64,8 +64,10 @@ Report uniq bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report uniq translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/unlink.1 b/src/bin/coreutils/man/unlink.1 index 8209c93d88..2e218632d5 100644 --- a/src/bin/coreutils/man/unlink.1 +++ b/src/bin/coreutils/man/unlink.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH UNLINK "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH UNLINK "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME unlink \- call the unlink function to remove the specified file .SH SYNOPSIS @@ -26,8 +26,10 @@ Report unlink bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report unlink translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/uptime.1 b/src/bin/coreutils/man/uptime.1 index 4ac0bdf331..5946f2d516 100644 --- a/src/bin/coreutils/man/uptime.1 +++ b/src/bin/coreutils/man/uptime.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH UPTIME "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH UPTIME "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME uptime \- tell how long the system has been running .SH SYNOPSIS @@ -27,8 +27,10 @@ Report uptime bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report uptime translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/users.1 b/src/bin/coreutils/man/users.1 index a4b6728dc4..8d6eaa53c0 100644 --- a/src/bin/coreutils/man/users.1 +++ b/src/bin/coreutils/man/users.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH USERS "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH USERS "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME users \- print the user names of users currently logged in to the current host .SH SYNOPSIS @@ -24,8 +24,10 @@ Report users bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report users translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/vdir.1 b/src/bin/coreutils/man/vdir.1 index baaac9ee36..af3371ed8c 100644 --- a/src/bin/coreutils/man/vdir.1 +++ b/src/bin/coreutils/man/vdir.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH VDIR "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH VDIR "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME vdir \- list directory contents .SH SYNOPSIS @@ -41,8 +41,8 @@ otherwise: sort by ctime list entries by columns .TP \fB\-\-color\fR[=\fIWHEN\fR] -control whether color is used to distinguish file -types. WHEN may be `never', `always', or `auto' +colorize the output. WHEN defaults to `always' +or can be `never' or `auto'. More info below .TP \fB\-d\fR, \fB\-\-directory\fR list directory entries instead of contents, @@ -221,12 +221,10 @@ output version information and exit SIZE may be (or may be an integer optionally followed by) one of following: KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y. .PP -By default, color is not used to distinguish types of files. That is -equivalent to using \fB\-\-color\fR=\fInone\fR. Using the \fB\-\-color\fR option without the -optional WHEN argument is equivalent to using \fB\-\-color\fR=\fIalways\fR. With -\fB\-\-color\fR=\fIauto\fR, color codes are output only if standard output is connected -to a terminal (tty). The environment variable LS_COLORS can influence the -colors, and can be set easily by the dircolors command. +Using color to distinguish file types is disabled both by default and +with \fB\-\-color\fR=\fInever\fR. With \fB\-\-color\fR=\fIauto\fR, ls emits color codes only when +standard output is connected to a terminal. The LS_COLORS environment +variable can change the settings. Use the dircolors command to set it. .SS "Exit status:" .TP 0 @@ -245,8 +243,10 @@ Report vdir bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report vdir translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/wc.1 b/src/bin/coreutils/man/wc.1 index 49bf92f689..dcf5a6216b 100644 --- a/src/bin/coreutils/man/wc.1 +++ b/src/bin/coreutils/man/wc.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH WC "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH WC "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME wc \- print newline, word, and byte counts for each file .SH SYNOPSIS @@ -48,8 +48,10 @@ Report wc bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report wc translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/who.1 b/src/bin/coreutils/man/who.1 index e2b002779e..79c9d8bb5e 100644 --- a/src/bin/coreutils/man/who.1 +++ b/src/bin/coreutils/man/who.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH WHO "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH WHO "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME who \- show who is logged on .SH SYNOPSIS @@ -74,8 +74,10 @@ Report who bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report who translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/whoami.1 b/src/bin/coreutils/man/whoami.1 index 393fd34d7c..4c3c325226 100644 --- a/src/bin/coreutils/man/whoami.1 +++ b/src/bin/coreutils/man/whoami.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH WHOAMI "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH WHOAMI "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME whoami \- print effective userid .SH SYNOPSIS @@ -24,8 +24,10 @@ Report whoami bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report whoami translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/man/yes.1 b/src/bin/coreutils/man/yes.1 index d31d977be3..4ceeb09c56 100644 --- a/src/bin/coreutils/man/yes.1 +++ b/src/bin/coreutils/man/yes.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35. -.TH YES "1" "September 2009" "GNU coreutils 7.5.88-dd7f8" "User Commands" +.TH YES "1" "January 2010" "GNU coreutils 8.3.10-a4da4" "User Commands" .SH NAME yes \- output a string repeatedly until killed .SH SYNOPSIS @@ -26,8 +26,10 @@ Report yes bugs to bug\-coreutils@gnu.org GNU coreutils home page: .br General help using GNU software: +.br +Report yes translation bugs to .SH COPYRIGHT -Copyright \(co 2009 Free Software Foundation, Inc. +Copyright \(co 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . .br This is free software: you are free to change and redistribute it. diff --git a/src/bin/coreutils/src/Jamfile b/src/bin/coreutils/src/Jamfile index 98d6be9d95..6678f5d5be 100644 --- a/src/bin/coreutils/src/Jamfile +++ b/src/bin/coreutils/src/Jamfile @@ -41,6 +41,7 @@ StdBinCommands mknod.c nl.c nohup.c + nproc.c od.c paste.c pathchk.c diff --git a/src/bin/coreutils/src/Makefile.am b/src/bin/coreutils/src/Makefile.am index 90e11c65a7..c73f7dc072 100644 --- a/src/bin/coreutils/src/Makefile.am +++ b/src/bin/coreutils/src/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to produce Makefile.in -*-Makefile-*- -## Copyright (C) 1990, 1991, 1993-2009 Free Software Foundation, Inc. +## Copyright (C) 1990-1991, 1993-2010 Free Software Foundation, Inc. ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -24,25 +24,115 @@ no_install__progs = \ arch hostname su build_if_possible__progs = \ - chroot df hostid nice pinky stdbuf libstdbuf.so stty su uname uptime users who + chroot \ + df \ + hostid \ + libstdbuf.so \ + nice \ + pinky \ + stdbuf \ + stty \ + su \ + uptime \ + users \ + who AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) EXTRA_PROGRAMS = \ $(no_install__progs) \ $(build_if_possible__progs) \ - [ chcon chgrp chown chmod cp dd dircolors du \ - ginstall link ln dir vdir ls mkdir \ - mkfifo mknod mktemp \ - mv nohup readlink rm rmdir shred stat sync touch unlink \ - cat cksum comm csplit cut expand fmt fold head join groups md5sum \ - nl od paste pr ptx sha1sum sha224sum sha256sum sha384sum sha512sum \ - shuf sort split sum tac tail tr tsort unexpand uniq wc \ - basename date dirname echo env expr factor false \ - id kill logname pathchk printenv printf pwd \ - runcon seq sleep tee \ - test timeout true truncate tty whoami yes \ - base64 + [ \ + base64 \ + basename \ + cat \ + chcon \ + chgrp \ + chmod \ + chown \ + cksum \ + comm \ + cp \ + csplit \ + cut \ + date \ + dd \ + dir \ + dircolors \ + dirname \ + du \ + echo \ + env \ + expand \ + expr \ + factor \ + false \ + fmt \ + fold \ + ginstall \ + groups \ + head \ + id \ + join \ + kill \ + link \ + ln \ + logname \ + ls \ + md5sum \ + mkdir \ + mkfifo \ + mknod \ + mktemp \ + mv \ + nl \ + nproc \ + nohup \ + od \ + paste \ + pathchk \ + pr \ + printenv \ + printf \ + ptx \ + pwd \ + readlink \ + rm \ + rmdir \ + runcon \ + seq \ + sha1sum \ + sha224sum \ + sha256sum \ + sha384sum \ + sha512sum \ + shred \ + shuf \ + sleep \ + sort \ + split \ + stat \ + sum \ + sync \ + tac \ + tail \ + tee \ + test \ + timeout \ + touch \ + tr \ + true \ + truncate \ + tsort \ + tty \ + uname \ + unexpand \ + uniq \ + unlink \ + vdir \ + wc \ + whoami \ + yes bin_PROGRAMS = $(OPTIONAL_BIN_PROGS) @@ -50,20 +140,20 @@ noinst_PROGRAMS = setuidgid getlimits pkglib_PROGRAMS = $(OPTIONAL_PKGLIB_PROGS) -noinst_HEADERS = \ - chown-core.h \ - copy.h \ - cp-hash.h \ - dircolors.h \ - fs.h \ - group-list.h \ - ls.h \ - operand2sig.h \ - prog-fprintf.h \ - remove.h \ - system.h \ - wheel-size.h \ - wheel.h \ +noinst_HEADERS = \ + chown-core.h \ + copy.h \ + cp-hash.h \ + dircolors.h \ + fs.h \ + group-list.h \ + ls.h \ + operand2sig.h \ + prog-fprintf.h \ + remove.h \ + system.h \ + wheel-size.h \ + wheel.h \ uname.h EXTRA_DIST = dcgen dircolors.hin tac-pipe.c \ @@ -87,99 +177,219 @@ nodist_libver_a_SOURCES = version.c version.h # replacement functions defined in libcoreutils.a. LDADD = libver.a ../lib/libcoreutils.a $(LIBINTL) ../lib/libcoreutils.a +# First, list all programs, to make listing per-program libraries easier. +# See [ below. +arch_LDADD = $(LDADD) +base64_LDADD = $(LDADD) +basename_LDADD = $(LDADD) cat_LDADD = $(LDADD) +chcon_LDADD = $(LDADD) +chgrp_LDADD = $(LDADD) +chmod_LDADD = $(LDADD) +chown_LDADD = $(LDADD) +chroot_LDADD = $(LDADD) +cksum_LDADD = $(LDADD) +comm_LDADD = $(LDADD) +nproc_LDADD = $(LDADD) +cp_LDADD = $(LDADD) +csplit_LDADD = $(LDADD) +cut_LDADD = $(LDADD) +date_LDADD = $(LDADD) +dd_LDADD = $(LDADD) df_LDADD = $(LDADD) +# See dir_LDADD below +dircolors_LDADD = $(LDADD) +dirname_LDADD = $(LDADD) du_LDADD = $(LDADD) +echo_LDADD = $(LDADD) +env_LDADD = $(LDADD) +expand_LDADD = $(LDADD) +expr_LDADD = $(LDADD) +factor_LDADD = $(LDADD) +false_LDADD = $(LDADD) +fmt_LDADD = $(LDADD) +fold_LDADD = $(LDADD) getlimits_LDADD = $(LDADD) +ginstall_LDADD = $(LDADD) +groups_LDADD = $(LDADD) +head_LDADD = $(LDADD) +hostid_LDADD = $(LDADD) +hostname_LDADD = $(LDADD) +id_LDADD = $(LDADD) +join_LDADD = $(LDADD) +kill_LDADD = $(LDADD) +link_LDADD = $(LDADD) +ln_LDADD = $(LDADD) +logname_LDADD = $(LDADD) +ls_LDADD = $(LDADD) +md5sum_LDADD = $(LDADD) +mkdir_LDADD = $(LDADD) +mkfifo_LDADD = $(LDADD) +mknod_LDADD = $(LDADD) +mktemp_LDADD = $(LDADD) +mv_LDADD = $(LDADD) +nice_LDADD = $(LDADD) +nl_LDADD = $(LDADD) +nohup_LDADD = $(LDADD) +od_LDADD = $(LDADD) +paste_LDADD = $(LDADD) +pathchk_LDADD = $(LDADD) +pinky_LDADD = $(LDADD) +pr_LDADD = $(LDADD) +printenv_LDADD = $(LDADD) +printf_LDADD = $(LDADD) ptx_LDADD = $(LDADD) +pwd_LDADD = $(LDADD) +readlink_LDADD = $(LDADD) +rm_LDADD = $(LDADD) +rmdir_LDADD = $(LDADD) +runcon_LDADD = $(LDADD) +seq_LDADD = $(LDADD) +setuidgid_LDADD = $(LDADD) +sha1sum_LDADD = $(LDADD) +sha224sum_LDADD = $(LDADD) +sha256sum_LDADD = $(LDADD) +sha384sum_LDADD = $(LDADD) +sha512sum_LDADD = $(LDADD) +shred_LDADD = $(LDADD) +shuf_LDADD = $(LDADD) +sleep_LDADD = $(LDADD) +sort_LDADD = $(LDADD) split_LDADD = $(LDADD) +stat_LDADD = $(LDADD) stdbuf_LDADD = $(LDADD) +stty_LDADD = $(LDADD) +su_LDADD = $(LDADD) +sum_LDADD = $(LDADD) +sync_LDADD = $(LDADD) +tac_LDADD = $(LDADD) +tail_LDADD = $(LDADD) +tee_LDADD = $(LDADD) +test_LDADD = $(LDADD) timeout_LDADD = $(LDADD) +touch_LDADD = $(LDADD) +tr_LDADD = $(LDADD) +true_LDADD = $(LDADD) truncate_LDADD = $(LDADD) +tsort_LDADD = $(LDADD) +tty_LDADD = $(LDADD) +uname_LDADD = $(LDADD) +unexpand_LDADD = $(LDADD) +uniq_LDADD = $(LDADD) +unlink_LDADD = $(LDADD) +uptime_LDADD = $(LDADD) +users_LDADD = $(LDADD) +# See vdir_LDADD below +wc_LDADD = $(LDADD) +who_LDADD = $(LDADD) +whoami_LDADD = $(LDADD) +yes_LDADD = $(LDADD) -# for eaccess in lib/euidaccess.c. -chcon_LDADD = $(LDADD) $(LIB_SELINUX) -cp_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX) -ginstall_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX) -mkdir_LDADD = $(LDADD) $(LIB_SELINUX) -mkfifo_LDADD = $(LDADD) $(LIB_SELINUX) -mknod_LDADD = $(LDADD) $(LIB_SELINUX) -mv_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX) -runcon_LDADD = $(LDADD) $(LIB_SELINUX) -pathchk_LDADD = $(LDADD) $(LIB_EACCESS) -rm_LDADD = $(LDADD) $(LIB_EACCESS) -test_LDADD = $(LDADD) $(LIB_EACCESS) -# This is for the '[' program. Automake transliterates '[' to '_'. -__LDADD = $(LDADD) $(LIB_EACCESS) +# Synonyms. Recall that Automake transliterates '[' to '_'. +__LDADD = $(test_LDADD) +dir_LDADD = $(ls_LDADD) +vdir_LDADD = $(ls_LDADD) -# for clock_gettime and fdatasync -dd_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC) -dir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) $(LIB_CAP) -id_LDADD = $(LDADD) $(LIB_SELINUX) -ls_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) $(LIB_CAP) -mktemp_LDADD = $(LDADD) $(LIB_GETHRXTIME) -pr_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) -shred_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC) -shuf_LDADD = $(LDADD) $(LIB_GETHRXTIME) -tac_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) -vdir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) $(LIB_CAP) +# Shared files +copy_LDADD = +cp_LDADD += $(copy_LDADD) +ginstall_LDADD += $(copy_LDADD) +mv_LDADD += $(copy_LDADD) -## If necessary, add -lm to resolve use of pow in lib/strtod.c. -sort_LDADD = $(LDADD) $(POW_LIB) $(LIB_GETHRXTIME) +remove_LDADD = +mv_LDADD += $(remove_LDADD) +rm_LDADD += $(remove_LDADD) -# for get_date and gettime -date_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) -touch_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) +# for eaccess, euidaccess +copy_LDADD += $(LIB_EACCESS) +remove_LDADD += $(LIB_EACCESS) +test_LDADD += $(LIB_EACCESS) -# If necessary, add -lm to resolve use of pow in lib/strtod.c. -# If necessary, add -liconv to resolve use of iconv in lib/unicodeio.c. -printf_LDADD = $(LDADD) $(POW_LIB) $(LIBICONV) +# for selinux use +chcon_LDADD += $(LIB_SELINUX) +copy_LDADD += $(LIB_SELINUX) +ginstall_LDADD += $(LIB_SELINUX) +id_LDADD += $(LIB_SELINUX) +ls_LDADD += $(LIB_SELINUX) +mkdir_LDADD += $(LIB_SELINUX) +mkfifo_LDADD += $(LIB_SELINUX) +mknod_LDADD += $(LIB_SELINUX) +runcon_LDADD += $(LIB_SELINUX) +stat_LDADD += $(LIB_SELINUX) -# If necessary, add -lm to resolve use of pow in lib/strtod.c. -seq_LDADD = $(LDADD) $(POW_LIB) +# for gettime, settime, utimecmp, utimens +copy_LDADD += $(LIB_CLOCK_GETTIME) +date_LDADD += $(LIB_CLOCK_GETTIME) +ginstall_LDADD += $(LIB_CLOCK_GETTIME) +ls_LDADD += $(LIB_CLOCK_GETTIME) +pr_LDADD += $(LIB_CLOCK_GETTIME) +touch_LDADD += $(LIB_CLOCK_GETTIME) -# If necessary, add libraries to resolve the `pow' reference in lib/strtod.c -# and the `nanosleep' reference in lib/xnanosleep.c. -nanosec_libs = $(LDADD) $(POW_LIB) $(LIB_NANOSLEEP) +# for gethrxtime, randint, randread, gen_tempname, mkstemp +dd_LDADD += $(LIB_GETHRXTIME) +mktemp_LDADD += $(LIB_GETHRXTIME) +shred_LDADD += $(LIB_GETHRXTIME) +shuf_LDADD += $(LIB_GETHRXTIME) +sort_LDADD += $(LIB_GETHRXTIME) +tac_LDADD += $(LIB_GETHRXTIME) + +# for cap_get_file +ls_LDADD += $(LIB_CAP) + +# for fdatasync +dd_LDADD += $(LIB_FDATASYNC) +shred_LDADD += $(LIB_FDATASYNC) + +# for strtod, strtold +printf_LDADD += $(POW_LIB) +seq_LDADD += $(POW_LIB) +sleep_LDADD += $(POW_LIB) +sort_LDADD += $(POW_LIB) +tail_LDADD += $(POW_LIB) +uptime_LDADD += $(POW_LIB) + +# for xnanosleep +sleep_LDADD += $(LIB_NANOSLEEP) +sort_LDADD += $(LIB_NANOSLEEP) +tail_LDADD += $(LIB_NANOSLEEP) # for various GMP functions -expr_LDADD = $(LDADD) $(LIB_GMP) +expr_LDADD += $(LIB_GMP) +factor_LDADD += $(LIB_GMP) -# for various GMP functions -factor_LDADD = $(LDADD) $(LIB_GMP) +# for getloadavg +uptime_LDADD += $(GETLOADAVG_LIBS) -sleep_LDADD = $(nanosec_libs) -tail_LDADD = $(nanosec_libs) +# for crypt +su_LDADD += $(LIB_CRYPT) -# If necessary, add -lm to resolve use of pow in lib/strtod.c. -uptime_LDADD = $(LDADD) $(POW_LIB) $(GETLOADAVG_LIBS) - -su_LDADD = $(LDADD) $(LIB_CRYPT) - -dir_LDADD += $(LIB_ACL) +# for various ACL functions +copy_LDADD += $(LIB_ACL) ls_LDADD += $(LIB_ACL) -vdir_LDADD += $(LIB_ACL) -cp_LDADD += $(LIB_ACL) $(LIB_XATTR) -mv_LDADD += $(LIB_ACL) $(LIB_XATTR) -ginstall_LDADD += $(LIB_ACL) $(LIB_XATTR) -stat_LDADD = $(LDADD) $(LIB_SELINUX) +# for various xattr functions +copy_LDADD += $(LIB_XATTR) -# Append $(LIBICONV) to each program that uses proper_name_utf8. +# for print_unicode_char, proper_name_utf8 cat_LDADD += $(LIBICONV) cp_LDADD += $(LIBICONV) df_LDADD += $(LIBICONV) du_LDADD += $(LIBICONV) getlimits_LDADD += $(LIBICONV) +printf_LDADD += $(LIBICONV) ptx_LDADD += $(LIBICONV) split_LDADD += $(LIBICONV) stdbuf_LDADD += $(LIBICONV) timeout_LDADD += $(LIBICONV) truncate_LDADD += $(LIBICONV) -# programs that use getaddrinfo (e.g., via canon_host) -pinky_LDADD = $(LDADD) $(GETADDRINFO_LIB) -who_LDADD = $(LDADD) $(GETADDRINFO_LIB) +# for canon_host +pinky_LDADD += $(GETADDRINFO_LIB) +who_LDADD += $(GETADDRINFO_LIB) + +# for gethostname, uname +hostname_LDADD += $(GETHOSTNAME_LIB) +uname_LDADD += $(GETHOSTNAME_LIB) $(PROGRAMS): ../lib/libcoreutils.a @@ -274,6 +484,7 @@ rmdir_SOURCES = rmdir.c prog-fprintf.c uname_SOURCES = uname.c uname-uname.c arch_SOURCES = uname.c uname-arch.c +nproc_SOURCES = nproc.c md5sum_SOURCES = md5sum.c md5sum_CPPFLAGS = -DHASH_ALGO_MD5=1 $(AM_CPPFLAGS) @@ -330,6 +541,59 @@ wheel.h: wheel-gen.pl Makefile.am # Tell automake to exempt then from that installcheck test. AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = false test +# Compare fs.h with the list of file system names/magic-numbers in the +# Linux statfs man page. This target prints any new name/number pairs. +# Also compare against /usr/include/linux/magic.h +.PHONY: fs-magic-compare +fs-magic-compare: fs-magic fs-kernel-magic fs-def + join -v1 -t@ fs-magic fs-def + join -v1 -t@ fs-kernel-magic fs-def + +CLEANFILES += fs-def +fs-def: fs.h + grep '^# *define ' $< > $@-t && mv $@-t $@ + +# Massage bits of the statfs man page and definitions from +# /usr/include/linux/magic.h to be in a form consistent with what's in fs.h. +fs_normalize_perl_subst = \ + -e 's/MINIX_SUPER_MAGIC\b/MINIX/;' \ + -e 's/MINIX_SUPER_MAGIC2\b/MINIX_30/;' \ + -e 's/MINIX2_SUPER_MAGIC\b/MINIX_V2/;' \ + -e 's/MINIX2_SUPER_MAGIC2\b/MINIX_V2_30/;' \ + -e 's/MINIX3_SUPER_MAGIC\b/MINIX_V3/;' \ + -e 's/CIFS_MAGIC_NUMBER/CIFS/;' \ + -e 's/(_SUPER)?_MAGIC//;' \ + -e 's/\s+0x(\S+)/" 0x" . uc $$1/e;' \ + -e 's/(\s+0x)(\X{3})\b/$${1}0$$2/;' \ + -e 's/(\s+0x)(\X{6})\b/$${1}00$$2/;' \ + -e 's/(\s+0x)(\X{7})\b/$${1}0$$2/;' \ + -e 's/^\s+//;' \ + -e 's/^\#define\s+//;' \ + -e 's/^_(XIAFS)/$$1/;' \ + -e 's/^USBDEVICE/USBDEVFS/;' \ + -e 's/NTFS_SB/NTFS/;' \ + -e 's/^/\# define S_MAGIC_/;' \ + -e 's,\s*/\* .*? \*/,,;' + +CLEANFILES += fs-magic +fs-magic: Makefile + man statfs \ + |perl -ne '/File system types:/.../Nobody kno/ and print' \ + |grep 0x | perl -p \ + $(fs_normalize_perl_subst) \ + | grep -Ev 'S_MAGIC_EXT[34]|STACK_END' \ + | LC_ALL=C sort \ + > $@-t && mv $@-t $@ + +CLEANFILES += fs-kernel-magic +fs-kernel-magic: Makefile + perl -ne '/^#define.*0x/ and print' /usr/include/linux/magic.h \ + | perl -p \ + $(fs_normalize_perl_subst) \ + | grep -Ev 'S_MAGIC_EXT[34]|STACK_END' \ + | LC_ALL=C sort \ + > $@-t && mv $@-t $@ + BUILT_SOURCES += fs.h fs.h: stat.c extract-magic $(AM_V_GEN)rm -f $@ @@ -453,7 +717,7 @@ sc_tight_scope: $(bin_PROGRAMS) ( printf 'main\nusage\n_.*\n'; \ grep -h -A1 '^extern .*[^;]$$' $$src \ | grep -vE '^(extern |--)' | sed 's/ .*//'; \ - perl -ne '/^extern \S+ (\S*) \(/ and print "$$1\n"' $$hdr; \ + perl -ne '/^extern (?:enum )?\S+ (\S*) \(/ and print "$$1\n"' $$hdr; \ ) | $(ASSORT) -u | sed 's/^/^/;s/$$/$$/' > $$t; \ nm -e *.$(OBJEXT) \ | sed -n 's/.* T //p' \ diff --git a/src/bin/coreutils/src/Makefile.in b/src/bin/coreutils/src/Makefile.in index da9a05dbfd..5e95c6f600 100644 --- a/src/bin/coreutils/src/Makefile.in +++ b/src/bin/coreutils/src/Makefile.in @@ -36,29 +36,29 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ EXTRA_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) [$(EXEEXT) \ - chcon$(EXEEXT) chgrp$(EXEEXT) chown$(EXEEXT) chmod$(EXEEXT) \ - cp$(EXEEXT) dd$(EXEEXT) dircolors$(EXEEXT) du$(EXEEXT) \ - ginstall$(EXEEXT) link$(EXEEXT) ln$(EXEEXT) dir$(EXEEXT) \ - vdir$(EXEEXT) ls$(EXEEXT) mkdir$(EXEEXT) mkfifo$(EXEEXT) \ - mknod$(EXEEXT) mktemp$(EXEEXT) mv$(EXEEXT) nohup$(EXEEXT) \ - readlink$(EXEEXT) rm$(EXEEXT) rmdir$(EXEEXT) shred$(EXEEXT) \ - stat$(EXEEXT) sync$(EXEEXT) touch$(EXEEXT) unlink$(EXEEXT) \ - cat$(EXEEXT) cksum$(EXEEXT) comm$(EXEEXT) csplit$(EXEEXT) \ - cut$(EXEEXT) expand$(EXEEXT) fmt$(EXEEXT) fold$(EXEEXT) \ - head$(EXEEXT) join$(EXEEXT) groups$(EXEEXT) md5sum$(EXEEXT) \ - nl$(EXEEXT) od$(EXEEXT) paste$(EXEEXT) pr$(EXEEXT) \ - ptx$(EXEEXT) sha1sum$(EXEEXT) sha224sum$(EXEEXT) \ - sha256sum$(EXEEXT) sha384sum$(EXEEXT) sha512sum$(EXEEXT) \ - shuf$(EXEEXT) sort$(EXEEXT) split$(EXEEXT) sum$(EXEEXT) \ - tac$(EXEEXT) tail$(EXEEXT) tr$(EXEEXT) tsort$(EXEEXT) \ - unexpand$(EXEEXT) uniq$(EXEEXT) wc$(EXEEXT) basename$(EXEEXT) \ - date$(EXEEXT) dirname$(EXEEXT) echo$(EXEEXT) env$(EXEEXT) \ - expr$(EXEEXT) factor$(EXEEXT) false$(EXEEXT) id$(EXEEXT) \ - kill$(EXEEXT) logname$(EXEEXT) pathchk$(EXEEXT) \ - printenv$(EXEEXT) printf$(EXEEXT) pwd$(EXEEXT) runcon$(EXEEXT) \ - seq$(EXEEXT) sleep$(EXEEXT) tee$(EXEEXT) test$(EXEEXT) \ - timeout$(EXEEXT) true$(EXEEXT) truncate$(EXEEXT) tty$(EXEEXT) \ - whoami$(EXEEXT) yes$(EXEEXT) base64$(EXEEXT) + base64$(EXEEXT) basename$(EXEEXT) cat$(EXEEXT) chcon$(EXEEXT) \ + chgrp$(EXEEXT) chmod$(EXEEXT) chown$(EXEEXT) cksum$(EXEEXT) \ + comm$(EXEEXT) cp$(EXEEXT) csplit$(EXEEXT) cut$(EXEEXT) \ + date$(EXEEXT) dd$(EXEEXT) dir$(EXEEXT) dircolors$(EXEEXT) \ + dirname$(EXEEXT) du$(EXEEXT) echo$(EXEEXT) env$(EXEEXT) \ + expand$(EXEEXT) expr$(EXEEXT) factor$(EXEEXT) false$(EXEEXT) \ + fmt$(EXEEXT) fold$(EXEEXT) ginstall$(EXEEXT) groups$(EXEEXT) \ + head$(EXEEXT) id$(EXEEXT) join$(EXEEXT) kill$(EXEEXT) \ + link$(EXEEXT) ln$(EXEEXT) logname$(EXEEXT) ls$(EXEEXT) \ + md5sum$(EXEEXT) mkdir$(EXEEXT) mkfifo$(EXEEXT) mknod$(EXEEXT) \ + mktemp$(EXEEXT) mv$(EXEEXT) nl$(EXEEXT) nproc$(EXEEXT) \ + nohup$(EXEEXT) od$(EXEEXT) paste$(EXEEXT) pathchk$(EXEEXT) \ + pr$(EXEEXT) printenv$(EXEEXT) printf$(EXEEXT) ptx$(EXEEXT) \ + pwd$(EXEEXT) readlink$(EXEEXT) rm$(EXEEXT) rmdir$(EXEEXT) \ + runcon$(EXEEXT) seq$(EXEEXT) sha1sum$(EXEEXT) \ + sha224sum$(EXEEXT) sha256sum$(EXEEXT) sha384sum$(EXEEXT) \ + sha512sum$(EXEEXT) shred$(EXEEXT) shuf$(EXEEXT) sleep$(EXEEXT) \ + sort$(EXEEXT) split$(EXEEXT) stat$(EXEEXT) sum$(EXEEXT) \ + sync$(EXEEXT) tac$(EXEEXT) tail$(EXEEXT) tee$(EXEEXT) \ + test$(EXEEXT) timeout$(EXEEXT) touch$(EXEEXT) tr$(EXEEXT) \ + true$(EXEEXT) truncate$(EXEEXT) tsort$(EXEEXT) tty$(EXEEXT) \ + uname$(EXEEXT) unexpand$(EXEEXT) uniq$(EXEEXT) unlink$(EXEEXT) \ + vdir$(EXEEXT) wc$(EXEEXT) whoami$(EXEEXT) yes$(EXEEXT) noinst_PROGRAMS = setuidgid$(EXEEXT) getlimits$(EXEEXT) subdir = src DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ @@ -79,35 +79,40 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/cloexec.m4 $(top_srcdir)/m4/close-stream.m4 \ $(top_srcdir)/m4/close.m4 $(top_srcdir)/m4/closein.m4 \ $(top_srcdir)/m4/closeout.m4 $(top_srcdir)/m4/codeset.m4 \ - $(top_srcdir)/m4/config-h.m4 $(top_srcdir)/m4/cycle-check.m4 \ - $(top_srcdir)/m4/d-ino.m4 $(top_srcdir)/m4/d-type.m4 \ - $(top_srcdir)/m4/dirent-safer.m4 $(top_srcdir)/m4/dirent_h.m4 \ - $(top_srcdir)/m4/dirfd.m4 $(top_srcdir)/m4/dirname.m4 \ - $(top_srcdir)/m4/dos.m4 $(top_srcdir)/m4/double-slash-root.m4 \ - $(top_srcdir)/m4/dup2.m4 $(top_srcdir)/m4/eealloc.m4 \ - $(top_srcdir)/m4/environ.m4 $(top_srcdir)/m4/errno_h.m4 \ - $(top_srcdir)/m4/error.m4 $(top_srcdir)/m4/euidaccess-stat.m4 \ + $(top_srcdir)/m4/config-h.m4 $(top_srcdir)/m4/ctype.m4 \ + $(top_srcdir)/m4/cycle-check.m4 $(top_srcdir)/m4/d-ino.m4 \ + $(top_srcdir)/m4/d-type.m4 $(top_srcdir)/m4/dirent-safer.m4 \ + $(top_srcdir)/m4/dirent_h.m4 $(top_srcdir)/m4/dirfd.m4 \ + $(top_srcdir)/m4/dirname.m4 $(top_srcdir)/m4/dos.m4 \ + $(top_srcdir)/m4/double-slash-root.m4 $(top_srcdir)/m4/dup2.m4 \ + $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/environ.m4 \ + $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/error.m4 \ + $(top_srcdir)/m4/euidaccess-stat.m4 \ $(top_srcdir)/m4/euidaccess.m4 $(top_srcdir)/m4/exclude.m4 \ $(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/exponentd.m4 \ $(top_srcdir)/m4/exponentf.m4 $(top_srcdir)/m4/exponentl.m4 \ - $(top_srcdir)/m4/extensions.m4 $(top_srcdir)/m4/fchdir.m4 \ - $(top_srcdir)/m4/fclose.m4 $(top_srcdir)/m4/fcntl-safer.m4 \ - $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/fd-reopen.m4 \ - $(top_srcdir)/m4/fdopendir.m4 $(top_srcdir)/m4/fflush.m4 \ - $(top_srcdir)/m4/file-type.m4 $(top_srcdir)/m4/fileblocks.m4 \ - $(top_srcdir)/m4/filemode.m4 $(top_srcdir)/m4/filenamecat.m4 \ - $(top_srcdir)/m4/flexmember.m4 $(top_srcdir)/m4/float_h.m4 \ - $(top_srcdir)/m4/fnmatch.m4 $(top_srcdir)/m4/fopen.m4 \ - $(top_srcdir)/m4/fpending.m4 $(top_srcdir)/m4/fpieee.m4 \ - $(top_srcdir)/m4/fprintftime.m4 $(top_srcdir)/m4/fpurge.m4 \ - $(top_srcdir)/m4/freading.m4 $(top_srcdir)/m4/frexp.m4 \ + $(top_srcdir)/m4/extensions.m4 $(top_srcdir)/m4/faccessat.m4 \ + $(top_srcdir)/m4/fchdir.m4 $(top_srcdir)/m4/fclose.m4 \ + $(top_srcdir)/m4/fcntl-o.m4 $(top_srcdir)/m4/fcntl-safer.m4 \ + $(top_srcdir)/m4/fcntl.m4 $(top_srcdir)/m4/fcntl_h.m4 \ + $(top_srcdir)/m4/fd-reopen.m4 $(top_srcdir)/m4/fdopendir.m4 \ + $(top_srcdir)/m4/fflush.m4 $(top_srcdir)/m4/file-type.m4 \ + $(top_srcdir)/m4/fileblocks.m4 $(top_srcdir)/m4/filemode.m4 \ + $(top_srcdir)/m4/filenamecat.m4 $(top_srcdir)/m4/flexmember.m4 \ + $(top_srcdir)/m4/float_h.m4 $(top_srcdir)/m4/fnmatch.m4 \ + $(top_srcdir)/m4/fopen.m4 $(top_srcdir)/m4/fpending.m4 \ + $(top_srcdir)/m4/fpieee.m4 $(top_srcdir)/m4/fprintftime.m4 \ + $(top_srcdir)/m4/fpurge.m4 $(top_srcdir)/m4/freading.m4 \ + $(top_srcdir)/m4/freopen.m4 $(top_srcdir)/m4/frexp.m4 \ $(top_srcdir)/m4/frexpl.m4 $(top_srcdir)/m4/fseeko.m4 \ $(top_srcdir)/m4/fstypename.m4 $(top_srcdir)/m4/fsusage.m4 \ - $(top_srcdir)/m4/ftello.m4 $(top_srcdir)/m4/ftruncate.m4 \ - $(top_srcdir)/m4/fts.m4 $(top_srcdir)/m4/getaddrinfo.m4 \ + $(top_srcdir)/m4/fsync.m4 $(top_srcdir)/m4/ftello.m4 \ + $(top_srcdir)/m4/ftruncate.m4 $(top_srcdir)/m4/fts.m4 \ + $(top_srcdir)/m4/getaddrinfo.m4 \ $(top_srcdir)/m4/getcwd-abort-bug.m4 \ $(top_srcdir)/m4/getcwd-path-max.m4 $(top_srcdir)/m4/getcwd.m4 \ $(top_srcdir)/m4/getdate.m4 $(top_srcdir)/m4/getdelim.m4 \ + $(top_srcdir)/m4/getdtablesize.m4 \ $(top_srcdir)/m4/getgroups.m4 $(top_srcdir)/m4/gethostname.m4 \ $(top_srcdir)/m4/gethrxtime.m4 $(top_srcdir)/m4/getline.m4 \ $(top_srcdir)/m4/getloadavg.m4 $(top_srcdir)/m4/getndelim2.m4 \ @@ -131,24 +136,27 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intmax_t.m4 \ $(top_srcdir)/m4/inttostr.m4 $(top_srcdir)/m4/inttypes-pri.m4 \ $(top_srcdir)/m4/inttypes.m4 $(top_srcdir)/m4/inttypes_h.m4 \ - $(top_srcdir)/m4/isapipe.m4 $(top_srcdir)/m4/isnand.m4 \ - $(top_srcdir)/m4/isnanf.m4 $(top_srcdir)/m4/isnanl.m4 \ - $(top_srcdir)/m4/jm-macros.m4 $(top_srcdir)/m4/jm-winsz1.m4 \ - $(top_srcdir)/m4/jm-winsz2.m4 $(top_srcdir)/m4/lchmod.m4 \ + $(top_srcdir)/m4/isapipe.m4 $(top_srcdir)/m4/isblank.m4 \ + $(top_srcdir)/m4/isnand.m4 $(top_srcdir)/m4/isnanf.m4 \ + $(top_srcdir)/m4/isnanl.m4 $(top_srcdir)/m4/jm-macros.m4 \ + $(top_srcdir)/m4/jm-winsz1.m4 $(top_srcdir)/m4/jm-winsz2.m4 \ + $(top_srcdir)/m4/langinfo_h.m4 $(top_srcdir)/m4/lchmod.m4 \ $(top_srcdir)/m4/lchown.m4 $(top_srcdir)/m4/ldexpl.m4 \ $(top_srcdir)/m4/lib-check.m4 $(top_srcdir)/m4/lib-ignore.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/link-follow.m4 \ - $(top_srcdir)/m4/link.m4 $(top_srcdir)/m4/localcharset.m4 \ - $(top_srcdir)/m4/locale-fr.m4 $(top_srcdir)/m4/locale-ja.m4 \ - $(top_srcdir)/m4/locale-tr.m4 $(top_srcdir)/m4/locale-zh.m4 \ - $(top_srcdir)/m4/long-options.m4 $(top_srcdir)/m4/longlong.m4 \ - $(top_srcdir)/m4/ls-mntd-fs.m4 $(top_srcdir)/m4/lseek.m4 \ - $(top_srcdir)/m4/lstat.m4 $(top_srcdir)/m4/malloc.m4 \ - $(top_srcdir)/m4/malloca.m4 $(top_srcdir)/m4/manywarnings.m4 \ - $(top_srcdir)/m4/math_h.m4 $(top_srcdir)/m4/mbchar.m4 \ - $(top_srcdir)/m4/mbiter.m4 $(top_srcdir)/m4/mbrlen.m4 \ - $(top_srcdir)/m4/mbrtowc.m4 $(top_srcdir)/m4/mbsinit.m4 \ + $(top_srcdir)/m4/link.m4 $(top_srcdir)/m4/linkat.m4 \ + $(top_srcdir)/m4/localcharset.m4 $(top_srcdir)/m4/locale-fr.m4 \ + $(top_srcdir)/m4/locale-ja.m4 $(top_srcdir)/m4/locale-tr.m4 \ + $(top_srcdir)/m4/locale-zh.m4 $(top_srcdir)/m4/locale_h.m4 \ + $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/long-options.m4 \ + $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/ls-mntd-fs.m4 \ + $(top_srcdir)/m4/lseek.m4 $(top_srcdir)/m4/lstat.m4 \ + $(top_srcdir)/m4/malloc.m4 $(top_srcdir)/m4/malloca.m4 \ + $(top_srcdir)/m4/manywarnings.m4 $(top_srcdir)/m4/math_h.m4 \ + $(top_srcdir)/m4/mbchar.m4 $(top_srcdir)/m4/mbiter.m4 \ + $(top_srcdir)/m4/mbrlen.m4 $(top_srcdir)/m4/mbrtowc.m4 \ + $(top_srcdir)/m4/mbsinit.m4 $(top_srcdir)/m4/mbslen.m4 \ $(top_srcdir)/m4/mbsrtowcs.m4 $(top_srcdir)/m4/mbstate_t.m4 \ $(top_srcdir)/m4/mbswidth.m4 $(top_srcdir)/m4/md5.m4 \ $(top_srcdir)/m4/memcasecmp.m4 $(top_srcdir)/m4/memchr.m4 \ @@ -157,34 +165,34 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/mempcpy.m4 $(top_srcdir)/m4/memrchr.m4 \ $(top_srcdir)/m4/memset.m4 $(top_srcdir)/m4/memxfrm.m4 \ $(top_srcdir)/m4/mgetgroups.m4 $(top_srcdir)/m4/mkancesdirs.m4 \ - $(top_srcdir)/m4/mkdir-p.m4 $(top_srcdir)/m4/mkdir-slash.m4 \ + $(top_srcdir)/m4/mkdir-p.m4 $(top_srcdir)/m4/mkdir.m4 \ $(top_srcdir)/m4/mkstemp.m4 $(top_srcdir)/m4/mktime.m4 \ $(top_srcdir)/m4/mmap-anon.m4 $(top_srcdir)/m4/mode_t.m4 \ $(top_srcdir)/m4/modechange.m4 $(top_srcdir)/m4/mountlist.m4 \ $(top_srcdir)/m4/mpsort.m4 $(top_srcdir)/m4/multiarch.m4 \ $(top_srcdir)/m4/nanosleep.m4 $(top_srcdir)/m4/netdb_h.m4 \ - $(top_srcdir)/m4/netinet_in_h.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/open.m4 \ - $(top_srcdir)/m4/openat.m4 $(top_srcdir)/m4/pathmax.m4 \ - $(top_srcdir)/m4/perl.m4 $(top_srcdir)/m4/perror.m4 \ - $(top_srcdir)/m4/physmem.m4 $(top_srcdir)/m4/po.m4 \ - $(top_srcdir)/m4/posix-shell.m4 $(top_srcdir)/m4/posixtm.m4 \ - $(top_srcdir)/m4/posixver.m4 $(top_srcdir)/m4/prereq.m4 \ - $(top_srcdir)/m4/printf-frexp.m4 \ + $(top_srcdir)/m4/netinet_in_h.m4 \ + $(top_srcdir)/m4/nl_langinfo.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/nproc.m4 \ + $(top_srcdir)/m4/open.m4 $(top_srcdir)/m4/openat.m4 \ + $(top_srcdir)/m4/pathmax.m4 $(top_srcdir)/m4/perl.m4 \ + $(top_srcdir)/m4/perror.m4 $(top_srcdir)/m4/physmem.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/posix-shell.m4 \ + $(top_srcdir)/m4/posixtm.m4 $(top_srcdir)/m4/posixver.m4 \ + $(top_srcdir)/m4/prereq.m4 $(top_srcdir)/m4/printf-frexp.m4 \ $(top_srcdir)/m4/printf-frexpl.m4 $(top_srcdir)/m4/printf.m4 \ $(top_srcdir)/m4/priv-set.m4 $(top_srcdir)/m4/progtest.m4 \ $(top_srcdir)/m4/putenv.m4 $(top_srcdir)/m4/quote.m4 \ $(top_srcdir)/m4/quotearg.m4 $(top_srcdir)/m4/read-file.m4 \ $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/readtokens.m4 \ $(top_srcdir)/m4/readutmp.m4 $(top_srcdir)/m4/realloc.m4 \ - $(top_srcdir)/m4/regex.m4 \ - $(top_srcdir)/m4/rename-dest-slash.m4 \ - $(top_srcdir)/m4/rename.m4 $(top_srcdir)/m4/rmdir-errno.m4 \ - $(top_srcdir)/m4/rmdir.m4 $(top_srcdir)/m4/root-dev-ino.m4 \ - $(top_srcdir)/m4/rpmatch.m4 $(top_srcdir)/m4/safe-read.m4 \ - $(top_srcdir)/m4/safe-write.m4 $(top_srcdir)/m4/same.m4 \ - $(top_srcdir)/m4/save-cwd.m4 $(top_srcdir)/m4/savedir.m4 \ - $(top_srcdir)/m4/savewd.m4 $(top_srcdir)/m4/select.m4 \ + $(top_srcdir)/m4/regex.m4 $(top_srcdir)/m4/remove.m4 \ + $(top_srcdir)/m4/rename.m4 $(top_srcdir)/m4/rmdir.m4 \ + $(top_srcdir)/m4/root-dev-ino.m4 $(top_srcdir)/m4/rpmatch.m4 \ + $(top_srcdir)/m4/safe-read.m4 $(top_srcdir)/m4/safe-write.m4 \ + $(top_srcdir)/m4/same.m4 $(top_srcdir)/m4/save-cwd.m4 \ + $(top_srcdir)/m4/savedir.m4 $(top_srcdir)/m4/savewd.m4 \ + $(top_srcdir)/m4/select.m4 \ $(top_srcdir)/m4/selinux-context-h.m4 \ $(top_srcdir)/m4/selinux-selinux-h.m4 \ $(top_srcdir)/m4/servent.m4 $(top_srcdir)/m4/setenv.m4 \ @@ -198,38 +206,45 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/socklen.m4 $(top_srcdir)/m4/sockpfaf.m4 \ $(top_srcdir)/m4/ssize_t.m4 $(top_srcdir)/m4/st_dm_mode.m4 \ $(top_srcdir)/m4/stat-prog.m4 $(top_srcdir)/m4/stat-time.m4 \ - $(top_srcdir)/m4/stdarg.m4 $(top_srcdir)/m4/stdbool.m4 \ - $(top_srcdir)/m4/stddef_h.m4 $(top_srcdir)/m4/stdint.m4 \ - $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/stdio-safer.m4 \ - $(top_srcdir)/m4/stdio_h.m4 $(top_srcdir)/m4/stdlib-safer.m4 \ - $(top_srcdir)/m4/stdlib_h.m4 $(top_srcdir)/m4/stpcpy.m4 \ - $(top_srcdir)/m4/stpncpy.m4 $(top_srcdir)/m4/strcspn.m4 \ - $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \ - $(top_srcdir)/m4/strftime.m4 $(top_srcdir)/m4/string_h.m4 \ - $(top_srcdir)/m4/strndup.m4 $(top_srcdir)/m4/strnlen.m4 \ - $(top_srcdir)/m4/strnumcmp.m4 $(top_srcdir)/m4/strpbrk.m4 \ + $(top_srcdir)/m4/stat.m4 $(top_srcdir)/m4/stdarg.m4 \ + $(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stddef_h.m4 \ + $(top_srcdir)/m4/stdint.m4 $(top_srcdir)/m4/stdint_h.m4 \ + $(top_srcdir)/m4/stdio-safer.m4 $(top_srcdir)/m4/stdio_h.m4 \ + $(top_srcdir)/m4/stdlib-safer.m4 $(top_srcdir)/m4/stdlib_h.m4 \ + $(top_srcdir)/m4/stpcpy.m4 $(top_srcdir)/m4/stpncpy.m4 \ + $(top_srcdir)/m4/strcspn.m4 $(top_srcdir)/m4/strdup.m4 \ + $(top_srcdir)/m4/strerror.m4 $(top_srcdir)/m4/strftime.m4 \ + $(top_srcdir)/m4/string_h.m4 $(top_srcdir)/m4/strndup.m4 \ + $(top_srcdir)/m4/strnlen.m4 $(top_srcdir)/m4/strnumcmp.m4 \ + $(top_srcdir)/m4/strpbrk.m4 $(top_srcdir)/m4/strsignal.m4 \ $(top_srcdir)/m4/strstr.m4 $(top_srcdir)/m4/strtod.m4 \ $(top_srcdir)/m4/strtoimax.m4 $(top_srcdir)/m4/strtol.m4 \ $(top_srcdir)/m4/strtoll.m4 $(top_srcdir)/m4/strtoul.m4 \ $(top_srcdir)/m4/strtoull.m4 $(top_srcdir)/m4/strtoumax.m4 \ - $(top_srcdir)/m4/strverscmp.m4 $(top_srcdir)/m4/sys_ioctl_h.m4 \ + $(top_srcdir)/m4/symlink.m4 $(top_srcdir)/m4/symlinkat.m4 \ + $(top_srcdir)/m4/sys_ioctl_h.m4 \ $(top_srcdir)/m4/sys_select_h.m4 \ $(top_srcdir)/m4/sys_socket_h.m4 \ $(top_srcdir)/m4/sys_stat_h.m4 $(top_srcdir)/m4/sys_time_h.m4 \ - $(top_srcdir)/m4/tempname.m4 $(top_srcdir)/m4/time_h.m4 \ - $(top_srcdir)/m4/time_r.m4 $(top_srcdir)/m4/timespec.m4 \ + $(top_srcdir)/m4/sys_utsname_h.m4 $(top_srcdir)/m4/tempname.m4 \ + $(top_srcdir)/m4/thread.m4 $(top_srcdir)/m4/threadlib.m4 \ + $(top_srcdir)/m4/time_h.m4 $(top_srcdir)/m4/time_r.m4 \ + $(top_srcdir)/m4/timespec.m4 $(top_srcdir)/m4/tls.m4 \ $(top_srcdir)/m4/tm_gmtoff.m4 $(top_srcdir)/m4/tzset.m4 \ - $(top_srcdir)/m4/ungetc.m4 $(top_srcdir)/m4/unicodeio.m4 \ - $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/unistd_h.m4 \ - $(top_srcdir)/m4/unlink-busy.m4 $(top_srcdir)/m4/unlinkdir.m4 \ + $(top_srcdir)/m4/uname.m4 $(top_srcdir)/m4/ungetc.m4 \ + $(top_srcdir)/m4/unicodeio.m4 $(top_srcdir)/m4/unistd-safer.m4 \ + $(top_srcdir)/m4/unistd_h.m4 $(top_srcdir)/m4/unlink-busy.m4 \ + $(top_srcdir)/m4/unlink.m4 $(top_srcdir)/m4/unlinkdir.m4 \ $(top_srcdir)/m4/unlocked-io.m4 $(top_srcdir)/m4/uptime.m4 \ - $(top_srcdir)/m4/userspec.m4 $(top_srcdir)/m4/utimbuf.m4 \ - $(top_srcdir)/m4/utimecmp.m4 $(top_srcdir)/m4/utimens.m4 \ - $(top_srcdir)/m4/utimes.m4 $(top_srcdir)/m4/vasnprintf.m4 \ + $(top_srcdir)/m4/userspec.m4 $(top_srcdir)/m4/usleep.m4 \ + $(top_srcdir)/m4/utimbuf.m4 $(top_srcdir)/m4/utimecmp.m4 \ + $(top_srcdir)/m4/utimens.m4 $(top_srcdir)/m4/utimes.m4 \ + $(top_srcdir)/m4/vasnprintf.m4 \ $(top_srcdir)/m4/vasprintf-posix.m4 \ $(top_srcdir)/m4/vasprintf.m4 $(top_srcdir)/m4/version-etc.m4 \ $(top_srcdir)/m4/vfprintf-posix.m4 \ - $(top_srcdir)/m4/vprintf-posix.m4 $(top_srcdir)/m4/warnings.m4 \ + $(top_srcdir)/m4/vprintf-posix.m4 \ + $(top_srcdir)/m4/warn-on-use.m4 $(top_srcdir)/m4/warnings.m4 \ $(top_srcdir)/m4/wchar.m4 $(top_srcdir)/m4/wchar_t.m4 \ $(top_srcdir)/m4/wcrtomb.m4 $(top_srcdir)/m4/wctob.m4 \ $(top_srcdir)/m4/wctype.m4 $(top_srcdir)/m4/wcwidth.m4 \ @@ -240,7 +255,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/m4/xstrndup.m4 \ $(top_srcdir)/m4/xstrtod.m4 $(top_srcdir)/m4/xstrtol.m4 \ $(top_srcdir)/m4/xvasprintf.m4 $(top_srcdir)/m4/yesno.m4 \ - $(top_srcdir)/configure.ac + $(top_srcdir)/m4/yield.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d @@ -252,7 +267,7 @@ AR = ar ARFLAGS = cru AM_V_AR = $(am__v_AR_$(V)) am__v_AR_ = $(am__v_AR_$(AM_DEFAULT_VERBOSITY)) -am__v_AR_0 = @echo " AR " $@; +am__v_AR_0 = @echo " AR " $@; AM_V_at = $(am__v_at_$(V)) am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) am__v_at_0 = @ @@ -262,9 +277,9 @@ nodist_libver_a_OBJECTS = version.$(OBJEXT) libver_a_OBJECTS = $(nodist_libver_a_OBJECTS) am__EXEEXT_1 = arch$(EXEEXT) hostname$(EXEEXT) su$(EXEEXT) am__EXEEXT_2 = chroot$(EXEEXT) df$(EXEEXT) hostid$(EXEEXT) \ - nice$(EXEEXT) pinky$(EXEEXT) stdbuf$(EXEEXT) \ - libstdbuf.so$(EXEEXT) stty$(EXEEXT) su$(EXEEXT) uname$(EXEEXT) \ - uptime$(EXEEXT) users$(EXEEXT) who$(EXEEXT) + libstdbuf.so$(EXEEXT) nice$(EXEEXT) pinky$(EXEEXT) \ + stdbuf$(EXEEXT) stty$(EXEEXT) su$(EXEEXT) uptime$(EXEEXT) \ + users$(EXEEXT) who$(EXEEXT) am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkglibdir)" PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) $(pkglib_PROGRAMS) am___OBJECTS = lbracket.$(OBJEXT) @@ -272,22 +287,17 @@ __OBJECTS = $(am___OBJECTS) am__DEPENDENCIES_1 = am__DEPENDENCIES_2 = libver.a ../lib/libcoreutils.a \ $(am__DEPENDENCIES_1) ../lib/libcoreutils.a -__DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) +am__DEPENDENCIES_3 = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) +__DEPENDENCIES = $(am__DEPENDENCIES_3) am_arch_OBJECTS = uname.$(OBJEXT) uname-arch.$(OBJEXT) arch_OBJECTS = $(am_arch_OBJECTS) -arch_LDADD = $(LDADD) -arch_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +arch_DEPENDENCIES = $(am__DEPENDENCIES_2) base64_SOURCES = base64.c base64_OBJECTS = base64.$(OBJEXT) -base64_LDADD = $(LDADD) -base64_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +base64_DEPENDENCIES = $(am__DEPENDENCIES_2) basename_SOURCES = basename.c basename_OBJECTS = basename.$(OBJEXT) -basename_LDADD = $(LDADD) -basename_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +basename_DEPENDENCIES = $(am__DEPENDENCIES_2) cat_SOURCES = cat.c cat_OBJECTS = cat.$(OBJEXT) cat_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) @@ -296,50 +306,36 @@ chcon_OBJECTS = chcon.$(OBJEXT) chcon_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) am_chgrp_OBJECTS = chgrp.$(OBJEXT) chown-core.$(OBJEXT) chgrp_OBJECTS = $(am_chgrp_OBJECTS) -chgrp_LDADD = $(LDADD) -chgrp_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +chgrp_DEPENDENCIES = $(am__DEPENDENCIES_2) chmod_SOURCES = chmod.c chmod_OBJECTS = chmod.$(OBJEXT) -chmod_LDADD = $(LDADD) -chmod_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +chmod_DEPENDENCIES = $(am__DEPENDENCIES_2) am_chown_OBJECTS = chown.$(OBJEXT) chown-core.$(OBJEXT) chown_OBJECTS = $(am_chown_OBJECTS) -chown_LDADD = $(LDADD) -chown_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +chown_DEPENDENCIES = $(am__DEPENDENCIES_2) chroot_SOURCES = chroot.c chroot_OBJECTS = chroot.$(OBJEXT) -chroot_LDADD = $(LDADD) -chroot_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +chroot_DEPENDENCIES = $(am__DEPENDENCIES_2) cksum_SOURCES = cksum.c cksum_OBJECTS = cksum.$(OBJEXT) -cksum_LDADD = $(LDADD) -cksum_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +cksum_DEPENDENCIES = $(am__DEPENDENCIES_2) comm_SOURCES = comm.c comm_OBJECTS = comm.$(OBJEXT) -comm_LDADD = $(LDADD) -comm_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +comm_DEPENDENCIES = $(am__DEPENDENCIES_2) am__objects_1 = copy.$(OBJEXT) cp-hash.$(OBJEXT) am_cp_OBJECTS = cp.$(OBJEXT) $(am__objects_1) cp_OBJECTS = $(am_cp_OBJECTS) -cp_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ +am__DEPENDENCIES_4 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) +cp_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_4) \ + $(am__DEPENDENCIES_1) csplit_SOURCES = csplit.c csplit_OBJECTS = csplit.$(OBJEXT) -csplit_LDADD = $(LDADD) -csplit_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +csplit_DEPENDENCIES = $(am__DEPENDENCIES_2) cut_SOURCES = cut.c cut_OBJECTS = cut.$(OBJEXT) -cut_LDADD = $(LDADD) -cut_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +cut_DEPENDENCIES = $(am__DEPENDENCIES_2) date_SOURCES = date.c date_OBJECTS = date.$(OBJEXT) date_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) @@ -352,37 +348,28 @@ df_OBJECTS = df.$(OBJEXT) df_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) am_dir_OBJECTS = ls.$(OBJEXT) ls-dir.$(OBJEXT) dir_OBJECTS = $(am_dir_OBJECTS) -dir_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ +am__DEPENDENCIES_5 = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) +dir_DEPENDENCIES = $(am__DEPENDENCIES_5) dircolors_SOURCES = dircolors.c dircolors_OBJECTS = dircolors.$(OBJEXT) -dircolors_LDADD = $(LDADD) -dircolors_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +dircolors_DEPENDENCIES = $(am__DEPENDENCIES_2) dirname_SOURCES = dirname.c dirname_OBJECTS = dirname.$(OBJEXT) -dirname_LDADD = $(LDADD) -dirname_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +dirname_DEPENDENCIES = $(am__DEPENDENCIES_2) du_SOURCES = du.c du_OBJECTS = du.$(OBJEXT) du_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) echo_SOURCES = echo.c echo_OBJECTS = echo.$(OBJEXT) -echo_LDADD = $(LDADD) -echo_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +echo_DEPENDENCIES = $(am__DEPENDENCIES_2) env_SOURCES = env.c env_OBJECTS = env.$(OBJEXT) -env_LDADD = $(LDADD) -env_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +env_DEPENDENCIES = $(am__DEPENDENCIES_2) expand_SOURCES = expand.c expand_OBJECTS = expand.$(OBJEXT) -expand_LDADD = $(LDADD) -expand_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +expand_DEPENDENCIES = $(am__DEPENDENCIES_2) expr_SOURCES = expr.c expr_OBJECTS = expr.$(OBJEXT) expr_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) @@ -391,19 +378,13 @@ factor_OBJECTS = factor.$(OBJEXT) factor_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) false_SOURCES = false.c false_OBJECTS = false.$(OBJEXT) -false_LDADD = $(LDADD) -false_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +false_DEPENDENCIES = $(am__DEPENDENCIES_2) fmt_SOURCES = fmt.c fmt_OBJECTS = fmt.$(OBJEXT) -fmt_LDADD = $(LDADD) -fmt_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +fmt_DEPENDENCIES = $(am__DEPENDENCIES_2) fold_SOURCES = fold.c fold_OBJECTS = fold.$(OBJEXT) -fold_LDADD = $(LDADD) -fold_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +fold_DEPENDENCIES = $(am__DEPENDENCIES_2) getlimits_SOURCES = getlimits.c getlimits_OBJECTS = getlimits.$(OBJEXT) getlimits_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) @@ -411,42 +392,29 @@ am__objects_2 = ginstall-copy.$(OBJEXT) ginstall-cp-hash.$(OBJEXT) am_ginstall_OBJECTS = ginstall-install.$(OBJEXT) \ ginstall-prog-fprintf.$(OBJEXT) $(am__objects_2) ginstall_OBJECTS = $(am_ginstall_OBJECTS) -ginstall_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) +ginstall_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_4) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_groups_OBJECTS = groups.$(OBJEXT) group-list.$(OBJEXT) groups_OBJECTS = $(am_groups_OBJECTS) -groups_LDADD = $(LDADD) -groups_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +groups_DEPENDENCIES = $(am__DEPENDENCIES_2) head_SOURCES = head.c head_OBJECTS = head.$(OBJEXT) -head_LDADD = $(LDADD) -head_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +head_DEPENDENCIES = $(am__DEPENDENCIES_2) hostid_SOURCES = hostid.c hostid_OBJECTS = hostid.$(OBJEXT) -hostid_LDADD = $(LDADD) -hostid_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +hostid_DEPENDENCIES = $(am__DEPENDENCIES_2) hostname_SOURCES = hostname.c hostname_OBJECTS = hostname.$(OBJEXT) -hostname_LDADD = $(LDADD) -hostname_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +hostname_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) am_id_OBJECTS = id.$(OBJEXT) group-list.$(OBJEXT) id_OBJECTS = $(am_id_OBJECTS) id_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) join_SOURCES = join.c join_OBJECTS = join.$(OBJEXT) -join_LDADD = $(LDADD) -join_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +join_DEPENDENCIES = $(am__DEPENDENCIES_2) am_kill_OBJECTS = kill.$(OBJEXT) operand2sig.$(OBJEXT) kill_OBJECTS = $(am_kill_OBJECTS) -kill_LDADD = $(LDADD) -kill_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +kill_DEPENDENCIES = $(am__DEPENDENCIES_2) libstdbuf_so_SOURCES = libstdbuf.c libstdbuf_so_OBJECTS = libstdbuf_so-libstdbuf.$(OBJEXT) libstdbuf_so_DEPENDENCIES = @@ -454,19 +422,13 @@ libstdbuf_so_LINK = $(CCLD) $(libstdbuf_so_CFLAGS) $(CFLAGS) \ $(libstdbuf_so_LDFLAGS) $(LDFLAGS) -o $@ link_SOURCES = link.c link_OBJECTS = link.$(OBJEXT) -link_LDADD = $(LDADD) -link_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +link_DEPENDENCIES = $(am__DEPENDENCIES_2) am_ln_OBJECTS = ln.$(OBJEXT) ln_OBJECTS = $(am_ln_OBJECTS) -ln_LDADD = $(LDADD) -ln_DEPENDENCIES = libver.a ../lib/libcoreutils.a $(am__DEPENDENCIES_1) \ - ../lib/libcoreutils.a +ln_DEPENDENCIES = $(am__DEPENDENCIES_2) logname_SOURCES = logname.c logname_OBJECTS = logname.$(OBJEXT) -logname_LDADD = $(LDADD) -logname_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +logname_DEPENDENCIES = $(am__DEPENDENCIES_2) am_ls_OBJECTS = ls.$(OBJEXT) ls-ls.$(OBJEXT) ls_OBJECTS = $(am_ls_OBJECTS) ls_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ @@ -474,9 +436,7 @@ ls_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) am_md5sum_OBJECTS = md5sum-md5sum.$(OBJEXT) md5sum_OBJECTS = $(am_md5sum_OBJECTS) -md5sum_LDADD = $(LDADD) -md5sum_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +md5sum_DEPENDENCIES = $(am__DEPENDENCIES_2) am_mkdir_OBJECTS = mkdir.$(OBJEXT) prog-fprintf.$(OBJEXT) mkdir_OBJECTS = $(am_mkdir_OBJECTS) mkdir_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) @@ -491,37 +451,30 @@ mktemp_OBJECTS = mktemp.$(OBJEXT) mktemp_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) am_mv_OBJECTS = mv.$(OBJEXT) remove.$(OBJEXT) $(am__objects_1) mv_OBJECTS = $(am_mv_OBJECTS) -mv_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) +am__DEPENDENCIES_6 = $(am__DEPENDENCIES_1) +mv_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_4) \ + $(am__DEPENDENCIES_6) nice_SOURCES = nice.c nice_OBJECTS = nice.$(OBJEXT) -nice_LDADD = $(LDADD) -nice_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +nice_DEPENDENCIES = $(am__DEPENDENCIES_2) nl_SOURCES = nl.c nl_OBJECTS = nl.$(OBJEXT) -nl_LDADD = $(LDADD) -nl_DEPENDENCIES = libver.a ../lib/libcoreutils.a $(am__DEPENDENCIES_1) \ - ../lib/libcoreutils.a +nl_DEPENDENCIES = $(am__DEPENDENCIES_2) nohup_SOURCES = nohup.c nohup_OBJECTS = nohup.$(OBJEXT) -nohup_LDADD = $(LDADD) -nohup_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +nohup_DEPENDENCIES = $(am__DEPENDENCIES_2) +am_nproc_OBJECTS = nproc.$(OBJEXT) +nproc_OBJECTS = $(am_nproc_OBJECTS) +nproc_DEPENDENCIES = $(am__DEPENDENCIES_2) od_SOURCES = od.c od_OBJECTS = od.$(OBJEXT) -od_LDADD = $(LDADD) -od_DEPENDENCIES = libver.a ../lib/libcoreutils.a $(am__DEPENDENCIES_1) \ - ../lib/libcoreutils.a +od_DEPENDENCIES = $(am__DEPENDENCIES_2) paste_SOURCES = paste.c paste_OBJECTS = paste.$(OBJEXT) -paste_LDADD = $(LDADD) -paste_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +paste_DEPENDENCIES = $(am__DEPENDENCIES_2) pathchk_SOURCES = pathchk.c pathchk_OBJECTS = pathchk.$(OBJEXT) -pathchk_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) +pathchk_DEPENDENCIES = $(am__DEPENDENCIES_2) pinky_SOURCES = pinky.c pinky_OBJECTS = pinky.$(OBJEXT) pinky_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) @@ -530,9 +483,7 @@ pr_OBJECTS = pr.$(OBJEXT) pr_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) printenv_SOURCES = printenv.c printenv_OBJECTS = printenv.$(OBJEXT) -printenv_LDADD = $(LDADD) -printenv_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +printenv_DEPENDENCIES = $(am__DEPENDENCIES_2) printf_SOURCES = printf.c printf_OBJECTS = printf.$(OBJEXT) printf_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ @@ -542,22 +493,16 @@ ptx_OBJECTS = ptx.$(OBJEXT) ptx_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) pwd_SOURCES = pwd.c pwd_OBJECTS = pwd.$(OBJEXT) -pwd_LDADD = $(LDADD) -pwd_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +pwd_DEPENDENCIES = $(am__DEPENDENCIES_2) readlink_SOURCES = readlink.c readlink_OBJECTS = readlink.$(OBJEXT) -readlink_LDADD = $(LDADD) -readlink_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +readlink_DEPENDENCIES = $(am__DEPENDENCIES_2) am_rm_OBJECTS = rm.$(OBJEXT) remove.$(OBJEXT) rm_OBJECTS = $(am_rm_OBJECTS) -rm_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) +rm_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_6) am_rmdir_OBJECTS = rmdir.$(OBJEXT) prog-fprintf.$(OBJEXT) rmdir_OBJECTS = $(am_rmdir_OBJECTS) -rmdir_LDADD = $(LDADD) -rmdir_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +rmdir_DEPENDENCIES = $(am__DEPENDENCIES_2) runcon_SOURCES = runcon.c runcon_OBJECTS = runcon.$(OBJEXT) runcon_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) @@ -566,34 +511,22 @@ seq_OBJECTS = seq.$(OBJEXT) seq_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) setuidgid_SOURCES = setuidgid.c setuidgid_OBJECTS = setuidgid.$(OBJEXT) -setuidgid_LDADD = $(LDADD) -setuidgid_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +setuidgid_DEPENDENCIES = $(am__DEPENDENCIES_2) am_sha1sum_OBJECTS = sha1sum-md5sum.$(OBJEXT) sha1sum_OBJECTS = $(am_sha1sum_OBJECTS) -sha1sum_LDADD = $(LDADD) -sha1sum_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +sha1sum_DEPENDENCIES = $(am__DEPENDENCIES_2) am_sha224sum_OBJECTS = sha224sum-md5sum.$(OBJEXT) sha224sum_OBJECTS = $(am_sha224sum_OBJECTS) -sha224sum_LDADD = $(LDADD) -sha224sum_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +sha224sum_DEPENDENCIES = $(am__DEPENDENCIES_2) am_sha256sum_OBJECTS = sha256sum-md5sum.$(OBJEXT) sha256sum_OBJECTS = $(am_sha256sum_OBJECTS) -sha256sum_LDADD = $(LDADD) -sha256sum_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +sha256sum_DEPENDENCIES = $(am__DEPENDENCIES_2) am_sha384sum_OBJECTS = sha384sum-md5sum.$(OBJEXT) sha384sum_OBJECTS = $(am_sha384sum_OBJECTS) -sha384sum_LDADD = $(LDADD) -sha384sum_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +sha384sum_DEPENDENCIES = $(am__DEPENDENCIES_2) am_sha512sum_OBJECTS = sha512sum-md5sum.$(OBJEXT) sha512sum_OBJECTS = $(am_sha512sum_OBJECTS) -sha512sum_LDADD = $(LDADD) -sha512sum_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +sha512sum_DEPENDENCIES = $(am__DEPENDENCIES_2) shred_SOURCES = shred.c shred_OBJECTS = shred.$(OBJEXT) shred_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ @@ -603,13 +536,12 @@ shuf_OBJECTS = shuf.$(OBJEXT) shuf_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) sleep_SOURCES = sleep.c sleep_OBJECTS = sleep.$(OBJEXT) -am__DEPENDENCIES_3 = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ +sleep_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) -sleep_DEPENDENCIES = $(am__DEPENDENCIES_3) sort_SOURCES = sort.c sort_OBJECTS = sort.$(OBJEXT) sort_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) split_SOURCES = split.c split_OBJECTS = split.$(OBJEXT) split_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) @@ -621,33 +553,26 @@ stdbuf_OBJECTS = stdbuf.$(OBJEXT) stdbuf_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) stty_SOURCES = stty.c stty_OBJECTS = stty.$(OBJEXT) -stty_LDADD = $(LDADD) -stty_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +stty_DEPENDENCIES = $(am__DEPENDENCIES_2) su_SOURCES = su.c su_OBJECTS = su.$(OBJEXT) su_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) sum_SOURCES = sum.c sum_OBJECTS = sum.$(OBJEXT) -sum_LDADD = $(LDADD) -sum_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +sum_DEPENDENCIES = $(am__DEPENDENCIES_2) sync_SOURCES = sync.c sync_OBJECTS = sync.$(OBJEXT) -sync_LDADD = $(LDADD) -sync_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +sync_DEPENDENCIES = $(am__DEPENDENCIES_2) tac_SOURCES = tac.c tac_OBJECTS = tac.$(OBJEXT) tac_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) tail_SOURCES = tail.c tail_OBJECTS = tail.$(OBJEXT) -tail_DEPENDENCIES = $(am__DEPENDENCIES_3) +tail_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) tee_SOURCES = tee.c tee_OBJECTS = tee.$(OBJEXT) -tee_LDADD = $(LDADD) -tee_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +tee_DEPENDENCIES = $(am__DEPENDENCIES_2) test_SOURCES = test.c test_OBJECTS = test.$(OBJEXT) test_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) @@ -659,79 +584,53 @@ touch_OBJECTS = touch.$(OBJEXT) touch_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) tr_SOURCES = tr.c tr_OBJECTS = tr.$(OBJEXT) -tr_LDADD = $(LDADD) -tr_DEPENDENCIES = libver.a ../lib/libcoreutils.a $(am__DEPENDENCIES_1) \ - ../lib/libcoreutils.a +tr_DEPENDENCIES = $(am__DEPENDENCIES_2) true_SOURCES = true.c true_OBJECTS = true.$(OBJEXT) -true_LDADD = $(LDADD) -true_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +true_DEPENDENCIES = $(am__DEPENDENCIES_2) truncate_SOURCES = truncate.c truncate_OBJECTS = truncate.$(OBJEXT) truncate_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) tsort_SOURCES = tsort.c tsort_OBJECTS = tsort.$(OBJEXT) -tsort_LDADD = $(LDADD) -tsort_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +tsort_DEPENDENCIES = $(am__DEPENDENCIES_2) tty_SOURCES = tty.c tty_OBJECTS = tty.$(OBJEXT) -tty_LDADD = $(LDADD) -tty_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +tty_DEPENDENCIES = $(am__DEPENDENCIES_2) am_uname_OBJECTS = uname.$(OBJEXT) uname-uname.$(OBJEXT) uname_OBJECTS = $(am_uname_OBJECTS) -uname_LDADD = $(LDADD) -uname_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +uname_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) unexpand_SOURCES = unexpand.c unexpand_OBJECTS = unexpand.$(OBJEXT) -unexpand_LDADD = $(LDADD) -unexpand_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +unexpand_DEPENDENCIES = $(am__DEPENDENCIES_2) uniq_SOURCES = uniq.c uniq_OBJECTS = uniq.$(OBJEXT) -uniq_LDADD = $(LDADD) -uniq_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +uniq_DEPENDENCIES = $(am__DEPENDENCIES_2) unlink_SOURCES = unlink.c unlink_OBJECTS = unlink.$(OBJEXT) -unlink_LDADD = $(LDADD) -unlink_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +unlink_DEPENDENCIES = $(am__DEPENDENCIES_2) uptime_SOURCES = uptime.c uptime_OBJECTS = uptime.$(OBJEXT) uptime_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) users_SOURCES = users.c users_OBJECTS = users.$(OBJEXT) -users_LDADD = $(LDADD) -users_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +users_DEPENDENCIES = $(am__DEPENDENCIES_2) am_vdir_OBJECTS = ls.$(OBJEXT) ls-vdir.$(OBJEXT) vdir_OBJECTS = $(am_vdir_OBJECTS) -vdir_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) +vdir_DEPENDENCIES = $(am__DEPENDENCIES_5) wc_SOURCES = wc.c wc_OBJECTS = wc.$(OBJEXT) -wc_LDADD = $(LDADD) -wc_DEPENDENCIES = libver.a ../lib/libcoreutils.a $(am__DEPENDENCIES_1) \ - ../lib/libcoreutils.a +wc_DEPENDENCIES = $(am__DEPENDENCIES_2) who_SOURCES = who.c who_OBJECTS = who.$(OBJEXT) who_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) whoami_SOURCES = whoami.c whoami_OBJECTS = whoami.$(OBJEXT) -whoami_LDADD = $(LDADD) -whoami_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +whoami_DEPENDENCIES = $(am__DEPENDENCIES_2) yes_SOURCES = yes.c yes_OBJECTS = yes.$(OBJEXT) -yes_LDADD = $(LDADD) -yes_DEPENDENCIES = libver.a ../lib/libcoreutils.a \ - $(am__DEPENDENCIES_1) ../lib/libcoreutils.a +yes_DEPENDENCIES = $(am__DEPENDENCIES_2) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/lib depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp am__depfiles_maybe = depfiles @@ -743,15 +642,15 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_$(V)) am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) -am__v_CC_0 = @echo " CC " $@; +am__v_CC_0 = @echo " CC " $@; CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_$(V)) am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) -am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) -am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(nodist_libver_a_SOURCES) $(__SOURCES) $(arch_SOURCES) \ base64.c basename.c cat.c chcon.c $(chgrp_SOURCES) chmod.c \ $(chown_SOURCES) chroot.c cksum.c comm.c $(cp_SOURCES) \ @@ -761,16 +660,16 @@ SOURCES = $(nodist_libver_a_SOURCES) $(__SOURCES) $(arch_SOURCES) \ head.c hostid.c hostname.c $(id_SOURCES) join.c \ $(kill_SOURCES) libstdbuf.c link.c $(ln_SOURCES) logname.c \ $(ls_SOURCES) $(md5sum_SOURCES) $(mkdir_SOURCES) mkfifo.c \ - mknod.c mktemp.c $(mv_SOURCES) nice.c nl.c nohup.c od.c \ - paste.c pathchk.c pinky.c pr.c printenv.c printf.c ptx.c pwd.c \ - readlink.c $(rm_SOURCES) $(rmdir_SOURCES) runcon.c seq.c \ - setuidgid.c $(sha1sum_SOURCES) $(sha224sum_SOURCES) \ - $(sha256sum_SOURCES) $(sha384sum_SOURCES) $(sha512sum_SOURCES) \ - shred.c shuf.c sleep.c sort.c split.c stat.c stdbuf.c stty.c \ - su.c sum.c sync.c tac.c tail.c tee.c test.c $(timeout_SOURCES) \ - touch.c tr.c true.c truncate.c tsort.c tty.c $(uname_SOURCES) \ - unexpand.c uniq.c unlink.c uptime.c users.c $(vdir_SOURCES) \ - wc.c who.c whoami.c yes.c + mknod.c mktemp.c $(mv_SOURCES) nice.c nl.c nohup.c \ + $(nproc_SOURCES) od.c paste.c pathchk.c pinky.c pr.c \ + printenv.c printf.c ptx.c pwd.c readlink.c $(rm_SOURCES) \ + $(rmdir_SOURCES) runcon.c seq.c setuidgid.c $(sha1sum_SOURCES) \ + $(sha224sum_SOURCES) $(sha256sum_SOURCES) $(sha384sum_SOURCES) \ + $(sha512sum_SOURCES) shred.c shuf.c sleep.c sort.c split.c \ + stat.c stdbuf.c stty.c su.c sum.c sync.c tac.c tail.c tee.c \ + test.c $(timeout_SOURCES) touch.c tr.c true.c truncate.c \ + tsort.c tty.c $(uname_SOURCES) unexpand.c uniq.c unlink.c \ + uptime.c users.c $(vdir_SOURCES) wc.c who.c whoami.c yes.c DIST_SOURCES = $(__SOURCES) $(arch_SOURCES) base64.c basename.c cat.c \ chcon.c $(chgrp_SOURCES) chmod.c $(chown_SOURCES) chroot.c \ cksum.c comm.c $(cp_SOURCES) csplit.c cut.c date.c dd.c df.c \ @@ -780,15 +679,16 @@ DIST_SOURCES = $(__SOURCES) $(arch_SOURCES) base64.c basename.c cat.c \ hostname.c $(id_SOURCES) join.c $(kill_SOURCES) libstdbuf.c \ link.c $(ln_SOURCES) logname.c $(ls_SOURCES) $(md5sum_SOURCES) \ $(mkdir_SOURCES) mkfifo.c mknod.c mktemp.c $(mv_SOURCES) \ - nice.c nl.c nohup.c od.c paste.c pathchk.c pinky.c pr.c \ - printenv.c printf.c ptx.c pwd.c readlink.c $(rm_SOURCES) \ - $(rmdir_SOURCES) runcon.c seq.c setuidgid.c $(sha1sum_SOURCES) \ - $(sha224sum_SOURCES) $(sha256sum_SOURCES) $(sha384sum_SOURCES) \ - $(sha512sum_SOURCES) shred.c shuf.c sleep.c sort.c split.c \ - stat.c stdbuf.c stty.c su.c sum.c sync.c tac.c tail.c tee.c \ - test.c $(timeout_SOURCES) touch.c tr.c true.c truncate.c \ - tsort.c tty.c $(uname_SOURCES) unexpand.c uniq.c unlink.c \ - uptime.c users.c $(vdir_SOURCES) wc.c who.c whoami.c yes.c + nice.c nl.c nohup.c $(nproc_SOURCES) od.c paste.c pathchk.c \ + pinky.c pr.c printenv.c printf.c ptx.c pwd.c readlink.c \ + $(rm_SOURCES) $(rmdir_SOURCES) runcon.c seq.c setuidgid.c \ + $(sha1sum_SOURCES) $(sha224sum_SOURCES) $(sha256sum_SOURCES) \ + $(sha384sum_SOURCES) $(sha512sum_SOURCES) shred.c shuf.c \ + sleep.c sort.c split.c stat.c stdbuf.c stty.c su.c sum.c \ + sync.c tac.c tail.c tee.c test.c $(timeout_SOURCES) touch.c \ + tr.c true.c truncate.c tsort.c tty.c $(uname_SOURCES) \ + unexpand.c uniq.c unlink.c uptime.c users.c $(vdir_SOURCES) \ + wc.c who.c whoami.c yes.c HEADERS = $(noinst_HEADERS) ETAGS = etags CTAGS = ctags @@ -804,7 +704,6 @@ ALLOCA_H = @ALLOCA_H@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@ -ARPA_INET_H = @ARPA_INET_H@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -824,7 +723,6 @@ CYGPATH_W = @CYGPATH_W@ DEFAULT_POSIX2_VERSION = @DEFAULT_POSIX2_VERSION@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ -DIRENT_H = @DIRENT_H@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ @@ -837,7 +735,6 @@ EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@ EOVERFLOW_VALUE = @EOVERFLOW_VALUE@ ERRNO_H = @ERRNO_H@ EXEEXT = @EXEEXT@ -FCNTL_H = @FCNTL_H@ FLOAT_H = @FLOAT_H@ FNMATCH_H = @FNMATCH_H@ GETADDRINFO_LIB = @GETADDRINFO_LIB@ @@ -855,6 +752,7 @@ GNULIB_ATOLL = @GNULIB_ATOLL@ GNULIB_BIND = @GNULIB_BIND@ GNULIB_BTOWC = @GNULIB_BTOWC@ GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@ +GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@ GNULIB_CEILF = @GNULIB_CEILF@ GNULIB_CEILL = @GNULIB_CEILL@ GNULIB_CHOWN = @GNULIB_CHOWN@ @@ -864,6 +762,7 @@ GNULIB_DIRFD = @GNULIB_DIRFD@ GNULIB_DPRINTF = @GNULIB_DPRINTF@ GNULIB_DUP2 = @GNULIB_DUP2@ GNULIB_DUP3 = @GNULIB_DUP3@ +GNULIB_DUPLOCALE = @GNULIB_DUPLOCALE@ GNULIB_ENVIRON = @GNULIB_ENVIRON@ GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@ GNULIB_FACCESSAT = @GNULIB_FACCESSAT@ @@ -871,6 +770,7 @@ GNULIB_FCHDIR = @GNULIB_FCHDIR@ GNULIB_FCHMODAT = @GNULIB_FCHMODAT@ GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@ GNULIB_FCLOSE = @GNULIB_FCLOSE@ +GNULIB_FCNTL = @GNULIB_FCNTL@ GNULIB_FDOPENDIR = @GNULIB_FDOPENDIR@ GNULIB_FFLUSH = @GNULIB_FFLUSH@ GNULIB_FLOORF = @GNULIB_FLOORF@ @@ -891,15 +791,18 @@ GNULIB_FSYNC = @GNULIB_FSYNC@ GNULIB_FTELL = @GNULIB_FTELL@ GNULIB_FTELLO = @GNULIB_FTELLO@ GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@ +GNULIB_FUTIMENS = @GNULIB_FUTIMENS@ GNULIB_FWRITE = @GNULIB_FWRITE@ GNULIB_GETADDRINFO = @GNULIB_GETADDRINFO@ GNULIB_GETCWD = @GNULIB_GETCWD@ GNULIB_GETDELIM = @GNULIB_GETDELIM@ GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@ GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@ +GNULIB_GETGROUPS = @GNULIB_GETGROUPS@ GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@ GNULIB_GETLINE = @GNULIB_GETLINE@ GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@ +GNULIB_GETLOGIN = @GNULIB_GETLOGIN@ GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@ GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@ GNULIB_GETPEERNAME = @GNULIB_GETPEERNAME@ @@ -912,6 +815,7 @@ GNULIB_IMAXDIV = @GNULIB_IMAXDIV@ GNULIB_INET_NTOP = @GNULIB_INET_NTOP@ GNULIB_INET_PTON = @GNULIB_INET_PTON@ GNULIB_IOCTL = @GNULIB_IOCTL@ +GNULIB_ISBLANK = @GNULIB_ISBLANK@ GNULIB_ISFINITE = @GNULIB_ISFINITE@ GNULIB_ISINF = @GNULIB_ISINF@ GNULIB_ISNAN = @GNULIB_ISNAN@ @@ -922,6 +826,7 @@ GNULIB_LCHMOD = @GNULIB_LCHMOD@ GNULIB_LCHOWN = @GNULIB_LCHOWN@ GNULIB_LDEXPL = @GNULIB_LDEXPL@ GNULIB_LINK = @GNULIB_LINK@ +GNULIB_LINKAT = @GNULIB_LINKAT@ GNULIB_LISTEN = @GNULIB_LISTEN@ GNULIB_LSEEK = @GNULIB_LSEEK@ GNULIB_LSTAT = @GNULIB_LSTAT@ @@ -952,10 +857,15 @@ GNULIB_MEMPCPY = @GNULIB_MEMPCPY@ GNULIB_MEMRCHR = @GNULIB_MEMRCHR@ GNULIB_MKDIRAT = @GNULIB_MKDIRAT@ GNULIB_MKDTEMP = @GNULIB_MKDTEMP@ +GNULIB_MKFIFO = @GNULIB_MKFIFO@ GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@ +GNULIB_MKNOD = @GNULIB_MKNOD@ GNULIB_MKNODAT = @GNULIB_MKNODAT@ GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@ +GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@ GNULIB_MKSTEMP = @GNULIB_MKSTEMP@ +GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@ +GNULIB_NL_LANGINFO = @GNULIB_NL_LANGINFO@ GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@ GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@ GNULIB_OPEN = @GNULIB_OPEN@ @@ -963,6 +873,7 @@ GNULIB_OPENAT = @GNULIB_OPENAT@ GNULIB_PERROR = @GNULIB_PERROR@ GNULIB_PIPE2 = @GNULIB_PIPE2@ GNULIB_POPEN = @GNULIB_POPEN@ +GNULIB_PREAD = @GNULIB_PREAD@ GNULIB_PRINTF = @GNULIB_PRINTF@ GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@ GNULIB_PUTC = @GNULIB_PUTC@ @@ -974,9 +885,13 @@ GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@ GNULIB_READLINK = @GNULIB_READLINK@ GNULIB_READLINKAT = @GNULIB_READLINKAT@ GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@ +GNULIB_REALPATH = @GNULIB_REALPATH@ GNULIB_RECV = @GNULIB_RECV@ GNULIB_RECVFROM = @GNULIB_RECVFROM@ +GNULIB_REMOVE = @GNULIB_REMOVE@ GNULIB_RENAME = @GNULIB_RENAME@ +GNULIB_RENAMEAT = @GNULIB_RENAMEAT@ +GNULIB_RMDIR = @GNULIB_RMDIR@ GNULIB_ROUND = @GNULIB_ROUND@ GNULIB_ROUNDF = @GNULIB_ROUNDF@ GNULIB_ROUNDL = @GNULIB_ROUNDL@ @@ -996,6 +911,7 @@ GNULIB_SLEEP = @GNULIB_SLEEP@ GNULIB_SNPRINTF = @GNULIB_SNPRINTF@ GNULIB_SOCKET = @GNULIB_SOCKET@ GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@ +GNULIB_STAT = @GNULIB_STAT@ GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@ GNULIB_STPCPY = @GNULIB_STPCPY@ GNULIB_STPNCPY = @GNULIB_STPNCPY@ @@ -1016,14 +932,19 @@ GNULIB_STRTOLL = @GNULIB_STRTOLL@ GNULIB_STRTOULL = @GNULIB_STRTOULL@ GNULIB_STRTOUMAX = @GNULIB_STRTOUMAX@ GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@ +GNULIB_SYMLINK = @GNULIB_SYMLINK@ GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@ GNULIB_TRUNC = @GNULIB_TRUNC@ GNULIB_TRUNCF = @GNULIB_TRUNCF@ GNULIB_TRUNCL = @GNULIB_TRUNCL@ +GNULIB_UNAME = @GNULIB_UNAME@ GNULIB_UNISTD_H_GETOPT = @GNULIB_UNISTD_H_GETOPT@ GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@ +GNULIB_UNLINK = @GNULIB_UNLINK@ GNULIB_UNLINKAT = @GNULIB_UNLINKAT@ GNULIB_UNSETENV = @GNULIB_UNSETENV@ +GNULIB_USLEEP = @GNULIB_USLEEP@ +GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@ GNULIB_VASPRINTF = @GNULIB_VASPRINTF@ GNULIB_VDPRINTF = @GNULIB_VDPRINTF@ GNULIB_VFPRINTF = @GNULIB_VFPRINTF@ @@ -1032,6 +953,7 @@ GNULIB_VPRINTF = @GNULIB_VPRINTF@ GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@ GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@ GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@ +GNULIB_WARN_CFLAGS = @GNULIB_WARN_CFLAGS@ GNULIB_WCRTOMB = @GNULIB_WCRTOMB@ GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@ GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@ @@ -1045,6 +967,8 @@ HAVE_ARPA_INET_H = @HAVE_ARPA_INET_H@ HAVE_ATOLL = @HAVE_ATOLL@ HAVE_BTOWC = @HAVE_BTOWC@ HAVE_CALLOC_POSIX = @HAVE_CALLOC_POSIX@ +HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@ +HAVE_CHOWN = @HAVE_CHOWN@ HAVE_DECL_ACOSL = @HAVE_DECL_ACOSL@ HAVE_DECL_ASINL = @HAVE_DECL_ASINL@ HAVE_DECL_ATANL = @HAVE_DECL_ATANL@ @@ -1095,51 +1019,69 @@ HAVE_EUIDACCESS = @HAVE_EUIDACCESS@ HAVE_FACCESSAT = @HAVE_FACCESSAT@ HAVE_FCHMODAT = @HAVE_FCHMODAT@ HAVE_FCHOWNAT = @HAVE_FCHOWNAT@ +HAVE_FCNTL = @HAVE_FCNTL@ HAVE_FDOPENDIR = @HAVE_FDOPENDIR@ -HAVE_FSEEKO = @HAVE_FSEEKO@ HAVE_FSTATAT = @HAVE_FSTATAT@ HAVE_FSYNC = @HAVE_FSYNC@ -HAVE_FTELLO = @HAVE_FTELLO@ HAVE_FTRUNCATE = @HAVE_FTRUNCATE@ +HAVE_FUTIMENS = @HAVE_FUTIMENS@ HAVE_GETDOMAINNAME = @HAVE_GETDOMAINNAME@ HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@ +HAVE_GETGROUPS = @HAVE_GETGROUPS@ HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@ +HAVE_GETLOGIN = @HAVE_GETLOGIN@ +HAVE_GETOPT_H = @HAVE_GETOPT_H@ HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@ HAVE_GETSUBOPT = @HAVE_GETSUBOPT@ HAVE_GETUSERSHELL = @HAVE_GETUSERSHELL@ HAVE_INTTYPES_H = @HAVE_INTTYPES_H@ +HAVE_ISBLANK = @HAVE_ISBLANK@ HAVE_ISNAND = @HAVE_ISNAND@ HAVE_ISNANF = @HAVE_ISNANF@ HAVE_ISNANL = @HAVE_ISNANL@ HAVE_ISWCNTRL = @HAVE_ISWCNTRL@ +HAVE_LANGINFO_CODESET = @HAVE_LANGINFO_CODESET@ +HAVE_LANGINFO_ERA = @HAVE_LANGINFO_ERA@ +HAVE_LANGINFO_H = @HAVE_LANGINFO_H@ HAVE_LCHMOD = @HAVE_LCHMOD@ +HAVE_LCHOWN = @HAVE_LCHOWN@ HAVE_LINK = @HAVE_LINK@ +HAVE_LINKAT = @HAVE_LINKAT@ HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@ HAVE_LSTAT = @HAVE_LSTAT@ HAVE_MALLOC_POSIX = @HAVE_MALLOC_POSIX@ HAVE_MBRLEN = @HAVE_MBRLEN@ HAVE_MBRTOWC = @HAVE_MBRTOWC@ HAVE_MBSINIT = @HAVE_MBSINIT@ +HAVE_MBSLEN = @HAVE_MBSLEN@ HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@ HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@ HAVE_MEMPCPY = @HAVE_MEMPCPY@ HAVE_MKDIRAT = @HAVE_MKDIRAT@ HAVE_MKDTEMP = @HAVE_MKDTEMP@ +HAVE_MKFIFO = @HAVE_MKFIFO@ HAVE_MKFIFOAT = @HAVE_MKFIFOAT@ +HAVE_MKNOD = @HAVE_MKNOD@ HAVE_MKNODAT = @HAVE_MKNODAT@ HAVE_MKOSTEMP = @HAVE_MKOSTEMP@ +HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@ +HAVE_MKSTEMPS = @HAVE_MKSTEMPS@ HAVE_NETDB_H = @HAVE_NETDB_H@ HAVE_NETINET_IN_H = @HAVE_NETINET_IN_H@ +HAVE_NL_LANGINFO = @HAVE_NL_LANGINFO@ HAVE_OPENAT = @HAVE_OPENAT@ HAVE_OS_H = @HAVE_OS_H@ HAVE_PIPE2 = @HAVE_PIPE2@ HAVE_POSIX_SIGNALBLOCKING = @HAVE_POSIX_SIGNALBLOCKING@ +HAVE_PREAD = @HAVE_PREAD@ HAVE_RANDOM_H = @HAVE_RANDOM_H@ HAVE_RANDOM_R = @HAVE_RANDOM_R@ HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@ HAVE_READLINK = @HAVE_READLINK@ HAVE_READLINKAT = @HAVE_READLINKAT@ HAVE_REALLOC_POSIX = @HAVE_REALLOC_POSIX@ +HAVE_REALPATH = @HAVE_REALPATH@ +HAVE_RENAMEAT = @HAVE_RENAMEAT@ HAVE_RPMATCH = @HAVE_RPMATCH@ HAVE_SA_FAMILY_T = @HAVE_SA_FAMILY_T@ HAVE_SCANDIR = @HAVE_SCANDIR@ @@ -1166,6 +1108,7 @@ HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@ HAVE_STRUCT_SIGACTION_SA_SIGACTION = @HAVE_STRUCT_SIGACTION_SA_SIGACTION@ HAVE_STRUCT_SOCKADDR_STORAGE = @HAVE_STRUCT_SOCKADDR_STORAGE@ HAVE_STRUCT_TIMEVAL = @HAVE_STRUCT_TIMEVAL@ +HAVE_STRUCT_UTSNAME = @HAVE_STRUCT_UTSNAME@ HAVE_STRVERSCMP = @HAVE_STRVERSCMP@ HAVE_SYMLINK = @HAVE_SYMLINK@ HAVE_SYMLINKAT = @HAVE_SYMLINKAT@ @@ -1178,11 +1121,15 @@ HAVE_SYS_SELECT_H = @HAVE_SYS_SELECT_H@ HAVE_SYS_SOCKET_H = @HAVE_SYS_SOCKET_H@ HAVE_SYS_TIME_H = @HAVE_SYS_TIME_H@ HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@ +HAVE_SYS_UTSNAME_H = @HAVE_SYS_UTSNAME_H@ HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@ +HAVE_UNAME = @HAVE_UNAME@ HAVE_UNISTD_H = @HAVE_UNISTD_H@ HAVE_UNLINKAT = @HAVE_UNLINKAT@ HAVE_UNSETENV = @HAVE_UNSETENV@ HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@ +HAVE_USLEEP = @HAVE_USLEEP@ +HAVE_UTIMENSAT = @HAVE_UTIMENSAT@ HAVE_VASPRINTF = @HAVE_VASPRINTF@ HAVE_VDPRINTF = @HAVE_VDPRINTF@ HAVE_WCHAR_H = @HAVE_WCHAR_H@ @@ -1194,12 +1141,15 @@ HAVE_WCTYPE_H = @HAVE_WCTYPE_H@ HAVE_WINSOCK2_H = @HAVE_WINSOCK2_H@ HAVE_WINT_T = @HAVE_WINT_T@ HAVE_WS2TCPIP_H = @HAVE_WS2TCPIP_H@ +HAVE_XLOCALE_H = @HAVE_XLOCALE_H@ HAVE__BOOL = @HAVE__BOOL@ HELP2MAN = @HELP2MAN@ HOSTENT_LIB = @HOSTENT_LIB@ ICONV_H = @ICONV_H@ INCLUDE_NEXT = @INCLUDE_NEXT@ INCLUDE_NEXT_AS_FIRST_DIRECTIVE = @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ +INET_NTOP_LIB = @INET_NTOP_LIB@ +INET_PTON_LIB = @INET_PTON_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = $(cu_install_program) @@ -1210,17 +1160,20 @@ INT32_MAX_LT_INTMAX_MAX = @INT32_MAX_LT_INTMAX_MAX@ INT64_MAX_EQ_LONG_MAX = @INT64_MAX_EQ_LONG_MAX@ INTLLIBS = @INTLLIBS@ INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -INTTYPES_H = @INTTYPES_H@ KMEM_GROUP = @KMEM_GROUP@ LDFLAGS = @LDFLAGS@ LIBCOREUTILS_LIBDEPS = @LIBCOREUTILS_LIBDEPS@ LIBCOREUTILS_LTLIBDEPS = @LIBCOREUTILS_LTLIBDEPS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ +LIBMULTITHREAD = @LIBMULTITHREAD@ LIBOBJS = @LIBOBJS@ +LIBPTH = @LIBPTH@ +LIBPTH_PREFIX = @LIBPTH_PREFIX@ LIBS = @LIBS@ LIBSOCKET = @LIBSOCKET@ LIBTESTS_LIBDEPS = @LIBTESTS_LIBDEPS@ +LIBTHREAD = @LIBTHREAD@ LIB_ACL = @LIB_ACL@ LIB_CAP = @LIB_CAP@ LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@ @@ -1241,7 +1194,10 @@ LOCALE_TR_UTF8 = @LOCALE_TR_UTF8@ LOCALE_ZH_CN = @LOCALE_ZH_CN@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ +LTLIBMULTITHREAD = @LTLIBMULTITHREAD@ LTLIBOBJS = @LTLIBOBJS@ +LTLIBPTH = @LTLIBPTH@ +LTLIBTHREAD = @LTLIBTHREAD@ MAKEINFO = @MAKEINFO@ MAN = @MAN@ MKDIR_P = @MKDIR_P@ @@ -1253,15 +1209,20 @@ NETDB_H = @NETDB_H@ NETINET_IN_H = @NETINET_IN_H@ NEXT_ARPA_INET_H = @NEXT_ARPA_INET_H@ NEXT_AS_FIRST_DIRECTIVE_ARPA_INET_H = @NEXT_AS_FIRST_DIRECTIVE_ARPA_INET_H@ +NEXT_AS_FIRST_DIRECTIVE_CTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_CTYPE_H@ NEXT_AS_FIRST_DIRECTIVE_DIRENT_H = @NEXT_AS_FIRST_DIRECTIVE_DIRENT_H@ NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@ NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@ NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@ +NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@ NEXT_AS_FIRST_DIRECTIVE_ICONV_H = @NEXT_AS_FIRST_DIRECTIVE_ICONV_H@ NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H = @NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H@ +NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H = @NEXT_AS_FIRST_DIRECTIVE_LANGINFO_H@ +NEXT_AS_FIRST_DIRECTIVE_LOCALE_H = @NEXT_AS_FIRST_DIRECTIVE_LOCALE_H@ NEXT_AS_FIRST_DIRECTIVE_MATH_H = @NEXT_AS_FIRST_DIRECTIVE_MATH_H@ NEXT_AS_FIRST_DIRECTIVE_NETDB_H = @NEXT_AS_FIRST_DIRECTIVE_NETDB_H@ NEXT_AS_FIRST_DIRECTIVE_NETINET_IN_H = @NEXT_AS_FIRST_DIRECTIVE_NETINET_IN_H@ +NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H = @NEXT_AS_FIRST_DIRECTIVE_SELINUX_SELINUX_H@ NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H = @NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H@ NEXT_AS_FIRST_DIRECTIVE_STDARG_H = @NEXT_AS_FIRST_DIRECTIVE_STDARG_H@ NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@ @@ -1274,19 +1235,25 @@ NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@ NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H@ +NEXT_AS_FIRST_DIRECTIVE_SYS_UTSNAME_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_UTSNAME_H@ NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@ NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@ NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@ NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@ +NEXT_CTYPE_H = @NEXT_CTYPE_H@ NEXT_DIRENT_H = @NEXT_DIRENT_H@ NEXT_ERRNO_H = @NEXT_ERRNO_H@ NEXT_FCNTL_H = @NEXT_FCNTL_H@ NEXT_FLOAT_H = @NEXT_FLOAT_H@ +NEXT_GETOPT_H = @NEXT_GETOPT_H@ NEXT_ICONV_H = @NEXT_ICONV_H@ NEXT_INTTYPES_H = @NEXT_INTTYPES_H@ +NEXT_LANGINFO_H = @NEXT_LANGINFO_H@ +NEXT_LOCALE_H = @NEXT_LOCALE_H@ NEXT_MATH_H = @NEXT_MATH_H@ NEXT_NETDB_H = @NEXT_NETDB_H@ NEXT_NETINET_IN_H = @NEXT_NETINET_IN_H@ +NEXT_SELINUX_SELINUX_H = @NEXT_SELINUX_SELINUX_H@ NEXT_SIGNAL_H = @NEXT_SIGNAL_H@ NEXT_STDARG_H = @NEXT_STDARG_H@ NEXT_STDDEF_H = @NEXT_STDDEF_H@ @@ -1299,6 +1266,7 @@ NEXT_SYS_SELECT_H = @NEXT_SYS_SELECT_H@ NEXT_SYS_SOCKET_H = @NEXT_SYS_SOCKET_H@ NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@ NEXT_SYS_TIME_H = @NEXT_SYS_TIME_H@ +NEXT_SYS_UTSNAME_H = @NEXT_SYS_UTSNAME_H@ NEXT_TIME_H = @NEXT_TIME_H@ NEXT_UNISTD_H = @NEXT_UNISTD_H@ NEXT_WCHAR_H = @NEXT_WCHAR_H@ @@ -1326,15 +1294,21 @@ PRI_MACROS_BROKEN = @PRI_MACROS_BROKEN@ PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@ RANLIB = @RANLIB@ REPLACE_BTOWC = @REPLACE_BTOWC@ +REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@ REPLACE_CEILF = @REPLACE_CEILF@ REPLACE_CEILL = @REPLACE_CEILL@ REPLACE_CHOWN = @REPLACE_CHOWN@ REPLACE_CLOSE = @REPLACE_CLOSE@ +REPLACE_CLOSEDIR = @REPLACE_CLOSEDIR@ REPLACE_DPRINTF = @REPLACE_DPRINTF@ +REPLACE_DUP = @REPLACE_DUP@ REPLACE_DUP2 = @REPLACE_DUP2@ +REPLACE_DUPLOCALE = @REPLACE_DUPLOCALE@ REPLACE_FCHDIR = @REPLACE_FCHDIR@ REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@ REPLACE_FCLOSE = @REPLACE_FCLOSE@ +REPLACE_FCNTL = @REPLACE_FCNTL@ +REPLACE_FDOPENDIR = @REPLACE_FDOPENDIR@ REPLACE_FFLUSH = @REPLACE_FFLUSH@ REPLACE_FLOORF = @REPLACE_FLOORF@ REPLACE_FLOORL = @REPLACE_FLOORL@ @@ -1346,10 +1320,13 @@ REPLACE_FREXP = @REPLACE_FREXP@ REPLACE_FREXPL = @REPLACE_FREXPL@ REPLACE_FSEEK = @REPLACE_FSEEK@ REPLACE_FSEEKO = @REPLACE_FSEEKO@ +REPLACE_FSTAT = @REPLACE_FSTAT@ REPLACE_FSTATAT = @REPLACE_FSTATAT@ REPLACE_FTELL = @REPLACE_FTELL@ REPLACE_FTELLO = @REPLACE_FTELLO@ +REPLACE_FUTIMENS = @REPLACE_FUTIMENS@ REPLACE_GETCWD = @REPLACE_GETCWD@ +REPLACE_GETGROUPS = @REPLACE_GETGROUPS@ REPLACE_GETLINE = @REPLACE_GETLINE@ REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@ REPLACE_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@ @@ -1364,6 +1341,7 @@ REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@ REPLACE_LCHOWN = @REPLACE_LCHOWN@ REPLACE_LDEXPL = @REPLACE_LDEXPL@ REPLACE_LINK = @REPLACE_LINK@ +REPLACE_LINKAT = @REPLACE_LINKAT@ REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@ REPLACE_LSEEK = @REPLACE_LSEEK@ REPLACE_LSTAT = @REPLACE_LSTAT@ @@ -1376,26 +1354,40 @@ REPLACE_MBSTATE_T = @REPLACE_MBSTATE_T@ REPLACE_MEMCHR = @REPLACE_MEMCHR@ REPLACE_MEMMEM = @REPLACE_MEMMEM@ REPLACE_MKDIR = @REPLACE_MKDIR@ +REPLACE_MKFIFO = @REPLACE_MKFIFO@ +REPLACE_MKNOD = @REPLACE_MKNOD@ REPLACE_MKSTEMP = @REPLACE_MKSTEMP@ REPLACE_MKTIME = @REPLACE_MKTIME@ REPLACE_NAN = @REPLACE_NAN@ REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@ +REPLACE_NL_LANGINFO = @REPLACE_NL_LANGINFO@ REPLACE_NULL = @REPLACE_NULL@ REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@ REPLACE_OPEN = @REPLACE_OPEN@ +REPLACE_OPENAT = @REPLACE_OPENAT@ +REPLACE_OPENDIR = @REPLACE_OPENDIR@ REPLACE_PERROR = @REPLACE_PERROR@ REPLACE_POPEN = @REPLACE_POPEN@ +REPLACE_PREAD = @REPLACE_PREAD@ REPLACE_PRINTF = @REPLACE_PRINTF@ REPLACE_PUTENV = @REPLACE_PUTENV@ +REPLACE_READLINK = @REPLACE_READLINK@ +REPLACE_REALPATH = @REPLACE_REALPATH@ +REPLACE_REMOVE = @REPLACE_REMOVE@ REPLACE_RENAME = @REPLACE_RENAME@ +REPLACE_RENAMEAT = @REPLACE_RENAMEAT@ +REPLACE_RMDIR = @REPLACE_RMDIR@ REPLACE_ROUND = @REPLACE_ROUND@ REPLACE_ROUNDF = @REPLACE_ROUNDF@ REPLACE_ROUNDL = @REPLACE_ROUNDL@ REPLACE_SELECT = @REPLACE_SELECT@ +REPLACE_SETENV = @REPLACE_SETENV@ REPLACE_SIGNBIT = @REPLACE_SIGNBIT@ REPLACE_SIGNBIT_USING_GCC = @REPLACE_SIGNBIT_USING_GCC@ +REPLACE_SLEEP = @REPLACE_SLEEP@ REPLACE_SNPRINTF = @REPLACE_SNPRINTF@ REPLACE_SPRINTF = @REPLACE_SPRINTF@ +REPLACE_STAT = @REPLACE_STAT@ REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@ REPLACE_STRCASESTR = @REPLACE_STRCASESTR@ REPLACE_STRDUP = @REPLACE_STRDUP@ @@ -1406,8 +1398,14 @@ REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@ REPLACE_STRSTR = @REPLACE_STRSTR@ REPLACE_STRTOD = @REPLACE_STRTOD@ REPLACE_STRTOK_R = @REPLACE_STRTOK_R@ +REPLACE_SYMLINK = @REPLACE_SYMLINK@ REPLACE_TIMEGM = @REPLACE_TIMEGM@ REPLACE_TRUNCL = @REPLACE_TRUNCL@ +REPLACE_UNLINK = @REPLACE_UNLINK@ +REPLACE_UNLINKAT = @REPLACE_UNLINKAT@ +REPLACE_UNSETENV = @REPLACE_UNSETENV@ +REPLACE_USLEEP = @REPLACE_USLEEP@ +REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@ REPLACE_VASPRINTF = @REPLACE_VASPRINTF@ REPLACE_VDPRINTF = @REPLACE_VDPRINTF@ REPLACE_VFPRINTF = @REPLACE_VFPRINTF@ @@ -1421,7 +1419,6 @@ REPLACE_WCTOB = @REPLACE_WCTOB@ REPLACE_WCWIDTH = @REPLACE_WCWIDTH@ REPLACE_WRITE = @REPLACE_WRITE@ SELINUX_CONTEXT_H = @SELINUX_CONTEXT_H@ -SELINUX_SELINUX_H = @SELINUX_SELINUX_H@ SEQ_LIBM = @SEQ_LIBM@ SERVENT_LIB = @SERVENT_LIB@ SET_MAKE = @SET_MAKE@ @@ -1433,10 +1430,8 @@ STDBOOL_H = @STDBOOL_H@ STDDEF_H = @STDDEF_H@ STDINT_H = @STDINT_H@ STRIP = @STRIP@ -SYS_IOCTL_H = @SYS_IOCTL_H@ SYS_IOCTL_H_HAVE_WINSOCK2_H = @SYS_IOCTL_H_HAVE_WINSOCK2_H@ SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ -SYS_SELECT_H = @SYS_SELECT_H@ SYS_SOCKET_H = @SYS_SOCKET_H@ SYS_TIME_H = @SYS_TIME_H@ SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ @@ -1450,9 +1445,7 @@ UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOC USE_ACL = @USE_ACL@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ -VOID_UNSETENV = @VOID_UNSETENV@ WARN_CFLAGS = @WARN_CFLAGS@ -WCHAR_H = @WCHAR_H@ WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@ WCTYPE_H = @WCTYPE_H@ WERROR_CFLAGS = @WERROR_CFLAGS@ @@ -1462,6 +1455,7 @@ XGETTEXT_015 = @XGETTEXT_015@ XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ YACC = @YACC@ YFLAGS = @YFLAGS@ +YIELD_LIB = @YIELD_LIB@ abs_aux_dir = @abs_aux_dir@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ @@ -1527,25 +1521,36 @@ no_install__progs = \ arch hostname su build_if_possible__progs = \ - chroot df hostid nice pinky stdbuf libstdbuf.so stty su uname uptime users who + chroot \ + df \ + hostid \ + libstdbuf.so \ + nice \ + pinky \ + stdbuf \ + stty \ + su \ + uptime \ + users \ + who AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) bin_PROGRAMS = $(OPTIONAL_BIN_PROGS) pkglib_PROGRAMS = $(OPTIONAL_PKGLIB_PROGS) noinst_HEADERS = \ - chown-core.h \ - copy.h \ - cp-hash.h \ - dircolors.h \ - fs.h \ - group-list.h \ - ls.h \ - operand2sig.h \ - prog-fprintf.h \ - remove.h \ - system.h \ - wheel-size.h \ - wheel.h \ + chown-core.h \ + copy.h \ + cp-hash.h \ + dircolors.h \ + fs.h \ + group-list.h \ + ls.h \ + operand2sig.h \ + prog-fprintf.h \ + remove.h \ + system.h \ + wheel-size.h \ + wheel.h \ uname.h EXTRA_DIST = dcgen dircolors.hin tac-pipe.c \ @@ -1556,7 +1561,8 @@ BUILT_SOURCES = dircolors.h wheel-size.h wheel.h fs.h version.c \ # Also remove these sometimes-built programs. # For example, even when excluded, they're built via sc_check-AUTHORS. -CLEANFILES = $(SCRIPTS) su $(no_install__progs) +CLEANFILES = $(SCRIPTS) su $(no_install__progs) fs-def fs-magic \ + fs-kernel-magic AM_CPPFLAGS = -I$(top_srcdir)/lib noinst_LIBRARIES = libver.a nodist_libver_a_SOURCES = version.c version.h @@ -1568,82 +1574,157 @@ nodist_libver_a_SOURCES = version.c version.h # replacement functions defined in libcoreutils.a. LDADD = libver.a ../lib/libcoreutils.a $(LIBINTL) ../lib/libcoreutils.a -# Append $(LIBICONV) to each program that uses proper_name_utf8. +# First, list all programs, to make listing per-program libraries easier. +# See [ below. +arch_LDADD = $(LDADD) +base64_LDADD = $(LDADD) +basename_LDADD = $(LDADD) + +# for print_unicode_char, proper_name_utf8 cat_LDADD = $(LDADD) $(LIBICONV) -df_LDADD = $(LDADD) $(LIBICONV) -du_LDADD = $(LDADD) $(LIBICONV) -getlimits_LDADD = $(LDADD) $(LIBICONV) -ptx_LDADD = $(LDADD) $(LIBICONV) -split_LDADD = $(LDADD) $(LIBICONV) -stdbuf_LDADD = $(LDADD) $(LIBICONV) -timeout_LDADD = $(LDADD) $(LIBICONV) -truncate_LDADD = $(LDADD) $(LIBICONV) -# for eaccess in lib/euidaccess.c. +# for selinux use chcon_LDADD = $(LDADD) $(LIB_SELINUX) -cp_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX) $(LIB_ACL) \ - $(LIB_XATTR) $(LIBICONV) -ginstall_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX) $(LIB_ACL) \ - $(LIB_XATTR) -mkdir_LDADD = $(LDADD) $(LIB_SELINUX) -mkfifo_LDADD = $(LDADD) $(LIB_SELINUX) -mknod_LDADD = $(LDADD) $(LIB_SELINUX) -mv_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX) $(LIB_ACL) \ - $(LIB_XATTR) -runcon_LDADD = $(LDADD) $(LIB_SELINUX) -pathchk_LDADD = $(LDADD) $(LIB_EACCESS) -rm_LDADD = $(LDADD) $(LIB_EACCESS) -test_LDADD = $(LDADD) $(LIB_EACCESS) -# This is for the '[' program. Automake transliterates '[' to '_'. -__LDADD = $(LDADD) $(LIB_EACCESS) - -# for clock_gettime and fdatasync -dd_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC) -dir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) $(LIB_CAP) \ - $(LIB_ACL) -id_LDADD = $(LDADD) $(LIB_SELINUX) -ls_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) $(LIB_CAP) \ - $(LIB_ACL) -mktemp_LDADD = $(LDADD) $(LIB_GETHRXTIME) -pr_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) -shred_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC) -shuf_LDADD = $(LDADD) $(LIB_GETHRXTIME) -tac_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) -vdir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) $(LIB_CAP) \ - $(LIB_ACL) -sort_LDADD = $(LDADD) $(POW_LIB) $(LIB_GETHRXTIME) - -# for get_date and gettime +chgrp_LDADD = $(LDADD) +chmod_LDADD = $(LDADD) +chown_LDADD = $(LDADD) +chroot_LDADD = $(LDADD) +cksum_LDADD = $(LDADD) +comm_LDADD = $(LDADD) +nproc_LDADD = $(LDADD) +cp_LDADD = $(LDADD) $(copy_LDADD) $(LIBICONV) +csplit_LDADD = $(LDADD) +cut_LDADD = $(LDADD) date_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) -touch_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) -# If necessary, add -lm to resolve use of pow in lib/strtod.c. -# If necessary, add -liconv to resolve use of iconv in lib/unicodeio.c. -printf_LDADD = $(LDADD) $(POW_LIB) $(LIBICONV) +# for gethrxtime, randint, randread, gen_tempname, mkstemp -# If necessary, add -lm to resolve use of pow in lib/strtod.c. -seq_LDADD = $(LDADD) $(POW_LIB) - -# If necessary, add libraries to resolve the `pow' reference in lib/strtod.c -# and the `nanosleep' reference in lib/xnanosleep.c. -nanosec_libs = $(LDADD) $(POW_LIB) $(LIB_NANOSLEEP) +# for fdatasync +dd_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC) +df_LDADD = $(LDADD) $(LIBICONV) +# See dir_LDADD below +dircolors_LDADD = $(LDADD) +dirname_LDADD = $(LDADD) +du_LDADD = $(LDADD) $(LIBICONV) +echo_LDADD = $(LDADD) +env_LDADD = $(LDADD) +expand_LDADD = $(LDADD) # for various GMP functions expr_LDADD = $(LDADD) $(LIB_GMP) - -# for various GMP functions factor_LDADD = $(LDADD) $(LIB_GMP) -sleep_LDADD = $(nanosec_libs) -tail_LDADD = $(nanosec_libs) +false_LDADD = $(LDADD) +fmt_LDADD = $(LDADD) +fold_LDADD = $(LDADD) +getlimits_LDADD = $(LDADD) $(LIBICONV) +ginstall_LDADD = $(LDADD) $(copy_LDADD) $(LIB_SELINUX) \ + $(LIB_CLOCK_GETTIME) +groups_LDADD = $(LDADD) +head_LDADD = $(LDADD) +hostid_LDADD = $(LDADD) -# If necessary, add -lm to resolve use of pow in lib/strtod.c. -uptime_LDADD = $(LDADD) $(POW_LIB) $(GETLOADAVG_LIBS) -su_LDADD = $(LDADD) $(LIB_CRYPT) -stat_LDADD = $(LDADD) $(LIB_SELINUX) +# for gethostname, uname +hostname_LDADD = $(LDADD) $(GETHOSTNAME_LIB) +id_LDADD = $(LDADD) $(LIB_SELINUX) +join_LDADD = $(LDADD) +kill_LDADD = $(LDADD) +link_LDADD = $(LDADD) +ln_LDADD = $(LDADD) +logname_LDADD = $(LDADD) -# programs that use getaddrinfo (e.g., via canon_host) +# for cap_get_file +ls_LDADD = $(LDADD) $(LIB_SELINUX) $(LIB_CLOCK_GETTIME) $(LIB_CAP) \ + $(LIB_ACL) +md5sum_LDADD = $(LDADD) +mkdir_LDADD = $(LDADD) $(LIB_SELINUX) +mkfifo_LDADD = $(LDADD) $(LIB_SELINUX) +mknod_LDADD = $(LDADD) $(LIB_SELINUX) +mktemp_LDADD = $(LDADD) $(LIB_GETHRXTIME) +mv_LDADD = $(LDADD) $(copy_LDADD) $(remove_LDADD) +nice_LDADD = $(LDADD) +nl_LDADD = $(LDADD) +nohup_LDADD = $(LDADD) +od_LDADD = $(LDADD) +paste_LDADD = $(LDADD) +pathchk_LDADD = $(LDADD) + +# for canon_host pinky_LDADD = $(LDADD) $(GETADDRINFO_LIB) +pr_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) +printenv_LDADD = $(LDADD) + +# for strtod, strtold +printf_LDADD = $(LDADD) $(POW_LIB) $(LIBICONV) +ptx_LDADD = $(LDADD) $(LIBICONV) +pwd_LDADD = $(LDADD) +readlink_LDADD = $(LDADD) +rm_LDADD = $(LDADD) $(remove_LDADD) +rmdir_LDADD = $(LDADD) +runcon_LDADD = $(LDADD) $(LIB_SELINUX) +seq_LDADD = $(LDADD) $(POW_LIB) +setuidgid_LDADD = $(LDADD) +sha1sum_LDADD = $(LDADD) +sha224sum_LDADD = $(LDADD) +sha256sum_LDADD = $(LDADD) +sha384sum_LDADD = $(LDADD) +sha512sum_LDADD = $(LDADD) +shred_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC) +shuf_LDADD = $(LDADD) $(LIB_GETHRXTIME) + +# for xnanosleep +sleep_LDADD = $(LDADD) $(POW_LIB) $(LIB_NANOSLEEP) +sort_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(POW_LIB) $(LIB_NANOSLEEP) +split_LDADD = $(LDADD) $(LIBICONV) +stat_LDADD = $(LDADD) $(LIB_SELINUX) +stdbuf_LDADD = $(LDADD) $(LIBICONV) +stty_LDADD = $(LDADD) + +# for crypt +su_LDADD = $(LDADD) $(LIB_CRYPT) +sum_LDADD = $(LDADD) +sync_LDADD = $(LDADD) +tac_LDADD = $(LDADD) $(LIB_GETHRXTIME) +tail_LDADD = $(LDADD) $(POW_LIB) $(LIB_NANOSLEEP) +tee_LDADD = $(LDADD) +test_LDADD = $(LDADD) $(LIB_EACCESS) +timeout_LDADD = $(LDADD) $(LIBICONV) +touch_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) +tr_LDADD = $(LDADD) +true_LDADD = $(LDADD) +truncate_LDADD = $(LDADD) $(LIBICONV) +tsort_LDADD = $(LDADD) +tty_LDADD = $(LDADD) +uname_LDADD = $(LDADD) $(GETHOSTNAME_LIB) +unexpand_LDADD = $(LDADD) +uniq_LDADD = $(LDADD) +unlink_LDADD = $(LDADD) + +# for getloadavg +uptime_LDADD = $(LDADD) $(POW_LIB) $(GETLOADAVG_LIBS) +users_LDADD = $(LDADD) +# See vdir_LDADD below +wc_LDADD = $(LDADD) who_LDADD = $(LDADD) $(GETADDRINFO_LIB) +whoami_LDADD = $(LDADD) +yes_LDADD = $(LDADD) + +# Synonyms. Recall that Automake transliterates '[' to '_'. +__LDADD = $(test_LDADD) +dir_LDADD = $(ls_LDADD) +vdir_LDADD = $(ls_LDADD) + +# Shared files + +# for eaccess, euidaccess + +# for gettime, settime, utimecmp, utimens + +# for various ACL functions + +# for various xattr functions +copy_LDADD = $(LIB_EACCESS) $(LIB_SELINUX) $(LIB_CLOCK_GETTIME) \ + $(LIB_ACL) $(LIB_XATTR) +remove_LDADD = $(LIB_EACCESS) # Get the release year from ../lib/version-etc.c. RELEASE_YEAR = \ @@ -1687,6 +1768,7 @@ mkdir_SOURCES = mkdir.c prog-fprintf.c rmdir_SOURCES = rmdir.c prog-fprintf.c uname_SOURCES = uname.c uname-uname.c arch_SOURCES = uname.c uname-arch.c +nproc_SOURCES = nproc.c md5sum_SOURCES = md5sum.c md5sum_CPPFLAGS = -DHASH_ALGO_MD5=1 $(AM_CPPFLAGS) sha1sum_SOURCES = md5sum.c @@ -1717,6 +1799,29 @@ wheel_size = 5 # test doesn't support --help or --version. # Tell automake to exempt then from that installcheck test. AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = false test + +# Massage bits of the statfs man page and definitions from +# /usr/include/linux/magic.h to be in a form consistent with what's in fs.h. +fs_normalize_perl_subst = \ + -e 's/MINIX_SUPER_MAGIC\b/MINIX/;' \ + -e 's/MINIX_SUPER_MAGIC2\b/MINIX_30/;' \ + -e 's/MINIX2_SUPER_MAGIC\b/MINIX_V2/;' \ + -e 's/MINIX2_SUPER_MAGIC2\b/MINIX_V2_30/;' \ + -e 's/MINIX3_SUPER_MAGIC\b/MINIX_V3/;' \ + -e 's/CIFS_MAGIC_NUMBER/CIFS/;' \ + -e 's/(_SUPER)?_MAGIC//;' \ + -e 's/\s+0x(\S+)/" 0x" . uc $$1/e;' \ + -e 's/(\s+0x)(\X{3})\b/$${1}0$$2/;' \ + -e 's/(\s+0x)(\X{6})\b/$${1}00$$2/;' \ + -e 's/(\s+0x)(\X{7})\b/$${1}0$$2/;' \ + -e 's/^\s+//;' \ + -e 's/^\#define\s+//;' \ + -e 's/^_(XIAFS)/$$1/;' \ + -e 's/^USBDEVICE/USBDEVFS/;' \ + -e 's/NTFS_SB/NTFS/;' \ + -e 's/^/\# define S_MAGIC_/;' \ + -e 's,\s*/\* .*? \*/,,;' + DISTCLEANFILES = version.c version.h MAINTAINERCLEANFILES = $(BUILT_SOURCES) @@ -2019,6 +2124,9 @@ nl$(EXEEXT): $(nl_OBJECTS) $(nl_DEPENDENCIES) nohup$(EXEEXT): $(nohup_OBJECTS) $(nohup_DEPENDENCIES) @rm -f nohup$(EXEEXT) $(AM_V_CCLD)$(LINK) $(nohup_OBJECTS) $(nohup_LDADD) $(LIBS) +nproc$(EXEEXT): $(nproc_OBJECTS) $(nproc_DEPENDENCIES) + @rm -f nproc$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(nproc_OBJECTS) $(nproc_LDADD) $(LIBS) od$(EXEEXT): $(od_OBJECTS) $(od_DEPENDENCIES) @rm -f od$(EXEEXT) $(AM_V_CCLD)$(LINK) $(od_OBJECTS) $(od_LDADD) $(LIBS) @@ -2246,6 +2354,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nice.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nohup.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nproc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/od.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/operand2sig.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/paste.Po@am__quote@ @@ -2546,6 +2655,20 @@ GTAGS: && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags @@ -2696,19 +2819,19 @@ uninstall-am: uninstall-binPROGRAMS uninstall-local \ .PHONY: CTAGS GTAGS all all-am all-local check check-am clean \ clean-binPROGRAMS clean-generic clean-noinstLIBRARIES \ - clean-noinstPROGRAMS clean-pkglibPROGRAMS ctags dist-hook \ - distclean distclean-compile distclean-generic distclean-tags \ - distdir dvi dvi-am html html-am info info-am install \ - install-am install-binPROGRAMS install-data install-data-am \ - install-dvi install-dvi-am install-exec install-exec-am \ - install-exec-hook install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-pkglibPROGRAMS install-ps install-ps-am install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ - uninstall-am uninstall-binPROGRAMS uninstall-local \ - uninstall-pkglibPROGRAMS + clean-noinstPROGRAMS clean-pkglibPROGRAMS cscopelist ctags \ + dist-hook distclean distclean-compile distclean-generic \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-binPROGRAMS install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-exec-hook install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-pkglibPROGRAMS install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-binPROGRAMS \ + uninstall-local uninstall-pkglibPROGRAMS $(PROGRAMS): ../lib/libcoreutils.a @@ -2762,6 +2885,31 @@ wheel.h: wheel-gen.pl Makefile.am $(AM_V_at)$(srcdir)/wheel-gen.pl $(wheel_size) > $@-t $(AM_V_at)chmod a-w $@-t $(AM_V_at)mv $@-t $@ + +# Compare fs.h with the list of file system names/magic-numbers in the +# Linux statfs man page. This target prints any new name/number pairs. +# Also compare against /usr/include/linux/magic.h +.PHONY: fs-magic-compare +fs-magic-compare: fs-magic fs-kernel-magic fs-def + join -v1 -t@ fs-magic fs-def + join -v1 -t@ fs-kernel-magic fs-def +fs-def: fs.h + grep '^# *define ' $< > $@-t && mv $@-t $@ +fs-magic: Makefile + man statfs \ + |perl -ne '/File system types:/.../Nobody kno/ and print' \ + |grep 0x | perl -p \ + $(fs_normalize_perl_subst) \ + | grep -Ev 'S_MAGIC_EXT[34]|STACK_END' \ + | LC_ALL=C sort \ + > $@-t && mv $@-t $@ +fs-kernel-magic: Makefile + perl -ne '/^#define.*0x/ and print' /usr/include/linux/magic.h \ + | perl -p \ + $(fs_normalize_perl_subst) \ + | grep -Ev 'S_MAGIC_EXT[34]|STACK_END' \ + | LC_ALL=C sort \ + > $@-t && mv $@-t $@ fs.h: stat.c extract-magic $(AM_V_GEN)rm -f $@ $(AM_V_at)$(PERL) $(srcdir)/extract-magic $(srcdir)/stat.c > $@t @@ -2858,7 +3006,7 @@ sc_tight_scope: $(bin_PROGRAMS) ( printf 'main\nusage\n_.*\n'; \ grep -h -A1 '^extern .*[^;]$$' $$src \ | grep -vE '^(extern |--)' | sed 's/ .*//'; \ - perl -ne '/^extern \S+ (\S*) \(/ and print "$$1\n"' $$hdr; \ + perl -ne '/^extern (?:enum )?\S+ (\S*) \(/ and print "$$1\n"' $$hdr; \ ) | $(ASSORT) -u | sed 's/^/^/;s/$$/$$/' > $$t; \ nm -e *.$(OBJEXT) \ | sed -n 's/.* T //p' \ diff --git a/src/bin/coreutils/src/base64.c b/src/bin/coreutils/src/base64.c index c7cf034da4..dde54459c7 100644 --- a/src/bin/coreutils/src/base64.c +++ b/src/bin/coreutils/src/base64.c @@ -1,5 +1,5 @@ /* Base64 encode/decode strings or files. - Copyright (C) 2004-2009 Free Software Foundation, Inc. + Copyright (C) 2004-2010 Free Software Foundation, Inc. This file is part of Base64. @@ -68,9 +68,8 @@ Base64 encode or decode FILE, or standard input, to standard output.\n\ -i, --ignore-garbage When decoding, ignore non-alphabet characters.\n\ \n\ "), stdout); - fputs (_("\ - --help Display this help and exit.\n\ - --version Output version information and exit.\n"), stdout); + fputs (HELP_OPTION_DESCRIPTION, stdout); + fputs (VERSION_OPTION_DESCRIPTION, stdout); fputs (_("\ \n\ With no FILE, or when FILE is -, read standard input.\n"), stdout); @@ -81,7 +80,7 @@ When decoding, the input may contain newlines in addition to the bytes of\n\ the formal base64 alphabet. Use --ignore-garbage to attempt to recover\n\ from any other non-alphabet bytes in the encoded stream.\n"), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); diff --git a/src/bin/coreutils/src/basename.c b/src/bin/coreutils/src/basename.c index 4300d49836..e81fdb1743 100644 --- a/src/bin/coreutils/src/basename.c +++ b/src/bin/coreutils/src/basename.c @@ -1,5 +1,5 @@ /* basename -- strip directory and suffix from file names - Copyright (C) 1990-1997, 1999-2009 Free Software Foundation, Inc. + Copyright (C) 1990-1997, 1999-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -66,7 +66,7 @@ Examples:\n\ %s include/stdio.h .h Output \"stdio\".\n\ "), program_name, program_name); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/cat.c b/src/bin/coreutils/src/cat.c index 41b2637f21..c33e0b3798 100644 --- a/src/bin/coreutils/src/cat.c +++ b/src/bin/coreutils/src/cat.c @@ -1,5 +1,5 @@ /* cat -- concatenate files and print on the standard output. - Copyright (C) 88, 90, 91, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1988, 1990-1991, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -119,7 +119,7 @@ Examples:\n\ %s Copy standard input to standard output.\n\ "), program_name, program_name); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -388,7 +388,7 @@ cat ( /* Are line numbers to be written at empty lines (-n)? */ - if (number & !number_nonblank) + if (number && !number_nonblank) { next_line_num (); bpout = stpcpy (bpout, line_num_print); @@ -657,7 +657,7 @@ main (int argc, char **argv) #endif } - if (! (number | show_ends | squeeze_blank)) + if (! (number || show_ends || squeeze_blank)) { file_open_mode |= O_BINARY; if (O_BINARY && ! isatty (STDOUT_FILENO)) @@ -719,8 +719,8 @@ main (int argc, char **argv) /* Select which version of `cat' to use. If any format-oriented options were given use `cat'; otherwise use `simple_cat'. */ - if (! (number | show_ends | show_nonprinting - | show_tabs | squeeze_blank)) + if (! (number || show_ends || show_nonprinting + || show_tabs || squeeze_blank)) { insize = MAX (insize, outsize); inbuf = xmalloc (insize + page_size - 1); diff --git a/src/bin/coreutils/src/chcon.c b/src/bin/coreutils/src/chcon.c index 7e8250d3da..02f190dae2 100644 --- a/src/bin/coreutils/src/chcon.c +++ b/src/bin/coreutils/src/chcon.c @@ -1,5 +1,5 @@ /* chcon -- change security context of files - Copyright (C) 2005-2009 Free Software Foundation, Inc. + Copyright (C) 2005-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -267,6 +267,14 @@ process_file (FTS *fts, FTSENT *ent) ok = false; break; + case FTS_DC: /* directory that causes cycles */ + if (cycle_warning_required (fts, ent)) + { + emit_cycle_warning (file_full_name); + return false; + } + break; + default: break; } @@ -380,7 +388,7 @@ one takes effect.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -546,10 +554,10 @@ main (int argc, char **argv) if (reference_file && component_specified) { error (0, 0, _("conflicting security context specifiers given")); - usage (1); + usage (EXIT_FAILURE); } - if (recurse & preserve_root) + if (recurse && preserve_root) { static struct dev_ino dev_ino_buf; root_dev_ino = get_root_dev_ino (&dev_ino_buf); diff --git a/src/bin/coreutils/src/chgrp.c b/src/bin/coreutils/src/chgrp.c index 0102ef0981..d41eefea7e 100644 --- a/src/bin/coreutils/src/chgrp.c +++ b/src/bin/coreutils/src/chgrp.c @@ -1,5 +1,5 @@ /* chgrp -- change group ownership of files - Copyright (C) 89, 90, 91, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1989-1991, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -158,7 +158,7 @@ Examples:\n\ %s -hR staff /u Change the group of /u and subfiles to \"staff\".\n\ "), program_name, program_name); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -293,7 +293,7 @@ main (int argc, char **argv) gid = parse_group (group_name); } - if (chopt.recurse & preserve_root) + if (chopt.recurse && preserve_root) { static struct dev_ino dev_ino_buf; chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf); diff --git a/src/bin/coreutils/src/chmod.c b/src/bin/coreutils/src/chmod.c index 282eadaffb..3dab92e68e 100644 --- a/src/bin/coreutils/src/chmod.c +++ b/src/bin/coreutils/src/chmod.c @@ -1,5 +1,5 @@ /* chmod -- change permission modes of files - Copyright (C) 89, 90, 91, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1989-1991, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -228,6 +228,15 @@ process_file (FTS *fts, FTSENT *ent) error (0, 0, _("cannot operate on dangling symlink %s"), quote (file_full_name)); ok = false; + break; + + case FTS_DC: /* directory that causes cycles */ + if (cycle_warning_required (fts, ent)) + { + emit_cycle_warning (file_full_name); + return false; + } + break; default: break; @@ -279,7 +288,7 @@ process_file (FTS *fts, FTSENT *ent) } } - if (chmod_succeeded & diagnose_surprises) + if (chmod_succeeded && diagnose_surprises) { mode_t naively_expected_mode = mode_adjust (old_mode, S_ISDIR (old_mode) != 0, 0, change, NULL); @@ -379,7 +388,7 @@ Change the mode of each FILE to MODE.\n\ \n\ Each MODE is of the form `[ugoa]*([-+=]([rwxXst]*|[ugo]))+'.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -523,7 +532,7 @@ main (int argc, char **argv) umask_value = umask (0); } - if (recurse & preserve_root) + if (recurse && preserve_root) { static struct dev_ino dev_ino_buf; root_dev_ino = get_root_dev_ino (&dev_ino_buf); diff --git a/src/bin/coreutils/src/chown-core.c b/src/bin/coreutils/src/chown-core.c index 705a29bd38..22a178ad92 100644 --- a/src/bin/coreutils/src/chown-core.c +++ b/src/bin/coreutils/src/chown-core.c @@ -1,5 +1,5 @@ /* chown-core.c -- core functions for changing ownership. - Copyright (C) 2000, 2002-2009 Free Software Foundation, Inc. + Copyright (C) 2000, 2002-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -316,6 +316,14 @@ change_file_owner (FTS *fts, FTSENT *ent, ok = false; break; + case FTS_DC: /* directory that causes cycles */ + if (cycle_warning_required (fts, ent)) + { + emit_cycle_warning (file_full_name); + return false; + } + break; + default: break; } @@ -440,7 +448,7 @@ change_file_owner (FTS *fts, FTSENT *ent, if (chopt->verbosity != V_off) { bool changed = - ((do_chown & ok & symlink_changed) + ((do_chown && ok && symlink_changed) && ! ((uid == (uid_t) -1 || uid == file_stats->st_uid) && (gid == (gid_t) -1 || gid == file_stats->st_gid))); diff --git a/src/bin/coreutils/src/chown-core.h b/src/bin/coreutils/src/chown-core.h index 4947cad290..6cf3734883 100644 --- a/src/bin/coreutils/src/chown-core.h +++ b/src/bin/coreutils/src/chown-core.h @@ -1,6 +1,6 @@ /* chown-core.h -- types and prototypes shared by chown and chgrp. - Copyright (C) 2000, 2003-2005, 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2000, 2003-2005, 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/src/chown.c b/src/bin/coreutils/src/chown.c index 35488d90e8..7a943b538e 100644 --- a/src/bin/coreutils/src/chown.c +++ b/src/bin/coreutils/src/chown.c @@ -1,5 +1,5 @@ /* chown -- change user and group ownership of files - Copyright (C) 89, 90, 91, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1989-1991, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -14,18 +14,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -/* - | user - | unchanged explicit - -------------|-------------------------+-------------------------| - g unchanged | --- | chown u | - r |-------------------------+-------------------------| - o explicit | chgrp g or chown .g | chown u.g | - u |-------------------------+-------------------------| - p from passwd| --- | chown u. | - |-------------------------+-------------------------| - - Written by David MacKenzie . */ +/* Written by David MacKenzie . */ #include #include @@ -153,7 +142,7 @@ Examples:\n\ %s -hR root /u Change the owner of /u and subfiles to \"root\".\n\ "), program_name, program_name, program_name); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -317,7 +306,7 @@ main (int argc, char **argv) optind++; } - if (chopt.recurse & preserve_root) + if (chopt.recurse && preserve_root) { static struct dev_ino dev_ino_buf; chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf); diff --git a/src/bin/coreutils/src/chroot.c b/src/bin/coreutils/src/chroot.c index 5329a9d68c..40448f6077 100644 --- a/src/bin/coreutils/src/chroot.c +++ b/src/bin/coreutils/src/chroot.c @@ -1,6 +1,5 @@ /* chroot -- run command or shell with special root directory - Copyright (C) 95, 96, 1997, 1999-2004, 2007-2009 - Free Software Foundation, Inc. + Copyright (C) 1995-1997, 1999-2004, 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -91,7 +90,7 @@ set_additional_groups (char const *groups) } if (n_gids == n_gids_allocated) - gids = x2nrealloc (gids, &n_gids_allocated, sizeof *gids); + gids = X2NREALLOC (gids, &n_gids_allocated); gids[n_gids++] = value; } @@ -142,7 +141,7 @@ Run COMMAND with root directory set to NEWROOT.\n\ \n\ If no command is given, run ``${SHELL} -i'' (default: /bin/sh).\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -160,7 +159,7 @@ main (int argc, char **argv) bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); - initialize_exit_failure (EXIT_FAILURE); + initialize_exit_failure (EXIT_CANCELED); atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version, @@ -177,22 +176,22 @@ main (int argc, char **argv) groups = optarg; break; default: - usage (EXIT_FAILURE); + usage (EXIT_CANCELED); } } if (argc <= optind) { error (0, 0, _("missing operand")); - usage (EXIT_FAILURE); + usage (EXIT_CANCELED); } if (chroot (argv[optind]) != 0) - error (EXIT_FAILURE, errno, _("cannot change root directory to %s"), + error (EXIT_CANCELED, errno, _("cannot change root directory to %s"), argv[optind]); if (chdir ("/")) - error (EXIT_FAILURE, errno, _("cannot chdir to root directory")); + error (EXIT_CANCELED, errno, _("cannot chdir to root directory")); if (argc == optind + 1) { @@ -224,7 +223,7 @@ main (int argc, char **argv) char const *err = parse_user_spec (userspec, &uid, &gid, &user, &group); if (err) - error (EXIT_FAILURE, errno, "%s", err); + error (EXIT_CANCELED, errno, "%s", err); free (user); free (group); @@ -255,7 +254,7 @@ main (int argc, char **argv) } if (fail) - exit (EXIT_FAILURE); + exit (EXIT_CANCELED); } /* Execute the given command. */ diff --git a/src/bin/coreutils/src/cksum.c b/src/bin/coreutils/src/cksum.c index 25cdb4789b..d240eb3862 100644 --- a/src/bin/coreutils/src/cksum.c +++ b/src/bin/coreutils/src/cksum.c @@ -1,5 +1,5 @@ /* cksum -- calculate and print POSIX checksums and sizes of files - Copyright (C) 92, 1995-2006, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 1992, 1995-2006, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -269,7 +269,7 @@ Print CRC checksum and byte counts of each FILE.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/comm.c b/src/bin/coreutils/src/comm.c index 63b6b0c269..4e4aad5162 100644 --- a/src/bin/coreutils/src/comm.c +++ b/src/bin/coreutils/src/comm.c @@ -1,5 +1,6 @@ /* comm -- compare two sorted files line by line. - Copyright (C) 86, 90, 91, 1995-2005, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 1986, 1990-1991, 1995-2005, 2008-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,6 +24,7 @@ #include "system.h" #include "linebuffer.h" #include "error.h" +#include "hard-locale.h" #include "quote.h" #include "stdio--.h" #include "memcmp2.h" @@ -140,7 +142,7 @@ Examples:\n\ %s -3 file1 file2 Print lines in file1 not in file2, and vice versa.\n\ "), program_name, program_name); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/copy.c b/src/bin/coreutils/src/copy.c index 8a1a6481d6..e20566a460 100644 --- a/src/bin/coreutils/src/copy.c +++ b/src/bin/coreutils/src/copy.c @@ -1,5 +1,5 @@ /* copy.c -- core functions for copying files and directories - Copyright (C) 89, 90, 91, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1989-1991, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -128,17 +128,12 @@ static char const *top_level_dst_name; static inline int utimens_symlink (char const *file, struct timespec const *timespec) { - int err = 0; - -#if HAVE_UTIMENSAT - err = utimensat (AT_FDCWD, file, timespec, AT_SYMLINK_NOFOLLOW); + int err = lutimens (file, timespec); /* When configuring on a system with new headers and libraries, and running on one with a kernel that is old enough to lack the syscall, utimensat fails with ENOSYS. Ignore that. */ if (err && errno == ENOSYS) err = 0; -#endif - return err; } @@ -454,11 +449,11 @@ set_owner (const struct cp_options *x, char const *dst_name, int dest_desc, group. Avoid the window by first changing to a restrictive temporary mode if necessary. */ - if (!new_dst && (x->preserve_mode | x->move_mode | x->set_mode)) + if (!new_dst && (x->preserve_mode || x->move_mode || x->set_mode)) { mode_t old_mode = dst_sb->st_mode; mode_t new_mode = - (x->preserve_mode | x->move_mode ? src_sb->st_mode : x->mode); + (x->preserve_mode || x->move_mode ? src_sb->st_mode : x->mode); mode_t restrictive_temp_mode = old_mode & new_mode & S_IRWXU; if ((USE_ACL @@ -928,6 +923,24 @@ copy_reg (char const *src_name, char const *dst_name, } } + /* To allow copying xattrs on read-only files, temporarily chmod u+rw. + This workaround is required as an inode permission check is done + by xattr_permission() in fs/xattr.c of the GNU/Linux kernel tree. */ + if (x->preserve_xattr) + { + bool access_changed = false; + + if (!(sb.st_mode & S_IWUSR) && geteuid() != 0) + access_changed = fchmod_or_lchmod (dest_desc, dst_name, 0600) == 0; + + if (!copy_attr_by_fd (src_name, source_desc, dst_name, dest_desc, x) + && x->require_preserve_xattr) + return_val = false; + + if (access_changed) + fchmod_or_lchmod (dest_desc, dst_name, dst_mode & ~omitted_permissions); + } + if (x->preserve_ownership && ! SAME_OWNER_AND_GROUP (*src_sb, sb)) { switch (set_owner (x, dst_name, dest_desc, src_sb, *new_dst, &sb)) @@ -944,11 +957,6 @@ copy_reg (char const *src_name, char const *dst_name, set_author (dst_name, dest_desc, src_sb); - if (x->preserve_xattr && ! copy_attr_by_fd (src_name, source_desc, - dst_name, dest_desc, x) - && x->require_preserve_xattr) - return_val = false; - if (x->preserve_mode || x->move_mode) { if (copy_acl (src_name, source_desc, dst_name, dest_desc, src_mode) != 0 @@ -1770,7 +1778,9 @@ copy_internal (char const *src_name, char const *dst_name, } else { - bool link_failed = (link (earlier_file, dst_name) != 0); + /* We want to guarantee that symlinks are not followed. */ + bool link_failed = (linkat (AT_FDCWD, earlier_file, AT_FDCWD, + dst_name, 0) != 0); /* If the link failed because of an existing destination, remove that file and then call link again. */ @@ -1783,7 +1793,8 @@ copy_internal (char const *src_name, char const *dst_name, } if (x->verbose) printf (_("removed %s\n"), quote (dst_name)); - link_failed = (link (earlier_file, dst_name) != 0); + link_failed = (linkat (AT_FDCWD, earlier_file, AT_FDCWD, + dst_name, 0) != 0); } if (link_failed) @@ -2081,25 +2092,15 @@ copy_internal (char const *src_name, char const *dst_name, } } - /* POSIX 2008 states that it is implementation-defined whether - link() on a symlink creates a hard-link to the symlink, or only - to the referent (effectively dereferencing the symlink) (POSIX - 2001 required the latter behavior, although many systems provided - the former). Yet cp, invoked with `--link --no-dereference', - should not follow the link. We can approximate the desired - behavior by skipping this hard-link creating block and instead - copying the symlink, via the `S_ISLNK'- copying code below. - LINK_FOLLOWS_SYMLINKS is tri-state; if it is -1, we don't know - how link() behaves, so we use the fallback case for safety. - - FIXME - use a gnulib linkat emulation for more fine-tuned - emulation, particularly when LINK_FOLLOWS_SYMLINKS is -1. */ + /* cp, invoked with `--link --no-dereference', should not follow the + link; we guarantee this with gnulib's linkat module (on systems + where link(2) follows the link, gnulib creates a symlink with + identical contents, which is good enough for our purposes). */ else if (x->hard_link - && (!LINK_FOLLOWS_SYMLINKS - || !S_ISLNK (src_mode) + && (!S_ISLNK (src_mode) || x->dereference != DEREF_NEVER)) { - if (link (src_name, dst_name)) + if (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0)) { error (0, errno, _("cannot create link %s"), quote (dst_name)); goto un_backup; diff --git a/src/bin/coreutils/src/copy.h b/src/bin/coreutils/src/copy.h index fd5b20e42a..5973034c21 100644 --- a/src/bin/coreutils/src/copy.h +++ b/src/bin/coreutils/src/copy.h @@ -1,5 +1,5 @@ /* core functions for copying files and directories - Copyright (C) 89, 90, 91, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1989-1991, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/src/coreutils.rdef b/src/bin/coreutils/src/coreutils.rdef index 9cf1de96af..8e5829c28d 100644 --- a/src/bin/coreutils/src/coreutils.rdef +++ b/src/bin/coreutils/src/coreutils.rdef @@ -1,10 +1,10 @@ resource app_version { - major = 7, - middle = 6, + major = 8, + middle = 4, minor = 0, variety = B_APPV_FINAL, internal = 0, short_info = "coreutils", - long_info = "coreutils ©2009 The Free Software Foundation" + long_info = "coreutils ©210 The Free Software Foundation" }; diff --git a/src/bin/coreutils/src/cp-hash.c b/src/bin/coreutils/src/cp-hash.c index b929d9ab90..b784a104be 100644 --- a/src/bin/coreutils/src/cp-hash.c +++ b/src/bin/coreutils/src/cp-hash.c @@ -1,5 +1,5 @@ /* cp-hash.c -- file copying (hash search routines) - Copyright (C) 89, 90, 91, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1989-1991, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/src/cp.c b/src/bin/coreutils/src/cp.c index 01387abfca..fbebc65df2 100644 --- a/src/bin/coreutils/src/cp.c +++ b/src/bin/coreutils/src/cp.c @@ -1,5 +1,5 @@ /* cp.c -- file copying (main routines) - Copyright (C) 89, 90, 91, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1989-1991, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -260,7 +260,7 @@ As a special case, cp makes a backup of SOURCE when the force and backup\n\ options are given and SOURCE and DEST are the same name for an existing,\n\ regular file.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -414,8 +414,8 @@ make_dir_parents_private (char const *const_dir, size_t src_offset, *slash = '\0'; missing_dir = (stat (dir, &stats) != 0); - if (missing_dir | x->preserve_ownership | x->preserve_mode - | x->preserve_timestamps) + if (missing_dir || x->preserve_ownership || x->preserve_mode + || x->preserve_timestamps) { /* Add this directory to the list of directories whose modes might need fixing later. */ @@ -1097,7 +1097,7 @@ main (int argc, char **argv) } } - if (x.hard_link & x.symbolic_link) + if (x.hard_link && x.symbolic_link) { error (0, 0, _("cannot make both hard and symbolic links")); usage (EXIT_FAILURE); @@ -1138,7 +1138,7 @@ main (int argc, char **argv) /* If --force (-f) was specified and we're in link-creation mode, first remove any existing destination file. */ - if (x.unlink_dest_after_failed_open & (x.hard_link | x.symbolic_link)) + if (x.unlink_dest_after_failed_open && (x.hard_link || x.symbolic_link)) x.unlink_dest_before_opening = true; if (x.preserve_security_context) diff --git a/src/bin/coreutils/src/csplit.c b/src/bin/coreutils/src/csplit.c index ba93d2b593..8cefdf3299 100644 --- a/src/bin/coreutils/src/csplit.c +++ b/src/bin/coreutils/src/csplit.c @@ -1,5 +1,5 @@ /* csplit - split a file into sections determined by context lines - Copyright (C) 91, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1991, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1481,7 +1481,7 @@ Read standard input if FILE is -. Each PATTERN may be:\n\ \n\ A line OFFSET is a required `+' or `-' followed by a positive integer.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/cut.c b/src/bin/coreutils/src/cut.c index 448e7ed7a0..96692dd4c8 100644 --- a/src/bin/coreutils/src/cut.c +++ b/src/bin/coreutils/src/cut.c @@ -1,5 +1,5 @@ /* cut - remove parts of lines of files - Copyright (C) 1997-2009 Free Software Foundation, Inc. + Copyright (C) 1997-2010 Free Software Foundation, Inc. Copyright (C) 1984 David M. Ihnat This program is free software: you can redistribute it and/or modify @@ -235,7 +235,7 @@ Each range is one of:\n\ \n\ With no FILE, or when FILE is -, read standard input.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/date.c b/src/bin/coreutils/src/date.c index cbc53e6a51..c39adb1c28 100644 --- a/src/bin/coreutils/src/date.c +++ b/src/bin/coreutils/src/date.c @@ -1,5 +1,5 @@ /* date - print or set the system date and time - Copyright (C) 1989-2009 Free Software Foundation, Inc. + Copyright (C) 1989-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -236,7 +236,7 @@ then an optional modifier, which is either\n\ E to use the locale's alternate representations if available, or\n\ O to use the locale's alternate numeric symbols if available.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/dcgen b/src/bin/coreutils/src/dcgen index 5c99f69fb0..108a365164 100755 --- a/src/bin/coreutils/src/dcgen +++ b/src/bin/coreutils/src/dcgen @@ -1,7 +1,7 @@ #!/usr/bin/perl -w # dcgen -- convert dircolors.hin to dircolors.h. -# Copyright (C) 1996, 1998, 2004, 2005, 2006, 2009 Free Software Foundation, Inc. +# Copyright (C) 1996, 1998, 2004-2006, 2009-2010 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/src/dd.c b/src/bin/coreutils/src/dd.c index 76a31e9816..36a5bc04f6 100644 --- a/src/bin/coreutils/src/dd.c +++ b/src/bin/coreutils/src/dd.c @@ -1,5 +1,5 @@ /* dd -- convert a file while copying it. - Copyright (C) 85, 90, 91, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1985, 1990-1991, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -575,7 +575,7 @@ Options are:\n\ fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -769,7 +769,7 @@ install_signal_handlers (void) static void process_signals (void) { - while (interrupt_signal | info_signal_count) + while (interrupt_signal || info_signal_count) { int interrupt; int infos; diff --git a/src/bin/coreutils/src/df.c b/src/bin/coreutils/src/df.c index 6cda35e75c..b8628791e4 100644 --- a/src/bin/coreutils/src/df.c +++ b/src/bin/coreutils/src/df.c @@ -1,5 +1,5 @@ /* df - summarize free disk space - Copyright (C) 91, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1991, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,7 +24,6 @@ #include #include "system.h" -#include "canonicalize.h" #include "error.h" #include "fsusage.h" #include "human.h" @@ -149,18 +148,26 @@ print_header (void) char buf[MAX (LONGEST_HUMAN_READABLE + 1, INT_BUFSIZE_BOUND (uintmax_t))]; if (print_type) + /* TRANSLATORS: + For best results (df header/column alignment), ensure that + your translation has the same length as the original. */ fputs (_("Filesystem Type"), stdout); else fputs (_("Filesystem "), stdout); if (inode_format) - printf (_(" Inodes IUsed IFree IUse%%")); + /* TRANSLATORS: + For best results (df header/column alignment), ensure that + your translation has the same length as the original. + Also, each column name translation should end at the same + column as the corresponding original. */ + fputs (_(" Inodes IUsed IFree IUse%"), stdout); else if (human_output_opts & human_autoscale) { if (human_output_opts & human_base_1024) - printf (_(" Size Used Avail Use%%")); + fputs (_(" Size Used Avail Use%"), stdout); else - printf (_(" Size Used Avail Use%%")); + fputs (_(" Size Used Avail Use%"), stdout); } else if (posix_format) printf (_(" %s-blocks Used Available Capacity"), @@ -198,7 +205,7 @@ print_header (void) human_readable (output_block_size, buf, opts, 1, 1)); } - printf (_(" Mounted on\n")); + fputs (_(" Mounted on\n"), stdout); } /* Is FSTYPE a type of file system that should be listed? */ @@ -333,10 +340,10 @@ show_dev (char const *disk, char const *mount_point, bool negate_used; double pct = -1; - if (me_remote & show_local_fs) + if (me_remote && show_local_fs) return; - if (me_dummy & !show_all_fs & !show_listed_fs) + if (me_dummy && !show_all_fs && !show_listed_fs) return; if (!selected_fstype (fstype) || excluded_fstype (fstype)) @@ -431,7 +438,7 @@ show_dev (char const *disk, char const *mount_point, total = fsu.fsu_blocks; available = fsu.fsu_bavail; negate_available = (fsu.fsu_bavail_top_bit_set - & known_value (available)); + && known_value (available)); available_to_root = fsu.fsu_bfree; if (known_value (total)) @@ -835,7 +842,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ fputs (VERSION_OPTION_DESCRIPTION, stdout); emit_blocksize_note ("DF"); emit_size_note (); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/dircolors.c b/src/bin/coreutils/src/dircolors.c index b724155921..f850bef7d5 100644 --- a/src/bin/coreutils/src/dircolors.c +++ b/src/bin/coreutils/src/dircolors.c @@ -1,5 +1,5 @@ /* dircolors - output commands to set the LS_COLOR environment variable - Copyright (C) 1996-2009 Free Software Foundation, Inc. + Copyright (C) 1996-2010 Free Software Foundation, Inc. Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000 H. Peter Anvin This program is free software: you can redistribute it and/or modify @@ -19,7 +19,6 @@ #include #include -#include #include "system.h" #include "dircolors.h" @@ -27,6 +26,7 @@ #include "error.h" #include "obstack.h" #include "quote.h" +#include "stdio--.h" #include "xstrndup.h" /* The official name of this program (e.g., no `g' prefix). */ @@ -112,7 +112,7 @@ If FILE is specified, read it to determine which colors to use for which\n\ file types and extensions. Otherwise, a precompiled database is used.\n\ For details on the format of these files, run `dircolors --print-database'.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); diff --git a/src/bin/coreutils/src/dircolors.h b/src/bin/coreutils/src/dircolors.h index 39c2fadf69..19be33cbd4 100644 --- a/src/bin/coreutils/src/dircolors.h +++ b/src/bin/coreutils/src/dircolors.h @@ -2,8 +2,7 @@ static char const G_line[] = { '#',' ','C','o','n','f','i','g','u','r','a','t','i','o','n',' ','f','i','l','e',' ','f','o','r',' ','d','i','r','c','o','l','o','r','s',',',' ','a',' ','u','t','i','l','i','t','y',' ','t','o',' ','h','e','l','p',' ','y','o','u',' ','s','e','t',' ','t','h','e',0, '#',' ','L','S','_','C','O','L','O','R','S',' ','e','n','v','i','r','o','n','m','e','n','t',' ','v','a','r','i','a','b','l','e',' ','u','s','e','d',' ','b','y',' ','G','N','U',' ','l','s',' ','w','i','t','h',' ','t','h','e',' ','-','-','c','o','l','o','r',' ','o','p','t','i','o','n','.',0, - '#',' ','C','o','p','y','r','i','g','h','t',' ','(','C',')',' ','1','9','9','6',',',' ','1','9','9','9','-','2','0','0','9',0, - '#',' ','F','r','e','e',' ','S','o','f','t','w','a','r','e',' ','F','o','u','n','d','a','t','i','o','n',',',' ','I','n','c','.',0, + '#',' ','C','o','p','y','r','i','g','h','t',' ','(','C',')',' ','1','9','9','6',',',' ','1','9','9','9','-','2','0','1','0',' ','F','r','e','e',' ','S','o','f','t','w','a','r','e',' ','F','o','u','n','d','a','t','i','o','n',',',' ','I','n','c','.',0, '#',' ','C','o','p','y','i','n','g',' ','a','n','d',' ','d','i','s','t','r','i','b','u','t','i','o','n',' ','o','f',' ','t','h','i','s',' ','f','i','l','e',',',' ','w','i','t','h',' ','o','r',' ','w','i','t','h','o','u','t',' ','m','o','d','i','f','i','c','a','t','i','o','n',',',0, '#',' ','a','r','e',' ','p','e','r','m','i','t','t','e','d',' ','p','r','o','v','i','d','e','d',' ','t','h','e',' ','c','o','p','y','r','i','g','h','t',' ','n','o','t','i','c','e',' ','a','n','d',' ','t','h','i','s',' ','n','o','t','i','c','e',' ','a','r','e',' ','p','r','e','s','e','r','v','e','d','.',0, '#',' ','T','h','e',' ','k','e','y','w','o','r','d','s',' ','C','O','L','O','R',',',' ','O','P','T','I','O','N','S',',',' ','a','n','d',' ','E','I','G','H','T','B','I','T',' ','(','h','o','n','o','r','e','d',' ','b','y',' ','t','h','e',0, @@ -110,6 +109,7 @@ static char const G_line[] = '.','Z',' ','0','1',';','3','1',0, '.','d','z',' ','0','1',';','3','1',0, '.','g','z',' ','0','1',';','3','1',0, + '.','l','z',' ','0','1',';','3','1',0, '.','x','z',' ','0','1',';','3','1',0, '.','b','z','2',' ','0','1',';','3','1',0, '.','b','z',' ','0','1',';','3','1',0, @@ -168,6 +168,8 @@ static char const G_line[] = '.','x','c','f',' ','0','1',';','3','5',0, '.','x','w','d',' ','0','1',';','3','5',0, '.','y','u','v',' ','0','1',';','3','5',0, + '.','c','g','m',' ','0','1',';','3','5',0, + '.','e','m','f',' ','0','1',';','3','5',0, '#',' ','h','t','t','p',':','/','/','w','i','k','i','.','x','i','p','h','.','o','r','g','/','i','n','d','e','x','.','p','h','p','/','M','I','M','E','_','T','y','p','e','s','_','a','n','d','_','F','i','l','e','_','E','x','t','e','n','s','i','o','n','s',0, '.','a','x','v',' ','0','1',';','3','5',0, '.','a','n','x',' ','0','1',';','3','5',0, diff --git a/src/bin/coreutils/src/dircolors.hin b/src/bin/coreutils/src/dircolors.hin index 91ddcb65a7..6a4b1e3e12 100644 --- a/src/bin/coreutils/src/dircolors.hin +++ b/src/bin/coreutils/src/dircolors.hin @@ -1,8 +1,7 @@ # Configuration file for dircolors, a utility to help you set the # LS_COLORS environment variable used by GNU ls with the --color option. -# Copyright (C) 1996, 1999-2009 -# Free Software Foundation, Inc. +# Copyright (C) 1996, 1999-2010 Free Software Foundation, Inc. # Copying and distribution of this file, with or without modification, # are permitted provided the copyright notice and this notice are preserved. @@ -116,6 +115,7 @@ EXEC 01;32 .Z 01;31 .dz 01;31 .gz 01;31 +.lz 01;31 .xz 01;31 .bz2 01;31 .bz 01;31 @@ -175,6 +175,8 @@ EXEC 01;32 .xcf 01;35 .xwd 01;35 .yuv 01;35 +.cgm 01;35 +.emf 01;35 # http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions .axv 01;35 diff --git a/src/bin/coreutils/src/dirname.c b/src/bin/coreutils/src/dirname.c index 53d0bdc7d9..4f18fe9558 100644 --- a/src/bin/coreutils/src/dirname.c +++ b/src/bin/coreutils/src/dirname.c @@ -1,6 +1,6 @@ /* dirname -- strip suffix from file name - Copyright (C) 1990-1997, 1999-2002, 2004-2009 Free Software Foundation, Inc. + Copyright (C) 1990-1997, 1999-2002, 2004-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -61,7 +61,7 @@ Examples:\n\ %s stdio.h Output \".\".\n\ "), program_name, program_name); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/du.c b/src/bin/coreutils/src/du.c index 0ffd147511..0613a29f85 100644 --- a/src/bin/coreutils/src/du.c +++ b/src/bin/coreutils/src/du.c @@ -1,5 +1,5 @@ /* du -- summarize disk usage - Copyright (C) 1988-1991, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1988-1991, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,7 +24,6 @@ Rewritten to use nftw, then to use fts by Jim Meyering. */ #include -#include #include #include #include @@ -40,6 +39,7 @@ #include "quotearg.h" #include "same.h" #include "stat-time.h" +#include "stdio--.h" #include "xfts.h" #include "xstrtol.h" @@ -67,7 +67,6 @@ extern bool fts_debug; /* Hash structure for inode and device numbers. The separate entry structure makes it easier to rehash "in place". */ - struct entry { ino_t st_ino; @@ -194,7 +193,6 @@ enum FILES0_FROM_OPTION, HUMAN_SI_OPTION, MAX_DEPTH_OPTION, - MEGABYTES_LONG_OPTION, TIME_OPTION, TIME_STYLE_OPTION }; @@ -332,7 +330,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ fputs (VERSION_OPTION_DESCRIPTION, stdout); emit_blocksize_note ("DU"); emit_size_note (); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -495,6 +493,15 @@ process_file (FTS *fts, FTSENT *ent) ok = false; break; + case FTS_DC: /* directory that causes cycles */ + if (cycle_warning_required (fts, ent)) + { + emit_cycle_warning (file); + return false; + } + ok = true; + break; + default: ok = true; break; @@ -757,10 +764,6 @@ main (int argc, char **argv) } break; - case MEGABYTES_LONG_OPTION: /* FIXME: remove in 2009 */ - error (0, 0, - _("the --megabytes option is deprecated; use -m instead")); - /* fall through */ case 'm': human_output_opts = 0; output_block_size = 1024 * 1024; @@ -845,7 +848,7 @@ main (int argc, char **argv) if (!ok) usage (EXIT_FAILURE); - if (opt_all & opt_summarize_only) + if (opt_all && opt_summarize_only) { error (0, 0, _("cannot both summarize and show all entries")); usage (EXIT_FAILURE); diff --git a/src/bin/coreutils/src/echo.c b/src/bin/coreutils/src/echo.c index 210352ca77..6a1eeedea9 100644 --- a/src/bin/coreutils/src/echo.c +++ b/src/bin/coreutils/src/echo.c @@ -1,5 +1,5 @@ /* echo.c, derived from code echo.c in Bash. - Copyright (C) 87,89, 1991-1997, 1999-2005, 2007-2009 Free Software + Copyright (C) 1987, 1989, 1991-1997, 1999-2005, 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -63,21 +63,25 @@ Echo the STRING(s) to standard output.\n\ \n\ If -e is in effect, the following sequences are recognized:\n\ \n\ - \\0NNN the character whose ASCII code is NNN (octal)\n\ - \\\\ backslash\n\ - \\a alert (BEL)\n\ - \\b backspace\n\ "), stdout); fputs (_("\ - \\c produce no further output\n\ - \\f form feed\n\ - \\n new line\n\ - \\r carriage return\n\ - \\t horizontal tab\n\ - \\v vertical tab\n\ + \\\\ backslash\n\ + \\a alert (BEL)\n\ + \\b backspace\n\ + \\c produce no further output\n\ + \\e escape\n\ + \\f form feed\n\ + \\n new line\n\ + \\r carriage return\n\ + \\t horizontal tab\n\ + \\v vertical tab\n\ +"), stdout); + fputs (_("\ + \\0NNN byte with octal value NNN (1 to 3 digits)\n\ + \\xHH byte with hexadecimal value HH (1 to 2 digits)\n\ "), stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -203,6 +207,7 @@ just_echo: case 'a': c = '\a'; break; case 'b': c = '\b'; break; case 'c': exit (EXIT_SUCCESS); + case 'e': c = '\x1B'; break; case 'f': c = '\f'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; diff --git a/src/bin/coreutils/src/env.c b/src/bin/coreutils/src/env.c index c22981ba3f..ca54a4aac1 100644 --- a/src/bin/coreutils/src/env.c +++ b/src/bin/coreutils/src/env.c @@ -1,5 +1,5 @@ /* env - run a program in a modified environment - Copyright (C) 1986, 1991-2005, 2007-2009 Free Software Foundation, Inc. + Copyright (C) 1986, 1991-2005, 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,66 +16,6 @@ /* Richard Mlynarik and David MacKenzie */ -/* Options: - - - -i - --ignore-environment - Construct a new environment from scratch; normally the - environment is inherited from the parent process, except as - modified by other options. - - -u variable - --unset=variable - Unset variable VARIABLE (remove it from the environment). - If VARIABLE was not set, does nothing. - - variable=value (an arg containing a "=" character) - Set the environment variable VARIABLE to value VALUE. VALUE - may be of zero length ("variable="). Setting a variable to a - zero-length value is different from unsetting it. - - -- - Indicate that the following argument is the program - to invoke. This is necessary when the program's name - begins with "-" or contains a "=". - - The first remaining argument specifies a program to invoke; - it is searched for according to the specification of the PATH - environment variable. Any arguments following that are - passed as arguments to that program. - - If no command name is specified following the environment - specifications, the resulting environment is printed. - This is like specifying a command name of "printenv". - - Examples: - - If the environment passed to "env" is - { LOGNAME=rms EDITOR=emacs PATH=.:/gnubin:/hacks } - - env - foo - runs "foo" in a null environment. - - env foo - runs "foo" in the environment - { LOGNAME=rms EDITOR=emacs PATH=.:/gnubin:/hacks } - - env DISPLAY=gnu:0 nemacs - runs "nemacs" in the environment - { LOGNAME=rms EDITOR=emacs PATH=.:/gnubin:/hacks DISPLAY=gnu:0 } - - env - LOGNAME=foo /hacks/hack bar baz - runs the "hack" program on arguments "bar" and "baz" in an - environment in which the only variable is "LOGNAME". Note that - the "-" option clears out the PATH variable, so one should be - careful to specify in which directory to find the program to - call. - - env -u EDITOR LOGNAME=foo PATH=/energy -- e=mc2 bar baz - runs the program "/energy/e=mc2" with environment - { LOGNAME=foo PATH=/energy } -*/ - #include #include #include @@ -83,6 +23,7 @@ #include "system.h" #include "error.h" +#include "quote.h" /* The official name of this program (e.g., no `g' prefix). */ #define PROGRAM_NAME "env" @@ -91,11 +32,10 @@ proper_name ("Richard Mlynarik"), \ proper_name ("David MacKenzie") -extern char **environ; - static struct option const longopts[] = { {"ignore-environment", no_argument, NULL, 'i'}, + {"null", no_argument, NULL, '0'}, {"unset", required_argument, NULL, 'u'}, {GETOPT_HELP_OPTION_DECL}, {GETOPT_VERSION_OPTION_DECL}, @@ -116,8 +56,9 @@ Usage: %s [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]\n"), fputs (_("\ Set each NAME to VALUE in the environment and run COMMAND.\n\ \n\ - -i, --ignore-environment start with an empty environment\n\ - -u, --unset=NAME remove variable from the environment\n\ + -i, --ignore-environment start with an empty environment\n\ + -0, --null end each output line with 0 byte rather than newline\n\ + -u, --unset=NAME remove variable from the environment\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); @@ -125,7 +66,7 @@ Set each NAME to VALUE in the environment and run COMMAND.\n\ \n\ A mere - implies -i. If no COMMAND, print the resulting environment.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -135,6 +76,7 @@ main (int argc, char **argv) { int optc; bool ignore_environment = false; + bool opt_nul_terminate_output = false; initialize_main (&argc, &argv); set_program_name (argv[0]); @@ -142,10 +84,10 @@ main (int argc, char **argv) bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); - initialize_exit_failure (EXIT_FAILURE); + initialize_exit_failure (EXIT_CANCELED); atexit (close_stdout); - while ((optc = getopt_long (argc, argv, "+iu:", longopts, NULL)) != -1) + while ((optc = getopt_long (argc, argv, "+iu:0", longopts, NULL)) != -1) { switch (optc) { @@ -154,10 +96,13 @@ main (int argc, char **argv) break; case 'u': break; + case '0': + opt_nul_terminate_output = true; + break; case_GETOPT_HELP_CHAR; case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); default: - usage (EXIT_FAILURE); + usage (EXIT_CANCELED); } } @@ -171,25 +116,36 @@ main (int argc, char **argv) } optind = 0; /* Force GNU getopt to re-initialize. */ - while ((optc = getopt_long (argc, argv, "+iu:", longopts, NULL)) != -1) - if (optc == 'u') - putenv (optarg); /* Requires GNU putenv. */ + while ((optc = getopt_long (argc, argv, "+iu:0", longopts, NULL)) != -1) + if (optc == 'u' && unsetenv (optarg)) + error (EXIT_CANCELED, errno, _("cannot unset %s"), quote (optarg)); if (optind < argc && STREQ (argv[optind], "-")) ++optind; while (optind < argc && strchr (argv[optind], '=')) - putenv (argv[optind++]); + if (putenv (argv[optind++])) + { + char *name = argv[optind - 1]; + *(strchr (name, '=')) = '\0'; + error (EXIT_CANCELED, errno, _("cannot set %s"), quote (name)); + } /* If no program is specified, print the environment and exit. */ if (argc <= optind) { char *const *e = environ; while (*e) - puts (*e++); + printf ("%s%c", *e++, opt_nul_terminate_output ? '\0' : '\n'); exit (EXIT_SUCCESS); } + if (opt_nul_terminate_output) + { + error (0, errno, _("cannot specify --null (-0) with command")); + usage (EXIT_CANCELED); + } + execvp (argv[optind], &argv[optind]); { diff --git a/src/bin/coreutils/src/expand.c b/src/bin/coreutils/src/expand.c index c8648335a3..fa1fdfeb78 100644 --- a/src/bin/coreutils/src/expand.c +++ b/src/bin/coreutils/src/expand.c @@ -1,5 +1,6 @@ /* expand - convert tabs to spaces - Copyright (C) 89, 91, 1995-2006, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 1989, 1991, 1995-2006, 2008-2010 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -121,7 +122,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -344,7 +345,7 @@ expand (void) error (EXIT_FAILURE, 0, _("input line is too long")); } - convert &= convert_entire_line | !! isblank (c); + convert &= convert_entire_line || !! isblank (c); } if (c < 0) diff --git a/src/bin/coreutils/src/expr.c b/src/bin/coreutils/src/expr.c index 11bf7ed477..133a163093 100644 --- a/src/bin/coreutils/src/expr.c +++ b/src/bin/coreutils/src/expr.c @@ -1,5 +1,5 @@ /* expr -- evaluate expressions. - Copyright (C) 86, 1991-1997, 1999-2009 Free Software Foundation, Inc. + Copyright (C) 1986, 1991-1997, 1999-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -55,7 +55,7 @@ static void integer_overflow (char) ATTRIBUTE_NORETURN; #else /* Approximate gmp.h well enough for expr.c's purposes. */ typedef intmax_t mpz_t[1]; -static void mpz_clear (mpz_t z) {} +static void mpz_clear (mpz_t z) { (void) z; } static void mpz_init_set_ui (mpz_t z, unsigned long int i) { z[0] = i; } static int mpz_init_set_str (mpz_t z, char *s, int base) @@ -117,6 +117,7 @@ static char * mpz_get_str (char const *str, int base, mpz_t z) { char buf[INT_BUFSIZE_BOUND (intmax_t)]; + (void) str; (void) base; return xstrdup (imaxtostr (z[0], buf)); } static int @@ -138,6 +139,7 @@ static int mpz_out_str (FILE *stream, int base, mpz_t z) { char buf[INT_BUFSIZE_BOUND (intmax_t)]; + (void) base; return fputs (imaxtostr (z[0], buf), stream) != EOF; } #endif @@ -265,7 +267,7 @@ Pattern matches return the string matched between \\( and \\) or null; if\n\ Exit status is 0 if EXPRESSION is neither null nor 0, 1 if EXPRESSION is null\n\ or 0, 2 if EXPRESSION is syntactically invalid, and 3 if an error occurred.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -923,7 +925,7 @@ eval1 (bool evaluate) { if (nextarg ("&")) { - r = eval2 (evaluate & ~ null (l)); + r = eval2 (evaluate && !null (l)); if (null (l) || null (r)) { freev (l); @@ -954,7 +956,7 @@ eval (bool evaluate) { if (nextarg ("|")) { - r = eval1 (evaluate & null (l)); + r = eval1 (evaluate && null (l)); if (null (l)) { freev (l); diff --git a/src/bin/coreutils/src/extract-magic b/src/bin/coreutils/src/extract-magic index dfea3d5fdd..cfa2ee2a70 100644 --- a/src/bin/coreutils/src/extract-magic +++ b/src/bin/coreutils/src/extract-magic @@ -1,7 +1,7 @@ #!/usr/bin/perl -w # Derive #define directives from specially formatted `case ...:' statements. -# Copyright (C) 2003, 2005, 2009 Free Software Foundation, Inc. +# Copyright (C) 2003, 2005, 2009-2010 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/src/factor.c b/src/bin/coreutils/src/factor.c index 59fe1f45fd..80aa3e639e 100644 --- a/src/bin/coreutils/src/factor.c +++ b/src/bin/coreutils/src/factor.c @@ -1,5 +1,5 @@ /* factor -- print prime factors of n. - Copyright (C) 86, 1995-2005, 2007-2009 Free Software Foundation, Inc. + Copyright (C) 1986, 1995-2005, 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ #include #include #if HAVE_GMP -#include +# include #endif #include @@ -60,6 +60,7 @@ debug (char const *fmt, ...) va_list ap; va_start (ap, fmt); vfprintf (stderr, fmt, ap); + va_end (ap); } } @@ -67,7 +68,7 @@ static void emit_factor (mpz_t n) { if (nfactors_found == nfactors_allocated) - factor = x2nrealloc (factor, &nfactors_allocated, sizeof *factor); + factor = X2NREALLOC (factor, &nfactors_allocated); mpz_init (factor[nfactors_found]); mpz_set (factor[nfactors_found], n); ++nfactors_found; @@ -502,7 +503,7 @@ are specified on the command line, read them from standard input.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/fmt.c b/src/bin/coreutils/src/fmt.c index c12072c58e..86b83ee7cd 100644 --- a/src/bin/coreutils/src/fmt.c +++ b/src/bin/coreutils/src/fmt.c @@ -1,5 +1,5 @@ /* GNU fmt -- simple text formatter. - Copyright (C) 1994-2006, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 1994-2006, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -293,7 +293,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ \n\ With no FILE, or when FILE is -, read standard input.\n"), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/fold.c b/src/bin/coreutils/src/fold.c index 52322657ad..9364a03f94 100644 --- a/src/bin/coreutils/src/fold.c +++ b/src/bin/coreutils/src/fold.c @@ -1,5 +1,5 @@ /* fold -- wrap each input line to fit in specified width. - Copyright (C) 91, 1995-2006, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 1991, 1995-2006, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -82,7 +82,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/fs.h b/src/bin/coreutils/src/fs.h index da751a6721..e599e0878d 100644 --- a/src/bin/coreutils/src/fs.h +++ b/src/bin/coreutils/src/fs.h @@ -5,56 +5,77 @@ #if defined __linux__ # define S_MAGIC_ADFS 0xADF5 # define S_MAGIC_AFFS 0xADFF -# define S_MAGIC_AUTOFS 0x187 +# define S_MAGIC_AFS 0x5346414F +# define S_MAGIC_ANON_INODE_FS 0x09041934 +# define S_MAGIC_AUTOFS 0x0187 # define S_MAGIC_BEFS 0x42465331 # define S_MAGIC_BFS 0x1BADFACE -# define S_MAGIC_BINFMT_MISC 0x42494e4d +# define S_MAGIC_BINFMT_MISC 0x42494E4D +# define S_MAGIC_BTRFS 0x9123683E +# define S_MAGIC_CGROUP 0x0027E0EB +# define S_MAGIC_CIFS 0xFF534D42 # define S_MAGIC_CODA 0x73757245 # define S_MAGIC_COH 0x012FF7B7 # define S_MAGIC_CRAMFS 0x28CD3D45 +# define S_MAGIC_CRAMFS_WEND 0x453DCD28 +# define S_MAGIC_DEBUGFS 0x64626720 # define S_MAGIC_DEVFS 0x1373 # define S_MAGIC_DEVPTS 0x1CD1 -# define S_MAGIC_EFS 0x414A53 +# define S_MAGIC_EFS 0x00414A53 # define S_MAGIC_EXT 0x137D # define S_MAGIC_EXT2 0xEF53 # define S_MAGIC_EXT2_OLD 0xEF51 # define S_MAGIC_FAT 0x4006 +# define S_MAGIC_FUSEBLK 0x65735546 # define S_MAGIC_FUSECTL 0x65735543 +# define S_MAGIC_FUTEXFS 0x0BAD1DEA +# define S_MAGIC_GFS 0x1161970 +# define S_MAGIC_HFS 0x4244 # define S_MAGIC_HPFS 0xF995E849 -# define S_MAGIC_HUGETLBFS 0x958458f6 +# define S_MAGIC_HUGETLBFS 0x958458F6 +# define S_MAGIC_INOTIFYFS 0x2BAD1DEA # define S_MAGIC_ISOFS 0x9660 # define S_MAGIC_ISOFS_R_WIN 0x4004 # define S_MAGIC_ISOFS_WIN 0x4000 -# define S_MAGIC_JFFS2 0x72B6 # define S_MAGIC_JFFS 0x07C0 +# define S_MAGIC_JFFS2 0x72B6 # define S_MAGIC_JFS 0x3153464A +# define S_MAGIC_KAFS 0x6B414653 # define S_MAGIC_LUSTRE 0x0BD00BD0 # define S_MAGIC_MINIX 0x137F # define S_MAGIC_MINIX_30 0x138F # define S_MAGIC_MINIX_V2 0x2468 # define S_MAGIC_MINIX_V2_30 0x2478 +# define S_MAGIC_MINIX_V3 0x4D5A # define S_MAGIC_MSDOS 0x4D44 # define S_MAGIC_NCP 0x564C # define S_MAGIC_NFS 0x6969 # define S_MAGIC_NFSD 0x6E667364 +# define S_MAGIC_NILFS 0x3434 # define S_MAGIC_NTFS 0x5346544E -# define S_MAGIC_OPENPROM 0x9fa1 +# define S_MAGIC_OPENPROM 0x9FA1 +# define S_MAGIC_OCFS2 0x7461636f # define S_MAGIC_PROC 0x9FA0 # define S_MAGIC_QNX4 0x002F # define S_MAGIC_RAMFS 0x858458F6 # define S_MAGIC_REISERFS 0x52654973 # define S_MAGIC_ROMFS 0x7275 +# define S_MAGIC_RPC_PIPEFS 0x67596969 +# define S_MAGIC_SECURITYFS 0x73636673 +# define S_MAGIC_SELINUX 0xF97CFF8C # define S_MAGIC_SMB 0x517B +# define S_MAGIC_SOCKFS 0x534F434B # define S_MAGIC_SQUASHFS 0x73717368 # define S_MAGIC_SYSFS 0x62656572 # define S_MAGIC_SYSV2 0x012FF7B6 # define S_MAGIC_SYSV4 0x012FF7B5 -# define S_MAGIC_TMPFS 0x1021994 +# define S_MAGIC_TMPFS 0x01021994 # define S_MAGIC_UDF 0x15013346 # define S_MAGIC_UFS 0x00011954 # define S_MAGIC_UFS_BYTESWAPPED 0x54190100 # define S_MAGIC_USBDEVFS 0x9FA2 # define S_MAGIC_VXFS 0xA501FCF5 +# define S_MAGIC_XENFS 0xABBA1974 # define S_MAGIC_XENIX 0x012FF7B4 # define S_MAGIC_XFS 0x58465342 # define S_MAGIC_XIAFS 0x012FD16D diff --git a/src/bin/coreutils/src/getlimits.c b/src/bin/coreutils/src/getlimits.c index 82cd34531e..bf11811c46 100644 --- a/src/bin/coreutils/src/getlimits.c +++ b/src/bin/coreutils/src/getlimits.c @@ -1,5 +1,5 @@ /* getlimits - print various platform dependent limits. - Copyright (C) 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -73,7 +73,7 @@ Output platform dependent limits in a format useful for shell scripts.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/group-list.c b/src/bin/coreutils/src/group-list.c index 4c5391ddb9..c69cbc7ca2 100644 --- a/src/bin/coreutils/src/group-list.c +++ b/src/bin/coreutils/src/group-list.c @@ -1,5 +1,5 @@ /* group-list.c --Print a list of group IDs or names. - Copyright (C) 1989-2009 Free Software Foundation, Inc. + Copyright (C) 1989-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -54,12 +54,11 @@ print_group_list (const char *username, ok = false; } -#if HAVE_GETGROUPS { - GETGROUPS_T *groups; + gid_t *groups; int i; - int n_groups = mgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1), + int n_groups = xgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1), &groups); if (n_groups < 0) { @@ -84,7 +83,6 @@ print_group_list (const char *username, } free (groups); } -#endif /* HAVE_GETGROUPS */ return ok; } diff --git a/src/bin/coreutils/src/group-list.h b/src/bin/coreutils/src/group-list.h index e9edf1e995..3a3f341b53 100644 --- a/src/bin/coreutils/src/group-list.h +++ b/src/bin/coreutils/src/group-list.h @@ -1,6 +1,6 @@ /* group-list.h -- prototypes shared by id and groups. - Copyright (C) 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/src/groups.c b/src/bin/coreutils/src/groups.c index 27e8724066..c05da37d2b 100644 --- a/src/bin/coreutils/src/groups.c +++ b/src/bin/coreutils/src/groups.c @@ -1,5 +1,5 @@ /* groups -- print the groups a user is in - Copyright (C) 1989-2009 Free Software Foundation, Inc. + Copyright (C) 1989-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -58,7 +58,7 @@ the current process (which may differ if the groups database has changed).\n"), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/head.c b/src/bin/coreutils/src/head.c index f014388097..7fa5823eb3 100644 --- a/src/bin/coreutils/src/head.c +++ b/src/bin/coreutils/src/head.c @@ -1,6 +1,5 @@ /* head -- output first part of file(s) - Copyright (C) 89, 90, 91, 1995-2006, 2008-2009 Free Software - Foundation, Inc. + Copyright (C) 1989-1991, 1995-2006, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -138,7 +137,7 @@ K may have a multiplier suffix:\n\ b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024,\n\ GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/hostid.c b/src/bin/coreutils/src/hostid.c index 7c93f2e768..11b649e753 100644 --- a/src/bin/coreutils/src/hostid.c +++ b/src/bin/coreutils/src/hostid.c @@ -1,7 +1,6 @@ /* print the hexadecimal identifier for the current host - Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2007-2009 Free - Software Foundation, Inc. + Copyright (C) 1997, 1999-2004, 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -48,7 +47,7 @@ Print the numeric identifier (in hexadecimal) for the current host.\n\ "), program_name); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/hostname.c b/src/bin/coreutils/src/hostname.c index 110014b3fc..3e6baed120 100644 --- a/src/bin/coreutils/src/hostname.c +++ b/src/bin/coreutils/src/hostname.c @@ -1,5 +1,5 @@ /* hostname - set or print the name of current host system - Copyright (C) 1994-1997, 1999-2005, 2007-2009 Free Software Foundation, Inc. + Copyright (C) 1994-1997, 1999-2005, 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -63,7 +63,7 @@ Print or set the hostname of the current system.\n\ program_name, program_name); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/id.c b/src/bin/coreutils/src/id.c index b28643b18a..3e7549c2ec 100644 --- a/src/bin/coreutils/src/id.c +++ b/src/bin/coreutils/src/id.c @@ -1,5 +1,5 @@ /* id -- print real and effective UIDs and GIDs - Copyright (C) 1989-2009 Free Software Foundation, Inc. + Copyright (C) 1989-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -98,7 +98,7 @@ or (when USERNAME omitted) for the current user.\n\ \n\ Without any OPTION, print some useful set of identified information.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -187,7 +187,7 @@ main (int argc, char **argv) if (just_user + just_group + just_group_list + just_context > 1) error (EXIT_FAILURE, 0, _("cannot print \"only\" of more than one choice")); - if (just_user + just_group + just_group_list == 0 && (use_real | use_name)) + if (just_user + just_group + just_group_list == 0 && (use_real || use_name)) error (EXIT_FAILURE, 0, _("cannot print only names or real IDs in default format")); @@ -292,12 +292,11 @@ print_full_info (const char *username) printf ("(%s)", grp->gr_name); } -#if HAVE_GETGROUPS { - GETGROUPS_T *groups; + gid_t *groups; int i; - int n_groups = mgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1), + int n_groups = xgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1), &groups); if (n_groups < 0) { @@ -327,7 +326,9 @@ print_full_info (const char *username) } free (groups); } -#endif /* HAVE_GETGROUPS */ - if (context != NULL) + + /* POSIX mandates the precise output format, and that it not include + any context=... part, so skip that if POSIXLY_CORRECT is set. */ + if (context != NULL && ! getenv ("POSIXLY_CORRECT")) printf (_(" context=%s"), context); } diff --git a/src/bin/coreutils/src/install.c b/src/bin/coreutils/src/install.c index fafa21a3cf..bac5c7c390 100644 --- a/src/bin/coreutils/src/install.c +++ b/src/bin/coreutils/src/install.c @@ -1,5 +1,5 @@ /* install - copy files and set attributes - Copyright (C) 89, 90, 91, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1989-1991, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -563,7 +563,7 @@ main (int argc, char **argv) } /* Check for invalid combinations of arguments. */ - if (dir_arg & strip_files) + if (dir_arg && strip_files) error (EXIT_FAILURE, 0, _("the strip option may not be used when installing a directory")); if (dir_arg && target_directory) @@ -1005,7 +1005,7 @@ the VERSION_CONTROL environment variable. Here are the values:\n\ existing, nil numbered if numbered backups exist, simple otherwise\n\ simple, never always make simple backups\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/join.c b/src/bin/coreutils/src/join.c index 73e1f37bb4..4792f1613a 100644 --- a/src/bin/coreutils/src/join.c +++ b/src/bin/coreutils/src/join.c @@ -1,5 +1,5 @@ /* join - join lines of two files on a common field - Copyright (C) 91, 1995-2006, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 1991, 1995-2006, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,6 +24,7 @@ #include "system.h" #include "error.h" +#include "hard-locale.h" #include "linebuffer.h" #include "memcasecmp.h" #include "quote.h" @@ -208,7 +209,7 @@ Note, comparisons honor the rules specified by `LC_COLLATE'.\n\ If the input is not sorted and some lines cannot be joined, a\n\ warning message will be given.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/kill.c b/src/bin/coreutils/src/kill.c index 3429cb19d0..dab4fa834e 100644 --- a/src/bin/coreutils/src/kill.c +++ b/src/bin/coreutils/src/kill.c @@ -1,5 +1,5 @@ /* kill -- send a signal to a process - Copyright (C) 2002, 2003, 2004, 2005, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2002-2005, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -111,7 +111,7 @@ or the exit status of a process terminated by a signal.\n\ PID is an integer; if negative it identifies a process group.\n\ "), stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/libstdbuf.c b/src/bin/coreutils/src/libstdbuf.c index 8eec0960aa..2ef848f86b 100644 --- a/src/bin/coreutils/src/libstdbuf.c +++ b/src/bin/coreutils/src/libstdbuf.c @@ -1,5 +1,5 @@ /* libstdbuf -- a shared lib to preload to setup stdio buffering for a command - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/src/link.c b/src/bin/coreutils/src/link.c index ead3ac2f57..36548fc83f 100644 --- a/src/bin/coreutils/src/link.c +++ b/src/bin/coreutils/src/link.c @@ -1,5 +1,5 @@ /* link utility for GNU. - Copyright (C) 2001, 2002, 2004, 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2004, 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -51,7 +51,7 @@ Usage: %s FILE1 FILE2\n\ stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/ln.c b/src/bin/coreutils/src/ln.c index 6a1dc32077..8612afef42 100644 --- a/src/bin/coreutils/src/ln.c +++ b/src/bin/coreutils/src/ln.c @@ -1,5 +1,5 @@ /* `ln' program to create links between files. - Copyright (C) 1986, 1989-1991, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1986, 1989-1991, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -39,26 +39,15 @@ proper_name ("Mike Parker"), \ proper_name ("David MacKenzie") -/* In being careful not even to try to make hard links to directories, - we have to know whether link(2) follows symlinks. If it does, then - we have to *stat* the `source' to see if the resulting link would be - to a directory. Otherwise, we have to use *lstat* so that we allow - users to make hard links to symlinks-that-point-to-directories. */ - -#if LINK_FOLLOWS_SYMLINKS -# define STAT_LIKE_LINK(File, Stat_buf) \ - stat (File, Stat_buf) -#else -# define STAT_LIKE_LINK(File, Stat_buf) \ - lstat (File, Stat_buf) -#endif - /* FIXME: document */ static enum backup_type backup_type; /* If true, make symbolic links; otherwise, make hard links. */ static bool symbolic_link; +/* If true, hard links are logical rather than physical. */ +static bool logical = !!LINK_FOLLOWS_SYMLINKS; + /* If true, ask the user before removing existing files. */ static bool interactive; @@ -71,7 +60,7 @@ static bool verbose; /* If true, allow the superuser to *attempt* to make hard links to directories. However, it appears that this option is not useful in practice, since even the superuser is prohibited from hard-linking - directories on most (all?) existing systems. */ + directories on most existing systems (Solaris being an exception). */ static bool hard_dir_link; /* If nonzero, and the specified destination is a symbolic link to a @@ -99,6 +88,8 @@ static struct option const long_options[] = {"interactive", no_argument, NULL, 'i'}, {"suffix", required_argument, NULL, 'S'}, {"target-directory", required_argument, NULL, 't'}, + {"logical", no_argument, NULL, 'L'}, + {"physical", no_argument, NULL, 'P'}, {"symbolic", no_argument, NULL, 's'}, {"verbose", no_argument, NULL, 'v'}, {GETOPT_HELP_OPTION_DECL}, @@ -143,18 +134,15 @@ do_link (const char *source, const char *dest) bool source_is_dir = false; bool ok; - /* Use stat here instead of lstat. - On SVR4, link does not follow symlinks, so this check disallows - making hard links to symlinks that point to directories. Big deal. - On other systems, link follows symlinks, so this check is right. - - FIXME - POSIX 2008 added the AT_SYMLINK_FOLLOW flag to linkat so - that we can specify either behavior, via the new options -L - (hard-link to symlinks) and -P (hard-link to the referent). Once - gnulib has a decent implementation, we should use it here. */ if (!symbolic_link) { - if (STAT_LIKE_LINK (source, &source_stats) != 0) + /* Which stat to use depends on whether linkat will follow the + symlink. We can't use the shorter + (logical?stat:lstat) (source, &source_stats) + since stat might be a function-like macro. */ + if ((logical ? stat (source, &source_stats) + : lstat (source, &source_stats)) + != 0) { error (0, errno, _("accessing %s"), quote (source)); return false; @@ -258,7 +246,9 @@ do_link (const char *source, const char *dest) } } - ok = ((symbolic_link ? symlink (source, dest) : link (source, dest)) + ok = ((symbolic_link ? symlink (source, dest) + : linkat (AT_FDCWD, source, AT_FDCWD, dest, + logical ? AT_SYMLINK_FOLLOW : 0)) == 0); /* If the attempt to create a link failed and we are removing or @@ -289,7 +279,9 @@ do_link (const char *source, const char *dest) return false; } - ok = ((symbolic_link ? symlink (source, dest) : link (source, dest)) + ok = ((symbolic_link ? symlink (source, dest) + : linkat (AT_FDCWD, source, AT_FDCWD, dest, + logical ? AT_SYMLINK_FOLLOW : 0)) == 0); } @@ -370,9 +362,11 @@ Mandatory arguments to long options are mandatory for short options too.\n\ -f, --force remove existing destination files\n\ "), stdout); fputs (_("\ + -i, --interactive prompt whether to remove destinations\n\ + -L, --logical make hard links to symbolic link references\n\ -n, --no-dereference treat destination that is a symlink to a\n\ directory as if it were a normal file\n\ - -i, --interactive prompt whether to remove destinations\n\ + -P, --physical make hard links directly to symbolic links\n\ -s, --symbolic make symbolic links instead of hard links\n\ "), stdout); fputs (_("\ @@ -391,13 +385,18 @@ The version control method may be selected via the --backup option or through\n\ the VERSION_CONTROL environment variable. Here are the values:\n\ \n\ "), stdout); + printf (_("\ +Using -s ignores -L and -P. Otherwise, the last option specified controls\n\ +behavior when the source is a symbolic link, defaulting to %s.\n\ +\n\ +"), LINK_FOLLOWS_SYMLINKS ? "-L" : "-P"); fputs (_("\ none, off never make backups (even if --backup is given)\n\ numbered, t make numbered backups\n\ existing, nil numbered if numbered backups exist, simple otherwise\n\ simple, never always make simple backups\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -430,7 +429,7 @@ main (int argc, char **argv) symbolic_link = remove_existing_files = interactive = verbose = hard_dir_link = false; - while ((c = getopt_long (argc, argv, "bdfinst:vFS:T", long_options, NULL)) + while ((c = getopt_long (argc, argv, "bdfinst:vFLPS:T", long_options, NULL)) != -1) { switch (c) @@ -452,9 +451,15 @@ main (int argc, char **argv) remove_existing_files = false; interactive = true; break; + case 'L': + logical = true; + break; case 'n': dereference_dest_dir_symlinks = false; break; + case 'P': + logical = false; + break; case 's': symbolic_link = true; break; diff --git a/src/bin/coreutils/src/logname.c b/src/bin/coreutils/src/logname.c index 8abb535f0d..7de8c44f4c 100644 --- a/src/bin/coreutils/src/logname.c +++ b/src/bin/coreutils/src/logname.c @@ -1,5 +1,5 @@ /* logname -- print user's login name - Copyright (C) 1990-1997, 1999-2005, 2007-2009 Free Software Foundation, Inc. + Copyright (C) 1990-1997, 1999-2005, 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -44,7 +44,7 @@ Print the name of the current user.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/ls.c b/src/bin/coreutils/src/ls.c index 588a0b28d0..de85bf940c 100644 --- a/src/bin/coreutils/src/ls.c +++ b/src/bin/coreutils/src/ls.c @@ -1,5 +1,6 @@ /* `dir', `vdir' and `ls' directory listing programs for GNU. - Copyright (C) 85, 88, 90, 91, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1985, 1988, 1990-1991, 1995-2010 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -38,10 +39,6 @@ #include #include -#ifdef HAVE_CAP -# include -#endif - #if HAVE_TERMIOS_H # include #endif @@ -93,6 +90,7 @@ #include "dev-ino.h" #include "error.h" #include "filenamecat.h" +#include "hard-locale.h" #include "hash.h" #include "human.h" #include "filemode.h" @@ -111,6 +109,13 @@ #include "areadlink.h" #include "mbsalign.h" +/* Include last to avoid a clash of + include guards with some premature versions of libcap. + For more details, see . */ +#ifdef HAVE_CAP +# include +#endif + #define PROGRAM_NAME (ls_mode == LS_LS ? "ls" \ : (ls_mode == LS_MULTI_COL \ ? "dir" : "vdir")) @@ -213,6 +218,9 @@ struct fileinfo /* For long listings, true if the file has an access control list, or an SELinux security context. */ enum acl_type acl_type; + + /* For color listings, true if a regular file has capability info. */ + bool has_capability; }; #define LEN_STR_PAIR(s) sizeof (s) - 1, s @@ -240,9 +248,8 @@ static bool file_ignored (char const *name); static uintmax_t gobble_file (char const *name, enum filetype type, ino_t inode, bool command_line_arg, char const *dirname); -static bool print_color_indicator (const char *name, mode_t mode, int linkok, - bool stat_ok, enum filetype type, - nlink_t nlink); +static bool print_color_indicator (const struct fileinfo *f, + bool symlink_target); static void put_indicator (const struct bin_str *ind); static void add_ignore_pattern (const char *pattern); static void attach (char *dest, const char *dirname, const char *name); @@ -263,11 +270,9 @@ static int format_user_width (uid_t u); static int format_group_width (gid_t g); static void print_long_format (const struct fileinfo *f); static void print_many_per_line (void); -static size_t print_name_with_quoting (const char *p, mode_t mode, - int linkok, bool stat_ok, - enum filetype type, +static size_t print_name_with_quoting (const struct fileinfo *f, + bool symlink_target, struct obstack *stack, - nlink_t nlink, size_t start_col); static void prep_non_filename_text (void); static bool print_type_indicator (bool stat_ok, mode_t mode, @@ -323,7 +328,7 @@ static bool color_symlink_as_referent; /* mode of appropriate file for colorization */ #define FILE_OR_LINK_MODE(File) \ - ((color_symlink_as_referent & (File)->linkok) \ + ((color_symlink_as_referent && (File)->linkok) \ ? (File)->linkmode : (File)->stat.st_mode) @@ -1180,7 +1185,7 @@ stophandler (int sig) static void process_signals (void) { - while (interrupt_signal | stop_signal_count) + while (interrupt_signal || stop_signal_count) { int sig; int stops; @@ -2479,13 +2484,14 @@ print_dir (char const *name, char const *realname, bool command_line_arg) error (0, 0, _("%s: not listing already-listed directory"), quotearg_colon (name)); closedir (dirp); + set_exit_status (true); return; } DEV_INO_PUSH (dir_stat.st_dev, dir_stat.st_ino); } - if (recursive | print_dir_name) + if (recursive || print_dir_name) { if (!first) DIRED_PUTCHAR ('\n'); @@ -2644,6 +2650,37 @@ unsigned_file_size (off_t size) return size + (size < 0) * ((uintmax_t) OFF_T_MAX - OFF_T_MIN + 1); } +#ifdef HAVE_CAP +/* Return true if NAME has a capability (see linux/capability.h) */ +static bool +has_capability (char const *name) +{ + char *result; + bool has_cap; + + cap_t cap_d = cap_get_file (name); + if (cap_d == NULL) + return false; + + result = cap_to_text (cap_d, NULL); + cap_free (cap_d); + if (!result) + return false; + + /* check if human-readable capability string is empty */ + has_cap = !!*result; + + cap_free (result); + return has_cap; +} +#else +static bool +has_capability (char const *name ATTRIBUTE_UNUSED) +{ + return false; +} +#endif + /* Enter and remove entries in the table `cwd_file'. */ /* Empty the table of files. */ @@ -2725,11 +2762,16 @@ gobble_file (char const *name, enum filetype type, ino_t inode, to see if it's executable. */ || (type == normal && (indicator_style == classify /* This is so that --color ends up - highlighting files with the executable - bit set even when options like -F are - not specified. */ + highlighting files with these mode + bits set even when options like -F are + not specified. Note we do a redundant + stat in the very unlikely case where + C_CAP is set but not the others. */ || (print_with_color - && is_colored (C_EXEC)) + && (is_colored (C_EXEC) + || is_colored (C_SETUID) + || is_colored (C_SETGID) + || is_colored (C_CAP))) ))))) { @@ -2800,6 +2842,11 @@ gobble_file (char const *name, enum filetype type, ino_t inode, f->stat_ok = true; + /* Note has_capability() adds around 30% runtime to `ls --color` */ + if ((type == normal || S_ISREG (f->stat.st_mode)) + && print_with_color && is_colored (C_CAP)) + f->has_capability = has_capability (absolute_name); + if (format == long_format || print_scontext) { bool have_selinux = false; @@ -2809,17 +2856,6 @@ gobble_file (char const *name, enum filetype type, ino_t inode, : lgetfilecon (absolute_name, &f->scontext)); err = (attr_len < 0); - /* Contrary to its documented API, getfilecon may return 0, - yet set f->scontext to NULL (on at least Debian's libselinux1 - 2.0.15-2+b1), so work around that bug. - FIXME: remove this work-around in 2011, or whenever affected - versions of libselinux are long gone. */ - if (attr_len == 0) - { - err = 0; - f->scontext = xstrdup ("unlabeled"); - } - if (err == 0) have_selinux = ! STREQ ("unlabeled", f->scontext); else @@ -2893,7 +2929,7 @@ gobble_file (char const *name, enum filetype type, ino_t inode, f->filetype = symbolic_link; else if (S_ISDIR (f->stat.st_mode)) { - if (command_line_arg & !immediate_dirs) + if (command_line_arg && !immediate_dirs) f->filetype = arg_directory; else f->filetype = directory; @@ -3249,8 +3285,7 @@ DEFINE_SORT_FUNCTIONS (extension, cmp_extension) All the other sort options, in fact, need xstrcoll and strcmp variants, because they all use a string comparison (either as the primary or secondary sort key), and xstrcoll has the ability to do a longjmp if strcoll fails for - locale reasons. Last, strverscmp is ALWAYS available in coreutils, - thanks to the gnulib library. */ + locale reasons. Lastly, filevercmp is ALWAYS available with gnulib. */ static inline int cmp_version (struct fileinfo const *a, struct fileinfo const *b) { @@ -3562,9 +3597,19 @@ format_group_width (gid_t g) return format_user_or_group_width (numeric_ids ? NULL : getgroup (g), g); } +/* Return a pointer to a formatted version of F->stat.st_ino, + possibly using buffer, BUF, of length BUFLEN, which must be at least + INT_BUFSIZE_BOUND (uintmax_t) bytes. */ +static char * +format_inode (char *buf, size_t buflen, const struct fileinfo *f) +{ + assert (INT_BUFSIZE_BOUND (uintmax_t) <= buflen); + return (f->stat_ok && f->stat.st_ino != NOT_AN_INODE_NUMBER + ? umaxtostr (f->stat.st_ino, buf) + : (char *) "?"); +} /* Print information about F in long format. */ - static void print_long_format (const struct fileinfo *f) { @@ -3621,9 +3666,7 @@ print_long_format (const struct fileinfo *f) { char hbuf[INT_BUFSIZE_BOUND (uintmax_t)]; sprintf (p, "%*s ", inode_number_width, - (f->stat.st_ino == NOT_AN_INODE_NUMBER - ? "?" - : umaxtostr (f->stat.st_ino, hbuf))); + format_inode (hbuf, sizeof hbuf, f)); /* Increment by strlen (p) here, rather than by inode_number_width + 1. The latter is wrong when inode_number_width is zero. */ p += strlen (p); @@ -3659,7 +3702,7 @@ print_long_format (const struct fileinfo *f) DIRED_INDENT (); - if (print_owner | print_group | print_author | print_scontext) + if (print_owner || print_group || print_author || print_scontext) { DIRED_FPUTS (buf, stdout, p - buf); @@ -3773,18 +3816,14 @@ print_long_format (const struct fileinfo *f) DIRED_FPUTS (buf, stdout, p - buf); { - size_t w = print_name_with_quoting (f->name, FILE_OR_LINK_MODE (f), f->linkok, - f->stat_ok, f->filetype, &dired_obstack, - f->stat.st_nlink, p - buf); + size_t w = print_name_with_quoting (f, false, &dired_obstack, p - buf); if (f->filetype == symbolic_link) { if (f->linkname) { DIRED_FPUTS_LITERAL (" -> ", stdout); - print_name_with_quoting (f->linkname, f->linkmode, f->linkok - 1, - f->stat_ok, f->filetype, NULL, - f->stat.st_nlink, (p - buf) + w + 4); + print_name_with_quoting (f, true, NULL, (p - buf) + w + 4); if (indicator_style != none) print_type_indicator (true, f->linkmode, unknown); } @@ -3961,20 +4000,21 @@ quote_name (FILE *out, const char *name, struct quoting_options const *options, } static size_t -print_name_with_quoting (const char *p, mode_t mode, int linkok, - bool stat_ok, enum filetype type, - struct obstack *stack, nlink_t nlink, +print_name_with_quoting (const struct fileinfo *f, + bool symlink_target, + struct obstack *stack, size_t start_col) { size_t width; + const char* name = symlink_target ? f->linkname : f->name; + bool used_color_this_time - = (print_with_color - && print_color_indicator (p, mode, linkok, stat_ok, type, nlink)); + = (print_with_color && print_color_indicator (f, symlink_target)); if (stack) PUSH_CURRENT_DIRED_POS (stack); - width = quote_name (stdout, p, filename_quoting_options, NULL); + width = quote_name (stdout, name, filename_quoting_options, NULL); dired_pos += width; if (stack) @@ -4015,19 +4055,18 @@ print_file_name_and_frills (const struct fileinfo *f, size_t start_col) if (print_inode) printf ("%*s ", format == with_commas ? 0 : inode_number_width, - umaxtostr (f->stat.st_ino, buf)); + format_inode (buf, sizeof buf, f)); if (print_block_size) printf ("%*s ", format == with_commas ? 0 : block_size_width, - human_readable (ST_NBLOCKS (f->stat), buf, human_output_opts, - ST_NBLOCKSIZE, output_block_size)); + ! f->stat_ok ? "?" + : human_readable (ST_NBLOCKS (f->stat), buf, human_output_opts, + ST_NBLOCKSIZE, output_block_size)); if (print_scontext) printf ("%*s ", format == with_commas ? 0 : scontext_width, f->scontext); { - size_t width = print_name_with_quoting (f->name, FILE_OR_LINK_MODE (f), - f->linkok, f->stat_ok, f->filetype, - NULL, f->stat.st_nlink, start_col); + size_t width = print_name_with_quoting (f, false, NULL, start_col); if (indicator_style != none) width += print_type_indicator (f->stat_ok, f->stat.st_mode, f->filetype); @@ -4079,85 +4118,72 @@ print_type_indicator (bool stat_ok, mode_t mode, enum filetype type) return !!c; } -#ifdef HAVE_CAP -/* Return true if NAME has a capability (see linux/capability.h) */ -static bool -has_capability (char const *name) -{ - char *result; - bool has_cap; - - cap_t cap_d = cap_get_file (name); - if (cap_d == NULL) - return false; - - result = cap_to_text (cap_d, NULL); - cap_free (cap_d); - if (!result) - return false; - - /* check if human-readable capability string is empty */ - has_cap = !!*result; - - cap_free (result); - return has_cap; -} -#else -static bool -has_capability (char const *name ATTRIBUTE_UNUSED) -{ - return false; -} -#endif - /* Returns whether any color sequence was printed. */ static bool -print_color_indicator (const char *name, mode_t mode, int linkok, - bool stat_ok, enum filetype filetype, - nlink_t nlink) +print_color_indicator (const struct fileinfo *f, bool symlink_target) { - int type; + enum indicator_no type; struct color_ext_type *ext; /* Color extension */ size_t len; /* Length of name */ + const char* name; + mode_t mode; + int linkok; + if (symlink_target) + { + name = f->linkname; + mode = f->linkmode; + linkok = f->linkok - 1; + } + else + { + name = f->name; + mode = FILE_OR_LINK_MODE (f); + linkok = f->linkok; + } + /* Is this a nonexistent file? If so, linkok == -1. */ if (linkok == -1 && color_indicator[C_MISSING].string != NULL) type = C_MISSING; - else if (! stat_ok) + else if (!f->stat_ok) { static enum indicator_no filetype_indicator[] = FILETYPE_INDICATORS; - type = filetype_indicator[filetype]; + type = filetype_indicator[f->filetype]; } else { if (S_ISREG (mode)) { type = C_FILE; - if ((mode & S_ISUID) != 0) + + if ((mode & S_ISUID) != 0 && is_colored (C_SETUID)) type = C_SETUID; - else if ((mode & S_ISGID) != 0) + else if ((mode & S_ISGID) != 0 && is_colored (C_SETGID)) type = C_SETGID; - else if (is_colored (C_CAP) && has_capability (name)) + else if (is_colored (C_CAP) && f->has_capability) type = C_CAP; - else if ((mode & S_IXUGO) != 0) + else if ((mode & S_IXUGO) != 0 && is_colored (C_EXEC)) type = C_EXEC; - else if (is_colored (C_MULTIHARDLINK) && (1 < nlink)) + else if ((1 < f->stat.st_nlink) && is_colored (C_MULTIHARDLINK)) type = C_MULTIHARDLINK; } else if (S_ISDIR (mode)) { - if ((mode & S_ISVTX) && (mode & S_IWOTH)) + type = C_DIR; + + if ((mode & S_ISVTX) && (mode & S_IWOTH) + && is_colored (C_STICKY_OTHER_WRITABLE)) type = C_STICKY_OTHER_WRITABLE; - else if ((mode & S_IWOTH) != 0) + else if ((mode & S_IWOTH) != 0 && is_colored (C_OTHER_WRITABLE)) type = C_OTHER_WRITABLE; - else if ((mode & S_ISVTX) != 0) + else if ((mode & S_ISVTX) != 0 && is_colored (C_STICKY)) type = C_STICKY; - else - type = C_DIR; } else if (S_ISLNK (mode)) - type = ((!linkok && color_indicator[C_ORPHAN].string) + type = ((!linkok + && (!strncmp (color_indicator[C_LINK].string, "target", 6) + || color_indicator[C_ORPHAN].string)) ? C_ORPHAN : C_LINK); else if (S_ISFIFO (mode)) type = C_FIFO; @@ -4235,9 +4261,10 @@ length_of_file_name_and_frills (const struct fileinfo *f) if (print_block_size) len += 1 + (format == with_commas - ? strlen (human_readable (ST_NBLOCKS (f->stat), buf, - human_output_opts, ST_NBLOCKSIZE, - output_block_size)) + ? strlen (! f->stat_ok ? "?" + : human_readable (ST_NBLOCKS (f->stat), buf, + human_output_opts, ST_NBLOCKSIZE, + output_block_size)) : block_size_width); if (print_scontext) @@ -4566,8 +4593,8 @@ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (_("\ -C list entries by columns\n\ - --color[=WHEN] control whether color is used to distinguish file\n\ - types. WHEN may be `never', `always', or `auto'\n\ + --color[=WHEN] colorize the output. WHEN defaults to `always'\n\ + or can be `never' or `auto'. More info below\n\ -d, --directory list directory entries instead of contents,\n\ and do not dereference symbolic links\n\ -D, --dired generate output designed for Emacs' dired mode\n\ @@ -4681,12 +4708,10 @@ Mandatory arguments to long options are mandatory for short options too.\n\ emit_size_note (); fputs (_("\ \n\ -By default, color is not used to distinguish types of files. That is\n\ -equivalent to using --color=none. Using the --color option without the\n\ -optional WHEN argument is equivalent to using --color=always. With\n\ ---color=auto, color codes are output only if standard output is connected\n\ -to a terminal (tty). The environment variable LS_COLORS can influence the\n\ -colors, and can be set easily by the dircolors command.\n\ +Using color to distinguish file types is disabled both by default and\n\ +with --color=never. With --color=auto, ls emits color codes only when\n\ +standard output is connected to a terminal. The LS_COLORS environment\n\ +variable can change the settings. Use the dircolors command to set it.\n\ "), stdout); fputs (_("\ \n\ @@ -4695,7 +4720,7 @@ Exit status:\n\ 1 if minor problems (e.g., cannot access subdirectory),\n\ 2 if serious trouble (e.g., cannot access command-line argument).\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/md5sum.c b/src/bin/coreutils/src/md5sum.c index c8e01efb84..edd21ceb5f 100644 --- a/src/bin/coreutils/src/md5sum.c +++ b/src/bin/coreutils/src/md5sum.c @@ -1,5 +1,5 @@ /* Compute MD5, SHA1, SHA224, SHA256, SHA384 or SHA512 checksum of files or strings - Copyright (C) 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -195,7 +195,7 @@ should be a former output of this program. The default mode is to print\n\ a line with checksum, a character indicating type (`*' for binary, ` ' for\n\ text), and name for each FILE.\n"), DIGEST_REFERENCE); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); @@ -251,11 +251,10 @@ static bool split_3 (char *s, size_t s_len, unsigned char **hex_digest, int *binary, char **file_name) { - size_t i; bool escaped_filename = false; size_t algo_name_len; - i = 0; + size_t i = 0; while (ISWHITE (s[i])) ++i; @@ -263,11 +262,13 @@ split_3 (char *s, size_t s_len, algo_name_len = strlen (DIGEST_TYPE_STRING); if (strncmp (s + i, DIGEST_TYPE_STRING, algo_name_len) == 0) { - if (strncmp (s + i + algo_name_len, " (", 2) == 0) + if (s[i + algo_name_len] == ' ') + ++i; + if (s[i + algo_name_len] == '(') { *binary = 0; - return bsd_split_3 (s + i + algo_name_len + 2, - s_len - (i + algo_name_len + 2), + return bsd_split_3 (s + i + algo_name_len + 1, + s_len - (i + algo_name_len + 1), hex_digest, file_name); } } @@ -512,7 +513,6 @@ digest_check (const char *checkfile_name) if (!status_only) { printf (_("%s: FAILED open or read\n"), filename); - fflush (stdout); } } else @@ -538,7 +538,6 @@ digest_check (const char *checkfile_name) printf ("%s: %s\n", filename, _("FAILED")); else if (!quiet) printf ("%s: %s\n", filename, _("OK")); - fflush (stdout); } } } @@ -618,6 +617,10 @@ main (int argc, char **argv) atexit (close_stdout); + /* Line buffer stdout to ensure lines are written atomically and immediately + so that processes running in parallel do not intersperse their output. */ + setvbuf (stdout, NULL, _IOLBF, 0); + while ((opt = getopt_long (argc, argv, "bctw", long_options, NULL)) != -1) switch (opt) { @@ -661,21 +664,21 @@ main (int argc, char **argv) usage (EXIT_FAILURE); } - if (status_only & !do_check) + if (status_only && !do_check) { error (0, 0, _("the --status option is meaningful only when verifying checksums")); usage (EXIT_FAILURE); } - if (warn & !do_check) + if (warn && !do_check) { error (0, 0, _("the --warn option is meaningful only when verifying checksums")); usage (EXIT_FAILURE); } - if (quiet & !do_check) + if (quiet && !do_check) { error (0, 0, _("the --quiet option is meaningful only when verifying checksums")); diff --git a/src/bin/coreutils/src/mkdir.c b/src/bin/coreutils/src/mkdir.c index 4ae4875935..b2d94ceb44 100644 --- a/src/bin/coreutils/src/mkdir.c +++ b/src/bin/coreutils/src/mkdir.c @@ -1,5 +1,5 @@ /* mkdir -- make directories - Copyright (C) 90, 1995-2002, 2004-2009 Free Software Foundation, Inc. + Copyright (C) 1990, 1995-2002, 2004-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -71,7 +71,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/mkfifo.c b/src/bin/coreutils/src/mkfifo.c index 5ea3e3b829..90241eba9b 100644 --- a/src/bin/coreutils/src/mkfifo.c +++ b/src/bin/coreutils/src/mkfifo.c @@ -1,5 +1,5 @@ /* mkfifo -- make fifo's (named pipes) - Copyright (C) 90, 91, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1990-1991, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -65,7 +65,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/mknod.c b/src/bin/coreutils/src/mknod.c index 94e4471ef2..67e379dc7d 100644 --- a/src/bin/coreutils/src/mknod.c +++ b/src/bin/coreutils/src/mknod.c @@ -1,5 +1,5 @@ /* mknod -- make special files - Copyright (C) 90, 91, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1990-1991, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -81,7 +81,7 @@ otherwise, as decimal. TYPE may be:\n\ p create a FIFO\n\ "), stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/mktemp.c b/src/bin/coreutils/src/mktemp.c index a9a8708ca3..952369d9ae 100644 --- a/src/bin/coreutils/src/mktemp.c +++ b/src/bin/coreutils/src/mktemp.c @@ -1,5 +1,5 @@ /* Create a temporary file or directory, safely. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -14,24 +14,27 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -/* Written by Jim Meyering. */ +/* Written by Jim Meyering and Eric Blake. */ #include -#include #include #include #include "system.h" +#include "close-stream.h" #include "error.h" #include "filenamecat.h" #include "quote.h" +#include "stdio--.h" #include "tempname.h" /* The official name of this program (e.g., no `g' prefix). */ #define PROGRAM_NAME "mktemp" -#define AUTHORS proper_name ("Jim Meyering") +#define AUTHORS \ + proper_name ("Jim Meyering"), \ + proper_name ("Eric Blake") static const char *default_template = "tmp.XXXXXXXXXX"; @@ -39,7 +42,8 @@ static const char *default_template = "tmp.XXXXXXXXXX"; non-character as a pseudo short option, starting with CHAR_MAX + 1. */ enum { - TMPDIR_OPTION = CHAR_MAX + 1 + SUFFIX_OPTION = CHAR_MAX + 1, + TMPDIR_OPTION }; static struct option const longopts[] = @@ -47,6 +51,7 @@ static struct option const longopts[] = {"directory", no_argument, NULL, 'd'}, {"quiet", no_argument, NULL, 'q'}, {"dry-run", no_argument, NULL, 'u'}, + {"suffix", required_argument, NULL, SUFFIX_OPTION}, {"tmpdir", optional_argument, NULL, TMPDIR_OPTION}, {GETOPT_HELP_OPTION_DECL}, {GETOPT_VERSION_OPTION_DECL}, @@ -64,47 +69,45 @@ usage (int status) printf (_("Usage: %s [OPTION]... [TEMPLATE]\n"), program_name); fputs (_("\ Create a temporary file or directory, safely, and print its name.\n\ -If TEMPLATE is not specified, use tmp.XXXXXXXXXX.\n\ +TEMPLATE must contain at least 3 consecutive `X's in last component.\n\ +If TEMPLATE is not specified, use tmp.XXXXXXXXXX, and --tmpdir is implied.\n\ "), stdout); fputs ("\n", stdout); fputs (_("\ - -d, --directory create a directory, not a file\n\ + -d, --directory create a directory, not a file\n\ + -u, --dry-run do not create anything; merely print a name (unsafe)\n\ + -q, --quiet suppress diagnostics about file/dir-creation failure\n\ "), stdout); fputs (_("\ - -q, --quiet suppress diagnostics about file/dir-creation failure\n\ + --suffix=SUFF append SUFF to TEMPLATE. SUFF must not contain slash.\n\ + This option is implied if TEMPLATE does not end in X.\n\ "), stdout); fputs (_("\ - -u, --dry-run do not create anything; merely print a name (unsafe)\n\ -"), stdout); - fputs (_("\ - --tmpdir[=DIR] interpret TEMPLATE relative to DIR. If DIR is\n\ - not specified, use $TMPDIR if set, else /tmp.\n\ - With this option, TEMPLATE must not be an absolute name.\n\ - Unlike with -t, TEMPLATE may contain slashes, but even\n\ - here, mktemp still creates only the final component.\n\ + --tmpdir[=DIR] interpret TEMPLATE relative to DIR. If DIR is not\n\ + specified, use $TMPDIR if set, else /tmp. With\n\ + this option, TEMPLATE must not be an absolute name.\n\ + Unlike with -t, TEMPLATE may contain slashes, but\n\ + mktemp creates only the final component.\n\ "), stdout); fputs ("\n", stdout); fputs (_("\ - -p DIR use DIR as a prefix; implies -t [deprecated]\n\ -"), stdout); - fputs (_("\ - -t interpret TEMPLATE as a single file name component,\n\ - relative to a directory: $TMPDIR, if set; else the\n\ - directory specified via -p; else /tmp [deprecated]\n\ + -p DIR use DIR as a prefix; implies -t [deprecated]\n\ + -t interpret TEMPLATE as a single file name component,\n\ + relative to a directory: $TMPDIR, if set; else the\n\ + directory specified via -p; else /tmp [deprecated]\n\ "), stdout); fputs ("\n", stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } static size_t -count_trailing_X_s (const char *s) +count_consecutive_X_s (const char *s, size_t len) { - size_t len = strlen (s); size_t n = 0; for ( ; len && s[len-1] == 'X'; len--) ++n; @@ -112,15 +115,33 @@ count_trailing_X_s (const char *s) } static int -mkstemp_len (char *tmpl, size_t suff_len, bool dry_run) +mkstemp_len (char *tmpl, size_t suff_len, size_t x_len, bool dry_run) { - return gen_tempname_len (tmpl, dry_run ? GT_NOCREATE : GT_FILE, suff_len); + return gen_tempname_len (tmpl, suff_len, 0, dry_run ? GT_NOCREATE : GT_FILE, + x_len); } static int -mkdtemp_len (char *tmpl, size_t suff_len, bool dry_run) +mkdtemp_len (char *tmpl, size_t suff_len, size_t x_len, bool dry_run) { - return gen_tempname_len (tmpl, dry_run ? GT_NOCREATE : GT_DIR, suff_len); + return gen_tempname_len (tmpl, suff_len, 0, dry_run ? GT_NOCREATE : GT_DIR, + x_len); +} + +/* True if we have already closed standard output. */ +static bool stdout_closed; + +/* Avoid closing stdout twice. Since we conditionally call + close_stream (stdout) in order to decide whether to clean up a + temporary file, the exit hook needs to know whether to do all of + close_stdout or just the stderr half. */ +static void +maybe_close_stdout (void) +{ + if (!stdout_closed) + close_stdout (); + else if (close_stream (stderr) != 0) + _exit (EXIT_FAILURE); } int @@ -132,12 +153,14 @@ main (int argc, char **argv) int c; unsigned int n_args; char *template; + char *suffix = NULL; bool use_dest_dir = false; bool deprecated_t_option = false; bool create_directory = false; bool dry_run = false; int status = EXIT_SUCCESS; size_t x_count; + size_t suffix_len; char *dest_name; initialize_main (&argc, &argv); @@ -146,7 +169,7 @@ main (int argc, char **argv) bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); - atexit (close_stdout); + atexit (maybe_close_stdout); while ((c = getopt_long (argc, argv, "dp:qtuV", longopts, NULL)) != -1) { @@ -175,9 +198,13 @@ main (int argc, char **argv) dest_dir_arg = optarg; break; + case SUFFIX_OPTION: + suffix = optarg; + break; + case_GETOPT_HELP_CHAR; - case 'V': + case 'V': /* Undocumented alias. FIXME: remove in 2011. */ case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); default: usage (EXIT_FAILURE); @@ -210,7 +237,41 @@ main (int argc, char **argv) template = argv[optind]; } - x_count = count_trailing_X_s (template); + if (suffix) + { + size_t len = strlen (template); + if (!len || template[len - 1] != 'X') + { + error (EXIT_FAILURE, 0, + _("with --suffix, template %s must end in X"), + quote (template)); + } + suffix_len = strlen (suffix); + dest_name = xcharalloc (len + suffix_len + 1); + memcpy (dest_name, template, len); + memcpy (dest_name + len, suffix, suffix_len + 1); + template = dest_name; + suffix = dest_name + len; + } + else + { + template = xstrdup (template); + suffix = strrchr (template, 'X'); + if (!suffix) + suffix = strchr (template, '\0'); + else + suffix++; + suffix_len = strlen (suffix); + } + + /* At this point, template is malloc'd, and suffix points into template. */ + if (suffix_len && last_component (suffix) != suffix) + { + error (EXIT_FAILURE, 0, + _("invalid suffix %s, contains directory separator"), + quote (suffix)); + } + x_count = count_consecutive_X_s (template, suffix - template); if (x_count < 3) error (EXIT_FAILURE, 0, _("too few X's in template %s"), quote (template)); @@ -244,11 +305,10 @@ main (int argc, char **argv) quote (template)); } - template = file_name_concat (dest_dir, template, NULL); - } - else - { - template = xstrdup (template); + dest_name = file_name_concat (dest_dir, template, NULL); + free (template); + template = dest_name; + /* Note that suffix is now invalid. */ } /* Make a copy to be used in case of diagnostic, since failing @@ -257,7 +317,7 @@ main (int argc, char **argv) if (create_directory) { - int err = mkdtemp_len (dest_name, x_count, dry_run); + int err = mkdtemp_len (dest_name, suffix_len, x_count, dry_run); if (err != 0) { error (0, errno, _("failed to create directory via template %s"), @@ -267,7 +327,7 @@ main (int argc, char **argv) } else { - int fd = mkstemp_len (dest_name, x_count, dry_run); + int fd = mkstemp_len (dest_name, suffix_len, x_count, dry_run); if (fd < 0 || (!dry_run && close (fd) != 0)) { error (0, errno, _("failed to create file via template %s"), @@ -277,7 +337,17 @@ main (int argc, char **argv) } if (status == EXIT_SUCCESS) - puts (dest_name); + { + puts (dest_name); + /* If we created a file, but then failed to output the file + name, we should clean up the mess before failing. */ + if (!dry_run && (stdout_closed = true) && close_stream (stdout) != 0) + { + int saved_errno = errno; + remove (dest_name); + error (EXIT_FAILURE, saved_errno, _("write error")); + } + } #ifdef lint free (dest_name); diff --git a/src/bin/coreutils/src/mv.c b/src/bin/coreutils/src/mv.c index 413855b7df..5948970153 100644 --- a/src/bin/coreutils/src/mv.c +++ b/src/bin/coreutils/src/mv.c @@ -1,5 +1,5 @@ /* mv -- move or rename files - Copyright (C) 86, 89, 90, 91, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1986, 1989-1991, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -220,11 +220,14 @@ do_move (const char *source, const char *dest, const struct cp_options *x) { struct rm_options rm_options; enum RM_status status; + char const *dir[2]; rm_option_init (&rm_options); rm_options.verbose = x->verbose; + dir[0] = dir_to_remove; + dir[1] = NULL; - status = rm (1, &dir_to_remove, &rm_options); + status = rm ((void*) dir, &rm_options); assert (VALID_STATUS (status)); if (status == RM_ERROR) ok = false; @@ -328,7 +331,7 @@ the VERSION_CONTROL environment variable. Here are the values:\n\ existing, nil numbered if numbered backups exist, simple otherwise\n\ simple, never always make simple backups\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/nice.c b/src/bin/coreutils/src/nice.c index 4a3c092122..871129d617 100644 --- a/src/bin/coreutils/src/nice.c +++ b/src/bin/coreutils/src/nice.c @@ -1,5 +1,5 @@ /* nice -- run a program with modified niceness - Copyright (C) 1990-2005, 2007-2009 Free Software Foundation, Inc. + Copyright (C) 1990-2005, 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -81,11 +81,17 @@ With no COMMAND, print the current niceness. Nicenesses range from\n\ fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } +static bool +perm_related_errno (int err) +{ + return err == EACCES || err == EPERM; +} + int main (int argc, char **argv) { @@ -101,7 +107,7 @@ main (int argc, char **argv) bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); - initialize_exit_failure (EXIT_FAILURE); + initialize_exit_failure (EXIT_CANCELED); atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version, @@ -132,7 +138,7 @@ main (int argc, char **argv) i += optind - 1; if (optc == '?') - usage (EXIT_FAILURE); + usage (EXIT_CANCELED); else if (optc == 'n') adjustment_given = optarg; else /* optc == -1 */ @@ -148,7 +154,7 @@ main (int argc, char **argv) enum { MIN_ADJUSTMENT = 1 - 2 * NZERO, MAX_ADJUSTMENT = 2 * NZERO - 1 }; long int tmp; if (LONGINT_OVERFLOW < xstrtol (adjustment_given, NULL, 10, &tmp, "")) - error (EXIT_FAILURE, 0, _("invalid adjustment %s"), + error (EXIT_CANCELED, 0, _("invalid adjustment %s"), quote (adjustment_given)); adjustment = MAX (MIN_ADJUSTMENT, MIN (tmp, MAX_ADJUSTMENT)); } @@ -158,13 +164,13 @@ main (int argc, char **argv) if (adjustment_given) { error (0, 0, _("a command must be given with an adjustment")); - usage (EXIT_FAILURE); + usage (EXIT_CANCELED); } /* No command given; print the niceness. */ errno = 0; current_niceness = GET_NICENESS (); if (current_niceness == -1 && errno != 0) - error (EXIT_FAILURE, errno, _("cannot get niceness")); + error (EXIT_CANCELED, errno, _("cannot get niceness")); printf ("%d\n", current_niceness); exit (EXIT_SUCCESS); } @@ -175,11 +181,21 @@ main (int argc, char **argv) #else current_niceness = GET_NICENESS (); if (current_niceness == -1 && errno != 0) - error (EXIT_FAILURE, errno, _("cannot get niceness")); + error (EXIT_CANCELED, errno, _("cannot get niceness")); ok = (setpriority (PRIO_PROCESS, 0, current_niceness + adjustment) == 0); #endif if (!ok) - error (errno == EPERM ? 0 : EXIT_FAILURE, errno, _("cannot set niceness")); + { + error (perm_related_errno (errno) ? 0 + : EXIT_CANCELED, errno, _("cannot set niceness")); + /* error() flushes stderr, but does not check for write failure. + Normally, we would catch this via our atexit() hook of + close_stdout, but execvp() gets in the way. If stderr + encountered a write failure, there is no need to try calling + error() again. */ + if (ferror (stderr)) + exit (EXIT_CANCELED); + } execvp (argv[i], &argv[i]); diff --git a/src/bin/coreutils/src/nl.c b/src/bin/coreutils/src/nl.c index 773740fa59..a9446f4445 100644 --- a/src/bin/coreutils/src/nl.c +++ b/src/bin/coreutils/src/nl.c @@ -1,5 +1,5 @@ /* nl -- number lines of files - Copyright (C) 89, 92, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1989, 1992, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -231,7 +231,7 @@ FORMAT is one of:\n\ rz right justified, leading zeros\n\ \n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/nohup.c b/src/bin/coreutils/src/nohup.c index f4b1b23423..86800756f3 100644 --- a/src/bin/coreutils/src/nohup.c +++ b/src/bin/coreutils/src/nohup.c @@ -1,5 +1,5 @@ /* nohup -- run a command immune to hangups, with output to a non-tty - Copyright (C) 2003, 2004, 2005, 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2003-2005, 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -40,7 +40,7 @@ enum { /* `nohup' itself failed. */ - NOHUP_FAILURE = 127 + POSIX_NOHUP_FAILURE = 127 }; void @@ -71,7 +71,7 @@ If standard error is a terminal, redirect it to standard output.\n\ To save output to FILE, use `%s COMMAND > FILE'.\n"), program_name); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -85,6 +85,7 @@ main (int argc, char **argv) bool redirecting_stdout; bool stdout_is_closed; bool redirecting_stderr; + int exit_internal_failure; initialize_main (&argc, &argv); set_program_name (argv[0]); @@ -92,18 +93,24 @@ main (int argc, char **argv) bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); - initialize_exit_failure (NOHUP_FAILURE); + /* POSIX 2008 requires that internal failure give status 127; unlike + for env, exec, nice, time, and xargs where it requires internal + failure give something in the range 1-125. For consistency with + other tools, fail with EXIT_CANCELED unless POSIXLY_CORRECT. */ + exit_internal_failure = (getenv ("POSIXLY_CORRECT") + ? POSIX_NOHUP_FAILURE : EXIT_CANCELED); + initialize_exit_failure (exit_internal_failure); atexit (close_stdout); parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version, usage, AUTHORS, (char const *) NULL); if (getopt_long (argc, argv, "+", NULL, NULL) != -1) - usage (NOHUP_FAILURE); + usage (exit_internal_failure); if (argc <= optind) { error (0, 0, _("missing operand")); - usage (NOHUP_FAILURE); + usage (exit_internal_failure); } ignoring_input = isatty (STDIN_FILENO); @@ -116,7 +123,11 @@ main (int argc, char **argv) to ensure any read evokes an error. */ if (ignoring_input) { - fd_reopen (STDIN_FILENO, "/dev/null", O_WRONLY, 0); + if (fd_reopen (STDIN_FILENO, "/dev/null", O_WRONLY, 0) < 0) + { + error (0, errno, _("failed to render standard input unusable")); + exit (exit_internal_failure); + } if (!redirecting_stdout && !redirecting_stderr) error (0, 0, _("ignoring input")); } @@ -154,7 +165,7 @@ main (int argc, char **argv) if (in_home) error (0, saved_errno2, _("failed to open %s"), quote (in_home)); - exit (NOHUP_FAILURE); + exit (exit_internal_failure); } file = in_home; } @@ -179,7 +190,7 @@ main (int argc, char **argv) if (0 <= saved_stderr_fd && set_cloexec_flag (saved_stderr_fd, true) != 0) - error (NOHUP_FAILURE, errno, + error (exit_internal_failure, errno, _("failed to set the copy of stderr to close on exec")); if (!redirecting_stdout) @@ -189,12 +200,22 @@ main (int argc, char **argv) : N_("redirecting stderr to stdout"))); if (dup2 (out_fd, STDERR_FILENO) < 0) - error (NOHUP_FAILURE, errno, _("failed to redirect standard error")); + error (exit_internal_failure, errno, + _("failed to redirect standard error")); if (stdout_is_closed) close (out_fd); } + /* error() flushes stderr, but does not check for write failure. + Normally, we would catch this via our atexit() hook of + close_stdout, but execvp() gets in the way. If stderr + encountered a write failure, there is no need to try calling + error() again, particularly since we may have just changed the + underlying fd out from under stderr. */ + if (ferror (stderr)) + exit (exit_internal_failure); + signal (SIGHUP, SIG_IGN); { diff --git a/src/bin/coreutils/src/nproc.c b/src/bin/coreutils/src/nproc.c new file mode 100644 index 0000000000..95bc499904 --- /dev/null +++ b/src/bin/coreutils/src/nproc.c @@ -0,0 +1,128 @@ +/* nproc - print the number of processors. + Copyright (C) 2009-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Giuseppe Scrivano. */ + +#include +#include +#include +#include + +#include "system.h" +#include "error.h" +#include "nproc.h" +#include "xstrtol.h" + +/* The official name of this program (e.g., no `g' prefix). */ +#define PROGRAM_NAME "nproc" + +#define AUTHORS proper_name ("Giuseppe Scrivano") + +enum +{ + ALL_OPTION = CHAR_MAX + 1, + IGNORE_OPTION +}; + +static struct option const longopts[] = +{ + {"all", no_argument, NULL, ALL_OPTION}, + {"ignore", required_argument, NULL, IGNORE_OPTION}, + {GETOPT_HELP_OPTION_DECL}, + {GETOPT_VERSION_OPTION_DECL}, + {NULL, 0, NULL, 0} +}; + +void +usage (int status) +{ + if (status != EXIT_SUCCESS) + fprintf (stderr, _("Try `%s --help' for more information.\n"), + program_name); + else + { + printf (_("Usage: %s [OPTION]...\n"), program_name); + fputs (_("\ +Print the number of processing units available to the current process,\n\ +which may be less than the number of online processors\n\ +\n\ +"), stdout); + fputs (_("\ + --all print the number of installed processors\n\ + --ignore=N if possible, exclude N processing units\n\ +"), stdout); + + fputs (HELP_OPTION_DESCRIPTION, stdout); + fputs (VERSION_OPTION_DESCRIPTION, stdout); + emit_ancillary_info (); + } + exit (status); +} + +int +main (int argc, char **argv) +{ + unsigned long nproc, ignore = 0; + enum nproc_query mode; + initialize_main (&argc, &argv); + set_program_name (argv[0]); + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + atexit (close_stdout); + + mode = NPROC_CURRENT_OVERRIDABLE; + + while (1) + { + int c = getopt_long (argc, argv, "", longopts, NULL); + if (c == -1) + break; + switch (c) + { + case_GETOPT_HELP_CHAR; + + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + + case ALL_OPTION: + mode = NPROC_ALL; + break; + + case IGNORE_OPTION: + if (xstrtoul (optarg, NULL, 10, &ignore, "") != LONGINT_OK) + { + error (0, 0, _("%s: invalid number to ignore"), optarg); + usage (EXIT_FAILURE); + } + break; + + default: + usage (EXIT_FAILURE); + } + } + + nproc = num_processors (mode); + + if (ignore < nproc) + nproc -= ignore; + else + nproc = 1; + + printf ("%lu\n", nproc); + + exit (EXIT_SUCCESS); +} diff --git a/src/bin/coreutils/src/od.c b/src/bin/coreutils/src/od.c index 085d6406cf..964552d975 100644 --- a/src/bin/coreutils/src/od.c +++ b/src/bin/coreutils/src/od.c @@ -1,5 +1,5 @@ /* od -- dump files in octal and other formats - Copyright (C) 92, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1992, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -394,7 +394,7 @@ output line.\n\ Option --string without a number implies 3; option --width without a number\n\ implies 32. By default, od uses -A o -t oS -w16.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -878,7 +878,7 @@ open_next_file (void) } while (in_stream == NULL); - if (limit_bytes_to_format & !flag_dump_strings) + if (limit_bytes_to_format && !flag_dump_strings) setvbuf (in_stream, NULL, _IONBF, 0); return ok; @@ -1742,7 +1742,7 @@ it must be one character from [doxn]"), od [file] [[+]offset[.][b]] */ - if (!modern | traditional) + if (!modern || traditional) { uintmax_t o1; uintmax_t o2; diff --git a/src/bin/coreutils/src/operand2sig.c b/src/bin/coreutils/src/operand2sig.c index 23f44bc6df..5b26a75fb1 100644 --- a/src/bin/coreutils/src/operand2sig.c +++ b/src/bin/coreutils/src/operand2sig.c @@ -1,5 +1,5 @@ /* operand2sig.c -- common function for parsing signal specifications - Copyright (C) 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/src/operand2sig.h b/src/bin/coreutils/src/operand2sig.h index 43c7005256..1781d6afd1 100644 --- a/src/bin/coreutils/src/operand2sig.h +++ b/src/bin/coreutils/src/operand2sig.h @@ -1,6 +1,6 @@ /* operand2sig.h -- prototype for signal specification function - Copyright (C) 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/src/paste.c b/src/bin/coreutils/src/paste.c index 730a288732..ca2847fc49 100644 --- a/src/bin/coreutils/src/paste.c +++ b/src/bin/coreutils/src/paste.c @@ -1,5 +1,5 @@ /* paste - merge lines of files - Copyright (C) 1997-2005, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 1997-2005, 2008-2010 Free Software Foundation, Inc. Copyright (C) 1984 David M. Ihnat This program is free software: you can redistribute it and/or modify @@ -450,7 +450,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); /* FIXME: add a couple of examples. */ - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/pathchk.c b/src/bin/coreutils/src/pathchk.c index 04b70a3898..d9f6c0a64d 100644 --- a/src/bin/coreutils/src/pathchk.c +++ b/src/bin/coreutils/src/pathchk.c @@ -1,5 +1,5 @@ /* pathchk -- check whether file names are valid or portable - Copyright (C) 1991-2009 Free Software Foundation, Inc. + Copyright (C) 1991-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -104,7 +104,7 @@ Diagnose invalid or unportable file names.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -270,7 +270,7 @@ validate_file_name (char *file, bool check_basic_portability, if (check_extra_portability && ! no_leading_hyphen (file)) return false; - if ((check_basic_portability | check_extra_portability) + if ((check_basic_portability || check_extra_portability) && filelen == 0) { /* Fail, since empty names are not portable. As of diff --git a/src/bin/coreutils/src/pinky.c b/src/bin/coreutils/src/pinky.c index f75002e1f0..87d0a6f367 100644 --- a/src/bin/coreutils/src/pinky.c +++ b/src/bin/coreutils/src/pinky.c @@ -1,5 +1,5 @@ /* GNU's pinky. - Copyright (C) 1992-1997, 1999-2006, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 1992-1997, 1999-2006, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,6 +26,7 @@ #include "canon-host.h" #include "error.h" +#include "hard-locale.h" #include "readutmp.h" /* The official name of this program (e.g., no `g' prefix). */ @@ -526,7 +527,7 @@ usage (int status) A lightweight `finger' program; print user information.\n\ The utmp file will be %s.\n\ "), UTMP_FILE); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/pr.c b/src/bin/coreutils/src/pr.c index f584fdd30b..1b08894ec4 100644 --- a/src/bin/coreutils/src/pr.c +++ b/src/bin/coreutils/src/pr.c @@ -1,5 +1,5 @@ /* pr -- convert text files for printing. - Copyright (C) 88, 91, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1988, 1991, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -314,6 +314,7 @@ #include #include "system.h" #include "error.h" +#include "hard-locale.h" #include "mbswidth.h" #include "quote.h" #include "stat-time.h" @@ -1094,11 +1095,11 @@ main (int argc, char **argv) if (first_page_number == 0) first_page_number = 1; - if (parallel_files & explicit_columns) + if (parallel_files && explicit_columns) error (EXIT_FAILURE, 0, _("cannot specify number of columns when printing in parallel")); - if (parallel_files & print_across_flag) + if (parallel_files && print_across_flag) error (EXIT_FAILURE, 0, _("cannot specify both printing across and printing in parallel")); @@ -1110,7 +1111,7 @@ main (int argc, char **argv) { if (old_w) { - if (parallel_files | explicit_columns) + if (parallel_files || explicit_columns) { /* activate -W */ truncate_lines = true; @@ -1127,7 +1128,7 @@ main (int argc, char **argv) else if (!use_col_separator) { /* No -S option read */ - if (old_s & (parallel_files | explicit_columns)) + if (old_s && (parallel_files || explicit_columns)) { if (!truncate_lines) { @@ -1414,7 +1415,7 @@ init_funcs (void) /* When numbering lines of parallel files, we enlarge the first column to accomodate the number. Looks better than the Sys V approach. */ - if (parallel_files & numbered_lines) + if (parallel_files && numbered_lines) h_next = h + chars_per_column + number_width; else h_next = h + chars_per_column; @@ -1465,7 +1466,7 @@ init_funcs (void) Doesn't need to be stored unless we intend to balance columns on the last page. */ - if (storing_columns & balance_columns) + if (storing_columns && balance_columns) { p->char_func = store_char; p->print_func = print_stored; @@ -1862,7 +1863,7 @@ print_page (void) if (cols_ready_to_print () <= 0 && !extremities) break; - if (double_space & pv) + if (double_space && pv) { putchar ('\n'); --lines_left_on_page; @@ -1876,9 +1877,9 @@ print_page (void) pad_vertically = pv; - if (pad_vertically & extremities) + if (pad_vertically && extremities) pad_down (lines_left_on_page + lines_per_footer); - else if (keep_FF & print_a_FF) + else if (keep_FF && print_a_FF) { putchar ('\f'); print_a_FF = false; @@ -2068,7 +2069,7 @@ add_line_number (COLUMN *p) output_position); } - if (truncate_lines & !parallel_files) + if (truncate_lines && !parallel_files) input_position += number_width; } @@ -2402,10 +2403,10 @@ print_header (void) lhs_spaces = available_width >> 1; rhs_spaces = available_width - lhs_spaces; - printf ("\n\n%*.*s%s%*.*s%s%*.*s%s\n\n\n", - chars_per_margin, chars_per_margin, " ", - date_text, lhs_spaces, lhs_spaces, " ", - file_text, rhs_spaces, rhs_spaces, " ", page_text); + printf ("\n\n%*s%s%*s%s%*s%s\n\n\n", + chars_per_margin, "", + date_text, lhs_spaces, " ", + file_text, rhs_spaces, " ", page_text); print_a_header = false; output_position = 0; @@ -2457,7 +2458,7 @@ read_line (COLUMN *p) if ((c = getc (p->fp)) != '\n') ungetc (c, p->fp); FF_only = true; - if (print_a_header & !storing_columns) + if (print_a_header && !storing_columns) { pad_vertically = true; print_header (); @@ -2485,10 +2486,10 @@ read_line (COLUMN *p) { pad_vertically = true; - if (print_a_header & !storing_columns) + if (print_a_header && !storing_columns) print_header (); - if (parallel_files & align_empty_cols) + if (parallel_files && align_empty_cols) { /* We have to align empty columns at the beginning of a line. */ k = separators_not_printed; @@ -2834,7 +2835,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ omit warning when a file cannot be opened\n\ "), stdout); fputs (_("\ - -s[CHAR],--separator[=CHAR]\n\ + -s[CHAR], --separator[=CHAR]\n\ separate columns by a single character, default for CHAR\n\ is the character without -w and \'no char\' with -w\n\ -s[CHAR] turns off line truncation of all 3 column\n\ @@ -2867,10 +2868,10 @@ Mandatory arguments to long options are mandatory for short options too.\n\ fputs (VERSION_OPTION_DESCRIPTION, stdout); fputs (_("\ \n\ --t is implied if PAGE_LENGTH <= 10. With no FILE, or when\n\ -FILE is -, read standard input.\n\ +-t is implied if PAGE_LENGTH <= 10. With no FILE, or when FILE is -, read\n\ +standard input.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/printenv.c b/src/bin/coreutils/src/printenv.c index 69e2a6639b..8b68fb397e 100644 --- a/src/bin/coreutils/src/printenv.c +++ b/src/bin/coreutils/src/printenv.c @@ -1,5 +1,5 @@ /* printenv -- print all or part of environment - Copyright (C) 1989-1997, 1999-2005, 2007-2009 Free Software Foundation, Inc. + Copyright (C) 1989-1997, 1999-2005, 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,7 +33,6 @@ #include #include "system.h" -#include "long-options.h" /* Exit status for syntax errors, etc. */ enum { PRINTENV_FAILURE = 2 }; @@ -45,7 +44,13 @@ enum { PRINTENV_FAILURE = 2 }; proper_name ("David MacKenzie"), \ proper_name ("Richard Mlynarik") -extern char **environ; +static struct option const longopts[] = +{ + {"null", no_argument, NULL, '0'}, + {GETOPT_HELP_OPTION_DECL}, + {GETOPT_VERSION_OPTION_DECL}, + {NULL, 0, NULL, 0} +}; void usage (int status) @@ -56,17 +61,19 @@ usage (int status) else { printf (_("\ -Usage: %s [VARIABLE]...\n\ - or: %s OPTION\n\ +Usage: %s [OPTION]... [VARIABLE]...\n\ Print the values of the specified environment VARIABLE(s).\n\ If no VARIABLE is specified, print name and value pairs for them all.\n\ \n\ "), - program_name, program_name); + program_name); + fputs (_("\ + -0, --null end each output line with 0 byte rather than newline\n\ +"), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -78,6 +85,8 @@ main (int argc, char **argv) char *ep, *ap; int i; bool ok; + int optc; + bool opt_nul_terminate_output = false; initialize_main (&argc, &argv); set_program_name (argv[0]); @@ -88,15 +97,24 @@ main (int argc, char **argv) initialize_exit_failure (PRINTENV_FAILURE); atexit (close_stdout); - parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version, - usage, AUTHORS, (char const *) NULL); - if (getopt_long (argc, argv, "+", NULL, NULL) != -1) - usage (PRINTENV_FAILURE); + while ((optc = getopt_long (argc, argv, "+iu:0", longopts, NULL)) != -1) + { + switch (optc) + { + case '0': + opt_nul_terminate_output = true; + break; + case_GETOPT_HELP_CHAR; + case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); + default: + usage (PRINTENV_FAILURE); + } + } if (optind >= argc) { for (env = environ; *env != NULL; ++env) - puts (*env); + printf ("%s%c", *env, opt_nul_terminate_output ? '\0' : '\n'); ok = true; } else @@ -107,6 +125,10 @@ main (int argc, char **argv) { bool matched = false; + /* 'printenv a=b' is silent, even if 'a=b=c' is in environ. */ + if (strchr (argv[i], '=')) + continue; + for (env = environ; *env; ++env) { ep = *env; @@ -115,7 +137,8 @@ main (int argc, char **argv) { if (*ep == '=' && *ap == '\0') { - puts (ep + 1); + printf ("%s%c", ep + 1, + opt_nul_terminate_output ? '\0' : '\n'); matched = true; break; } diff --git a/src/bin/coreutils/src/printf.c b/src/bin/coreutils/src/printf.c index 5fa25dee82..1f5451e2e6 100644 --- a/src/bin/coreutils/src/printf.c +++ b/src/bin/coreutils/src/printf.c @@ -1,5 +1,5 @@ /* printf - format and print data - Copyright (C) 1990-2009 Free Software Foundation, Inc. + Copyright (C) 1990-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,6 +25,7 @@ \a = alert (bell) \b = backspace \c = produce no further output + \e = escape \f = form feed \n = new line \r = carriage return @@ -101,22 +102,21 @@ Print ARGUMENT(s) according to FORMAT, or execute according to OPTION:\n\ FORMAT controls the output as in C printf. Interpreted sequences are:\n\ \n\ \\\" double quote\n\ - \\NNN character with octal value NNN (1 to 3 digits)\n\ - \\\\ backslash\n\ "), stdout); fputs (_("\ + \\\\ backslash\n\ \\a alert (BEL)\n\ \\b backspace\n\ \\c produce no further output\n\ + \\e escape\n\ \\f form feed\n\ -"), stdout); - fputs (_("\ \\n new line\n\ \\r carriage return\n\ \\t horizontal tab\n\ \\v vertical tab\n\ "), stdout); fputs (_("\ + \\NNN byte with octal value NNN (1 to 3 digits)\n\ \\xHH byte with hexadecimal value HH (1 to 2 digits)\n\ \\uHHHH Unicode (ISO/IEC 10646) character with hex value HHHH (4 digits)\n\ \\UHHHHHHHH Unicode character with hex value HHHHHHHH (8 digits)\n\ @@ -130,7 +130,7 @@ and all C format specifications ending with one of diouxXfeEgGcs, with\n\ ARGUMENTs converted to proper type first. Variable widths are handled.\n\ "), stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -200,6 +200,9 @@ print_esc_char (char c) case 'c': /* Cancel the rest of the output. */ exit (EXIT_SUCCESS); break; + case 'e': /* Escape. */ + putchar ('\x1B'); + break; case 'f': /* Form feed. */ putchar ('\f'); break; @@ -256,7 +259,7 @@ print_esc (const char *escstart, bool octal_0) esc_value = esc_value * 8 + octtobin (*p); putchar (esc_value); } - else if (*p && strchr ("\"\\abcfnrtv", *p)) + else if (*p && strchr ("\"\\abcefnrtv", *p)) print_esc_char (*p++); else if (*p == 'u' || *p == 'U') { diff --git a/src/bin/coreutils/src/prog-fprintf.c b/src/bin/coreutils/src/prog-fprintf.c index 771d838770..5dd25b6c31 100644 --- a/src/bin/coreutils/src/prog-fprintf.c +++ b/src/bin/coreutils/src/prog-fprintf.c @@ -1,5 +1,5 @@ /* prog-fprintf.c - common formating output functions and definitions - Copyright (C) 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/src/prog-fprintf.h b/src/bin/coreutils/src/prog-fprintf.h index 98029ab9ce..3f4b679762 100644 --- a/src/bin/coreutils/src/prog-fprintf.h +++ b/src/bin/coreutils/src/prog-fprintf.h @@ -1,5 +1,5 @@ /* prog-fprintf.h - common formating output functions and definitions - Copyright (C) 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/src/ptx.c b/src/bin/coreutils/src/ptx.c index 806908eeeb..c6efb04c0f 100644 --- a/src/bin/coreutils/src/ptx.c +++ b/src/bin/coreutils/src/ptx.c @@ -1,5 +1,5 @@ /* Permuted index for GNU, with keywords in their context. - Copyright (C) 1990, 1991, 1993, 1998-2009 Free Software Foundation, Inc. + Copyright (C) 1990-1991, 1993, 1998-2010 Free Software Foundation, Inc. François Pinard , 1988. This program is free software: you can redistribute it and/or modify @@ -19,7 +19,6 @@ #include -#include #include #include #include "system.h" @@ -29,6 +28,7 @@ #include "quote.h" #include "quotearg.h" #include "regex.h" +#include "stdio--.h" #include "xstrtol.h" /* The official name of this program (e.g., no `g' prefix). */ @@ -455,7 +455,7 @@ initialize_regex (void) if (!*context_regex.string) context_regex.string = NULL; } - else if (gnu_extensions & !input_reference) + else if (gnu_extensions && !input_reference) context_regex.string = "[.?!][]\"')}]*\\($\\|\t\\| \\)[ \t\n]*"; else context_regex.string = "\n"; @@ -1296,7 +1296,7 @@ fix_output_parameters (void) /* If the reference appears to the left of the output line, reserve some space for it right away, including one gap size. */ - if ((auto_reference | input_reference) & !right_reference) + if ((auto_reference || input_reference) && !right_reference) line_width -= reference_max_width + gap_size; /* The output lines, minimally, will contain from left to right a left @@ -1660,7 +1660,7 @@ output_one_roff_line (void) /* Conditionally output the `reference' field. */ - if (auto_reference | input_reference) + if (auto_reference || input_reference) { fputs (" \"", stdout); print_field (reference); @@ -1699,7 +1699,7 @@ output_one_tex_line (void) fputs ("}{", stdout); print_field (head); putchar ('}'); - if (auto_reference | input_reference) + if (auto_reference || input_reference) { putchar ('{'); print_field (reference); @@ -1791,12 +1791,12 @@ output_one_dumb_line (void) } else - if ((auto_reference | input_reference) & right_reference) + if ((auto_reference || input_reference) && right_reference) print_spaces (half_line_width - (keyafter.end - keyafter.start) - (keyafter_truncation ? truncation_string_length : 0)); - if ((auto_reference | input_reference) & right_reference) + if ((auto_reference || input_reference) && right_reference) { /* Output the `reference' field. */ @@ -1923,7 +1923,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ \n\ With no FILE or if FILE is -, read Standard Input. `-F /' by default.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/pwd.c b/src/bin/coreutils/src/pwd.c index b74ba47071..b012a6e4e0 100644 --- a/src/bin/coreutils/src/pwd.c +++ b/src/bin/coreutils/src/pwd.c @@ -1,5 +1,5 @@ /* pwd - print current directory - Copyright (C) 1994-1997, 1999-2009 Free Software Foundation, Inc. + Copyright (C) 1994-1997, 1999-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -66,7 +66,7 @@ Print the full filename of the current working directory.\n\ fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/readlink.c b/src/bin/coreutils/src/readlink.c index a6f42f5c0e..a0f9173fbf 100644 --- a/src/bin/coreutils/src/readlink.c +++ b/src/bin/coreutils/src/readlink.c @@ -1,5 +1,5 @@ /* readlink -- display value of a symbolic link. - Copyright (C) 2002-2009 Free Software Foundation, Inc. + Copyright (C) 2002-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -82,7 +82,7 @@ usage (int status) "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/remove.c b/src/bin/coreutils/src/remove.c index d7bb86390b..96d5dc3260 100644 --- a/src/bin/coreutils/src/remove.c +++ b/src/bin/coreutils/src/remove.c @@ -1,5 +1,5 @@ /* remove.c -- core functions for removing files and directories - Copyright (C) 88, 90, 91, 1994-2009 Free Software Foundation, Inc. + Copyright (C) 1988, 1990-1991, 1994-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -14,16 +14,14 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -/* Extracted from rm.c and librarified, then rewritten by Jim Meyering. */ +/* Extracted from rm.c and librarified, then rewritten twice by Jim Meyering. */ #include #include #include -#include #include #include "system.h" -#include "cycle-check.h" #include "error.h" #include "euidaccess-stat.h" #include "file-type.h" @@ -33,44 +31,10 @@ #include "quote.h" #include "remove.h" #include "root-dev-ino.h" -#include "unlinkdir.h" #include "write-any-file.h" +#include "xfts.h" #include "yesno.h" -/* Avoid shadowing warnings because these are functions declared - in dirname.h as well as locals used below. */ -#define dir_name rm_dir_name -#define dir_len rm_dir_len - -/* This is the maximum number of consecutive readdir/unlink calls that - can be made (with no intervening rewinddir or closedir/opendir) before - triggering a bug that makes readdir return NULL even though some - directory entries have not been processed. The bug afflicts SunOS's - readdir when applied to ufs file systems and Darwin 6.5's (and OSX - v.10.3.8's) HFS+. This maximum is conservative in that demonstrating - the problem requires a directory containing at least 16 deletable - entries (which doesn't count . and ..). - This problem also affects Darwin 7.9.0 (aka MacOS X 10.3.9) on HFS+ - and NFS-mounted file systems, but not vfat ones. */ -enum - { - CONSECUTIVE_READDIR_UNLINK_THRESHOLD = 10 - }; - -/* If the heuristics in preprocess_dir suggest that there - are fewer than this many entries in a directory, then it - skips the preprocessing altogether. */ -enum -{ - INODE_SORT_DIR_ENTRIES_THRESHOLD = 10000 -}; - -/* FIXME: in 2009, or whenever Darwin 7.9.0 (aka MacOS X 10.3.9) is no - longer relevant, remove this work-around code. Then, there will be - no need to perform the extra rewinddir call, ever. */ -#define NEED_REWIND(readdir_unlink_count) \ - (CONSECUTIVE_READDIR_UNLINK_THRESHOLD <= (readdir_unlink_count)) - enum Ternary { T_UNKNOWN = 2, @@ -88,38 +52,9 @@ enum Prompt_action PA_REMOVE_DIR }; -/* Initial capacity of per-directory hash table of entries that have - been processed but not been deleted. */ -enum { HT_UNREMOVABLE_INITIAL_CAPACITY = 13 }; - -/* An entry in the active directory stack. - Each entry corresponds to an `active' directory. */ -struct AD_ent -{ - /* For a given active directory, this is the set of names of - entries in that directory that could/should not be removed. - For example, `.' and `..', as well as files/dirs for which - unlink/rmdir failed e.g., due to access restrictions. */ - Hash_table *unremovable; - - /* Record the status for a given active directory; we need to know - whether an entry was not removed, either because of an error or - because the user declined. */ - enum RM_status status; - - /* The directory's dev/ino. Used to ensure that a malicious user does - not replace a directory we're about to process with a symlink to - some other directory. */ - struct dev_ino dev_ino; -}; - /* D_TYPE(D) is the type of directory entry D if known, DT_UNKNOWN otherwise. */ -#if HAVE_STRUCT_DIRENT_D_TYPE -# define D_TYPE(d) ((d)->d_type) -#else -# define D_TYPE(d) DT_UNKNOWN - +#if ! HAVE_STRUCT_DIRENT_D_TYPE /* Any int values will do here, so long as they're distinct. Undef any existing macros out of the way. */ # undef DT_UNKNOWN @@ -130,45 +65,6 @@ struct AD_ent # define DT_LNK 2 #endif -struct dirstack_state -{ - /* The name of the directory (starting with and relative to a command - line argument) being processed. When a subdirectory is entered, a new - component is appended (pushed). Remove (pop) the top component - upon chdir'ing out of a directory. This is used to form the full - name of the current directory or a file therein, when necessary. */ - struct obstack dir_stack; - - /* Stack of lengths of directory names (including trailing slash) - appended to dir_stack. We have to have a separate stack of lengths - (rather than just popping back to previous slash) because the first - element pushed onto the dir stack may contain slashes. */ - struct obstack len_stack; - - /* Stack of active directory entries. - The first `active' directory is the initial working directory. - Additional active dirs are pushed onto the stack as we `chdir' - into each directory to be processed. When finished with the - hierarchy under a directory, pop the active dir stack. */ - struct obstack Active_dir; - - /* Used to detect cycles. */ - struct cycle_check_state cycle_check_state; - - /* Target of a longjmp in case rm has to stop processing the current - command-line argument. This happens 1) when rm detects a directory - cycle or 2) when it has processed one or more directories, but then - is unable to return to the initial working directory to process - additional `.'-relative command-line arguments. */ - jmp_buf current_arg_jumpbuf; -}; -typedef struct dirstack_state Dirstack_state; - -/* A static buffer and its allocated size, these variables are used by - xfull_filename and full_filename to form full, relative file names. */ -static char *g_buf; -static size_t g_n_allocated; - /* Like fstatat, but cache the result. If ST->st_size is -1, the status has not been gotten yet. If less than -1, fstatat failed with errno == ST->st_ino. Otherwise, the status has already @@ -209,573 +105,16 @@ cache_stat_ok (struct stat *st) return (0 <= st->st_size); } - -static void -hash_freer (void *x) -{ - free (x); -} - -static bool -hash_compare_strings (void const *x, void const *y) -{ - return STREQ (x, y) ? true : false; -} - -/* Obstack allocator: longjump on failure. */ -static void * -rm_malloc (void *v_jumpbuf, long size) -{ - jmp_buf *jumpbuf = v_jumpbuf; - void *p = malloc (size); - if (p) - return p; - longjmp (*jumpbuf, 1); -} - -/* With the 2-arg allocator, we must also provide a two-argument freer. */ -static void -rm_free (void *v_jumpbuf ATTRIBUTE_UNUSED, void *ptr) -{ - free (ptr); -} - -static inline void -push_dir (Dirstack_state *ds, const char *dir_name) -{ - size_t len = strlen (dir_name); - - /* Don't copy trailing slashes. */ - while (1 < len && dir_name[len - 1] == '/') - --len; - - /* Append the string onto the stack. */ - obstack_grow (&ds->dir_stack, dir_name, len); - - /* Append a trailing slash. */ - obstack_1grow (&ds->dir_stack, '/'); - - /* Add one for the slash. */ - ++len; - - /* Push the length (including slash) onto its stack. */ - obstack_grow (&ds->len_stack, &len, sizeof (len)); -} - -/* Return the entry name of the directory on the top of the stack - in malloc'd storage. */ -static inline char * -top_dir (Dirstack_state *ds) -{ - size_t n_lengths = obstack_object_size (&ds->len_stack) / sizeof (size_t); - size_t *length = obstack_base (&ds->len_stack); - size_t top_len = length[n_lengths - 1]; - char const *p = obstack_next_free (&ds->dir_stack) - top_len; - char *q = malloc (top_len); - if (q == NULL) - longjmp (ds->current_arg_jumpbuf, 1); - memcpy (q, p, top_len - 1); - q[top_len - 1] = 0; - return q; -} - -static inline void -pop_dir (Dirstack_state *ds) -{ - size_t n_lengths = obstack_object_size (&ds->len_stack) / sizeof (size_t); - size_t *length = obstack_base (&ds->len_stack); - size_t top_len; - - assert (n_lengths > 0); - top_len = length[n_lengths - 1]; - assert (top_len >= 2); - - /* Pop the specified length of file name. */ - assert (obstack_object_size (&ds->dir_stack) >= top_len); - obstack_blank (&ds->dir_stack, -top_len); - - /* Pop the length stack, too. */ - assert (obstack_object_size (&ds->len_stack) >= sizeof (size_t)); - obstack_blank (&ds->len_stack, -(int) sizeof (size_t)); -} - -/* Copy the SRC_LEN bytes of data beginning at SRC into the DST_LEN-byte - buffer, DST, so that the last source byte is at the end of the destination - buffer. If SRC_LEN is longer than DST_LEN, then set *TRUNCATED. - Set *RESULT to point to the beginning of (the portion of) the source data - in DST. Return the number of bytes remaining in the destination buffer. */ - -static size_t -right_justify (char *dst, size_t dst_len, const char *src, size_t src_len, - char **result, bool *truncated) -{ - const char *sp; - char *dp; - - if (src_len <= dst_len) - { - sp = src; - dp = dst + (dst_len - src_len); - *truncated = false; - } - else - { - sp = src + (src_len - dst_len); - dp = dst; - src_len = dst_len; - *truncated = true; - } - - *result = memcpy (dp, sp, src_len); - return dst_len - src_len; -} - -/* Using the global directory name obstack, create the full name of FILENAME. - Return it in sometimes-realloc'd space that should not be freed by the - caller. Realloc as necessary. If realloc fails, return NULL. */ - -static char * -full_filename0 (Dirstack_state const *ds, const char *filename) -{ - size_t dir_len = obstack_object_size (&ds->dir_stack); - char *dir_name = obstack_base (&ds->dir_stack); - size_t filename_len = strlen (filename); - size_t n_bytes_needed = dir_len + filename_len + 1; - - if (g_n_allocated < n_bytes_needed) - { - char *new_buf = realloc (g_buf, n_bytes_needed); - if (new_buf == NULL) - return NULL; - - g_buf = new_buf; - g_n_allocated = n_bytes_needed; - } - - if (STREQ (filename, ".") && dir_len) - { - /* FILENAME is just `.' and dir_len is nonzero. - Copy the directory part, omitting the trailing slash, - and append a trailing zero byte. */ - char *p = mempcpy (g_buf, dir_name, dir_len - 1); - *p = 0; - } - else - { - /* Copy the directory part, including trailing slash, and then - append the filename part, including a trailing zero byte. */ - memcpy (mempcpy (g_buf, dir_name, dir_len), filename, filename_len + 1); - assert (strlen (g_buf) + 1 == n_bytes_needed); - } - - return g_buf; -} - -/* Using the global directory name obstack, create the full name of FILENAME. - Return it in sometimes-realloc'd space that should not be freed by the - caller. Realloc as necessary. If realloc fails, die. */ - -static char * -xfull_filename (Dirstack_state const *ds, const char *filename) -{ - char *buf = full_filename0 (ds, filename); - if (buf == NULL) - xalloc_die (); - return buf; -} - -/* Using the global directory name obstack, create the full name FILENAME. - Return it in sometimes-realloc'd space that should not be freed by the - caller. Realloc as necessary. If realloc fails, use a static buffer - and put as long a suffix in that buffer as possible. Be careful not - to change errno. */ - -#define full_filename(Filename) full_filename_ (ds, Filename) -static char * -full_filename_ (Dirstack_state const *ds, const char *filename) -{ - int saved_errno = errno; - char *full_name = full_filename0 (ds, filename); - if (full_name) - { - errno = saved_errno; - return full_name; - } - - { -#define SBUF_SIZE 512 -#define ELLIPSES_PREFIX "[...]" - static char static_buf[SBUF_SIZE]; - bool file_truncated; - bool dir_truncated; - size_t n_bytes_remaining; - char *p; - char *dir_name = obstack_base (&ds->dir_stack); - size_t dir_len = obstack_object_size (&ds->dir_stack); - - free (g_buf); - n_bytes_remaining = right_justify (static_buf, SBUF_SIZE, filename, - strlen (filename) + 1, &p, - &file_truncated); - right_justify (static_buf, n_bytes_remaining, dir_name, dir_len, - &p, &dir_truncated); - if (file_truncated || dir_truncated) - { - memcpy (static_buf, ELLIPSES_PREFIX, - sizeof (ELLIPSES_PREFIX) - 1); - } - errno = saved_errno; - return p; - } -} - -static inline size_t -AD_stack_height (Dirstack_state const *ds) -{ - return obstack_object_size (&ds->Active_dir) / sizeof (struct AD_ent); -} - -static inline struct AD_ent * -AD_stack_top (Dirstack_state const *ds) -{ - return (struct AD_ent *) - ((char *) obstack_next_free (&ds->Active_dir) - sizeof (struct AD_ent)); -} - -static void -AD_stack_pop (Dirstack_state *ds) -{ - struct AD_ent *top; - assert (0 < AD_stack_height (ds)); - - /* operate on Active_dir. pop and free top entry */ - top = AD_stack_top (ds); - if (top->unremovable) - hash_free (top->unremovable); - obstack_blank (&ds->Active_dir, -(int) sizeof (struct AD_ent)); -} - -static void -AD_stack_clear (Dirstack_state *ds) -{ - while (0 < AD_stack_height (ds)) - { - AD_stack_pop (ds); - } -} - -/* Initialize obstack O just enough so that it may be freed - with obstack_free. */ -static void -obstack_init_minimal (struct obstack *o) -{ - o->chunk = NULL; -} - -static void -ds_init (Dirstack_state *ds) -{ - unsigned int i; - struct obstack *o[3]; - o[0] = &ds->dir_stack; - o[1] = &ds->len_stack; - o[2] = &ds->Active_dir; - - /* Ensure each of these is NULL, in case init/allocation - fails and we end up calling ds_free on all three while only - one or two has been initialized. */ - for (i = 0; i < 3; i++) - obstack_init_minimal (o[i]); - - for (i = 0; i < 3; i++) - obstack_specify_allocation_with_arg - (o[i], 0, 0, rm_malloc, rm_free, &ds->current_arg_jumpbuf); -} - -static void -ds_clear (Dirstack_state *ds) -{ - obstack_free (&ds->dir_stack, obstack_finish (&ds->dir_stack)); - obstack_free (&ds->len_stack, obstack_finish (&ds->len_stack)); - while (0 < AD_stack_height (ds)) - AD_stack_pop (ds); - obstack_free (&ds->Active_dir, obstack_finish (&ds->Active_dir)); -} - -static void -ds_free (Dirstack_state *ds) -{ - obstack_free (&ds->dir_stack, NULL); - obstack_free (&ds->len_stack, NULL); - obstack_free (&ds->Active_dir, NULL); -} - -/* Pop the active directory (AD) stack and prepare to move `up' one level, - safely. Moving `up' usually means opening `..', but when we've just - finished recursively processing a command-line directory argument, - there's nothing left on the stack, so set *FDP to AT_FDCWD in that case. - The idea is to return with *FDP opened on the parent directory, - assuming there are entries in that directory that we need to remove. - - Note that we must not call opendir (or fdopendir) just yet, since - the caller must first remove the directory we're coming from. - That is because some file system implementations cache readdir - results at opendir time; so calling opendir, rmdir, readdir would - return an entry for the just-removed directory. - - Whenever using chdir '..' (virtually, now, via openat), verify - that the post-chdir dev/ino numbers for `.' match the saved ones. - If any system call fails or if dev/ino don't match, then give a - diagnostic and longjump out. - Return the name (in malloc'd storage) of the - directory (usually now empty) from which we're coming, and which - corresponds to the input value of DIRP. - - Finally, note that while this function's name is no longer as - accurate as it once was (it no longer calls chdir), it does open - the destination directory. */ -static char * -AD_pop_and_chdir (DIR *dirp, int *fdp, Dirstack_state *ds) -{ - struct AD_ent *leaf_dir_ent = AD_stack_top(ds); - struct dev_ino leaf_dev_ino = leaf_dir_ent->dev_ino; - enum RM_status old_status = leaf_dir_ent->status; - struct AD_ent *top; - - /* Get the name of the current (but soon to be `previous') directory - from the top of the stack. */ - char *prev_dir = top_dir (ds); - - AD_stack_pop (ds); - pop_dir (ds); - top = AD_stack_top (ds); - - /* If the directory we're about to leave (and try to rmdir) - is the one whose dev_ino is being used to detect a cycle, - reset cycle_check_state.dev_ino to that of the parent. - Otherwise, once that directory is removed, its dev_ino - could be reused in the creation (by some other process) - of a directory that this rm process would encounter, - which would result in a false-positive cycle indication. */ - CYCLE_CHECK_REFLECT_CHDIR_UP (&ds->cycle_check_state, - top->dev_ino, leaf_dev_ino); - - /* Propagate any failure to parent. */ - UPDATE_STATUS (top->status, old_status); - - assert (AD_stack_height (ds)); - - if (1 < AD_stack_height (ds)) - { - struct stat sb; - int fd = openat (dirfd (dirp), "..", O_RDONLY); - if (closedir (dirp) != 0) - { - error (0, errno, _("FATAL: failed to close directory %s"), - quote (full_filename (prev_dir))); - goto next_cmdline_arg; - } - - /* The above fails with EACCES when DIRP is readable but not - searchable, when using Solaris' openat. Without this openat - call, tests/rm2 would fail to remove directories a/2 and a/3. */ - if (fd < 0) - fd = openat (AT_FDCWD, xfull_filename (ds, "."), O_RDONLY); - - if (fd < 0) - { - error (0, errno, _("FATAL: cannot open .. from %s"), - quote (full_filename (prev_dir))); - goto next_cmdline_arg; - } - - if (fstat (fd, &sb)) - { - error (0, errno, - _("FATAL: cannot ensure %s (returned to via ..) is safe"), - quote (full_filename ("."))); - goto close_and_next; - } - - /* Ensure that post-chdir dev/ino match the stored ones. */ - if ( ! SAME_INODE (sb, top->dev_ino)) - { - error (0, 0, _("FATAL: directory %s changed dev/ino"), - quote (full_filename ("."))); - close_and_next:; - close (fd); - - next_cmdline_arg:; - free (prev_dir); - longjmp (ds->current_arg_jumpbuf, 1); - } - *fdp = fd; - } - else - { - if (closedir (dirp) != 0) - { - error (0, errno, _("FATAL: failed to close directory %s"), - quote (full_filename (prev_dir))); - goto next_cmdline_arg; - } - *fdp = AT_FDCWD; - } - - return prev_dir; -} - -/* Initialize *HT if it is NULL. Return *HT. */ -static Hash_table * -AD_ensure_initialized (Hash_table **ht) -{ - if (*ht == NULL) - { - *ht = hash_initialize (HT_UNREMOVABLE_INITIAL_CAPACITY, NULL, hash_pjw, - hash_compare_strings, hash_freer); - if (*ht == NULL) - xalloc_die (); - } - - return *ht; -} - -/* Initialize *HT if it is NULL. - Insert FILENAME into HT. */ -static void -AD_mark_helper (Hash_table **ht, char *filename) -{ - void *ent = hash_insert (AD_ensure_initialized (ht), filename); - if (ent == NULL) - xalloc_die (); - else - { - if (ent != filename) - free (filename); - } -} - -/* Mark FILENAME (in current directory) as unremovable. */ -static void -AD_mark_as_unremovable (Dirstack_state *ds, char const *filename) -{ - AD_mark_helper (&AD_stack_top(ds)->unremovable, xstrdup (filename)); -} - -/* Mark the current directory as unremovable. I.e., mark the entry - in the parent directory corresponding to `.'. - This happens e.g., when an opendir fails and the only name - the caller has conveniently at hand is `.'. */ -static void -AD_mark_current_as_unremovable (Dirstack_state *ds) -{ - struct AD_ent *top = AD_stack_top (ds); - char *curr = top_dir (ds); - - assert (1 < AD_stack_height (ds)); - - --top; - AD_mark_helper (&top->unremovable, curr); -} - -/* Push an initial dummy entry onto the stack. - This will always be the bottommost entry on the stack. */ -static void -AD_push_initial (Dirstack_state *ds) -{ - struct AD_ent *top; - - /* Extend the stack. */ - obstack_blank (&ds->Active_dir, sizeof (struct AD_ent)); - - /* Fill in the new values. */ - top = AD_stack_top (ds); - top->unremovable = NULL; - - /* These should never be used. - Give them values that might look suspicious - in a debugger or in a diagnostic. */ - top->dev_ino.st_dev = TYPE_MAXIMUM (dev_t); - top->dev_ino.st_ino = TYPE_MAXIMUM (ino_t); -} - -/* Push info about the current working directory (".") onto the - active directory stack. DIR is the ./-relative name through - which we've just `chdir'd to this directory. DIR_SB_FROM_PARENT - is the result of calling lstat on DIR from the parent of DIR. - Longjump out (skipping the entire command line argument we're - dealing with) if `fstat (FD_CWD, ...' fails or if someone has - replaced DIR with e.g., a symlink to some other directory. */ -static void -AD_push (int fd_cwd, Dirstack_state *ds, char const *dir, - struct stat const *dir_sb_from_parent) -{ - struct AD_ent *top; - - push_dir (ds, dir); - - /* If our uses of openat are guaranteed not to - follow a symlink, then we can skip this check. */ - if (! HAVE_WORKING_O_NOFOLLOW) - { - struct stat sb; - if (fstat (fd_cwd, &sb) != 0) - { - error (0, errno, _("FATAL: cannot enter directory %s"), - quote (full_filename ("."))); - longjmp (ds->current_arg_jumpbuf, 1); - } - - if ( ! SAME_INODE (sb, *dir_sb_from_parent)) - { - error (0, 0, - _("FATAL: just-changed-to directory %s changed dev/ino"), - quote (full_filename ("."))); - longjmp (ds->current_arg_jumpbuf, 1); - } - } - - if (cycle_check (&ds->cycle_check_state, dir_sb_from_parent)) - { - error (0, 0, _("\ -WARNING: Circular directory structure.\n\ -This almost certainly means that you have a corrupted file system.\n\ -NOTIFY YOUR SYSTEM MANAGER.\n\ -The following directory is part of the cycle:\n %s\n"), - quote (full_filename ("."))); - longjmp (ds->current_arg_jumpbuf, 1); - } - - /* Extend the stack. */ - obstack_blank (&ds->Active_dir, sizeof (struct AD_ent)); - - /* The active directory stack must be one larger than the length stack. */ - assert (AD_stack_height (ds) == - 1 + obstack_object_size (&ds->len_stack) / sizeof (size_t)); - - /* Fill in the new values. */ - top = AD_stack_top (ds); - top->dev_ino.st_dev = dir_sb_from_parent->st_dev; - top->dev_ino.st_ino = dir_sb_from_parent->st_ino; - top->unremovable = NULL; -} - -static inline bool -AD_is_removable (Dirstack_state const *ds, char const *file) -{ - struct AD_ent *top = AD_stack_top (ds); - return ! (top->unremovable && hash_lookup (top->unremovable, file)); -} - /* Return 1 if FILE is an unwritable non-symlink, 0 if it is writable or some other type of file, -1 and set errno if there is some problem in determining the answer. + Use FULL_NAME only if necessary. Set *BUF to the file status. This is to avoid calling euidaccess when FILE is a symlink. */ static int write_protected_non_symlink (int fd_cwd, char const *file, - Dirstack_state const *ds, + char const *full_name, struct stat *buf) { if (can_write_any_file ()) @@ -803,13 +142,13 @@ write_protected_non_symlink (int fd_cwd, Disadvantage: changes working directory (not reentrant) and can't work if save_cwd fails. - 3) if (euidaccess (xfull_filename (file), W_OK) == 0) - Disadvantage: doesn't work if xfull_filename is too long. + 3) if (euidaccess (full_name, W_OK) == 0) + Disadvantage: doesn't work if full_name is too long. Inefficient for very deep trees (O(Depth^2)). 4) If the full pathname is sufficiently short (say, less than PATH_MAX or 8192 bytes, whichever is shorter): - use method (3) (i.e., euidaccess (xfull_filename (file), W_OK)); + use method (3) (i.e., euidaccess (full_name, W_OK)); Otherwise: vfork, fchdir in the child, run euidaccess in the child, then the child exits with a status that tells the parent whether euidaccess succeeded. @@ -823,7 +162,7 @@ write_protected_non_symlink (int fd_cwd, 5) If the full file name is sufficiently short (say, less than PATH_MAX or 8192 bytes, whichever is shorter): - use method (3) (i.e., euidaccess (xfull_filename (file), W_OK)); + use method (3) (i.e., euidaccess (full_name, W_OK)); Otherwise: look just at the file bits. Perhaps issue a warning the first time this occurs. @@ -833,19 +172,26 @@ write_protected_non_symlink (int fd_cwd, mess up with long file names). */ { + /* This implements #1: on decent systems, either faccessat is + native or /proc/self/fd allows us to skip a chdir. */ + if (!openat_needs_fchdir () + && faccessat (fd_cwd, file, W_OK, AT_EACCESS) == 0) + return 0; + + { /* This implements #5: */ - size_t file_name_len - = obstack_object_size (&ds->dir_stack) + strlen (file); + size_t file_name_len = strlen (full_name); if (MIN (PATH_MAX, 8192) <= file_name_len) return ! euidaccess_stat (buf, W_OK); - if (euidaccess (xfull_filename (ds, file), W_OK) == 0) + if (euidaccess (full_name, W_OK) == 0) return 0; if (errno == EACCES) { errno = 0; return 1; } + } /* Perhaps some other process has removed the file, or perhaps this is a buggy NFS client. */ @@ -853,42 +199,54 @@ write_protected_non_symlink (int fd_cwd, } } -/* Prompt whether to remove FILENAME, if required via a combination of +/* Prompt whether to remove FILENAME (ent->, if required via a combination of the options specified by X and/or file attributes. If the file may be removed, return RM_OK. If the user declines to remove the file, return RM_USER_DECLINED. If not ignoring missing files and we cannot lstat FILENAME, then return RM_ERROR. - *PDIRENT_TYPE is the type of the directory entry; update it to DT_DIR - or DT_LNK as needed. *SBUF is the file's status. + IS_DIR is true if ENT designates a directory, false otherwise. Depending on MODE, ask whether to `descend into' or to `remove' the directory FILENAME. MODE is ignored when FILENAME is not a directory. - Set *IS_EMPTY to T_YES if FILENAME is an empty directory, and it is + Set *IS_EMPTY_P to T_YES if FILENAME is an empty directory, and it is appropriate to try to remove it with rmdir (e.g. recursive mode). - Don't even try to set *IS_EMPTY when MODE == PA_REMOVE_DIR. */ + Don't even try to set *IS_EMPTY_P when MODE == PA_REMOVE_DIR. */ static enum RM_status -prompt (int fd_cwd, Dirstack_state const *ds, char const *filename, - int *pdirent_type, struct stat *sbuf, +prompt (FTS const *fts, FTSENT const *ent, bool is_dir, struct rm_options const *x, enum Prompt_action mode, - Ternary *is_empty) + Ternary *is_empty_p) { + int wp_errno; + int fd_cwd = fts->fts_cwd_fd; + char const *full_name = ent->fts_path; + char const *filename = ent->fts_accpath; + struct stat st; + struct stat *sbuf = &st; + int dirent_type = is_dir ? DT_DIR : DT_UNKNOWN; int write_protected = 0; - int dirent_type = *pdirent_type; - int wp_errno = 0; + if (is_empty_p) + *is_empty_p = T_UNKNOWN; - *is_empty = T_UNKNOWN; + + cache_stat_init (sbuf); + + /* When nonzero, this indicates that we failed to remove a child entry, + either because the user declined an interactive prompt, or due to + some other failure, like permissions. */ + if (ent->fts_number) + return RM_USER_DECLINED; if (x->interactive == RMI_NEVER) return RM_OK; - errno = 0; - + wp_errno = 0; if (!x->ignore_missing_files && ((x->interactive == RMI_ALWAYS) || x->stdin_tty) && dirent_type != DT_LNK) { - write_protected = write_protected_non_symlink (fd_cwd, filename, ds, sbuf); + write_protected = write_protected_non_symlink (fd_cwd, filename, + full_name, sbuf); wp_errno = errno; } @@ -903,7 +261,6 @@ prompt (int fd_cwd, Dirstack_state const *ds, char const *filename, else if (S_ISDIR (sbuf->st_mode)) dirent_type = DT_DIR; /* Otherwise it doesn't matter, so leave it DT_UNKNOWN. */ - *pdirent_type = dirent_type; } else { @@ -930,24 +287,29 @@ prompt (int fd_cwd, Dirstack_state const *ds, char const *filename, } break; } - { - char const *quoted_name = quote (full_filename (filename)); - + char const *quoted_name = quote (full_name); + bool is_empty; + if (write_protected < 0) { error (0, wp_errno, _("cannot remove %s"), quoted_name); return RM_ERROR; } + + if (is_empty_p) + { + is_empty = is_empty_dir (fd_cwd, filename); + *is_empty_p = is_empty ? T_YES : T_NO; + } + else + is_empty = false; + /* Issue the prompt. */ - /* FIXME: use a variant of error (instead of fprintf) that doesn't - append a newline. Then we won't have to declare program_name in - this file. */ if (dirent_type == DT_DIR && mode == PA_DESCEND_INTO_DIR - && ((*is_empty = (is_empty_dir (fd_cwd, filename) ? T_YES : T_NO)) - == T_NO)) + && !is_empty) fprintf (stderr, (write_protected ? _("%s: descend into write-protected directory %s? ") @@ -1009,40 +371,6 @@ is_nondir_lstat (int fd_cwd, char const *filename, struct stat *st) return is_non_dir; } -#define DO_UNLINK(Fd_cwd, Filename, X) \ - do \ - { \ - if (unlinkat (Fd_cwd, Filename, 0) == 0) \ - { \ - if ((X)->verbose) \ - printf (_("removed %s\n"), quote (full_filename (Filename))); \ - return RM_OK; \ - } \ - \ - if (ignorable_missing (X, errno)) \ - return RM_OK; \ - } \ - while (0) - -#define DO_RMDIR(Fd_cwd, Filename, X) \ - do \ - { \ - if (unlinkat (Fd_cwd, Filename, AT_REMOVEDIR) == 0) /* rmdir */ \ - { \ - if ((X)->verbose) \ - printf (_("removed directory: %s\n"), \ - quote (full_filename (Filename))); \ - return RM_OK; \ - } \ - \ - if (ignorable_missing (X, errno)) \ - return RM_OK; \ - \ - if (errno == ENOTEMPTY || errno == EEXIST) \ - return RM_NONEMPTY_DIR; \ - } \ - while (0) - /* When a function like unlink, rmdir, or fstatat fails with an errno value of ERRNUM, return true if the specified file system object is guaranteed not to exist; otherwise, return false. */ @@ -1072,802 +400,246 @@ ignorable_missing (struct rm_options const *x, int errnum) return x->ignore_missing_files && nonexistent_file_errno (errnum); } -/* Remove the file or directory specified by FILENAME. - Return RM_OK if it is removed, and RM_ERROR or RM_USER_DECLINED if not. - But if FILENAME specifies a non-empty directory, return RM_NONEMPTY_DIR. */ - -static enum RM_status -remove_entry (int fd_cwd, Dirstack_state const *ds, char const *filename, - int dirent_type_arg, struct stat *st, - struct rm_options const *x) +/* Tell fts not to traverse into the hierarchy at ENT. */ +static void +fts_skip_tree (FTS *fts, FTSENT *ent) { - Ternary is_empty_directory; - enum RM_status s = prompt (fd_cwd, ds, filename, &dirent_type_arg, st, x, - PA_DESCEND_INTO_DIR, - &is_empty_directory); - int dirent_type = dirent_type_arg; - if (s != RM_OK) - return s; + fts_set (fts, ent, FTS_SKIP); + /* Ensure that we do not process ENT a second time. */ + ent = fts_read (fts); +} - /* Why bother with the following if/else block? Because on systems with - an unlink function that *can* unlink directories, we must determine the - type of each entry before removing it. Otherwise, we'd risk unlinking - an entire directory tree simply by unlinking a single directory; then - all the storage associated with that hierarchy would not be freed until - the next fsck. Not nice. To avoid that, on such slightly losing - systems, we need to call lstat to determine the type of each entry, - and that represents extra overhead that -- it turns out -- we can - avoid on non-losing systems, since there, unlink will never remove - a directory. Also, on systems where unlink may unlink directories, - we're forced to allow a race condition: we lstat a non-directory, then - go to unlink it, but in the mean time, a malicious someone could have - replaced it with a directory. */ - - if (cannot_unlink_dir ()) +/* Upon unlink failure, or when the user declines to remove ENT, mark + each of its ancestor directories, so that we know not to prompt for + its removal. */ +static void +mark_ancestor_dirs (FTSENT *ent) +{ + FTSENT *p; + for (p = ent->fts_parent; FTS_ROOTLEVEL <= p->fts_level; p = p->fts_parent) { - if (dirent_type == DT_DIR && ! x->recursive) - { - error (0, EISDIR, _("cannot remove %s"), - quote (full_filename (filename))); - return RM_ERROR; - } - - /* is_empty_directory is set iff it's ok to use rmdir. - Note that it's set only in interactive mode -- in which case it's - an optimization that arranges so that the user is asked just - once whether to remove the directory. */ - if (is_empty_directory == T_YES) - DO_RMDIR (fd_cwd, filename, x); - - /* If we happen to know that FILENAME is a directory, return now - and let the caller remove it -- this saves the overhead of a failed - unlink call. If FILENAME is a command-line argument, then - DIRENT_TYPE is DT_UNKNOWN so we'll first try to unlink it. - Using unlink here is ok, because it cannot remove a - directory. */ - if (dirent_type == DT_DIR) - return RM_NONEMPTY_DIR; - - DO_UNLINK (fd_cwd, filename, x); - - /* Upon a failed attempt to unlink a directory, most non GNU/Linux - systems set errno to the POSIX-required value EPERM. In that case, - change errno to EISDIR so that we emit a better diagnostic. */ - if (! x->recursive && errno == EPERM && is_dir_lstat (fd_cwd, - filename, st)) - errno = EISDIR; - - if (! x->recursive - || (cache_stat_ok (st) && !S_ISDIR (st->st_mode)) - || ((errno == EACCES || errno == EPERM) - && is_nondir_lstat (fd_cwd, filename, st)) - ) - { - if (ignorable_missing (x, errno)) - return RM_OK; - - /* Either --recursive is not in effect, or the file cannot be a - directory. Report the unlink problem and fail. */ - error (0, errno, _("cannot remove %s"), - quote (full_filename (filename))); - return RM_ERROR; - } - assert (!cache_stat_ok (st) || S_ISDIR (st->st_mode)); + if (p->fts_number) + break; + p->fts_number = 1; } - else +} + +/* Remove the file system object specified by ENT. IS_DIR specifies + whether it is expected to be a directory or non-directory. + Return RM_OK upon success, else RM_ERROR. */ +static enum RM_status +excise (FTS *fts, FTSENT *ent, struct rm_options const *x, bool is_dir) +{ + int flag = is_dir ? AT_REMOVEDIR : 0; + if (unlinkat (fts->fts_cwd_fd, ent->fts_accpath, flag) == 0) { - /* If we don't already know whether FILENAME is a directory, - find out now. Then, if it's a non-directory, we can use - unlink on it. */ - - if (dirent_type == DT_UNKNOWN) + if (x->verbose) { - if (fstatat (fd_cwd, filename, st, AT_SYMLINK_NOFOLLOW)) - { - if (ignorable_missing (x, errno)) - return RM_OK; + printf ((is_dir + ? _("removed directory: %s\n") + : _("removed %s\n")), quote (ent->fts_path)); + } + return RM_OK; + } - error (0, errno, _("cannot remove %s"), - quote (full_filename (filename))); + /* The unlinkat from kernels like linux-2.6.32 reports EROFS even for + nonexistent files. When the file is indeed missing, map that to ENOENT, + so that rm -f ignores it, as required. Even without -f, this is useful + because it makes rm print the more precise diagnostic. */ + if (errno == EROFS) + { + struct stat st; + if ( ! (lstatat (fts->fts_cwd_fd, ent->fts_accpath, &st) + && errno == ENOENT)) + errno = EROFS; + } + + if (ignorable_missing (x, errno)) + return RM_OK; + + /* When failing to rmdir an unreadable directory, the typical + errno value is EISDIR, but that is not as useful to the user + as the errno value from the failed open (probably EPERM). + Use the earlier, more descriptive errno value. */ + if (ent->fts_info == FTS_DNR) + errno = ent->fts_errno; + error (0, errno, _("cannot remove %s"), quote (ent->fts_path)); + mark_ancestor_dirs (ent); + return RM_ERROR; +} + +/* This function is called once for every file system object that fts + encounters. fts performs a depth-first traversal. + A directory is usually processed twice, first with fts_info == FTS_D, + and later, after all of its entries have been processed, with FTS_DP. + Return RM_ERROR upon error, RM_USER_DECLINED for a negative response + to an interactive prompt, and otherwise, RM_OK. */ +static enum RM_status +rm_fts (FTS *fts, FTSENT *ent, struct rm_options const *x) +{ + switch (ent->fts_info) + { + case FTS_D: /* preorder directory */ + if (! x->recursive) + { + /* This is the first (pre-order) encounter with a directory. + Not recursive, so arrange to skip contents. */ + error (0, EISDIR, _("cannot remove %s"), quote (ent->fts_path)); + mark_ancestor_dirs (ent); + fts_skip_tree (fts, ent); + return RM_ERROR; + } + + /* Perform checks that can apply only for command-line arguments. */ + if (ent->fts_level == FTS_ROOTLEVEL) + { + if (strip_trailing_slashes (ent->fts_path)) + ent->fts_pathlen = strlen (ent->fts_path); + + /* If the basename of a command line argument is "." or "..", + diagnose it and do nothing more with that argument. */ + if (dot_or_dotdot (last_component (ent->fts_accpath))) + { + error (0, 0, _("cannot remove directory: %s"), + quote (ent->fts_path)); + fts_skip_tree (fts, ent); return RM_ERROR; } - if (S_ISDIR (st->st_mode)) - dirent_type = DT_DIR; + /* If a command line argument resolves to "/" (and --preserve-root + is in effect -- default) diagnose and skip it. */ + if (ROOT_DEV_INO_CHECK (x->root_dev_ino, ent->fts_statp)) + { + ROOT_DEV_INO_WARN (ent->fts_path); + fts_skip_tree (fts, ent); + return RM_ERROR; + } } - if (dirent_type != DT_DIR) + { + Ternary is_empty_directory; + enum RM_status s = prompt (fts, ent, true /*is_dir*/, x, + PA_DESCEND_INTO_DIR, &is_empty_directory); + + if (s == RM_OK && is_empty_directory == T_YES) + { + /* When we know (from prompt when in interactive mode) + that this is an empty directory, don't prompt twice. */ + s = excise (fts, ent, x, true); + fts_skip_tree (fts, ent); + } + + if (s != RM_OK) + { + mark_ancestor_dirs (ent); + fts_skip_tree (fts, ent); + } + + return s; + } + + case FTS_F: /* regular file */ + case FTS_NS: /* stat(2) failed */ + case FTS_SL: /* symbolic link */ + case FTS_SLNONE: /* symbolic link without target */ + case FTS_DP: /* postorder directory */ + case FTS_DNR: /* unreadable directory */ + case FTS_NSOK: /* e.g., dangling symlink */ + case FTS_DEFAULT: /* none of the above */ + { + /* With --one-file-system, do not attempt to remove a mount point. + fts' FTS_XDEV ensures that we don't process any entries under + the mount point. */ + if (ent->fts_info == FTS_DP + && x->one_file_system + && FTS_ROOTLEVEL < ent->fts_level + && ent->fts_statp->st_dev != fts->fts_dev) + { + mark_ancestor_dirs (ent); + error (0, 0, _("skipping %s, since it's on a different device"), + quote (ent->fts_path)); + return RM_ERROR; + } + { - /* At this point, barring race conditions, FILENAME is known - to be a non-directory, so it's ok to try to unlink it. */ - DO_UNLINK (fd_cwd, filename, x); - - /* unlink failed with some other error code. report it. */ - error (0, errno, _("cannot remove %s"), - quote (full_filename (filename))); - return RM_ERROR; + bool is_dir = ent->fts_info == FTS_DP || ent->fts_info == FTS_DNR; + enum RM_status s = prompt (fts, ent, is_dir, x, PA_REMOVE_DIR, NULL); + if (s != RM_OK) + return s; + return excise (fts, ent, x, is_dir); } + } - if (! x->recursive) - { - error (0, EISDIR, _("cannot remove %s"), - quote (full_filename (filename))); - return RM_ERROR; - } + case FTS_DC: /* directory that causes cycles */ + emit_cycle_warning (ent->fts_path); + fts_skip_tree (fts, ent); + return RM_ERROR; - if (is_empty_directory == T_YES) - { - DO_RMDIR (fd_cwd, filename, x); - /* Don't diagnose any failure here. - It'll be detected when the caller tries another way. */ - } - } - - return RM_NONEMPTY_DIR; -} - -/* Given FD_CWD, the file descriptor for an open directory, - open its subdirectory F (F is already `known' to be a directory, - so if it is no longer one, someone is playing games), return a DIR* - pointer for F, and put F's `stat' data in *SUBDIR_SB. - Upon failure give a diagnostic and return NULL. - If PREV_ERRNO is nonzero, it is the errno value from a preceding failed - unlink- or rmdir-like system call -- use that value instead of ENOTDIR - if an opened file turns out not to be a directory. This is important - when the preceding non-dir-unlink failed due to e.g., EPERM or EACCES. - The caller must use a nonnnull CWD_ERRNO the first - time this function is called for each command-line-specified directory. - If CWD_ERRNO is not null, set *CWD_ERRNO to the appropriate error number - if this function fails to restore the initial working directory. - If it is null, report an error and exit if the working directory - isn't restored. */ -static DIR * -fd_to_subdirp (int fd_cwd, char const *f, - int prev_errno, - struct stat *subdir_sb, - int *cwd_errno ATTRIBUTE_UNUSED) -{ - int open_flags = O_RDONLY | O_NOCTTY | O_NOFOLLOW | O_NONBLOCK; - int fd_sub = openat_permissive (fd_cwd, f, open_flags, 0, cwd_errno); - int saved_errno; - - /* Record dev/ino of F. We may compare them against saved values - to thwart any attempt to subvert the traversal. They are also used - to detect directory cycles. */ - if (fd_sub < 0) - return NULL; - else if (fstat (fd_sub, subdir_sb) != 0) - saved_errno = errno; - else if (S_ISDIR (subdir_sb->st_mode)) - { - DIR *subdir_dirp = fdopendir (fd_sub); - if (subdir_dirp) - return subdir_dirp; - saved_errno = errno; - } - else - saved_errno = (prev_errno ? prev_errno : ENOTDIR); - - close (fd_sub); - errno = saved_errno; - return NULL; -} - -struct readdir_data -{ - ino_t ino; - char name[FLEXIBLE_ARRAY_MEMBER]; -}; - -#if HAVE_STRUCT_DIRENT_D_TYPE -/* A comparison function to sort on increasing inode number. */ -static int -compare_ino (void const *av, void const *bv) -{ - struct readdir_data const *const *a = av; - struct readdir_data const *const *b = bv; - return (a[0]->ino < b[0]->ino ? -1 - : b[0]->ino < a[0]->ino ? 1 : 0); -} - -/* Return an approximation of the maximum number of dirent entries - in a directory with stat data *ST. */ -static size_t -dirent_count (struct stat const *st) -{ - return st->st_size / 16; -} - -#if defined __linux__ \ - && HAVE_SYS_VFS_H && HAVE_FSTATFS && HAVE_STRUCT_STATFS_F_TYPE -# include -# include "fs.h" - -/* Return false if it is easy to determine the file system type of - the directory on which DIR_FD is open, and sorting dirents on - inode numbers is known not to improve traversal performance with - that type of file system. Otherwise, return true. */ -static bool -dirent_inode_sort_may_be_useful (int dir_fd) -{ - /* Skip the sort only if we can determine efficiently - that skipping it is the right thing to do. - The cost of performing an unnecessary sort is negligible, - while the cost of *not* performing it can be O(N^2) with - a very large constant. */ - struct statfs fs_buf; - - /* If fstatfs fails, assume sorting would be useful. */ - if (fstatfs (dir_fd, &fs_buf) != 0) - return true; - - /* FIXME: what about when f_type is not an integral type? - deal with that if/when it's encountered. */ - switch (fs_buf.f_type) - { - case S_MAGIC_TMPFS: - case S_MAGIC_NFS: - /* On a file system of any of these types, sorting - is unnecessary, and hence wasteful. */ - return false; + case FTS_ERR: + /* Various failures, from opendir to ENOMEM, to failure to "return" + to preceding directory, can provoke this. */ + error (0, ent->fts_errno, _("traversal failed: %s"), + quote (ent->fts_path)); + fts_skip_tree (fts, ent); + return RM_ERROR; default: - return true; + error (0, 0, _("unexpected failure: fts_info=%d: %s\n" + "please report to %s"), + ent->fts_info, + quote (ent->fts_path), + PACKAGE_BUGREPORT); + abort (); } } -# else /* !HAVE_STRUCT_STATFS_F_TYPE */ -static bool dirent_inode_sort_may_be_useful (int dir_fd ATTRIBUTE_UNUSED) + +/* Remove FILEs, honoring options specified via X. + Return RM_OK if successful. */ +enum RM_status +rm (char *const *file, struct rm_options const *x) { - return true; -} -# endif /* !HAVE_STRUCT_STATFS_F_TYPE */ -#endif /* HAVE_STRUCT_DIRENT_D_TYPE */ + enum RM_status rm_status = RM_OK; -/* When a directory contains very many entries, operating on N entries in - readdir order can be very seek-intensive (be it to unlink or even to - merely stat each entry), to the point that it results in O(N^2) work. - This is file-system-specific: ext3 and ext4 (as of 2008) are susceptible, - but tmpfs is not. The general solution is to process entries in inode - order. That means reading all entries, and sorting them before operating - on any. As such, it is useful only on systems with useful dirent.d_ino. - Since 'rm -r's removal process must traverse into directories and since - this preprocessing phase can allocate O(N) storage, here we store and - sort only non-directory entries, and then remove all of those, so that we - can free all allocated storage before traversing into any subdirectory. - Perform this optimization only when not interactive and not in verbose - mode, to keep the implementation simple and to minimize duplication. - Upon failure, simply free any resources and return. */ -static void -preprocess_dir (DIR **dirp, struct rm_options const *x) -{ -#if HAVE_STRUCT_DIRENT_D_TYPE - - struct stat st; - /* There are many reasons to return right away, skipping this - optimization. The penalty for being wrong is that we will - perform a small amount of extra work. - - Skip this optimization if... */ - - int dir_fd = dirfd (*dirp); - if (/* - there is a chance of interactivity */ - x->interactive != RMI_NEVER - - /* - we're in verbose mode */ - || x->verbose - - /* - privileged users can unlink nonempty directories. - Otherwise, there'd be a race condition between the readdir - call (in which we learn dirent.d_type) and the unlink, by - which time the non-directory may be replaced with a directory. */ - || ! cannot_unlink_dir () - - /* - we can't fstat the file descriptor */ - || fstat (dir_fd, &st) != 0 - - /* - the directory is smaller than some threshold. - Estimate the number of inodes with a heuristic. - There's no significant benefit to sorting if there are - too few inodes. */ - || dirent_count (&st) < INODE_SORT_DIR_ENTRIES_THRESHOLD - - /* Sort only if it might help. */ - || ! dirent_inode_sort_may_be_useful (dir_fd)) - return; - - /* FIXME: maybe test file system type, too; skip if it's tmpfs: see fts.c */ - - struct obstack o_readdir_data; /* readdir data: inode,name pairs */ - struct obstack o_p; /* an array of pointers to each inode,name pair */ - - /* Arrange to longjmp upon obstack allocation failure. */ - jmp_buf readdir_jumpbuf; - if (setjmp (readdir_jumpbuf)) - goto cleanup; - - obstack_init_minimal (&o_readdir_data); - obstack_init_minimal (&o_p); - - obstack_specify_allocation_with_arg (&o_readdir_data, 0, 0, - rm_malloc, rm_free, &readdir_jumpbuf); - obstack_specify_allocation_with_arg (&o_p, 0, 0, - rm_malloc, rm_free, &readdir_jumpbuf); - - /* Read all entries, storing for each non-dir one. - Maintain a parallel list of pointers into the primary buffer. */ - while (1) + if (*file) { - struct dirent const *dp; - dp = readdir_ignoring_dot_and_dotdot (*dirp); - /* no need to distinguish EOF from failure */ - if (dp == NULL) - break; + int bit_flags = (FTS_CWDFD + | FTS_NOSTAT + | FTS_PHYSICAL); + FTS *fts; - /* Skip known-directory and type-unknown entries. */ - if (D_TYPE (dp) == DT_UNKNOWN || D_TYPE (dp) == DT_DIR) - break; + if (x->one_file_system) + bit_flags |= FTS_XDEV; - size_t name_len = strlen (dp->d_name); - size_t ent_len = offsetof (struct readdir_data, name) + name_len + 1; - struct readdir_data *v = obstack_alloc (&o_readdir_data, ent_len); - v->ino = D_INO (dp); - memcpy (v->name, dp->d_name, name_len + 1); + fts = xfts_open (file, bit_flags, NULL); - /* Append V to the list of pointers. */ - obstack_ptr_grow (&o_p, v); - } - - /* Compute size and finalize VV. */ - size_t n = obstack_object_size (&o_p) / sizeof (void *); - struct readdir_data **vv = obstack_finish (&o_p); - - /* Sort on inode number. */ - qsort(vv, n, sizeof *vv, compare_ino); - - /* Iterate through those pointers, unlinking each name. */ - for (size_t i = 0; i < n; i++) - { - /* ignore failure */ - unlinkat (dir_fd, vv[i]->name, 0); - } - - cleanup: - obstack_free (&o_readdir_data, NULL); - obstack_free (&o_p, NULL); - rewinddir (*dirp); -#endif -} - -/* Remove entries in the directory open on DIRP - Upon finding a directory that is both non-empty and that can be chdir'd - into, return RM_OK and set *SUBDIR and fill in SUBDIR_SB, where - SUBDIR is the malloc'd name of the subdirectory if the chdir succeeded, - NULL otherwise (e.g., if opendir failed or if there was no subdirectory). - Likewise, SUBDIR_SB is the result of calling lstat on SUBDIR. - Return RM_OK if all entries are removed. Return RM_ERROR if any - entry cannot be removed. Otherwise, return RM_USER_DECLINED if - the user declines to remove at least one entry. Remove as much as - possible, continuing even if we fail to remove some entries. */ -static enum RM_status -remove_cwd_entries (DIR **dirp, - Dirstack_state *ds, char **subdir, struct stat *subdir_sb, - struct rm_options const *x) -{ - struct AD_ent *top = AD_stack_top (ds); - enum RM_status status = top->status; - size_t n_unlinked_since_opendir_or_last_rewind = 0; - - assert (VALID_STATUS (status)); - *subdir = NULL; - - /* This is just an optimization. - It's not a fatal problem if it fails. */ - preprocess_dir (dirp, x); - - while (1) - { - struct dirent const *dp; - enum RM_status tmp_status; - const char *f; - - /* Set errno to zero so we can distinguish between a readdir failure - and when readdir simply finds that there are no more entries. */ - errno = 0; - dp = readdir_ignoring_dot_and_dotdot (*dirp); - if (dp == NULL) + while (1) { - if (errno) + FTSENT *ent; + enum RM_status s; + + ent = fts_read (fts); + if (ent == NULL) { - /* fall through */ - } - else if (NEED_REWIND (n_unlinked_since_opendir_or_last_rewind)) - { - /* Call rewinddir if we've called unlink or rmdir so many times - (since the opendir or the previous rewinddir) that this - NULL-return may be the symptom of a buggy readdir. */ - rewinddir (*dirp); - n_unlinked_since_opendir_or_last_rewind = 0; - continue; - } - break; - } - - f = dp->d_name; - - /* Skip files we've already tried/failed to remove. */ - if ( ! AD_is_removable (ds, f)) - continue; - - /* Pass dp->d_type info to remove_entry so the non-glibc - case can decide whether to use unlink or chdir. - Systems without the d_type member will have to endure - the performance hit of first calling lstat F. */ - cache_stat_init (subdir_sb); - tmp_status = remove_entry (dirfd (*dirp), ds, f, - D_TYPE (dp), subdir_sb, x); - switch (tmp_status) - { - case RM_OK: - /* Count how many files we've unlinked since the initial - opendir or the last rewinddir. On buggy systems, if you - remove too many, readdir returns NULL even though there - remain unprocessed directory entries. */ - ++n_unlinked_since_opendir_or_last_rewind; - break; - - case RM_ERROR: - case RM_USER_DECLINED: - AD_mark_as_unremovable (ds, f); - UPDATE_STATUS (status, tmp_status); - break; - - case RM_NONEMPTY_DIR: - { - DIR *subdir_dirp = fd_to_subdirp (dirfd (*dirp), f, - errno, subdir_sb, NULL); - if (subdir_dirp == NULL) - { - status = RM_ERROR; - - /* CAUTION: this test and diagnostic are identical to - those following the other use of fd_to_subdirp. */ - if (ignorable_missing (x, errno)) - { - /* With -f, don't report "file not found". */ - } - else - { - /* Upon fd_to_subdirp failure, try to remove F directly, - in case it's just an empty directory. */ - int saved_errno = errno; - if (unlinkat (dirfd (*dirp), f, AT_REMOVEDIR) == 0) - status = RM_OK; - else - error (0, saved_errno, - _("cannot remove %s"), quote (full_filename (f))); - } - - if (status == RM_ERROR) - AD_mark_as_unremovable (ds, f); - break; - } - - *subdir = xstrdup (f); - if (closedir (*dirp) != 0) - { - error (0, 0, _("failed to close directory %s"), - quote (full_filename ("."))); - status = RM_ERROR; - } - *dirp = subdir_dirp; - - break; - } - } - - /* Record status for this directory. */ - UPDATE_STATUS (top->status, status); - - if (*subdir) - break; - } - - /* Ensure that *dirp is not NULL and that its file descriptor is valid. */ - assert (*dirp != NULL); - assert (0 <= fcntl (dirfd (*dirp), F_GETFD)); - - return status; -} - -/* Do this after each call to AD_push or AD_push_initial. - Because the status = RM_OK bit is too remove-specific to - go into the general-purpose AD_* package. */ -#define AD_INIT_OTHER_MEMBERS() \ - do \ - { \ - AD_stack_top(ds)->status = RM_OK; \ - } \ - while (0) - -/* Remove the hierarchy rooted at DIR. - Do that by changing into DIR, then removing its contents, then - returning to the original working directory and removing DIR itself. - Don't use recursion. Be careful when using chdir ".." that we - return to the same directory from which we came, if necessary. - Return an RM_status value to indicate success or failure. */ - -static enum RM_status -remove_dir (int fd_cwd, Dirstack_state *ds, char const *dir, - struct stat *dir_st, - struct rm_options const *x, int *cwd_errno) -{ - enum RM_status status; - dev_t current_dev = dir_st->st_dev; - - /* There is a race condition in that an attacker could replace the nonempty - directory, DIR, with a symlink between the preceding call to rmdir - (unlinkat, in our caller) and fd_to_subdirp's openat call. But on most - systems, even those without openat, this isn't a problem, since we ensure - that opening a symlink will fail, when that is possible. Otherwise, - fd_to_subdirp's fstat, along with the `fstat' and the dev/ino - comparison in AD_push ensure that we detect it and fail. */ - - DIR *dirp = fd_to_subdirp (fd_cwd, dir, 0, dir_st, cwd_errno); - - if (dirp == NULL) - { - /* CAUTION: this test and diagnostic are identical to - those following the other use of fd_to_subdirp. */ - if (ignorable_missing (x, errno)) - { - /* With -f, don't report "file not found". */ - } - else - { - /* Upon fd_to_subdirp failure, try to remove DIR directly, - in case it's just an empty directory. */ - int saved_errno = errno; - if (unlinkat (fd_cwd, dir, AT_REMOVEDIR) == 0) - return RM_OK; - - error (0, saved_errno, - _("cannot remove %s"), quote (full_filename (dir))); - } - - return RM_ERROR; - } - - if (ROOT_DEV_INO_CHECK (x->root_dev_ino, dir_st)) - { - ROOT_DEV_INO_WARN (full_filename (dir)); - status = RM_ERROR; - goto closedir_and_return; - } - - AD_push (dirfd (dirp), ds, dir, dir_st); - AD_INIT_OTHER_MEMBERS (); - - status = RM_OK; - - while (1) - { - char *subdir = NULL; - struct stat subdir_sb; - enum RM_status tmp_status; - - tmp_status = remove_cwd_entries (&dirp, ds, &subdir, &subdir_sb, x); - - if (tmp_status != RM_OK) - { - UPDATE_STATUS (status, tmp_status); - AD_mark_current_as_unremovable (ds); - } - if (subdir) - { - if ( ! x->one_file_system - || subdir_sb.st_dev == current_dev) - { - AD_push (dirfd (dirp), ds, subdir, &subdir_sb); - AD_INIT_OTHER_MEMBERS (); - free (subdir); - continue; + if (errno != 0) + { + error (0, errno, _("fts_read failed")); + rm_status = RM_ERROR; + } + break; } - /* Here, --one-file-system is in effect, and with remove_cwd_entries' - traversal into the current directory, (known as SUBDIR, from ..), - DIRP's device number is different from CURRENT_DEV. Arrange not - to do anything more with this hierarchy. */ - error (0, 0, _("skipping %s, since it's on a different device"), - quote (full_filename (subdir))); - free (subdir); - AD_mark_current_as_unremovable (ds); - tmp_status = RM_ERROR; - UPDATE_STATUS (status, tmp_status); - } + s = rm_fts (fts, ent, x); - /* Execution reaches this point when we've removed the last - removable entry from the current directory -- or, with - --one-file-system, when the current directory is on a - different file system. */ - { - int fd; - /* The name of the directory that we have just processed, - nominally removing all of its contents. */ - char *empty_dir = AD_pop_and_chdir (dirp, &fd, ds); - dirp = NULL; - assert (fd != AT_FDCWD || AD_stack_height (ds) == 1); - - /* Try to remove EMPTY_DIR only if remove_cwd_entries succeeded. */ - if (tmp_status == RM_OK) - { - struct stat empty_st; - Ternary is_empty; - int dirent_type = DT_DIR; - enum RM_status s = prompt (fd, ds, empty_dir, &dirent_type, - cache_stat_init (&empty_st), x, - PA_REMOVE_DIR, &is_empty); - - if (s != RM_OK) - { - free (empty_dir); - status = s; - if (fd != AT_FDCWD) - close (fd); - goto closedir_and_return; - } - - if (unlinkat (fd, empty_dir, AT_REMOVEDIR) == 0) - { - if (x->verbose) - printf (_("removed directory: %s\n"), - quote (full_filename (empty_dir))); - } - else - { - error (0, errno, _("cannot remove directory %s"), - quote (full_filename (empty_dir))); - AD_mark_as_unremovable (ds, empty_dir); - status = RM_ERROR; - UPDATE_STATUS (AD_stack_top(ds)->status, status); - } - } - - free (empty_dir); - - if (fd == AT_FDCWD) - break; - - dirp = fdopendir (fd); - if (dirp == NULL) - { - error (0, errno, _("FATAL: cannot return to .. from %s"), - quote (full_filename ("."))); - close (fd); - longjmp (ds->current_arg_jumpbuf, 1); - } - } - } - - /* If the first/final hash table of unremovable entries was used, - free it here. */ - AD_stack_pop (ds); - - closedir_and_return:; - if (dirp != NULL && closedir (dirp) != 0) - { - error (0, 0, _("failed to close directory %s"), - quote (full_filename ("."))); - status = RM_ERROR; - } - - return status; -} - -/* Remove the file or directory specified by FILENAME. - Return RM_OK if it is removed, and RM_ERROR or RM_USER_DECLINED if not. */ - -static enum RM_status -rm_1 (Dirstack_state *ds, char const *filename, - struct rm_options const *x, int *cwd_errno) -{ - char const *base = last_component (filename); - if (dot_or_dotdot (base)) - { - error (0, 0, _(base == filename - ? N_("cannot remove directory %s") - : N_("cannot remove %s directory %s")), - quote_n (0, base), quote_n (1, filename)); - return RM_ERROR; - } - - { - struct stat st; - cache_stat_init (&st); - cycle_check_init (&ds->cycle_check_state); - if (x->root_dev_ino) - { - if (cache_fstatat (AT_FDCWD, filename, &st, AT_SYMLINK_NOFOLLOW) != 0) - { - if (ignorable_missing (x, errno)) - return RM_OK; - error (0, errno, _("cannot remove %s"), quote (filename)); - return RM_ERROR; - } - if (SAME_INODE (st, *(x->root_dev_ino))) - { - error (0, 0, _("cannot remove root directory %s"), quote (filename)); - return RM_ERROR; - } - } - - AD_push_initial (ds); - AD_INIT_OTHER_MEMBERS (); - - { - enum RM_status status = remove_entry (AT_FDCWD, ds, filename, - DT_UNKNOWN, &st, x); - if (status == RM_NONEMPTY_DIR) - { - /* In the event that remove_dir->remove_cwd_entries detects - a directory cycle, arrange to fail, give up on this FILE, but - continue on with any other arguments. */ - if (setjmp (ds->current_arg_jumpbuf)) - status = RM_ERROR; - else - status = remove_dir (AT_FDCWD, ds, filename, &st, x, cwd_errno); - - AD_stack_clear (ds); - } - - ds_clear (ds); - return status; -} - } -} - -/* Remove all files and/or directories specified by N_FILES and FILE. - Apply the options in X. */ -extern enum RM_status -rm (size_t n_files, char const *const *file, struct rm_options const *x) -{ - enum RM_status status = RM_OK; - Dirstack_state ds; - int cwd_errno = 0; - size_t i; - - /* Arrange for obstack allocation failure to longjmp. */ - if (setjmp (ds.current_arg_jumpbuf)) - { - status = RM_ERROR; - goto cleanup; - } - - ds_init (&ds); - - for (i = 0; i < n_files; i++) - { - if (cwd_errno && IS_RELATIVE_FILE_NAME (file[i])) - { - error (0, 0, _("cannot remove relative-named %s"), quote (file[i])); - status = RM_ERROR; - } - else - { - enum RM_status s = rm_1 (&ds, file[i], x, &cwd_errno); assert (VALID_STATUS (s)); - UPDATE_STATUS (status, s); + UPDATE_STATUS (rm_status, s); + } + + if (fts_close (fts) != 0) + { + error (0, errno, _("fts_close failed")); + rm_status = RM_ERROR; } } - if (x->require_restore_cwd && cwd_errno) - { - error (0, cwd_errno, - _("cannot restore current working directory")); - status = RM_ERROR; - } - - cleanup:; - ds_free (&ds); - - return status; + return rm_status; } diff --git a/src/bin/coreutils/src/remove.h b/src/bin/coreutils/src/remove.h index ed1a0214e4..f860cb45c6 100644 --- a/src/bin/coreutils/src/remove.h +++ b/src/bin/coreutils/src/remove.h @@ -1,6 +1,6 @@ /* Remove directory entries. - Copyright (C) 1998, 2000, 2002, 2003-2009 Free Software Foundation, Inc. + Copyright (C) 1998, 2000, 2002-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,6 +37,7 @@ struct rm_options /* If true, query the user about whether to remove each file. */ enum rm_interactive interactive; + // FIXME: remove /* If true, do not traverse into (or remove) any directory that is on a file system (i.e., that has a different device number) other than that of the corresponding command line argument. Note that @@ -88,7 +89,6 @@ enum RM_status } \ while (0) -enum RM_status rm (size_t n_files, char const *const *file, - struct rm_options const *x); +extern enum RM_status rm (char *const *file, struct rm_options const *x); #endif diff --git a/src/bin/coreutils/src/rm.c b/src/bin/coreutils/src/rm.c index 191d2c89eb..766ad2476e 100644 --- a/src/bin/coreutils/src/rm.c +++ b/src/bin/coreutils/src/rm.c @@ -1,5 +1,5 @@ /* `rm' file deletion utility for GNU. - Copyright (C) 88, 90, 91, 1994-2009 Free Software Foundation, Inc. + Copyright (C) 1988, 1990-1991, 1994-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -14,32 +14,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -/* Written by Paul Rubin, David MacKenzie, and Richard Stallman. - Reworked to use chdir and avoid recursion by Jim Meyering. */ - -/* Implementation overview: - - In the `usual' case, RM saves no state for directories it is processing. - When a removal fails (either due to an error or to an interactive `no' - reply), the failure is noted (see description of `ht' in remove.c's - remove_cwd_entries function) so that when/if the containing directory - is reopened, RM doesn't try to remove the entry again. - - RM may delete arbitrarily deep hierarchies -- even ones in which file - names (from root to leaf) are longer than the system-imposed maximum. - It does this by using chdir to change to each directory in turn before - removing the entries in that directory. - - RM detects directory cycles lazily. See lib/cycle-check.c. - - RM is careful to avoid forming full file names whenever possible. - A full file name is formed only when it is about to be used -- e.g. - in a diagnostic or in an interactive-mode prompt. - - RM minimizes the number of lstat system calls it makes. On systems - that have valid d_type data in directory entries, RM makes only one - lstat call per command line argument -- regardless of the depth of - the hierarchy. */ +/* Initially written by Paul Rubin, David MacKenzie, and Richard Stallman. + Reworked to use chdir and avoid recursion, and later, rewritten + once again, to use fts, by Jim Meyering. */ #include #include @@ -203,7 +180,7 @@ Note that if you use rm to remove a file, it is usually possible to recover\n\ the contents of that file. If you want more assurance that the contents are\n\ truly unrecoverable, consider using shred.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -348,7 +325,7 @@ main (int argc, char **argv) } } - if (x.recursive & preserve_root) + if (x.recursive && preserve_root) { static struct dev_ino dev_ino_buf; x.root_dev_ino = get_root_dev_ino (&dev_ino_buf); @@ -356,10 +333,9 @@ main (int argc, char **argv) error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), quote ("/")); } - { size_t n_files = argc - optind; - char const *const *file = (char const *const *) argv + optind; + char **file = argv + optind; if (prompt_once && (x.recursive || 3 < n_files)) { @@ -371,8 +347,9 @@ main (int argc, char **argv) if (!yesno ()) exit (EXIT_SUCCESS); } + { - enum RM_status status = rm (n_files, file, &x); + enum RM_status status = rm (file, &x); assert (VALID_STATUS (status)); exit (status == RM_ERROR ? EXIT_FAILURE : EXIT_SUCCESS); } diff --git a/src/bin/coreutils/src/rmdir.c b/src/bin/coreutils/src/rmdir.c index 3bfff22d45..90a80a602a 100644 --- a/src/bin/coreutils/src/rmdir.c +++ b/src/bin/coreutils/src/rmdir.c @@ -1,6 +1,6 @@ /* rmdir -- remove directories - Copyright (C) 90, 91, 1995-2002, 2004-2009 Free Software Foundation, Inc. + Copyright (C) 1990-1991, 1995-2002, 2004-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -74,7 +74,7 @@ static struct option const longopts[] = static bool errno_rmdir_non_empty (int error_number) { - return (error_number == RMDIR_ERRNO_NOT_EMPTY); + return error_number == ENOTEMPTY || error_number == EEXIST; } /* Return true if when rmdir fails with errno == ERROR_NUMBER @@ -177,7 +177,7 @@ Remove the DIRECTORY(ies), if they are empty.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/runcon.c b/src/bin/coreutils/src/runcon.c index 7bf256821d..3b25da3dfd 100644 --- a/src/bin/coreutils/src/runcon.c +++ b/src/bin/coreutils/src/runcon.c @@ -1,5 +1,5 @@ /* runcon -- run command with specified security context - Copyright (C) 2005-2009 Free Software Foundation, Inc. + Copyright (C) 2005-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -99,7 +99,7 @@ With neither CONTEXT nor COMMAND, print the current security context.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -182,7 +182,7 @@ main (int argc, char **argv) if (optind >= argc) { error (0, 0, _("you must specify -c, -t, -u, -l, -r, or context")); - usage (1); + usage (EXIT_FAILURE); } context = argv[optind++]; } @@ -190,12 +190,12 @@ main (int argc, char **argv) if (optind >= argc) { error (0, 0, _("no command specified")); - usage (1); + usage (EXIT_FAILURE); } if (is_selinux_enabled () != 1) error (EXIT_FAILURE, 0, - _("runcon may be used only on a SELinux kernel")); + _("%s may be used only on a SELinux kernel"), program_name); if (context) { diff --git a/src/bin/coreutils/src/seq.c b/src/bin/coreutils/src/seq.c index e47de58133..4191fe5200 100644 --- a/src/bin/coreutils/src/seq.c +++ b/src/bin/coreutils/src/seq.c @@ -1,5 +1,5 @@ /* seq - print sequence of numbers to standard output. - Copyright (C) 1994-2009 Free Software Foundation, Inc. + Copyright (C) 1994-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -94,7 +94,7 @@ FORMAT must be suitable for printing one argument of type `double';\n\ it defaults to %.PRECf if FIRST, INCREMENT, and LAST are all fixed point\n\ decimal numbers with maximum precision PREC, and to %g otherwise.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -148,6 +148,7 @@ scan_arg (const char *arg) if (! arg[strcspn (arg, "xX")] && isfinite (ret.value)) { + char const *e; char const *decimal_point = strchr (arg, '.'); if (! decimal_point) ret.precision = 0; @@ -161,8 +162,7 @@ scan_arg (const char *arg) : (decimal_point == arg /* .# -> 0.# */ || ! ISDIGIT (decimal_point[-1]))); /* -.# -> 0.# */ } - { - char const *e = strchr (arg, 'e'); + e = strchr (arg, 'e'); if (! e) e = strchr (arg, 'E'); if (e) @@ -170,7 +170,6 @@ scan_arg (const char *arg) long exponent = strtol (e + 1, NULL, 10); ret.precision += exponent < 0 ? -exponent : 0; } - } } return ret; @@ -317,19 +316,18 @@ get_default_format (operand first, operand step, operand last) size_t first_width = first.width + (prec - first.precision); /* adjust last_width to use precision from first/step */ size_t last_width = last.width + (prec - last.precision); + size_t width; if (last.precision && prec == 0) last_width--; /* don't include space for '.' */ if (last.precision == 0 && prec) last_width++; /* include space for '.' */ - { - size_t width = MAX (first_width, last_width); + width = MAX (first_width, last_width); if (width <= INT_MAX) { int w = width; sprintf (format_buf, "%%0%d.%dLf", w, prec); return format_buf; } - } } else { diff --git a/src/bin/coreutils/src/setuidgid.c b/src/bin/coreutils/src/setuidgid.c index 43aa16480f..4881b46d70 100644 --- a/src/bin/coreutils/src/setuidgid.c +++ b/src/bin/coreutils/src/setuidgid.c @@ -1,5 +1,5 @@ /* setuidgid - run a command with the UID and GID of a specified user - Copyright (C) 2003-2009 Free Software Foundation, Inc. + Copyright (C) 2003-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -67,7 +67,7 @@ This program is useful only when run by root (user ID zero).\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -110,7 +110,7 @@ main (int argc, char **argv) error (EXIT_FAILURE, 0, _("invalid group %s"), quote (gr)); if (n_gids == n_gids_allocated) - gids = x2nrealloc (gids, &n_gids_allocated, sizeof *gids); + gids = X2NREALLOC (gids, &n_gids_allocated); gids[n_gids++] = tmp_ul; if (*ptr == '\0') @@ -179,9 +179,9 @@ main (int argc, char **argv) #if HAVE_SETGROUPS if (n_gids == 0) { - int n = mgetgroups (pwd->pw_name, pwd->pw_gid, &gids); + int n = xgetgroups (pwd->pw_name, pwd->pw_gid, &gids); if (n <= 0) - error (1, errno, _("failed to get groups for user %s"), + error (EXIT_FAILURE, errno, _("failed to get groups for user %s"), quote (pwd->pw_name)); n_gids = n; } diff --git a/src/bin/coreutils/src/shred.c b/src/bin/coreutils/src/shred.c index ea0d25cd76..26298c154a 100644 --- a/src/bin/coreutils/src/shred.c +++ b/src/bin/coreutils/src/shred.c @@ -1,6 +1,6 @@ /* shred.c - overwrite files and devices to make it harder to recover data - Copyright (C) 1999-2009 Free Software Foundation, Inc. + Copyright (C) 1999-2010 Free Software Foundation, Inc. Copyright (C) 1997, 1998, 1999 Colin Plumb. This program is free software: you can redistribute it and/or modify @@ -229,7 +229,7 @@ In addition, file system backups and remote mirrors may contain copies\n\ of the file that cannot be removed, and that will allow a shredded file\n\ to be recovered later.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/shuf.c b/src/bin/coreutils/src/shuf.c index 0e61e32dd6..4f4ca1c782 100644 --- a/src/bin/coreutils/src/shuf.c +++ b/src/bin/coreutils/src/shuf.c @@ -1,6 +1,6 @@ /* Shuffle lines of text. - Copyright (C) 2006, 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2006-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,7 +19,6 @@ #include -#include #include #include "system.h" @@ -29,6 +28,7 @@ #include "quotearg.h" #include "randint.h" #include "randperm.h" +#include "stdio--.h" #include "xstrtol.h" /* The official name of this program (e.g., no `g' prefix). */ @@ -71,7 +71,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ \n\ With no FILE, or when FILE is -, read standard input.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); diff --git a/src/bin/coreutils/src/sleep.c b/src/bin/coreutils/src/sleep.c index 4c203e6214..699edbd732 100644 --- a/src/bin/coreutils/src/sleep.c +++ b/src/bin/coreutils/src/sleep.c @@ -1,6 +1,6 @@ /* sleep - delay for a specified amount of time. - Copyright (C) 84, 1991-1997, 1999-2005, 2007-2009 - Free Software Foundation, Inc. + Copyright (C) 1984, 1991-1997, 1999-2005, 2007-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -56,7 +56,7 @@ specified by the sum of their values.\n\ program_name, program_name); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/sort.c b/src/bin/coreutils/src/sort.c index 7a8eaaa29a..22958c5557 100644 --- a/src/bin/coreutils/src/sort.c +++ b/src/bin/coreutils/src/sort.c @@ -1,5 +1,5 @@ /* sort - sort lines of text (with all kinds of options). - Copyright (C) 1988, 1991-2009 Free Software Foundation, Inc. + Copyright (C) 1988, 1991-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,6 +30,7 @@ #include "argmatch.h" #include "error.h" #include "filevercmp.h" +#include "hard-locale.h" #include "hash.h" #include "md5.h" #include "physmem.h" @@ -43,6 +44,7 @@ #include "strnumcmp.h" #include "xmemcoll.h" #include "xmemxfrm.h" +#include "xnanosleep.h" #include "xstrtol.h" #if HAVE_SYS_RESOURCE_H @@ -106,13 +108,13 @@ enum /* The number of times we should try to fork a compression process (we retry if the fork call fails). We don't _need_ to compress temp files, this is just to reduce disk access, so this number - can be small. */ - MAX_FORK_TRIES_COMPRESS = 2, + can be small. Each retry doubles in duration. */ + MAX_FORK_TRIES_COMPRESS = 4, /* The number of times we should try to fork a decompression process. If we can't fork a decompression process, we can't sort, so this - number should be big. */ - MAX_FORK_TRIES_DECOMPRESS = 8 + number should be big. Each retry doubles in duration. */ + MAX_FORK_TRIES_DECOMPRESS = 9 }; /* The representation of the decimal point in the current locale. */ @@ -414,7 +416,7 @@ The locale specified by the environment affects sort order.\n\ Set LC_ALL=C to get the traditional sort order that uses\n\ native byte values.\n\ "), stdout ); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); @@ -867,7 +869,7 @@ pipe_fork (int pipefds[2], size_t tries) #if HAVE_WORKING_FORK struct tempnode *saved_temphead; int saved_errno; - unsigned int wait_retry = 1; + double wait_retry = 0.25; pid_t pid IF_LINT (= -1); struct cs_status cs; @@ -894,7 +896,7 @@ pipe_fork (int pipefds[2], size_t tries) break; else { - sleep (wait_retry); + xnanosleep (wait_retry); wait_retry *= 2; reap_some (); } @@ -1473,7 +1475,7 @@ limfield (const struct line *line, const struct keyfield *key) { while (ptr < lim && *ptr != tab) ++ptr; - if (ptr < lim && (eword | echar)) + if (ptr < lim && (eword || echar)) ++ptr; } else @@ -2034,7 +2036,7 @@ keycompare (const struct line *a, const struct line *b) if (key->random) diff = compare_random (texta, lena, textb, lenb); - else if (key->numeric | key->general_numeric | key->human_numeric) + else if (key->numeric || key->general_numeric || key->human_numeric) { char savea = *lima, saveb = *limb; @@ -2200,7 +2202,7 @@ compare (const struct line *a, const struct line *b) if (keylist) { diff = keycompare (a, b); - if (diff | unique | stable) + if (diff || unique || stable) return diff; } @@ -3260,6 +3262,7 @@ main (int argc, char **argv) } #endif } + signal (SIGCHLD, SIG_DFL); /* Don't inherit CHLD handling from parent. */ /* The signal mask is known, so it is safe to invoke exit_cleanup. */ atexit (exit_cleanup); @@ -3306,7 +3309,7 @@ main (int argc, char **argv) { bool minus_pos_usage = (optind != argc && argv[optind][0] == '-' && ISDIGIT (argv[optind][1])); - obsolete_usage |= minus_pos_usage & ~posixly_correct; + obsolete_usage |= minus_pos_usage && !posixly_correct; if (obsolete_usage) { /* Treat +POS1 [-POS2] as a key if possible; but silently @@ -3315,7 +3318,7 @@ main (int argc, char **argv) s = parse_field_count (optarg + 1, &key->sword, NULL); if (s && *s == '.') s = parse_field_count (s + 1, &key->schar, NULL); - if (! (key->sword | key->schar)) + if (! (key->sword || key->schar)) key->sword = SIZE_MAX; if (! s || *set_ordering (s, key, bl_start)) key = NULL; @@ -3406,7 +3409,7 @@ main (int argc, char **argv) badfieldspec (optarg, N_("character offset is zero")); } } - if (! (key->sword | key->schar)) + if (! (key->sword || key->schar)) key->sword = SIZE_MAX; s = set_ordering (s, key, bl_start); if (*s != ',') @@ -3595,14 +3598,14 @@ main (int argc, char **argv) if (! (key->ignore || key->translate || (key->skipsblanks - | key->reverse - | key->skipeblanks - | key->month - | key->numeric - | key->version - | key->general_numeric - | key->human_numeric - | key->random))) + || key->reverse + || key->skipeblanks + || key->month + || key->numeric + || key->version + || key->general_numeric + || key->human_numeric + || key->random))) { key->ignore = gkey.ignore; key->translate = gkey.translate; @@ -3623,13 +3626,13 @@ main (int argc, char **argv) if (!keylist && (gkey.ignore || gkey.translate || (gkey.skipsblanks - | gkey.skipeblanks - | gkey.month - | gkey.numeric - | gkey.general_numeric - | gkey.human_numeric - | gkey.random - | gkey.version))) + || gkey.skipeblanks + || gkey.month + || gkey.numeric + || gkey.general_numeric + || gkey.human_numeric + || gkey.random + || gkey.version))) { insertkey (&gkey); need_random |= gkey.random; diff --git a/src/bin/coreutils/src/split.c b/src/bin/coreutils/src/split.c index e02f7433a4..5bd9ebb4b0 100644 --- a/src/bin/coreutils/src/split.c +++ b/src/bin/coreutils/src/split.c @@ -1,5 +1,5 @@ /* split.c -- split a file into pieces. - Copyright (C) 1988, 1991, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1988, 1991, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -127,7 +127,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); emit_size_note (); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/stat.c b/src/bin/coreutils/src/stat.c index 3302270279..50aaac4e88 100644 --- a/src/bin/coreutils/src/stat.c +++ b/src/bin/coreutils/src/stat.c @@ -1,5 +1,5 @@ /* stat.c -- display file or file system status - Copyright (C) 2001-2009 Free Software Foundation, Inc. + Copyright (C) 2001-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -208,7 +208,8 @@ human_fstype (STRUCT_STATVFS const *statfsbuf) diff -u sym_stat sym_libc */ - /* Also sync from the list in "man 2 statfs". */ + /* Also compare with the list in "man 2 statfs" using the + fs-magic-compare make target. */ /* IMPORTANT NOTE: Each of the following `case S_MAGIC_...:' statements must be followed by a hexadecimal constant in @@ -219,25 +220,39 @@ human_fstype (STRUCT_STATVFS const *statfsbuf) return "adfs"; case S_MAGIC_AFFS: /* 0xADFF */ return "affs"; - case S_MAGIC_AUTOFS: /* 0x187 */ + case S_MAGIC_AFS: /* 0x5346414F */ + return "afs"; + case S_MAGIC_ANON_INODE_FS: /* 0x09041934 */ + return "anon-inode FS"; + case S_MAGIC_AUTOFS: /* 0x0187 */ return "autofs"; case S_MAGIC_BEFS: /* 0x42465331 */ return "befs"; case S_MAGIC_BFS: /* 0x1BADFACE */ return "bfs"; - case S_MAGIC_BINFMT_MISC: /* 0x42494e4d */ + case S_MAGIC_BINFMT_MISC: /* 0x42494E4D */ return "binfmt_misc"; + case S_MAGIC_BTRFS: /* 0x9123683E */ + return "btrfs"; + case S_MAGIC_CGROUP: /* 0x0027E0EB */ + return "cgroupfs"; + case S_MAGIC_CIFS: /* 0xFF534D42 */ + return "cifs"; case S_MAGIC_CODA: /* 0x73757245 */ return "coda"; case S_MAGIC_COH: /* 0x012FF7B7 */ return "coh"; case S_MAGIC_CRAMFS: /* 0x28CD3D45 */ return "cramfs"; + case S_MAGIC_CRAMFS_WEND: /* 0x453DCD28 */ + return "cramfs-wend"; + case S_MAGIC_DEBUGFS: /* 0x64626720 */ + return "debugfs"; case S_MAGIC_DEVFS: /* 0x1373 */ return "devfs"; case S_MAGIC_DEVPTS: /* 0x1CD1 */ return "devpts"; - case S_MAGIC_EFS: /* 0x414A53 */ + case S_MAGIC_EFS: /* 0x00414A53 */ return "efs"; case S_MAGIC_EXT: /* 0x137D */ return "ext"; @@ -247,24 +262,36 @@ human_fstype (STRUCT_STATVFS const *statfsbuf) return "ext2"; case S_MAGIC_FAT: /* 0x4006 */ return "fat"; + case S_MAGIC_FUSEBLK: /* 0x65735546 */ + return "fuseblk"; case S_MAGIC_FUSECTL: /* 0x65735543 */ return "fusectl"; + case S_MAGIC_FUTEXFS: /* 0x0BAD1DEA */ + return "futexfs"; + case S_MAGIC_GFS: /* 0x1161970 */ + return "gfs/gfs2"; + case S_MAGIC_HFS: /* 0x4244 */ + return "hfs"; case S_MAGIC_HPFS: /* 0xF995E849 */ return "hpfs"; - case S_MAGIC_HUGETLBFS: /* 0x958458f6 */ + case S_MAGIC_HUGETLBFS: /* 0x958458F6 */ return "hugetlbfs"; + case S_MAGIC_INOTIFYFS: /* 0x2BAD1DEA */ + return "inotifyfs"; case S_MAGIC_ISOFS: /* 0x9660 */ return "isofs"; case S_MAGIC_ISOFS_R_WIN: /* 0x4004 */ return "isofs"; case S_MAGIC_ISOFS_WIN: /* 0x4000 */ return "isofs"; - case S_MAGIC_JFFS2: /* 0x72B6 */ - return "jffs2"; case S_MAGIC_JFFS: /* 0x07C0 */ return "jffs"; + case S_MAGIC_JFFS2: /* 0x72B6 */ + return "jffs2"; case S_MAGIC_JFS: /* 0x3153464A */ return "jfs"; + case S_MAGIC_KAFS: /* 0x6B414653 */ + return "k-afs"; case S_MAGIC_LUSTRE: /* 0x0BD00BD0 */ return "lustre"; case S_MAGIC_MINIX: /* 0x137F */ @@ -275,6 +302,8 @@ human_fstype (STRUCT_STATVFS const *statfsbuf) return "minix v2"; case S_MAGIC_MINIX_V2_30: /* 0x2478 */ return "minix v2 (30 char.)"; + case S_MAGIC_MINIX_V3: /* 0x4D5A */ + return "minix3"; case S_MAGIC_MSDOS: /* 0x4D44 */ return "msdos"; case S_MAGIC_NCP: /* 0x564C */ @@ -283,10 +312,14 @@ human_fstype (STRUCT_STATVFS const *statfsbuf) return "nfs"; case S_MAGIC_NFSD: /* 0x6E667364 */ return "nfsd"; + case S_MAGIC_NILFS: /* 0x3434 */ + return "nilfs"; case S_MAGIC_NTFS: /* 0x5346544E */ return "ntfs"; - case S_MAGIC_OPENPROM: /* 0x9fa1 */ + case S_MAGIC_OPENPROM: /* 0x9FA1 */ return "openprom"; + case S_MAGIC_OCFS2: /* 0x7461636f */ + return "ocfs2"; case S_MAGIC_PROC: /* 0x9FA0 */ return "proc"; case S_MAGIC_QNX4: /* 0x002F */ @@ -297,8 +330,16 @@ human_fstype (STRUCT_STATVFS const *statfsbuf) return "reiserfs"; case S_MAGIC_ROMFS: /* 0x7275 */ return "romfs"; + case S_MAGIC_RPC_PIPEFS: /* 0x67596969 */ + return "rpc_pipefs"; + case S_MAGIC_SECURITYFS: /* 0x73636673 */ + return "securityfs"; + case S_MAGIC_SELINUX: /* 0xF97CFF8C */ + return "selinux"; case S_MAGIC_SMB: /* 0x517B */ return "smb"; + case S_MAGIC_SOCKFS: /* 0x534F434B */ + return "sockfs"; case S_MAGIC_SQUASHFS: /* 0x73717368 */ return "squashfs"; case S_MAGIC_SYSFS: /* 0x62656572 */ @@ -307,7 +348,7 @@ human_fstype (STRUCT_STATVFS const *statfsbuf) return "sysv2"; case S_MAGIC_SYSV4: /* 0x012FF7B5 */ return "sysv4"; - case S_MAGIC_TMPFS: /* 0x1021994 */ + case S_MAGIC_TMPFS: /* 0x01021994 */ return "tmpfs"; case S_MAGIC_UDF: /* 0x15013346 */ return "udf"; @@ -319,6 +360,8 @@ human_fstype (STRUCT_STATVFS const *statfsbuf) return "usbdevfs"; case S_MAGIC_VXFS: /* 0xA501FCF5 */ return "vxfs"; + case S_MAGIC_XENFS: /* 0xABBA1974 */ + return "xenfs"; case S_MAGIC_XENIX: /* 0x012FF7B4 */ return "xenix"; case S_MAGIC_XFS: /* 0x58465342 */ @@ -693,6 +736,9 @@ print_esc_char (char c) case 'b': /* Backspace. */ c ='\b'; break; + case 'e': /* Escape. */ + c ='\x1B'; + break; case 'f': /* Form feed. */ c ='\f'; break; @@ -829,6 +875,13 @@ do_statfs (char const *filename, bool terse, char const *format) { STRUCT_STATVFS statfsbuf; + if (STREQ (filename, "-")) + { + error (0, 0, _("using %s to denote standard input does not work" + " in file system mode"), quote (filename)); + return false; + } + if (STATFS (filename, &statfsbuf) != 0) { error (0, errno, _("cannot read file system information for %s"), @@ -857,7 +910,20 @@ do_stat (char const *filename, bool terse, char const *format) { struct stat statbuf; - if ((follow_links ? stat : lstat) (filename, &statbuf) != 0) + if (STREQ (filename, "-")) + { + if (fstat (STDIN_FILENO, &statbuf) != 0) + { + error (0, errno, _("cannot stat standard input")); + return false; + } + } + /* We can't use the shorter + (follow_links?stat:lstat) (filename, &statbug) + since stat might be a function-like macro. */ + else if ((follow_links + ? stat (filename, &statbuf) + : lstat (filename, &statbuf)) != 0) { error (0, errno, _("cannot stat %s"), quote (filename)); return false; @@ -983,7 +1049,7 @@ Valid format sequences for file systems:\n\ %T Type in human readable form\n\ "), stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/stdbuf.c b/src/bin/coreutils/src/stdbuf.c index 007cc21946..de3f515aa0 100644 --- a/src/bin/coreutils/src/stdbuf.c +++ b/src/bin/coreutils/src/stdbuf.c @@ -1,5 +1,5 @@ /* stdbuf -- setup the standard streams for a command - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,8 +24,10 @@ #include "system.h" #include "error.h" +#include "filenamecat.h" #include "posixver.h" #include "quote.h" +#include "xreadlink.h" #include "xstrtol.h" #include "c-ctype.h" @@ -35,13 +37,8 @@ #define AUTHORS proper_name_utf8 ("Padraig Brady", "P\303\241draig Brady") -/* Internal error */ -enum { EXIT_CANCELED = 125 }; - static char *program_path; -extern char **environ; - static struct { size_t size; @@ -125,7 +122,7 @@ for e.g.) then that will override corresponding settings changed by `stdbuf'.\n\ Also some filters (like `dd' and `cat' etc.) don't use streams for I/O,\n\ and are thus unaffected by `stdbuf' settings.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -145,34 +142,26 @@ set_program_path (const char *arg) } else { - char *path; - char tmppath[PATH_MAX + 1]; - ssize_t len = readlink ("/proc/self/exe", tmppath, sizeof (tmppath) - 1); - if (len > 0) - { - tmppath[len] = '\0'; - program_path = dir_name (tmppath); - } + char *path = xreadlink ("/proc/self/exe"); + if (path) + program_path = dir_name (path); else if ((path = getenv ("PATH"))) { char *dir; path = xstrdup (path); for (dir = strtok (path, ":"); dir != NULL; dir = strtok (NULL, ":")) { - int req = snprintf (tmppath, sizeof (tmppath), "%s/%s", dir, arg); - if (req >= sizeof (tmppath)) + char *candidate = file_name_concat (dir, arg, NULL); + if (access (candidate, X_OK) == 0) { - error (0, 0, _("path truncated when looking for %s"), - quote (arg)); - } - else if (access (tmppath, X_OK) == 0) - { - program_path = dir_name (tmppath); + program_path = dir_name (candidate); + free (candidate); break; } + free (candidate); } - free (path); } + free (path); } } diff --git a/src/bin/coreutils/src/stty.c b/src/bin/coreutils/src/stty.c index b980e8482f..8c6920fe1a 100644 --- a/src/bin/coreutils/src/stty.c +++ b/src/bin/coreutils/src/stty.c @@ -1,5 +1,5 @@ /* stty -- change and print terminal line settings - Copyright (C) 1990-2005, 2007-2009 Free Software Foundation, Inc. + Copyright (C) 1990-2005, 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -279,18 +279,18 @@ static struct mode_info const mode_info[] = {"cr0", output, SANE_SET, CR0, CRDLY}, #endif #ifdef TABDLY -#ifdef TAB3 +# ifdef TAB3 {"tab3", output, SANE_UNSET, TAB3, TABDLY}, -#endif -#ifdef TAB2 +# endif +# ifdef TAB2 {"tab2", output, SANE_UNSET, TAB2, TABDLY}, -#endif -#ifdef TAB1 +# endif +# ifdef TAB1 {"tab1", output, SANE_UNSET, TAB1, TABDLY}, -#endif -#ifdef TAB0 +# endif +# ifdef TAB0 {"tab0", output, SANE_SET, TAB0, TABDLY}, -#endif +# endif #else # ifdef OXTABS {"tab3", output, SANE_UNSET, OXTABS, 0}, @@ -724,7 +724,7 @@ prints baud rate, line discipline, and deviations from stty sane. In\n\ settings, CHAR is taken literally, or coded as in ^c, 0x37, 0177 or\n\ 127; special values ^- or undef used to disable special characters.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -817,13 +817,13 @@ main (int argc, char **argv) } /* Specifying both -a and -g gets an error. */ - if (verbose_output & recoverable_output) + if (verbose_output && recoverable_output) error (EXIT_FAILURE, 0, _("the options for verbose and stty-readable output styles are\n" "mutually exclusive")); /* Specifying any other arguments with -a or -g gets an error. */ - if (!noargs && (verbose_output | recoverable_output)) + if (!noargs && (verbose_output || recoverable_output)) error (EXIT_FAILURE, 0, _("when specifying an output style, modes may not be set")); @@ -849,7 +849,7 @@ main (int argc, char **argv) if (tcgetattr (STDIN_FILENO, &mode)) error (EXIT_FAILURE, errno, "%s", device_name); - if (verbose_output | recoverable_output | noargs) + if (verbose_output || recoverable_output || noargs) { max_col = screen_columns (); current_col = 0; @@ -883,7 +883,7 @@ main (int argc, char **argv) break; } } - if (!match_found & reversed) + if (!match_found && reversed) { error (0, 0, _("invalid argument %s"), quote (arg - 1)); usage (EXIT_FAILURE); diff --git a/src/bin/coreutils/src/su.c b/src/bin/coreutils/src/su.c index ec9c6001ca..f8f5b6188a 100644 --- a/src/bin/coreutils/src/su.c +++ b/src/bin/coreutils/src/su.c @@ -1,5 +1,5 @@ /* su for GNU. Run a shell with substitute user and group IDs. - Copyright (C) 1992-2006, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 1992-2006, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -53,16 +53,9 @@ #include #include -/* Hide any system prototype for getusershell. - This is necessary because some Cray systems have a conflicting - prototype (returning `int') in . */ -#define getusershell _getusershell_sys_proto_ - #include "system.h" #include "getpass.h" -#undef getusershell - #if HAVE_SYSLOG_H && HAVE_SYSLOG # include #else @@ -119,11 +112,6 @@ #define DEFAULT_USER "root" char *crypt (char const *key, char const *salt); -char *getusershell (void); -void endusershell (void); -void setusershell (void); - -extern char **environ; static void run_shell (char const *, char const *, char **, size_t) ATTRIBUTE_NORETURN; @@ -296,13 +284,13 @@ change_identity (const struct passwd *pw) #ifdef HAVE_INITGROUPS errno = 0; if (initgroups (pw->pw_name, pw->pw_gid) == -1) - error (EXIT_FAILURE, errno, _("cannot set groups")); + error (EXIT_CANCELED, errno, _("cannot set groups")); endgrent (); #endif if (setgid (pw->pw_gid)) - error (EXIT_FAILURE, errno, _("cannot set group id")); + error (EXIT_CANCELED, errno, _("cannot set group id")); if (setuid (pw->pw_uid)) - error (EXIT_FAILURE, errno, _("cannot set user id")); + error (EXIT_CANCELED, errno, _("cannot set user id")); } /* Run SHELL, or DEFAULT_SHELL if SHELL is empty. @@ -395,7 +383,7 @@ Change the effective user id and group id to that of USER.\n\ \n\ A mere - implies -l. If USER not given, assume root.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -416,7 +404,7 @@ main (int argc, char **argv) bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); - initialize_exit_failure (EXIT_FAILURE); + initialize_exit_failure (EXIT_CANCELED); atexit (close_stdout); fast_startup = false; @@ -453,7 +441,7 @@ main (int argc, char **argv) case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); default: - usage (EXIT_FAILURE); + usage (EXIT_CANCELED); } } @@ -468,7 +456,7 @@ main (int argc, char **argv) pw = getpwnam (new_user); if (! (pw && pw->pw_name && pw->pw_name[0] && pw->pw_dir && pw->pw_dir[0] && pw->pw_passwd)) - error (EXIT_FAILURE, 0, _("user %s does not exist"), new_user); + error (EXIT_CANCELED, 0, _("user %s does not exist"), new_user); /* Make a copy of the password information and point pw at the local copy instead. Otherwise, some systems (e.g. GNU/Linux) would clobber @@ -491,7 +479,7 @@ main (int argc, char **argv) #ifdef SYSLOG_FAILURE log_su (pw, false); #endif - error (EXIT_FAILURE, 0, _("incorrect password")); + error (EXIT_CANCELED, 0, _("incorrect password")); } #ifdef SYSLOG_SUCCESS else @@ -518,5 +506,13 @@ main (int argc, char **argv) if (simulate_login && chdir (pw->pw_dir) != 0) error (0, errno, _("warning: cannot change directory to %s"), pw->pw_dir); + /* error() flushes stderr, but does not check for write failure. + Normally, we would catch this via our atexit() hook of + close_stdout, but execv() gets in the way. If stderr + encountered a write failure, there is no need to try calling + error() again. */ + if (ferror (stderr)) + exit (EXIT_CANCELED); + run_shell (shell, command, argv + optind, MAX (0, argc - optind)); } diff --git a/src/bin/coreutils/src/sum.c b/src/bin/coreutils/src/sum.c index e53bad2ca6..d0d160f7b9 100644 --- a/src/bin/coreutils/src/sum.c +++ b/src/bin/coreutils/src/sum.c @@ -1,6 +1,6 @@ /* sum -- checksum and count the blocks in a file - Copyright (C) 86, 89, 91, 1995-2002, 2004, 2005, - 2008-2009 Free Software Foundation, Inc. + Copyright (C) 1986, 1989, 1991, 1995-2002, 2004-2005, 2008-2010 Free + Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -72,7 +72,7 @@ Print checksum and block counts for each FILE.\n\ \n\ With no FILE, or when FILE is -, read standard input.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -233,6 +233,10 @@ main (int argc, char **argv) atexit (close_stdout); + /* Line buffer stdout to ensure lines are written atomically and immediately + so that processes running in parallel do not intersperse their output. */ + setvbuf (stdout, NULL, _IOLBF, 0); + have_read_stdin = false; while ((optc = getopt_long (argc, argv, "rs", longopts, NULL)) != -1) diff --git a/src/bin/coreutils/src/sync.c b/src/bin/coreutils/src/sync.c index 593071347b..730df10ba9 100644 --- a/src/bin/coreutils/src/sync.c +++ b/src/bin/coreutils/src/sync.c @@ -1,5 +1,5 @@ /* sync - update the super block - Copyright (C) 1994-2004, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 1994-2004, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -45,7 +45,7 @@ Force changed blocks to disk, update the super block.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/system.h b/src/bin/coreutils/src/system.h index a15c298b8b..7d2bc43d64 100644 --- a/src/bin/coreutils/src/system.h +++ b/src/bin/coreutils/src/system.h @@ -1,5 +1,5 @@ /* system-dependent definitions for coreutils - Copyright (C) 1989, 1991-2009 Free Software Foundation, Inc. + Copyright (C) 1989, 1991-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -44,16 +44,8 @@ you must include before including this file #include "configmake.h" -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif +#include +#include /* Since major is a function on SVR4, we can't use `ifndef major'. */ #if MAJOR_IN_MKDEV @@ -86,16 +78,8 @@ you must include before including this file #include -/* Some systems don't define the following symbols. */ -#ifndef EDQUOT -# define EDQUOT (-1) -#endif -#ifndef EISDIR -# define EISDIR (-1) -#endif -#ifndef ENOSYS -# define ENOSYS (-1) -#endif +/* Some systems don't define this; POSIX mentions it but says it is + obsolete, so gnulib does not provide it either. */ #ifndef ENODATA # define ENODATA (-1) #endif @@ -107,8 +91,10 @@ you must include before including this file /* Exit statuses for programs like 'env' that exec other programs. */ enum { - EXIT_CANNOT_INVOKE = 126, - EXIT_ENOENT = 127 + EXIT_TIMEDOUT = 124, /* Time expired before child completed. */ + EXIT_CANCELED = 125, /* Internal error prior to exec attempt. */ + EXIT_CANNOT_INVOKE = 126, /* Program located, but not usable. */ + EXIT_ENOENT = 127 /* Could not find program to exec. */ }; #include "exitfail.h" @@ -123,13 +109,6 @@ initialize_exit_failure (int status) #include -#ifndef F_OK -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 -#endif - #include #ifndef _D_EXACT_NAMLEN # define _D_EXACT_NAMLEN(dp) strlen ((dp)->d_name) @@ -233,10 +212,6 @@ enum #include -#if ! (defined isblank || HAVE_DECL_ISBLANK) -# define isblank(c) ((c) == ' ' || (c) == '\t') -#endif - /* ISDIGIT differs from isdigit, as follows: - Its arg may be any int or unsigned int; it need not be an unsigned char or EOF. @@ -279,30 +254,6 @@ select_plural (uintmax_t n) #define STREQ(a, b) (strcmp (a, b) == 0) -#if !HAVE_DECL_FREE -void free (); -#endif - -#if !HAVE_DECL_MALLOC -char *malloc (); -#endif - -#if !HAVE_DECL_MEMCHR -char *memchr (); -#endif - -#if !HAVE_DECL_REALLOC -char *realloc (); -#endif - -#if !HAVE_DECL_GETENV -char *getenv (); -#endif - -#if !HAVE_DECL_LSEEK -off_t lseek (); -#endif - #if !HAVE_DECL_GETLOGIN char *getlogin (); #endif @@ -547,10 +498,6 @@ enum while (0) #endif -#ifndef EOVERFLOW -# define EOVERFLOW EINVAL -#endif - #if ! HAVE_SYNC # define sync() /* empty */ #endif @@ -635,10 +582,10 @@ Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).\n\ "), program); } -#include "hard-locale.h" static inline void -emit_bug_reporting_address (void) +emit_ancillary_info (void) { + const char *lc_messages; printf (_("\nReport %s bugs to %s\n"), last_component (program_name), PACKAGE_BUGREPORT); /* FIXME 2010: use AC_PACKAGE_URL once we require autoconf-2.64 */ @@ -646,8 +593,10 @@ emit_bug_reporting_address (void) PACKAGE_NAME, PACKAGE); fputs (_("General help using GNU software: \n"), stdout); - - if (hard_locale (LC_MESSAGES)) + /* Don't output this redundant message for English locales. + Note we still output for 'C' so that it gets included in the man page. */ + lc_messages = setlocale (LC_MESSAGES, NULL); + if (lc_messages && strncmp (lc_messages, "en_", 3)) { /* TRANSLATORS: Replace LANG_CODE in this URL with your language code to form one of @@ -657,6 +606,8 @@ emit_bug_reporting_address (void) "\n"), last_component (program_name)); } + printf (_("For complete documentation, run: " + "info coreutils '%s invocation'\n"), last_component (program_name)); } #include "inttostr.h" @@ -722,6 +673,18 @@ io_blksize (struct stat sb) void usage (int status) ATTRIBUTE_NORETURN; +#define emit_cycle_warning(file_name) \ + do \ + { \ + error (0, 0, _("\ +WARNING: Circular directory structure.\n\ +This almost certainly means that you have a corrupted file system.\n\ +NOTIFY YOUR SYSTEM MANAGER.\n\ +The following directory is part of the cycle:\n %s\n"), \ + quote (file_name)); \ + } \ + while (0) + #ifndef ARRAY_CARDINALITY # define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array)) #endif diff --git a/src/bin/coreutils/src/tac-pipe.c b/src/bin/coreutils/src/tac-pipe.c index 1612e2d486..72ec814d50 100644 --- a/src/bin/coreutils/src/tac-pipe.c +++ b/src/bin/coreutils/src/tac-pipe.c @@ -1,6 +1,7 @@ /* tac from a pipe. - Copyright (C) 1997, 1998, 2002, 2004, 2009 Free Software Foundation, Inc. + Copyright (C) 1997-1998, 2002, 2004, 2009-2010 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/src/tac.c b/src/bin/coreutils/src/tac.c index e1f71945fb..59b46b1d7d 100644 --- a/src/bin/coreutils/src/tac.c +++ b/src/bin/coreutils/src/tac.c @@ -1,5 +1,5 @@ /* tac - concatenate and print files in reverse - Copyright (C) 1988-1991, 1995-2006, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 1988-1991, 1995-2006, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -149,7 +149,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -633,6 +633,8 @@ main (int argc, char **argv) if (! (read_size < half_buffer_size && half_buffer_size < G_buffer_size)) xalloc_die (); G_buffer = xmalloc (G_buffer_size); + { + void *buf = G_buffer; if (sentinel_length) { strcpy (G_buffer, separator); @@ -661,6 +663,11 @@ main (int argc, char **argv) output ((char *) NULL, (char *) NULL); if (have_read_stdin && close (STDIN_FILENO) < 0) - error (EXIT_FAILURE, errno, "-"); + { + error (0, errno, "-"); + ok = false; + } + free (buf); + } exit (ok ? EXIT_SUCCESS : EXIT_FAILURE); } diff --git a/src/bin/coreutils/src/tail.c b/src/bin/coreutils/src/tail.c index 3f583f114b..02c4a1a1dc 100644 --- a/src/bin/coreutils/src/tail.c +++ b/src/bin/coreutils/src/tail.c @@ -1,6 +1,5 @@ /* tail -- output the last part of file(s) - Copyright (C) 1989, 90, 91, 1995-2006, 2008-2009 Free Software - Foundation, Inc. + Copyright (C) 1989-1991, 1995-2006, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -52,6 +51,12 @@ # include /* `select' is used by tail_forever_inotify. */ # include + +/* inotify needs to know if a file is local. */ +# include "fs.h" +# if HAVE_SYS_STATFS_H +# include +# endif #endif /* The official name of this program (e.g., no `g' prefix). */ @@ -105,9 +110,6 @@ struct File_spec /* The actual file name, or "-" for stdin. */ char *name; - /* File descriptor on which the file is open; -1 if it's not open. */ - int fd; - /* Attributes of the file the last time we checked. */ off_t size; struct timespec mtime; @@ -115,24 +117,27 @@ struct File_spec ino_t ino; mode_t mode; - /* 1 if O_NONBLOCK is clear, 0 if set, -1 if not known. */ - int blocking; - /* The specified name initially referred to a directory or some other type for which tail isn't meaningful. Unlike for a permission problem (tailable, below) once this is set, the name is not checked ever again. */ bool ignore; - /* See description of DEFAULT_MAX_N_... below. */ - uintmax_t n_unchanged_stats; + /* See the description of fremote. */ + bool remote; /* A file is tailable if it exists, is readable, and is of type IS_TAILABLE_FILE_TYPE. */ bool tailable; + /* File descriptor on which the file is open; -1 if it's not open. */ + int fd; + /* The value of errno seen last time we checked this file. */ int errnum; + /* 1 if O_NONBLOCK is clear, 0 if set, -1 if not known. */ + int blocking; + #if HAVE_INOTIFY /* The watch descriptor used by inotify. */ int wd; @@ -144,6 +149,9 @@ struct File_spec /* Offset in NAME of the basename part. */ size_t basename_start; #endif + + /* See description of DEFAULT_MAX_N_... below. */ + uintmax_t n_unchanged_stats; }; #if HAVE_INOTIFY @@ -201,8 +209,7 @@ static bool have_read_stdin; more expensive) code unconditionally. Intended solely for testing. */ static bool presume_input_pipe; -/* If nonzero then don't use inotify even if available. - Intended solely for testing. */ +/* If nonzero then don't use inotify even if available. */ static bool disable_inotify; /* For long options that have no equivalent short option, use a @@ -260,8 +267,8 @@ With no FILE, or when FILE is -, read standard input.\n\ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (_("\ - -c, --bytes=K output the last K bytes; alternatively, use +K to\n\ - output bytes starting with the Kth of each file\n\ + -c, --bytes=K output the last K bytes; alternatively, use -c +K\n\ + to output bytes starting with the Kth of each file\n\ "), stdout); fputs (_("\ -f, --follow[={name|descriptor}]\n\ @@ -272,7 +279,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); printf (_("\ -n, --lines=K output the last K lines, instead of the last %d;\n\ - or use +K to output lines starting with the Kth\n\ + or use -n +K to output lines starting with the Kth\n\ --max-unchanged-stats=N\n\ with --follow=name, reopen a FILE which has not\n\ changed size after N (default %d) iterations\n\ @@ -308,16 +315,12 @@ GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.\n\ fputs (_("\ With --follow (-f), tail defaults to following the file descriptor, which\n\ means that even if a tail'ed file is renamed, tail will continue to track\n\ -its end. \ -"), stdout); - fputs (_("\ -This default behavior is not desirable when you really want to\n\ +its end. This default behavior is not desirable when you really want to\n\ track the actual name of the file, not the file descriptor (e.g., log\n\ rotation). Use --follow=name in that case. That causes tail to track the\n\ -named file by reopening it periodically to see if it has been removed and\n\ -recreated by some other program.\n\ +named file in a way that accommodates renaming, removal and creation.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -865,6 +868,56 @@ start_lines (const char *pretty_filename, int fd, uintmax_t n_lines, } } +#if HAVE_INOTIFY +/* Without inotify support, always return false. Otherwise, return false + when FD is open on a file known to reside on a local file system. + If fstatfs fails, give a diagnostic and return true. + If fstatfs cannot be called, return true. */ +static bool +fremote (int fd, const char *name) +{ + bool remote = true; /* be conservative (poll by default). */ + +# if HAVE_FSTATFS && HAVE_STRUCT_STATFS_F_TYPE && defined __linux__ + struct statfs buf; + int err = fstatfs (fd, &buf); + if (err != 0) + { + error (0, errno, _("cannot determine location of %s. " + "reverting to polling"), quote (name)); + } + else + { + switch (buf.f_type) + { + case S_MAGIC_AFS: + case S_MAGIC_CIFS: + case S_MAGIC_CODA: + case S_MAGIC_FUSEBLK: + case S_MAGIC_FUSECTL: + case S_MAGIC_GFS: + case S_MAGIC_KAFS: + case S_MAGIC_LUSTRE: + case S_MAGIC_NCP: + case S_MAGIC_NFS: + case S_MAGIC_NFSD: + case S_MAGIC_OCFS2: + case S_MAGIC_SMB: + break; + default: + remote = false; + } + } +# endif + + return remote; +} +#else +/* Without inotify support, whether a file is remote is irrelevant. + Always return "false" in that case. */ +# define fremote(fd, name) false +#endif + /* FIXME: describe */ static void @@ -921,6 +974,15 @@ recheck (struct File_spec *f, bool blocking) quote (pretty_name (f))); f->ignore = true; } + else if (!disable_inotify && fremote (fd, pretty_name (f))) + { + ok = false; + f->errnum = -1; + error (0, 0, _("%s has been replaced with a remote file. " + "giving up on this name"), quote (pretty_name (f))); + f->ignore = true; + f->remote = true; + } else { f->errnum = 0; @@ -1126,7 +1188,7 @@ tail_forever (struct File_spec *f, size_t n_files, double sleep_interval) break; } - if ((!any_input | blocking) && fflush (stdout) != 0) + if ((!any_input || blocking) && fflush (stdout) != 0) error (EXIT_FAILURE, errno, _("write error")); /* If nothing was read, sleep and/or check for dead writers. */ @@ -1135,9 +1197,6 @@ tail_forever (struct File_spec *f, size_t n_files, double sleep_interval) if (writer_is_dead) break; - if (xnanosleep (sleep_interval)) - error (EXIT_FAILURE, errno, _("cannot read realtime clock")); - /* Once the writer is dead, read the files once more to avoid a race condition. */ writer_is_dead = (pid != 0 @@ -1146,12 +1205,44 @@ tail_forever (struct File_spec *f, size_t n_files, double sleep_interval) signal to the writer, so kill fails and sets errno to EPERM. */ && errno != EPERM); + + if (!writer_is_dead && xnanosleep (sleep_interval)) + error (EXIT_FAILURE, errno, _("cannot read realtime clock")); + } } } #if HAVE_INOTIFY +/* Return true if any of the N_FILES files in F is remote, i.e., has + an open file descriptor and is on a network file system. */ + +static bool +any_remote_file (const struct File_spec *f, size_t n_files) +{ + size_t i; + + for (i = 0; i < n_files; i++) + if (0 <= f[i].fd && f[i].remote) + return true; + return false; +} + +/* Return true if any of the N_FILES files in F represents + stdin and is tailable. */ + +static bool +tailable_stdin (const struct File_spec *f, size_t n_files) +{ + size_t i; + + for (i = 0; i < n_files; i++) + if (!f[i].ignore && STREQ (f[i].name, "-")) + return true; + return false; +} + static size_t wd_hasher (const void *entry, size_t tabsize) { @@ -1167,31 +1258,73 @@ wd_comparator (const void *e1, const void *e2) return spec1->wd == spec2->wd; } +/* Helper function used by `tail_forever_inotify'. */ +static void +check_fspec (struct File_spec *fspec, int wd, int *prev_wd) +{ + struct stat stats; + char const *name = pretty_name (fspec); + + if (fstat (fspec->fd, &stats) != 0) + { + close_fd (fspec->fd, name); + fspec->fd = -1; + fspec->errnum = errno; + return; + } + + if (S_ISREG (fspec->mode) && stats.st_size < fspec->size) + { + error (0, 0, _("%s: file truncated"), name); + *prev_wd = wd; + xlseek (fspec->fd, stats.st_size, SEEK_SET, name); + fspec->size = stats.st_size; + } + else if (S_ISREG (fspec->mode) && stats.st_size == fspec->size + && timespec_cmp (fspec->mtime, get_stat_mtime (&stats)) == 0) + return; + + if (wd != *prev_wd) + { + if (print_headers) + write_header (name); + *prev_wd = wd; + } + + uintmax_t bytes_read = dump_remainder (name, fspec->fd, COPY_TO_EOF); + fspec->size += bytes_read; + + if (fflush (stdout) != 0) + error (EXIT_FAILURE, errno, _("write error")); +} + /* Tail N_FILES files forever, or until killed. Check modifications using the inotify events system. */ - static void tail_forever_inotify (int wd, struct File_spec *f, size_t n_files, double sleep_interval) { - size_t i; unsigned int max_realloc = 3; - Hash_table *wd_table; + + /* Map an inotify watch descriptor to the name of the file it's watching. */ + Hash_table *wd_to_name; bool found_watchable = false; + bool writer_is_dead = false; int prev_wd; size_t evlen = 0; char *evbuf; size_t evbuf_off = 0; size_t len = 0; - wd_table = hash_initialize (n_files, NULL, wd_hasher, wd_comparator, NULL); - if (! wd_table) + wd_to_name = hash_initialize (n_files, NULL, wd_hasher, wd_comparator, NULL); + if (! wd_to_name) xalloc_die (); /* Add an inotify watch for each watched file. If -F is specified then watch its parent directory too, in this way when they re-appear we can add them again to the watch list. */ + size_t i; for (i = 0; i < n_files; i++) { if (!f[i].ignore) @@ -1235,7 +1368,7 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files, continue; } - if (hash_insert (wd_table, &(f[i])) == NULL) + if (hash_insert (wd_to_name, &(f[i])) == NULL) xalloc_die (); found_watchable = true; @@ -1247,6 +1380,14 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files, prev_wd = f[n_files - 1].wd; + /* Check files again. New data can be available since last time we checked + and before they are watched by inotify. */ + for (i = 0; i < n_files; i++) + { + if (!f[i].ignore) + check_fspec (&f[i], f[i].wd, &prev_wd); + } + evlen += sizeof (struct inotify_event) + 1; evbuf = xmalloc (evlen); @@ -1255,41 +1396,37 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files, This loop sleeps on the `safe_read' call until a new event is notified. */ while (1) { - char const *name; struct File_spec *fspec; - uintmax_t bytes_read; - struct stat stats; - struct inotify_event *ev; /* When watching a PID, ensure that a read from WD will not block - indefinetely. */ + indefinitely. */ if (pid) { - fd_set rfd; - struct timeval select_timeout; - int n_descriptors; + if (writer_is_dead) + exit (EXIT_SUCCESS); - FD_ZERO (&rfd); - FD_SET (wd, &rfd); + writer_is_dead = (kill (pid, 0) != 0 && errno != EPERM); - select_timeout.tv_sec = (time_t) sleep_interval; - select_timeout.tv_usec = 1000000 * (sleep_interval - - select_timeout.tv_sec); - - n_descriptors = select (wd + 1, &rfd, NULL, NULL, &select_timeout); - - if (n_descriptors == -1) - error (EXIT_FAILURE, errno, _("error monitoring inotify event")); - - if (n_descriptors == 0) + struct timeval delay; /* how long to wait for file changes. */ + if (writer_is_dead) + delay.tv_sec = delay.tv_usec = 0; + else { - /* See if the process we are monitoring is still alive. */ - if (kill (pid, 0) != 0 && errno != EPERM) - exit (EXIT_SUCCESS); - - continue; + delay.tv_sec = (time_t) sleep_interval; + delay.tv_usec = 1000000 * (sleep_interval - delay.tv_sec); } + + fd_set rfd; + FD_ZERO (&rfd); + FD_SET (wd, &rfd); + + int file_change = select (wd + 1, &rfd, NULL, NULL, &delay); + + if (file_change == 0) + continue; + else if (file_change == -1) + error (EXIT_FAILURE, errno, _("error monitoring inotify event")); } if (len <= evbuf_off) @@ -1315,41 +1452,59 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files, ev = (struct inotify_event *) (evbuf + evbuf_off); evbuf_off += sizeof (*ev) + ev->len; - if (ev->len) + if (ev->len) /* event on ev->name in watched directory */ { - for (i = 0; i < n_files; i++) + size_t j; + for (j = 0; j < n_files; j++) { /* With N=hundreds of frequently-changing files, this O(N^2) process might be a problem. FIXME: use a hash table? */ - if (f[i].parent_wd == ev->wd - && STREQ (ev->name, f[i].name + f[i].basename_start)) + if (f[j].parent_wd == ev->wd + && STREQ (ev->name, f[j].name + f[j].basename_start)) break; } /* It is not a watched file. */ - if (i == n_files) + if (j == n_files) continue; - f[i].wd = inotify_add_watch (wd, f[i].name, inotify_wd_mask); - - if (f[i].wd < 0) + /* It's fine to add the same file more than once. */ + int new_wd = inotify_add_watch (wd, f[j].name, inotify_wd_mask); + if (new_wd < 0) { - error (0, errno, _("cannot watch %s"), quote (f[i].name)); + error (0, errno, _("cannot watch %s"), quote (f[j].name)); continue; } - fspec = &(f[i]); - if (hash_insert (wd_table, fspec) == NULL) + fspec = &(f[j]); + + /* Remove `fspec' and re-add it using `new_fd' as its key. */ + hash_delete (wd_to_name, fspec); + fspec->wd = new_wd; + + /* If the file was moved then inotify will use the source file wd for + the destination file. Make sure the key is not present in the + table. */ + struct File_spec *prev = hash_delete (wd_to_name, fspec); + if (prev && prev != fspec) + { + if (follow_mode == Follow_name) + recheck (prev, false); + prev->wd = -1; + close_fd (prev->fd, pretty_name (prev)); + } + + if (hash_insert (wd_to_name, fspec) == NULL) xalloc_die (); if (follow_mode == Follow_name) - recheck (&(f[i]), false); + recheck (fspec, false); } else { struct File_spec key; key.wd = ev->wd; - fspec = hash_lookup (wd_table, &key); + fspec = hash_lookup (wd_to_name, &key); } if (! fspec) @@ -1357,47 +1512,23 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files, if (ev->mask & (IN_ATTRIB | IN_DELETE_SELF | IN_MOVE_SELF)) { - if (ev->mask & (IN_DELETE_SELF | IN_MOVE_SELF)) + /* For IN_DELETE_SELF, we always want to remove the watch. + However, for IN_MOVE_SELF (the file we're watching has + been clobbered via a rename), when tailing by NAME, we + must continue to watch the file. It's only when following + by file descriptor that we must remove the watch. */ + if ((ev->mask & IN_DELETE_SELF) + || ((ev->mask & IN_MOVE_SELF) && follow_mode == Follow_descriptor)) { - inotify_rm_watch (wd, f[i].wd); - hash_delete (wd_table, &(f[i])); + inotify_rm_watch (wd, fspec->wd); + hash_delete (wd_to_name, fspec); } if (follow_mode == Follow_name) recheck (fspec, false); continue; } - - name = pretty_name (fspec); - - if (fstat (fspec->fd, &stats) != 0) - { - close_fd (fspec->fd, name); - fspec->fd = -1; - fspec->errnum = errno; - continue; - } - - if (S_ISREG (fspec->mode) && stats.st_size < fspec->size) - { - error (0, 0, _("%s: file truncated"), name); - prev_wd = ev->wd; - xlseek (fspec->fd, stats.st_size, SEEK_SET, name); - fspec->size = stats.st_size; - } - - if (ev->wd != prev_wd) - { - if (print_headers) - write_header (name); - prev_wd = ev->wd; - } - - bytes_read = dump_remainder (name, fspec->fd, COPY_TO_EOF); - fspec->size += bytes_read; - - if (fflush (stdout) != 0) - error (EXIT_FAILURE, errno, _("write error")); + check_fspec (fspec, ev->wd, &prev_wd); } } #endif @@ -1596,7 +1727,7 @@ tail_file (struct File_spec *f, uintmax_t n_units) /* Before the tail function provided `read_pos', there was a race condition described in the URL below. This sleep call made the window big enough to exercise the problem. */ - sleep (1); + xnanosleep (1); #endif f->errnum = ok - 1; if (fstat (fd, &stats) < 0) @@ -1626,6 +1757,7 @@ tail_file (struct File_spec *f, uintmax_t n_units) to avoid a race condition described by Ken Raeburn: http://mail.gnu.org/archive/html/bug-textutils/2003-05/msg00007.html */ record_open_fd (f, fd, read_pos, &stats, (is_stdin ? -1 : 1)); + f->remote = fremote (fd, pretty_name (f)); } } else @@ -1866,6 +1998,35 @@ parse_options (int argc, char **argv, } } +/* Mark as '.ignore'd each member of F that corresponds to a + pipe or fifo, and return the number of non-ignored members. */ +static size_t +ignore_fifo_and_pipe (struct File_spec *f, size_t n_files) +{ + /* When there is no FILE operand and stdin is a pipe or FIFO + POSIX requires that tail ignore the -f option. + Since we allow multiple FILE operands, we extend that to say: with -f, + ignore any "-" operand that corresponds to a pipe or FIFO. */ + size_t n_viable = 0; + + size_t i; + for (i = 0; i < n_files; i++) + { + bool is_a_fifo_or_pipe = + (STREQ (f[i].name, "-") + && !f[i].ignore + && 0 <= f[i].fd + && (S_ISFIFO (f[i].mode) + || (HAVE_FIFO_PIPES != 1 && isapipe (f[i].fd)))); + if (is_a_fifo_or_pipe) + f[i].ignore = true; + else + ++n_viable; + } + + return n_viable; +} + int main (int argc, char **argv) { @@ -1957,42 +2118,31 @@ main (int argc, char **argv) for (i = 0; i < n_files; i++) ok &= tail_file (&F[i], n_units); - /* When there is no FILE operand and stdin is a pipe or FIFO - POSIX requires that tail ignore the -f option. - Since we allow multiple FILE operands, we extend that to say: - ignore any "-" operand that corresponds to a pipe or FIFO. */ - { - size_t n_viable = 0; - for (i = 0; i < n_files; i++) - { - bool is_a_fifo_or_pipe = - (STREQ (F[i].name, "-") - && !F[i].ignore - && 0 <= F[i].fd - && (S_ISFIFO (F[i].mode) - || (HAVE_FIFO_PIPES != 1 && isapipe (F[i].fd)))); - if (is_a_fifo_or_pipe) - F[i].ignore = true; - else - ++n_viable; - } - - if (forever && n_viable) + if (forever && ignore_fifo_and_pipe (F, n_files)) { #if HAVE_INOTIFY - /* If the user specifies stdin via a command line argument of "-", - or implicitly by providing no arguments, we won't use inotify. + /* tailable_stdin() checks if the user specifies stdin via "-", + or implicitly by providing no arguments. If so, we won't use inotify. Technically, on systems with a working /dev/stdin, we *could*, but would it be worth it? Verifying that it's a real device and hooked up to stdin is not trivial, while reverting to - non-inotify-based tail_forever is easy and portable. */ - bool stdin_cmdline_arg = false; + non-inotify-based tail_forever is easy and portable. - for (i = 0; i < n_files; i++) - if (!F[i].ignore && STREQ (F[i].name, "-")) - stdin_cmdline_arg = true; + any_remote_file() checks if the user has specified any + files that reside on remote file systems. inotify is not used + in this case because it would miss any updates to the file + that were not initiated from the local system. - if (!disable_inotify && !stdin_cmdline_arg) + FIXME: inotify doesn't give any notification when a new + (remote) file or directory is mounted on top a watched file. + When follow_mode == Follow_name we would ideally like to detect that. + Note if there is a change to the original file then we'll + recheck it and follow the new file, or ignore it if the + file has changed to being remote. */ + if (tailable_stdin (F, n_files) || any_remote_file (F, n_files)) + disable_inotify = true; + + if (!disable_inotify) { int wd = inotify_init (); if (wd < 0) @@ -2014,7 +2164,6 @@ main (int argc, char **argv) #endif tail_forever (F, n_files, sleep_interval); } - } if (have_read_stdin && close (STDIN_FILENO) < 0) error (EXIT_FAILURE, errno, "-"); diff --git a/src/bin/coreutils/src/tee.c b/src/bin/coreutils/src/tee.c index 03a33b0602..39d989274d 100644 --- a/src/bin/coreutils/src/tee.c +++ b/src/bin/coreutils/src/tee.c @@ -1,5 +1,5 @@ /* tee - read from standard input and write to standard output and files. - Copyright (C) 85,1990-2006, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 1985, 1990-2006, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -72,7 +72,7 @@ Copy standard input to each FILE, and also to standard output.\n\ \n\ If a FILE is -, copy again to standard output.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/test.c b/src/bin/coreutils/src/test.c index f7c689cf9c..59d8b4eb09 100644 --- a/src/bin/coreutils/src/test.c +++ b/src/bin/coreutils/src/test.c @@ -2,7 +2,7 @@ /* Modified to run with the GNU shell by bfox. */ -/* Copyright (C) 1987-2005, 2007-2009 Free Software Foundation, Inc. +/* Copyright (C) 1987-2005, 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -318,7 +318,7 @@ binary_operator (bool l_is_l) struct timespec lt, rt; bool le, re; pos += 3; - if (l_is_l | r_is_l) + if (l_is_l || r_is_l) test_syntax_error (_("-nt does not accept -l"), NULL); le = get_mtime (argv[op - 1], <); re = get_mtime (argv[op + 1], &rt); @@ -331,7 +331,7 @@ binary_operator (bool l_is_l) { /* ef - hard link? */ pos += 3; - if (l_is_l | r_is_l) + if (l_is_l || r_is_l) test_syntax_error (_("-ef does not accept -l"), NULL); return (stat (argv[op - 1], &stat_buf) == 0 && stat (argv[op + 1], &stat_spare) == 0 @@ -347,7 +347,7 @@ binary_operator (bool l_is_l) struct timespec lt, rt; bool le, re; pos += 3; - if (l_is_l | r_is_l) + if (l_is_l || r_is_l) test_syntax_error (_("-ot does not accept -l"), NULL); le = get_mtime (argv[op - 1], <); re = get_mtime (argv[op + 1], &rt); @@ -770,7 +770,7 @@ NOTE: [ honors the --help and --version options, but test does not.\n\ test treats each of those as it treats any other nonempty STRING.\n\ "), stdout); printf (USAGE_BUILTIN_WARNING, _("test and/or [")); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/timeout.c b/src/bin/coreutils/src/timeout.c index 6d9d109128..10dcbe8554 100644 --- a/src/bin/coreutils/src/timeout.c +++ b/src/bin/coreutils/src/timeout.c @@ -1,5 +1,5 @@ /* timeout -- run a command with bounded time - Copyright (C) 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -73,12 +73,6 @@ #define AUTHORS proper_name_utf8 ("Padraig Brady", "P\303\241draig Brady") -/* Note ETIMEDOUT is 110 on GNU/Linux systems but this is non standard */ -#define EXIT_TIMEDOUT 124 - -/* Internal failure. */ -#define EXIT_CANCELED 125 - static int timed_out; static int term_signal = SIGTERM; /* same default as kill command. */ static int monitored_pid; @@ -153,13 +147,12 @@ Mandatory arguments to long options are mandatory for short options too.\n\ fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); fputs (_("\n\ -If the command times out, then we exit with status 124,\n\ -otherwise the normal exit status of the command is returned.\n\ -If no signal is specified, the TERM signal is sent. The TERM signal\n\ -will kill processes which do not catch this signal. For other processes,\n\ -it may be necessary to use the KILL (9) signal, since this signal cannot\n\ -be caught.\n"), stdout); - emit_bug_reporting_address (); +If the command times out, then exit with status 124. Otherwise, exit\n\ +with the status of COMMAND. If no signal is specified, send the TERM\n\ +signal upon timeout. The TERM signal kills any process that does not\n\ +block or catch that signal. For other processes, it may be necessary to\n\ +use the KILL (9) signal, since this signal cannot be caught.\n"), stdout); + emit_ancillary_info (); } exit (status); } @@ -203,7 +196,7 @@ apply_time_suffix (unsigned long *x, char suffix_char) } static void -install_signal_handlers (void) +install_signal_handlers (int sigterm) { struct sigaction sa; sigemptyset(&sa.sa_mask); /* Allow concurrent calls to handler */ @@ -213,8 +206,9 @@ install_signal_handlers (void) sigaction (SIGALRM, &sa, NULL); /* our timeout. */ sigaction (SIGINT, &sa, NULL); /* Ctrl-C at terminal for example. */ sigaction (SIGQUIT, &sa, NULL); /* Ctrl-\ at terminal for example. */ - sigaction (SIGTERM, &sa, NULL); /* if we're killed, stop monitored proc. */ sigaction (SIGHUP, &sa, NULL); /* terminal closed for example. */ + sigaction (SIGTERM, &sa, NULL); /* if we're killed, stop monitored proc. */ + sigaction (sigterm, &sa, NULL); /* user specified termination signal. */ } int @@ -278,9 +272,10 @@ main (int argc, char **argv) /* Setup handlers before fork() so that we handle any signals caused by child, without races. */ - install_signal_handlers (); + install_signal_handlers (term_signal); signal (SIGTTIN, SIG_IGN); /* don't sTop if background child needs tty. */ signal (SIGTTOU, SIG_IGN); /* don't sTop if background child needs tty. */ + signal (SIGCHLD, SIG_DFL); /* Don't inherit CHLD handling from parent. */ monitored_pid = fork (); if (monitored_pid == -1) diff --git a/src/bin/coreutils/src/touch.c b/src/bin/coreutils/src/touch.c index ed9847175c..db1bc8d97a 100644 --- a/src/bin/coreutils/src/touch.c +++ b/src/bin/coreutils/src/touch.c @@ -1,6 +1,6 @@ /* touch -- change modification and access times of files - Copyright (C) 87, 1989-1991, 1995-2005, 2007-2009 - Free Software Foundation, Inc. + Copyright (C) 1987, 1989-1991, 1995-2005, 2007-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,6 +22,7 @@ #include #include #include +#include #include "system.h" #include "argmatch.h" @@ -57,6 +58,9 @@ static bool no_create; /* (-r) If true, use times from a reference file. */ static bool use_ref; +/* (-h) If true, change the times of an existing symlink, if possible. */ +static bool no_dereference; + /* If true, the only thing we have to do is change both the modification and access time to the current time, so we don't have to own the file, just be able to read and write it. @@ -84,6 +88,7 @@ static struct option const longopts[] = {"date", required_argument, NULL, 'd'}, {"file", required_argument, NULL, 'r'}, /* FIXME: remove --file in 2010 */ {"reference", required_argument, NULL, 'r'}, + {"no-dereference", no_argument, NULL, 'h'}, {GETOPT_HELP_OPTION_DECL}, {GETOPT_VERSION_OPTION_DECL}, {NULL, 0, NULL, 0} @@ -119,15 +124,13 @@ static bool touch (const char *file) { bool ok; - struct stat sbuf; int fd = -1; int open_errno = 0; - struct timespec timespec[2]; - struct timespec const *t; + struct timespec const *t = newtime; if (STREQ (file, "-")) fd = STDOUT_FILENO; - else if (! no_create) + else if (! (no_create || no_dereference)) { /* Try to open FILE, creating it if necessary. */ fd = fd_reopen (STDIN_FILENO, file, @@ -144,24 +147,13 @@ touch (const char *file) if (change_times != (CH_ATIME | CH_MTIME)) { - /* We're setting only one of the time values. stat the target to get - the other one. If we have the file descriptor already, use fstat. - Otherwise, either we're in no-create mode (and hence didn't call open) - or FILE is inaccessible or a directory, so we have to use stat. */ - if (fd != -1 ? fstat (fd, &sbuf) : stat (file, &sbuf)) + /* We're setting only one of the time values. */ + if (change_times == CH_MTIME) + newtime[0].tv_nsec = UTIME_OMIT; + else { - if (open_errno) - error (0, open_errno, _("creating %s"), quote (file)); - else - { - if (no_create && (errno == ENOENT || errno == EBADF)) - return true; - error (0, errno, _("failed to get attributes of %s"), - quote (file)); - } - if (fd == STDIN_FILENO) - close (fd); - return false; + assert (change_times == CH_ATIME); + newtime[1].tv_nsec = UTIME_OMIT; } } @@ -171,18 +163,9 @@ touch (const char *file) write access to the file, but don't own it. */ t = NULL; } - else - { - timespec[0] = (change_times & CH_ATIME - ? newtime[0] - : get_stat_atime (&sbuf)); - timespec[1] = (change_times & CH_MTIME - ? newtime[1] - : get_stat_mtime (&sbuf)); - t = timespec; - } - ok = (gl_futimens (fd, (fd == STDOUT_FILENO ? NULL : file), t) == 0); + ok = ((no_dereference && fd == -1) ? lutimens (file, t) + : gl_futimens (fd, (fd == STDOUT_FILENO ? NULL : file), t)) == 0; if (fd == STDIN_FILENO) { @@ -195,8 +178,7 @@ touch (const char *file) else if (fd == STDOUT_FILENO) { /* Do not diagnose "touch -c - >&-". */ - if (!ok && errno == EBADF && no_create - && change_times == (CH_ATIME | CH_MTIME)) + if (!ok && errno == EBADF && no_create) return true; } @@ -234,7 +216,8 @@ usage (int status) fputs (_("\ Update the access and modification times of each FILE to the current time.\n\ \n\ -A FILE argument that does not exist is created empty.\n\ +A FILE argument that does not exist is created empty, unless -c or -h\n\ +is supplied.\n\ \n\ A FILE argument string of - is handled specially and causes touch to\n\ change the times of the file associated with standard output.\n\ @@ -248,6 +231,11 @@ Mandatory arguments to long options are mandatory for short options too.\n\ -c, --no-create do not create any files\n\ -d, --date=STRING parse STRING and use it instead of current time\n\ -f (ignored)\n\ +"), stdout); + fputs (_("\ + -h, --no-dereference affect each symbolic link instead of any referenced\n\ + file (useful only on systems that can change the\n\ + timestamps of a symlink)\n\ -m change only the modification time\n\ "), stdout); fputs (_("\ @@ -263,7 +251,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ \n\ Note that the -d and -t options accept different time-date formats.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -288,7 +276,7 @@ main (int argc, char **argv) change_times = 0; no_create = use_ref = false; - while ((c = getopt_long (argc, argv, "acd:fmr:t:", longopts, &long_idx)) != -1) + while ((c = getopt_long (argc, argv, "acd:fhmr:t:", longopts, &long_idx)) != -1) { switch (c) { @@ -307,6 +295,10 @@ main (int argc, char **argv) case 'f': break; + case 'h': + no_dereference = true; + break; + case 'm': change_times |= CH_MTIME; break; @@ -356,7 +348,10 @@ main (int argc, char **argv) if (use_ref) { struct stat ref_stats; - if (stat (ref_file, &ref_stats)) + /* Don't use (no_dereference?lstat:stat) (args), since stat + might be an object-like macro. */ + if (no_dereference ? lstat (ref_file, &ref_stats) + : stat (ref_file, &ref_stats)) error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), quote (ref_file)); newtime[0] = get_stat_atime (&ref_stats); @@ -429,10 +424,7 @@ main (int argc, char **argv) if (change_times == (CH_ATIME | CH_MTIME)) amtime_now = true; else - { - gettime (&newtime[0]); - newtime[1] = newtime[0]; - } + newtime[1].tv_nsec = newtime[0].tv_nsec = UTIME_NOW; } if (optind == argc) diff --git a/src/bin/coreutils/src/tr.c b/src/bin/coreutils/src/tr.c index 0b985f801a..c7510c335a 100644 --- a/src/bin/coreutils/src/tr.c +++ b/src/bin/coreutils/src/tr.c @@ -1,5 +1,5 @@ /* tr -- a filter to translate characters - Copyright (C) 91, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1991, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -346,7 +346,7 @@ only be used in pairs to specify case conversion. -s uses SET1 if not\n\ translating nor deleting; else squeezing uses SET2 and occurs after\n\ translation or deletion.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/true.c b/src/bin/coreutils/src/true.c index 66d1e01116..e750e40a1e 100644 --- a/src/bin/coreutils/src/true.c +++ b/src/bin/coreutils/src/true.c @@ -1,5 +1,5 @@ /* Exit with a status code indicating success. - Copyright (C) 1999-2003, 2005, 2007-2009 Free Software Foundation, Inc. + Copyright (C) 1999-2003, 2005, 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -47,25 +47,25 @@ Usage: %s [ignored command line arguments]\n\ fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); - emit_bug_reporting_address (); + emit_ancillary_info (); exit (status); } int main (int argc, char **argv) { - initialize_main (&argc, &argv); - set_program_name (argv[0]); - setlocale (LC_ALL, ""); - bindtextdomain (PACKAGE, LOCALEDIR); - textdomain (PACKAGE); - - atexit (close_stdout); - /* Recognize --help or --version only if it's the only command-line argument. */ if (argc == 2) { + initialize_main (&argc, &argv); + set_program_name (argv[0]); + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + atexit (close_stdout); + if (STREQ (argv[1], "--help")) usage (EXIT_STATUS); diff --git a/src/bin/coreutils/src/truncate.c b/src/bin/coreutils/src/truncate.c index 77783794ea..5085d2c0ff 100644 --- a/src/bin/coreutils/src/truncate.c +++ b/src/bin/coreutils/src/truncate.c @@ -1,5 +1,5 @@ /* truncate -- truncate or extend the length of files. - Copyright (C) 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -133,7 +133,7 @@ SIZE may also be prefixed by one of the following modifying characters:\n\ \n\ Note that the -r and -s options are mutually exclusive.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/tsort.c b/src/bin/coreutils/src/tsort.c index d74b620919..3746f9ec0b 100644 --- a/src/bin/coreutils/src/tsort.c +++ b/src/bin/coreutils/src/tsort.c @@ -1,5 +1,5 @@ /* tsort - topological sort. - Copyright (C) 1998-2005, 2007-2009 Free Software Foundation, Inc. + Copyright (C) 1998-2005, 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,7 +22,6 @@ #include -#include #include #include #include @@ -32,6 +31,7 @@ #include "error.h" #include "quote.h" #include "readtokens.h" +#include "stdio--.h" /* The official name of this program (e.g., no `g' prefix). */ #define PROGRAM_NAME "tsort" @@ -87,7 +87,7 @@ With no FILE, or when FILE is -, read standard input.\n\ "), program_name); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); diff --git a/src/bin/coreutils/src/tty.c b/src/bin/coreutils/src/tty.c index cc15cfe4af..02bbb1db95 100644 --- a/src/bin/coreutils/src/tty.c +++ b/src/bin/coreutils/src/tty.c @@ -1,5 +1,5 @@ /* tty -- print the name of the terminal connected to standard input - Copyright (C) 1990-2005, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 1990-2005, 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -70,7 +70,7 @@ Print the file name of the terminal connected to standard input.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/uname.c b/src/bin/coreutils/src/uname.c index 63b3374e39..f85d7e9124 100644 --- a/src/bin/coreutils/src/uname.c +++ b/src/bin/coreutils/src/uname.c @@ -1,7 +1,7 @@ /* uname -- print system information - Copyright (C) 1989, 1992, 1993, 1996, 1997, 1999-2005, - 2007-2009 Free Software Foundation, Inc. + Copyright (C) 1989, 1992-1993, 1996-1997, 1999-2005, 2007-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -150,7 +150,7 @@ Print machine architecture.\n\ fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/unexpand.c b/src/bin/coreutils/src/unexpand.c index bfe22964ea..dfe93053fb 100644 --- a/src/bin/coreutils/src/unexpand.c +++ b/src/bin/coreutils/src/unexpand.c @@ -1,5 +1,6 @@ /* unexpand - convert blanks to tabs - Copyright (C) 89, 91, 1995-2006, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 1989, 1991, 1995-2006, 2008-2010 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -130,7 +131,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -429,7 +430,7 @@ unexpand (void) } prev_blank = blank; - convert &= convert_entire_line | blank; + convert &= convert_entire_line || blank; } if (c < 0) diff --git a/src/bin/coreutils/src/uniq.c b/src/bin/coreutils/src/uniq.c index 13aaebccc3..8f6b78a5ac 100644 --- a/src/bin/coreutils/src/uniq.c +++ b/src/bin/coreutils/src/uniq.c @@ -1,5 +1,5 @@ /* uniq -- remove duplicate lines from a sorted file - Copyright (C) 86, 91, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1986, 1991, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,7 +18,6 @@ #include -#include #include #include @@ -26,8 +25,10 @@ #include "argmatch.h" #include "linebuffer.h" #include "error.h" +#include "hard-locale.h" #include "posixver.h" #include "quote.h" +#include "stdio--.h" #include "xmemcoll.h" #include "xstrtol.h" #include "memcasecmp.h" @@ -174,7 +175,7 @@ Note: 'uniq' does not detect repeated lines unless they are adjacent.\n\ You may want to sort the input first, or use `sort -u' without `uniq'.\n\ Also, comparisons honor the rules specified by `LC_COLLATE'.\n\ "), stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/unlink.c b/src/bin/coreutils/src/unlink.c index 47cbfb2e31..cd6a56f7b0 100644 --- a/src/bin/coreutils/src/unlink.c +++ b/src/bin/coreutils/src/unlink.c @@ -1,5 +1,5 @@ /* unlink utility for GNU. - Copyright (C) 2001, 2002, 2004, 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2004, 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -50,7 +50,7 @@ Usage: %s FILE\n\ stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/uptime.c b/src/bin/coreutils/src/uptime.c index 175fe8f73b..20949fce6f 100644 --- a/src/bin/coreutils/src/uptime.c +++ b/src/bin/coreutils/src/uptime.c @@ -1,5 +1,5 @@ /* GNU's uptime. - Copyright (C) 1992-2002, 2004-2009 Free Software Foundation, Inc. + Copyright (C) 1992-2002, 2004-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -111,7 +111,11 @@ print_uptime (size_t n, const STRUCT_UTMP *this) boot_time = UT_TIME_MEMBER (this); ++this; } +#else + (void) n; + (void) this; #endif + time_now = time (NULL); #if defined HAVE_PROC_UPTIME if (uptime == 0) @@ -216,7 +220,7 @@ If FILE is not specified, use %s. %s as FILE is common.\n\ UTMP_FILE, WTMP_FILE); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/users.c b/src/bin/coreutils/src/users.c index d5115c6911..c2addc321e 100644 --- a/src/bin/coreutils/src/users.c +++ b/src/bin/coreutils/src/users.c @@ -1,5 +1,5 @@ /* GNU's users. - Copyright (C) 1992-2005, 2007-2009 Free Software Foundation, Inc. + Copyright (C) 1992-2005, 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -112,7 +112,7 @@ If FILE is not specified, use %s. %s as FILE is common.\n\ UTMP_FILE, WTMP_FILE); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/wc.c b/src/bin/coreutils/src/wc.c index a75c15b7d8..592be2af63 100644 --- a/src/bin/coreutils/src/wc.c +++ b/src/bin/coreutils/src/wc.c @@ -1,5 +1,5 @@ /* wc - print the number of lines, words, and bytes in files - Copyright (C) 85, 91, 1995-2009 Free Software Foundation, Inc. + Copyright (C) 1985, 1991, 1995-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -131,7 +131,7 @@ read standard input.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } @@ -205,10 +205,10 @@ wc (int fd, char const *file_x, struct fstatus *fstatus) else #endif { - count_bytes = print_bytes | print_chars; + count_bytes = print_bytes || print_chars; count_chars = false; } - count_complicated = print_words | print_linelength; + count_complicated = print_words || print_linelength; /* When counting only bytes, save some line- and word-counting overhead. If FD is a `regular' Unix file, using lseek is enough @@ -220,7 +220,7 @@ wc (int fd, char const *file_x, struct fstatus *fstatus) `(dd ibs=99k skip=1 count=0; ./wc -c) < /etc/group' should make wc report `0' bytes. */ - if (count_bytes & !count_chars & !print_lines & !count_complicated) + if (count_bytes && !count_chars && !print_lines && !count_complicated) { off_t current_pos, end_pos; @@ -601,6 +601,10 @@ main (int argc, char **argv) atexit (close_stdout); + /* Line buffer stdout to ensure lines are written atomically and immediately + so that processes running in parallel do not intersperse their output. */ + setvbuf (stdout, NULL, _IOLBF, 0); + print_lines = print_words = print_chars = print_bytes = false; print_linelength = false; total_lines = total_words = total_chars = total_bytes = max_line_length = 0; @@ -640,8 +644,8 @@ main (int argc, char **argv) usage (EXIT_FAILURE); } - if (! (print_lines | print_words | print_chars | print_bytes - | print_linelength)) + if (! (print_lines || print_words || print_chars || print_bytes + || print_linelength)) print_lines = print_words = print_bytes = true; if (files_from) diff --git a/src/bin/coreutils/src/wheel-gen.pl b/src/bin/coreutils/src/wheel-gen.pl index 96fb48f05f..5ed9841b0c 100755 --- a/src/bin/coreutils/src/wheel-gen.pl +++ b/src/bin/coreutils/src/wheel-gen.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl -w # Generate the spokes of a wheel, for wheel factorization. -# Copyright (C) 2001, 2005, 2009 Free Software Foundation, Inc. +# Copyright (C) 2001, 2005, 2009-2010 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/src/bin/coreutils/src/who.c b/src/bin/coreutils/src/who.c index f162fab58a..f71db3bb5e 100644 --- a/src/bin/coreutils/src/who.c +++ b/src/bin/coreutils/src/who.c @@ -1,5 +1,5 @@ /* GNU's who. - Copyright (C) 1992-2009 Free Software Foundation, Inc. + Copyright (C) 1992-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,6 +34,7 @@ #include "canon-host.h" #include "readutmp.h" #include "error.h" +#include "hard-locale.h" #include "quote.h" /* The official name of this program (e.g., no `g' prefix). */ @@ -665,7 +666,7 @@ Print information about users who are currently logged in.\n\ If FILE is not specified, use %s. %s as FILE is common.\n\ If ARG1 ARG2 given, -m presumed: `am i' or `mom likes' are usual.\n\ "), UTMP_FILE, WTMP_FILE); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/whoami.c b/src/bin/coreutils/src/whoami.c index 928f69e455..fe0407d1ff 100644 --- a/src/bin/coreutils/src/whoami.c +++ b/src/bin/coreutils/src/whoami.c @@ -1,7 +1,7 @@ /* whoami -- print effective userid - Copyright (C) 89,90, 1991-1997, 1999-2002, 2004, 2005, - 2007-2009 Free Software Foundation, Inc. + Copyright (C) 1989-1997, 1999-2002, 2004-2005, 2007-2010 Free Software + Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -51,7 +51,7 @@ Same as id -un.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); } diff --git a/src/bin/coreutils/src/yes.c b/src/bin/coreutils/src/yes.c index e974de29fb..9c79101bc4 100644 --- a/src/bin/coreutils/src/yes.c +++ b/src/bin/coreutils/src/yes.c @@ -1,5 +1,5 @@ /* yes - output a string repeatedly until killed - Copyright (C) 1991-1997, 1999-2004, 2007-2009 Free Software Foundation, Inc. + Copyright (C) 1991-1997, 1999-2004, 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -51,7 +51,7 @@ Repeatedly output a line with all specified STRING(s), or `y'.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_bug_reporting_address (); + emit_ancillary_info (); } exit (status); }