Subject: one more patch (menu position hints)

From: Dominik Vogt <[email-masked]>
Date: Wed, 10 Feb 1999 23:25:23 +0100

--- misc.c.orig	Wed Jan 27 20:11:50 1999
+++ misc.c	Wed Feb 10 23:09:08 1999
@@ -473,38 +473,49 @@
 char *GetOneMenuPositionArgument(char *action,int x,int w,int *pFinalX,
 				 float *width_factor)
 {
-  char *token, *naction;
+  char *token, *orgtoken, *naction;
+  char c;
   int val;
-  int length;
+  int chars;
   float factor = (float)w/100;
 
   naction = GetNextToken(action, &token);
   if (token == NULL)
     return action;
-  length = strlen(token);
-  if (token[length-1] == 'p') {
-    factor = 1;  /* Use pixels, so don't multiply by factor */
-    token[length-1] = '\0';
+  orgtoken = token;
+  *pFinalX = x;
+  *width_factor = 0;
+  if (sscanf(token,"o%d%n", &val, &chars) >= 1) {
+    token += chars;
+    *pFinalX += val*factor;
+    *width_factor -= val/100;
+  } else if (token[0] == 'c') {
+    token++;
+    *pFinalX += w/2;
+    *width_factor -= 0.5;
   }
-  if (strcmp(token,"c") == 0) {
-    *pFinalX = x + ((float)w)/2;
-    *width_factor = -0.5;
-  } else if (sscanf(token,"c-%d",&val) == 1) {
-    *pFinalX = x + ((float)w)/2 - val*factor;
-    *width_factor = -0.5;
-  } else if (sscanf(token,"c+%d",&val) == 1) {
-    *pFinalX = x + ((float)w)/2 + val*factor;
-    *width_factor = -0.5;
-  } else if (sscanf(token,"-%d",&val) == 1) {
-    *pFinalX = x + w - val*factor;
-    *width_factor = -1;
-  } else if (sscanf(token,"%d",&val) == 1) {
-    *pFinalX = x + val*factor;
-    *width_factor = 0;
-  } else {
-    naction = action;
+  while (*token != 0) {
+    if (sscanf(token,"%d%n", &val, &chars) >= 1) {
+      token += chars;
+      if (sscanf(token,"%c", &c) == 1) {
+	if (c == 'm') {
+	  token++;
+	  *width_factor += val/100;
+	} else if (c == 'p') {
+	  token++;
+	  *pFinalX += val;
+	} else {
+	  *pFinalX += val*factor;
+	}
+      } else {
+	*pFinalX += val*factor;
+      }
+    } else {
+      naction = action;
+      break;
+    }
   }
-  free(token);
+  free(orgtoken);
   return naction;
 }