summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@redhat.com>2009-04-02 18:44:34 -0400
committerMasami Hiramatsu <mhiramat@redhat.com>2009-04-02 18:44:34 -0400
commitb9e80fe13706ae1c820e565e9b26f00b5f5a8dca (patch)
treee66a847f51f97a299d43f09403fc8d7045bd0c62
parent5aa1f218c5ff8a459c324ac64ee7a9b8046e683d (diff)
downloadsystemtap-steved-b9e80fe13706ae1c820e565e9b26f00b5f5a8dca.tar.gz
systemtap-steved-b9e80fe13706ae1c820e565e9b26f00b5f5a8dca.tar.xz
systemtap-steved-b9e80fe13706ae1c820e565e9b26f00b5f5a8dca.zip
Fix strftime format bug
This fixes bugs in strftime-subset function. This modifies %C, %l and %j to fit the output of date command.
-rw-r--r--runtime/staprun/common.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/runtime/staprun/common.c b/runtime/staprun/common.c
index 8200ec9d..26b166c2 100644
--- a/runtime/staprun/common.c
+++ b/runtime/staprun/common.c
@@ -82,7 +82,7 @@ int stap_strfloctime(char *buf, size_t max, const char *fmt, time_t t)
num = tm.tm_year % 100;
goto numbering02;
case 'C':
- num = ((tm.tm_year + 1900 - 1) / 100) + 1;
+ num = ((tm.tm_year + 1900) / 100);
goto numbering;
case 'm':
num = tm.tm_mon + 1;
@@ -107,7 +107,7 @@ int stap_strfloctime(char *buf, size_t max, const char *fmt, time_t t)
if (num == 0) num = 12;
goto numbering02;
case 'j':
- ret = snprintf(c, end - c, "%03d", tm.tm_yday);
+ ret = snprintf(c, end - c, "%03d", tm.tm_yday + 1);
if (ret < 0) return ret;
c += ret;
break;
@@ -117,7 +117,10 @@ int stap_strfloctime(char *buf, size_t max, const char *fmt, time_t t)
case 'l':
num = tm.tm_hour % 12;
if (num == 0) num = 12;
- goto numbering;
+ ret = snprintf(c, end - c, "%2d", num);
+ if (ret < 0) return ret;
+ c += ret;
+ break;
case 'M':
num = tm.tm_min;
goto numbering02;