include strlcpy and *printf and use them
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14930 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
include $(top_srcdir)/Makefile.am.common
|
include $(top_srcdir)/Makefile.am.common
|
||||||
|
|
||||||
|
if do_roken_rename
|
||||||
|
ES = snprintf.c strlcpy.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
AM_CPPFLAGS += $(ROKEN_RENAME)
|
||||||
|
|
||||||
YFLAGS = -d
|
YFLAGS = -d
|
||||||
|
|
||||||
lib_LTLIBRARIES = libcom_err.la
|
lib_LTLIBRARIES = libcom_err.la
|
||||||
@@ -13,7 +19,7 @@ include_HEADERS = com_err.h com_right.h
|
|||||||
|
|
||||||
compile_et_SOURCES = compile_et.c compile_et.h parse.y lex.l
|
compile_et_SOURCES = compile_et.c compile_et.h parse.y lex.l
|
||||||
|
|
||||||
libcom_err_la_SOURCES = error.c com_err.c roken_rename.h
|
libcom_err_la_SOURCES = error.c com_err.c roken_rename.h $(ES)
|
||||||
|
|
||||||
CLEANFILES = lex.c parse.c parse.h
|
CLEANFILES = lex.c parse.c parse.h
|
||||||
|
|
||||||
@@ -22,3 +28,8 @@ $(compile_et_OBJECTS): parse.h parse.c ## XXX broken automake 1.4s
|
|||||||
compile_et_LDADD = \
|
compile_et_LDADD = \
|
||||||
$(LIB_roken) \
|
$(LIB_roken) \
|
||||||
$(LEXLIB)
|
$(LEXLIB)
|
||||||
|
|
||||||
|
snprintf.c:
|
||||||
|
$(LN_S) $(srcdir)/../roken/snprintf.c .
|
||||||
|
strlcpy.c:
|
||||||
|
$(LN_S) $(srcdir)/../roken/strlcpy.c .
|
||||||
|
@@ -51,15 +51,14 @@ error_message (long code)
|
|||||||
const char *p = com_right(_et_list, code);
|
const char *p = com_right(_et_list, code);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
if (code < 0)
|
if (code < 0)
|
||||||
sprintf(msg, "Unknown error %ld", code);
|
snprintf(msg, sizeof(msg), "Unknown error %ld", code);
|
||||||
else
|
else
|
||||||
p = strerror(code);
|
p = strerror(code);
|
||||||
}
|
}
|
||||||
if (p != NULL && *p != '\0') {
|
if (p != NULL && *p != '\0') {
|
||||||
strncpy(msg, p, sizeof(msg) - 1);
|
strlcpy(msg, p, sizeof(msg));
|
||||||
msg[sizeof(msg) - 1] = 0;
|
|
||||||
} else
|
} else
|
||||||
sprintf(msg, "Unknown error %ld", code);
|
snprintf(msg, sizeof(msg), "Unknown error %ld", code);
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -102,9 +102,8 @@ statement : INDEX NUMBER
|
|||||||
}
|
}
|
||||||
| PREFIX STRING
|
| PREFIX STRING
|
||||||
{
|
{
|
||||||
prefix = realloc(prefix, strlen($2) + 2);
|
free(prefix);
|
||||||
strcpy(prefix, $2);
|
asprintf (&prefix, "%s_", $2);
|
||||||
strcat(prefix, "_");
|
|
||||||
free($2);
|
free($2);
|
||||||
}
|
}
|
||||||
| PREFIX
|
| PREFIX
|
||||||
|
@@ -36,4 +36,27 @@
|
|||||||
#ifndef __roken_rename_h__
|
#ifndef __roken_rename_h__
|
||||||
#define __roken_rename_h__
|
#define __roken_rename_h__
|
||||||
|
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
#define snprintf _com_err_snprintf
|
||||||
|
#endif
|
||||||
|
#ifndef HAVE_VSNPRINTF
|
||||||
|
#define vsnprintf _com_err_vsnprintf
|
||||||
|
#endif
|
||||||
|
#ifndef HAVE_ASPRINTF
|
||||||
|
#define asprintf _com_err_asprintf
|
||||||
|
#endif
|
||||||
|
#ifndef HAVE_ASNPRINTF
|
||||||
|
#define asnprintf _com_err_asnprintf
|
||||||
|
#endif
|
||||||
|
#ifndef HAVE_VASPRINTF
|
||||||
|
#define vasprintf _com_err_vasprintf
|
||||||
|
#endif
|
||||||
|
#ifndef HAVE_VASNPRINTF
|
||||||
|
#define vasnprintf _com_err_vasnprintf
|
||||||
|
#endif
|
||||||
|
#ifndef HAVE_STRLCPY
|
||||||
|
#define strlcpy _com_err_strlcpy
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif /* __roken_rename_h__ */
|
#endif /* __roken_rename_h__ */
|
||||||
|
Reference in New Issue
Block a user