Hello, scrīpsit markus schnalke <mei...@marmaro.de>:
| Work still to do: | | - There are some tests that fail. See: | http://marmaro.de/prog/mmh/nightly/tests-log/runalltests.log | * tests/ali/test-ali that's okay, we need to port code from nmh | * tests/bad-input/test-header adjust the testcase or m_getfld2()? | * tests/mhparam/test-mhparam ? | * tests/mhsign/test-mhsign (see above) | In the release, only the ali(1) test should still fail. With the attached patch, mhparam passes tests/mhparam/test-mhparam. I believe that mhparam was failing the test for two reasons. First, there was a spelling error in an error message that readconfig prints. sbr/readconfig.c says 75 advise(NULL, "%s is poorly formated", file); but test/tests/mhparam/test-mhparam says 138 mhparam: `cat test-temp-dir`/.mmh/profile2 is poorly formatted The second reason is, I believe, the following. 1. tests/mhparam/test-mhparam feeds mhparam an mmh profile file in which the "Editor" parameter is set on a line that lacks a new-line character; tests/mhparam/test-mhparam 134 # check with text file that does not end with newline 135 # in mmh this is invalid 136 printf 'Editor: emacs' >>"$MMHP" 137 runandcheck 'mhparam -nocomponent editor' <<! 138 mhparam: `cat test-temp-dir`/.mmh/profile2 is poorly formatted 139 ! 2. realizing that this line lacks a new-line character, m_getfld2 eventually returns FMTERR2 to readconfig; sbr/m_getfld2.c 43 enum state 44 m_getfld2(enum state s, struct field *f, FILE *msg) 45 { 46 char *tmpline = NULL; 47 size_t len = 0; 48 ssize_t nchars; 49 enum threestate falted = B_FALSE; 50 enum state ret = s; 51 52 switch (s) { 53 case FLD2: 54 nchars = getline(&tmpline, &len, msg); ... 69 if (*(tmpline + nchars - 1) != '\n') { 70 ret = FMTERR2; 71 } 3. readconfig, seeing FMTERR2, doesn't create a new node to store the "Editor" component and its value ("emacs") that m_getfld2 parsed from the mmh profile file; sbr/readconfig.c 36 void 37 readconfig(struct node **npp, FILE *ib, char *file, int ctx) 38 { 39 enum state state; 40 struct field f = {{0}}; 41 struct node *np; 42 struct procstr *ps; ... 50 switch (state = m_getfld2(state, &f, ib)) { ... 54 case FLD2: 55 np = mh_xcalloc(1, sizeof(*np)); 56 *npp = np; 57 *(npp = &np->n_next) = NULL; 58 np->n_name = mh_xstrdup(f.name); 59 np->n_field = trimcpy(f.value); 60 np->n_context = ctx; 61 62 /* 63 ** Now scan the list of `procs' and link in 64 ** the field value to the global variable. 65 */ 66 for (ps = procs; ps->procname; ps++) { 67 if (mh_strcasecmp(np->n_name, 68 ps->procname) == 0) { 69 *ps->procnaddr = np->n_field; 70 break; 71 } 72 } 73 continue; 74 case FMTERR2: 75 advise(NULL, "%s is poorly formated", file); 76 state = FLD2; 77 continue; 4. context_read later sets the editor manually, since it doesn't find one with context_find. sbr/context_read.c 35 void 36 context_read(void) 37 { ... 39 char *cp; /* miscellaneous pointer */ ... 181 /* Set editor */ 182 if (!(cp = getenv("MMHEDITOR")) || !*cp) { 183 if (!(cp = context_find("editor")) || !*cp) { 184 if (!(cp = getenv("VISUAL")) || !*cp) { 185 if (!(cp = getenv("EDITOR")) || !*cp) { 186 cp = defaulteditor; 187 } 188 } 189 } 190 } 191 defaulteditor = cp; Michael
diff --git a/sbr/readconfig.c b/sbr/readconfig.c index 45e1cb6..6253c23 100644 --- a/sbr/readconfig.c +++ b/sbr/readconfig.c @@ -72,7 +72,7 @@ readconfig(struct node **npp, FILE *ib, char *file, int ctx) } continue; case FMTERR2: - advise(NULL, "%s is poorly formated", file); + advise(NULL, "%s is poorly formatted", file); state = FLD2; continue; case BODY2: diff --git a/test/tests/mhparam/test-mhparam b/test/tests/mhparam/test-mhparam index 7f21be3..4b95500 100755 --- a/test/tests/mhparam/test-mhparam +++ b/test/tests/mhparam/test-mhparam @@ -134,9 +134,12 @@ al...@example.org, b...@example.net, cha...@example.comp # check with text file that does not end with newline # in mmh this is invalid printf 'Editor: emacs' >>"$MMHP" +export VISUAL=ed runandcheck 'mhparam -nocomponent editor' <<! mhparam: `cat test-temp-dir`/.mmh/profile2 is poorly formatted +$VISUAL ! +unset VISUAL exit