Add gnulib's stpcpy.
PATCH 1/1 Add gnulib's stpcpy.
The attached patch adds gnulib's stpcpy. This is required on systems lacking stpcpy, e.g., NetBSD 5.1.
Note: I used gnulib's sources from 2010-09-20, since this is, afaics, the date of import of gnulib files in GRUB.
Grégoire
=== modified file 'grub-core/gnulib/Makefile.am'
gnulib/Makefile.am +10 -1
@@ -9,7 +9,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=grub-core/gnulib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-libtool --macro-prefix=gl --no-vc-files argp error fnmatch getdelim getline gettext progname regex +# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=grub-core/gnulib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-libtool --macro-prefix=gl --no-vc-files argp error fnmatch getdelim getline gettext progname regex stpcpy AUTOMAKE_OPTIONS = 1.5 gnits
@@ -859,6 +859,15 @@ ## end gnulib module stdlib +## begin gnulib module stpcpy + + +EXTRA_DIST += stpcpy.c + +EXTRA_libgnu_a_SOURCES += stpcpy.c + +## end gnulib module stpcpy + ## begin gnulib module strcase
=== added file 'grub-core/gnulib/stpcpy.c'
gnulib/stpcpy.c +49 -0
49 lines not on this page · raw message
=== modified file 'm4/gnulib-cache.m4'
gnulib-cache.m4 +2 -1
@@ -15,7 +15,7 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --lib=libgnu --source-base=grub-core/gnulib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-libtool --macro-prefix=gl --no-vc-files argp error fnmatch getdelim getline gettext progname regex +# gnulib-tool --import --dir=. --lib=libgnu --source-base=grub-core/gnulib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-libtool --macro-prefix=gl --no-vc-files argp error fnmatch getdelim getline gettext progname regex stpcpy # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([])
@@ -28,6 +28,7 @@ gettext progname regex + stpcpy ]) gl_AVOID([]) gl_SOURCE_BASE([grub-core/gnulib])
=== modified file 'm4/gnulib-comp.m4'
gnulib-comp.m4 +6 -0
@@ -73,6 +73,7 @@ # Code from module stdint: # Code from module stdio: # Code from module stdlib: + # Code from module stpcpy: # Code from module strcase: # Code from module strchrnul: # Code from module streq:
@@ -221,6 +222,9 @@ gl_STDIO_H # Code from module stdlib: gl_STDLIB_H + # Code from module stpcpy: + gl_FUNC_STPCPY + gl_STRING_MODULE_INDICATOR([stpcpy]) # Code from module strcase: gl_STRCASE # Code from module strchrnul:
@@ -482,6 +486,7 @@ lib/stdio-write.c lib/stdio.in.h lib/stdlib.in.h + lib/stpcpy.c lib/strcasecmp.c lib/strchrnul.c lib/strchrnul.valgrind
@@ -576,6 +581,7 @@ m4/stdint_h.m4 m4/stdio_h.m4 m4/stdlib_h.m4 + m4/stpcpy.m4 m4/strcase.m4 m4/strchrnul.m4 m4/strerror.m4
=== added file 'm4/stpcpy.m4'
stpcpy.m4 +26 -0
@@ -0,0 +1,26 @@ +# stpcpy.m4 serial 7 +dnl Copyright (C) 2002, 2007, 2009, 2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_STPCPY], +[ + dnl Persuade glibc <string.h> to declare stpcpy(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + dnl The stpcpy() declaration in lib/string.in.h uses 'restrict'. + AC_REQUIRE([AC_C_RESTRICT]) + + AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) + AC_REPLACE_FUNCS([stpcpy]) + if test $ac_cv_func_stpcpy = no; then + HAVE_STPCPY=0 + gl_PREREQ_STPCPY + fi +]) + +# Prerequisites of lib/stpcpy.c. +AC_DEFUN([gl_PREREQ_STPCPY], [ + : +])
Quoted 3 lines · Grégoire Sutre
The attached patch adds gnulib's stpcpy. This is required on systems lacking stpcpy, e.g., NetBSD 5.1.
Where do we need it? It may make more sense to just use grub_stpcpy in these places.
Quoted 11 lines
Note: I used gnulib's sources from 2010-09-20, since this is, afaics, the date of import of gnulib files in GRUB.
Grégoire
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 8 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 3 lines · Grégoire Sutre
The attached patch adds gnulib's stpcpy. This is required on systems lacking stpcpy, e.g., NetBSD 5.1.
Where do we need it? It may make more sense to just use
grub_stpcpyin these places.
Calls to a stpcpy appear a couple times in:
- util/grub-fstest.c
- util/grub-probe.c
- util/getroot.c [__linux__]
I agree that using grub_stpcpy is fine there. The benefit of importing gnulib's stpcpy is that it solves current calls to stpcpy, as well as the future ones (that might be added to GRUB).
There are also calls to stpcpy in:
- grub-core/lib/libgcrypt/cipher/pubkey.c
- grub-core/lib/libgcrypt/cipher/dsa.c
but they do not cause any problem (these files are not compiled afaics).
Grégoire