Sfoglia il codice sorgente

Added total lenght of the parameters, including = and ""

Jan Janak 22 anni fa
parent
commit
cdc9fcf8b3
2 ha cambiato i file con 6 aggiunte e 1 eliminazioni
  1. 5 1
      parser/parse_param.c
  2. 1 0
      parser/parse_param.h

+ 5 - 1
parser/parse_param.c

@@ -318,10 +318,14 @@ int parse_params(str* _s, pclass_t _c, param_hooks_t* _h, param_t** _p)
 				goto error;
 			}
 
+			t->len = _s->s - t->name.s;
+
 			trim_leading(_s);
 			if (_s->len == 0) {
 				goto ok;
 			}
+		} else {
+			t->len = _s-s - t->name.s;
 		}
 
 		if (_s->s[0] == ',') goto ok; /* To be able to parse header parameters */
@@ -394,7 +398,7 @@ static inline void print_param(param_t* _p)
 	printf("type: %s\n", type);
 	printf("name: \'%.*s\'\n", _p->name.len, _p->name.s);
 	printf("body: \'%.*s\'\n", _p->body.len, _p->body.s);
-	
+	printf("len : %d\n", _p->len);
 	printf("---/param---\n");
 }
 

+ 1 - 0
parser/parse_param.h

@@ -65,6 +65,7 @@ typedef struct param {
 	ptype_t type;         /* Type of the parameter */
 	str name;             /* Parameter name */
 	str body;             /* Parameter body */
+	int len;              /* Total lenght of the parameter including = and quotes */
 	struct param* next;   /* Next parameter in the list */
 } param_t;