+int convert_numeric_option(char opt, int min_value)
+{
+ int value;
+ char *ptr;
+
+ value = strtol(optarg, &ptr, 0);
+ if(value<min_value || *ptr)
+ {
+ printf("Invalid option argument in -%c %s\n", opt, optarg);
+ exit(1);
+ }
+
+ return value;
+}
+
+void convert_code_point_range(char opt, int *begin, int *end)
+{
+ char *ptr;
+
+ if(!strcmp(optarg, "all"))
+ {
+ *begin = 0;
+ *end = 0x10FFFF;
+ return;
+ }
+
+ *begin = strtol(optarg, &ptr, 0);
+ if(*begin>0 && *ptr==',')
+ {
+ *end = strtol(ptr+1, &ptr, 0);
+ if(*end>0 && !*ptr)
+ return;
+ }
+
+ printf("Invalid option argument in -%c %s\n", opt, optarg);
+ exit(1);
+}
+
+void convert_size(char opt, int *width, int *height)
+{
+ char *ptr;
+
+ if(!strcmp(optarg, "auto"))
+ {
+ *width = 0;
+ *height = 0;
+ return;
+ }
+ else if(!strcmp(optarg, "autorect"))
+ {
+ *width = 0;
+ *height = 1;
+ return;
+ }
+
+ *width = strtol(optarg, &ptr, 0);
+ if(*width>0)
+ {
+ if(*ptr=='x')
+ {
+ *height = strtol(ptr+1, &ptr, 0);
+ if(*height>0 && !*ptr)
+ return;
+ }
+ else if(!*ptr)
+ {
+ *height = *width;
+ return;
+ }
+ }
+
+ printf("Invalid option argument in -%c %s\n", opt, optarg);
+ exit(1);
+}
+