summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--NEWS1
-rw-r--r--src/lib/ecore/Ecore_Getopt.h13
-rw-r--r--src/lib/ecore/ecore_getopt.c29
4 files changed, 46 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index e9353a4601..2658538090 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
12012-12-10 Gustavo Sverzut Barbieri (k-s)
2
3 * Added ECORE_GETOPT_ACTION_BREAK to force breaking out of argument
4 parsing logic (will behabe same as GNU's "--", useful for xterm -e)
5
12012-12-07 Cedric Bail 62012-12-07 Cedric Bail
2 7
3 * Don't leak fd on exec. 8 * Don't leak fd on exec.
diff --git a/NEWS b/NEWS
index a691df2710..2c735fa90b 100644
--- a/NEWS
+++ b/NEWS
@@ -38,6 +38,7 @@ Additions:
38 - Add window profile support. 38 - Add window profile support.
39 * ecore_evas_buffer: 39 * ecore_evas_buffer:
40 - Add window profile support. 40 - Add window profile support.
41 * ecore_getopt: add ECORE_GETOPT_ACTION_BREAK
41 42
42Deprecations: 43Deprecations:
43 * ecore_x: 44 * ecore_x:
diff --git a/src/lib/ecore/Ecore_Getopt.h b/src/lib/ecore/Ecore_Getopt.h
index 0a11787d4d..3574ba5bfa 100644
--- a/src/lib/ecore/Ecore_Getopt.h
+++ b/src/lib/ecore/Ecore_Getopt.h
@@ -64,7 +64,8 @@ typedef enum {
64 ECORE_GETOPT_ACTION_HELP, 64 ECORE_GETOPT_ACTION_HELP,
65 ECORE_GETOPT_ACTION_VERSION, 65 ECORE_GETOPT_ACTION_VERSION,
66 ECORE_GETOPT_ACTION_COPYRIGHT, 66 ECORE_GETOPT_ACTION_COPYRIGHT,
67 ECORE_GETOPT_ACTION_LICENSE 67 ECORE_GETOPT_ACTION_LICENSE,
68 ECORE_GETOPT_ACTION_BREAK
68} Ecore_Getopt_Action; 69} Ecore_Getopt_Action;
69 70
70typedef enum { 71typedef enum {
@@ -369,6 +370,16 @@ struct _Ecore_Getopt
369 ECORE_GETOPT_ACTION_LICENSE, \ 370 ECORE_GETOPT_ACTION_LICENSE, \
370 {.dummy = NULL}} 371 {.dummy = NULL}}
371 372
373#define ECORE_GETOPT_BREAK(shortname, longname) \
374 {shortname, longname, "stop parsing options.", NULL, \
375 ECORE_GETOPT_ACTION_BREAK, \
376 {.dummy = NULL}}
377
378#define ECORE_GETOPT_BREAK_STR(shortname, longname, help) \
379 {shortname, longname, help, NULL, \
380 ECORE_GETOPT_ACTION_BREAK, \
381 {.dummy = NULL}}
382
372#define ECORE_GETOPT_SENTINEL {0, NULL, NULL, NULL, 0, {.dummy = NULL}} 383#define ECORE_GETOPT_SENTINEL {0, NULL, NULL, NULL, 0, {.dummy = NULL}}
373 384
374#define ECORE_GETOPT_VALUE_STR(val) {.strp = &(val)} 385#define ECORE_GETOPT_VALUE_STR(val) {.strp = &(val)}
diff --git a/src/lib/ecore/ecore_getopt.c b/src/lib/ecore/ecore_getopt.c
index 42e43e8915..f31f7c2290 100644
--- a/src/lib/ecore/ecore_getopt.c
+++ b/src/lib/ecore/ecore_getopt.c
@@ -763,19 +763,26 @@ _ecore_getopt_parse_find_nonargs_base(const Ecore_Getopt *parser,
763 char **argv) 763 char **argv)
764{ 764{
765 char **nonargs; 765 char **nonargs;
766 int src, dst, used, base; 766 int src, dst, used, base, abreak;
767 767
768 nonargs = alloca(sizeof(char *) * argc); 768 nonargs = alloca(sizeof(char *) * argc);
769 src = 1; 769 src = 1;
770 dst = 1; 770 dst = 1;
771 used = 0; 771 used = 0;
772 base = 0; 772 base = 0;
773 abreak = 0;
773 while (src < argc) 774 while (src < argc)
774 { 775 {
775 const Ecore_Getopt_Desc *desc; 776 const Ecore_Getopt_Desc *desc;
776 Ecore_Getopt_Desc_Arg_Requirement arg_req; 777 Ecore_Getopt_Desc_Arg_Requirement arg_req;
777 char *arg = argv[src]; 778 char *arg = argv[src];
778 779
780 if (abreak)
781 {
782 base = 1;
783 break;
784 }
785
779 if (arg[0] != '-') 786 if (arg[0] != '-')
780 goto found_nonarg; 787 goto found_nonarg;
781 788
@@ -806,6 +813,11 @@ _ecore_getopt_parse_find_nonargs_base(const Ecore_Getopt *parser,
806 goto found_nonarg; 813 goto found_nonarg;
807 } 814 }
808 815
816
817
818 if (desc->action == ECORE_GETOPT_ACTION_BREAK)
819 abreak = 1;
820
809 if (src != dst) 821 if (src != dst)
810 argv[dst] = argv[src]; 822 argv[dst] = argv[src];
811 src++; 823 src++;
@@ -1408,6 +1420,18 @@ _ecore_getopt_parse_license(const Ecore_Getopt *parser,
1408} 1420}
1409 1421
1410static Eina_Bool 1422static Eina_Bool
1423_ecore_getopt_parse_break(const Ecore_Getopt *parser EINA_UNUSED,
1424 const Ecore_Getopt_Desc *desc EINA_UNUSED,
1425 Ecore_Getopt_Value *val,
1426 const char *arg_val EINA_UNUSED)
1427{
1428 if (val->boolp)
1429 (*val->boolp) = EINA_TRUE;
1430
1431 return EINA_TRUE;
1432}
1433
1434static Eina_Bool
1411_ecore_getopt_desc_handle(const Ecore_Getopt *parser, 1435_ecore_getopt_desc_handle(const Ecore_Getopt *parser,
1412 const Ecore_Getopt_Desc *desc, 1436 const Ecore_Getopt_Desc *desc,
1413 Ecore_Getopt_Value *value, 1437 Ecore_Getopt_Value *value,
@@ -1451,6 +1475,9 @@ _ecore_getopt_desc_handle(const Ecore_Getopt *parser,
1451 case ECORE_GETOPT_ACTION_LICENSE: 1475 case ECORE_GETOPT_ACTION_LICENSE:
1452 return _ecore_getopt_parse_license(parser, desc, value, arg_val); 1476 return _ecore_getopt_parse_license(parser, desc, value, arg_val);
1453 1477
1478 case ECORE_GETOPT_ACTION_BREAK:
1479 return _ecore_getopt_parse_break(parser, desc, value, arg_val);
1480
1454 default: 1481 default:
1455 return EINA_FALSE; 1482 return EINA_FALSE;
1456 } 1483 }