bug-gperf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gperf] Bug in in_word_set GNU gperf 3.0.4


From: Hor Meng Yoong
Subject: [bug-gperf] Bug in in_word_set GNU gperf 3.0.4
Date: Sun, 20 Jul 2014 22:50:00 +0800

Hi:

I use this code: calendar.gperf

%{
#include <stdio.h>
#include <string.h>
/* Command-line options:
-C -p -a -n -t -o -j 1 -k 2,3
-N is_month */
%}
struct months {
  char *name;
  int number;
  int days;
  int leap_days;
};
%%
january,   1, 31, 31
february,  2, 28, 29
march,     3, 31, 31
april,     4, 30, 30
may,       5, 31, 31
june,      6, 30, 30
july,      7, 31, 31
august,    8, 31, 31
september, 9, 30, 30
october,  10, 31, 31
november, 11, 30, 30
december, 12, 31, 31
%%
/* Auxiliary code goes here... */
int main () {
  int hash_value = hash("may", sizeof("may"));
  printf("Hash value of may is %d\n", hash_value);
  printf("may is in hash function = %s", in_word_set("may", sizeof("may")));
}

$ gperf calendar.gperf > calendar.c
$ gcc -o calendar calendar.c
$ ./calendar
Hash value of may is 4
may is in hash function = (null)


The suspected bugs
  1. "May" is the 3rd index of wordlist[]. So it should be 3?
  2. The in_word_set() could not find the "may". If the wordlist[key-1] is used, may could be found.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]