=?UTF-8?Q?Fr=C3=A9d=C3=A9ric=20Delanoy=20?=: cmd: Move common error reporting code in WCMD_if.

Alexandre Julliard julliard at winehq.org
Fri Oct 26 11:36:21 CDT 2012


Module: wine
Branch: master
Commit: dd1395442448ec73b6e16c89d8e9affd554a4e8b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=dd1395442448ec73b6e16c89d8e9affd554a4e8b

Author: Frédéric Delanoy <frederic.delanoy at gmail.com>
Date:   Thu Oct 25 23:48:00 2012 +0200

cmd: Move common error reporting code in WCMD_if.

---

 programs/cmd/builtins.c |   19 ++++++++-----------
 1 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index d13cb5c..ffdfe8d 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -2346,9 +2346,8 @@ void WCMD_popd (void) {
  *
  * FIXME: Much more syntax checking needed!
  */
-
-void WCMD_if (WCHAR *p, CMD_LIST **cmdList) {
-
+void WCMD_if (WCHAR *p, CMD_LIST **cmdList)
+{
   int negate; /* Negate condition */
   int test;   /* Condition evaluation result */
   WCHAR condition[MAX_PATH], *command, *s;
@@ -2368,10 +2367,7 @@ void WCMD_if (WCHAR *p, CMD_LIST **cmdList) {
     WCHAR *param = WCMD_parameter(p, 1+negate, NULL, FALSE, FALSE);
     WCHAR *endptr;
     long int param_int = strtolW(param, &endptr, 10);
-    if (*endptr) {
-      WCMD_output_stderr(WCMD_LoadMessage(WCMD_SYNTAXERR));
-      return;
-    }
+    if (*endptr) goto syntax_err;
     test = ((long int)errorlevel >= param_int);
     WCMD_parameter(p, 2+negate, &command, FALSE, FALSE);
   }
@@ -2401,14 +2397,15 @@ void WCMD_if (WCHAR *p, CMD_LIST **cmdList) {
                               rightPart, rightPartLen) == CSTR_EQUAL);
     WCMD_parameter(s, 1, &command, FALSE, FALSE);
   }
-  else {
-    WCMD_output_stderr(WCMD_LoadMessage(WCMD_SYNTAXERR));
-    return;
-  }
+  else goto syntax_err;
 
   /* Process rest of IF statement which is on the same line
      Note: This may process all or some of the cmdList (eg a GOTO) */
   WCMD_part_execute(cmdList, command, NULL, NULL, TRUE, (test != negate));
+  return;
+
+syntax_err:
+  WCMD_output_stderr(WCMD_LoadMessage(WCMD_SYNTAXERR));
 }
 
 /****************************************************************************




More information about the wine-cvs mailing list