Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/lcms2/utils/common/xgetopt.c @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 | |
| 2 //--------------------------------------------------------------------------------- | |
| 3 // | |
| 4 // Little Color Management System | |
| 5 // Copyright (c) 1998-2023 Marti Maria Saguer | |
| 6 // | |
| 7 // Permission is hereby granted, free of charge, to any person obtaining | |
| 8 // a copy of this software and associated documentation files (the "Software"), | |
| 9 // to deal in the Software without restriction, including without limitation | |
| 10 // the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
| 11 // and/or sell copies of the Software, and to permit persons to whom the Software | |
| 12 // is furnished to do so, subject to the following conditions: | |
| 13 // | |
| 14 // The above copyright notice and this permission notice shall be included in | |
| 15 // all copies or substantial portions of the Software. | |
| 16 // | |
| 17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
| 18 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO | |
| 19 // THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
| 20 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | |
| 21 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | |
| 22 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
| 23 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
| 24 // | |
| 25 //--------------------------------------------------------------------------------- | |
| 26 // | |
| 27 // xgetopt.c -- loosely based on System V getopt() | |
| 28 // | |
| 29 // option ::= SW [optLetter]* [argLetter space* argument] | |
| 30 // | |
| 31 | |
| 32 #include <string.h> | |
| 33 #include <stdio.h> | |
| 34 | |
| 35 int xoptind = 1; | |
| 36 char *xoptarg; | |
| 37 | |
| 38 static char *nextArg = NULL; | |
| 39 | |
| 40 #define SW '-' | |
| 41 | |
| 42 | |
| 43 int xgetopt(int argc, char* argv[], char* optionS) | |
| 44 { | |
| 45 unsigned char ch; | |
| 46 char* optP; | |
| 47 | |
| 48 if (argc > xoptind) | |
| 49 { | |
| 50 | |
| 51 if (nextArg == NULL) | |
| 52 { | |
| 53 if ((nextArg = argv[xoptind]) == NULL || *(nextArg++) != SW) goto end_eof; | |
| 54 } | |
| 55 | |
| 56 if ((ch = *(nextArg++)) == 0) | |
| 57 { | |
| 58 xoptind++; | |
| 59 goto end_eof; | |
| 60 } | |
| 61 | |
| 62 if (ch == ':' || (optP = strchr(optionS, ch)) == NULL) | |
| 63 goto end_error; | |
| 64 | |
| 65 if (*(++optP) == ':') | |
| 66 { | |
| 67 xoptind++; | |
| 68 | |
| 69 if (*nextArg == 0) | |
| 70 { | |
| 71 if (argc <= xoptind) goto end_error; | |
| 72 nextArg = argv[xoptind++]; | |
| 73 } | |
| 74 | |
| 75 xoptarg = nextArg; | |
| 76 nextArg = NULL; | |
| 77 | |
| 78 } | |
| 79 else | |
| 80 { | |
| 81 if (*nextArg == 0) | |
| 82 { | |
| 83 xoptind++; | |
| 84 nextArg = NULL; | |
| 85 } | |
| 86 | |
| 87 xoptarg = NULL; | |
| 88 } | |
| 89 | |
| 90 return ch; | |
| 91 } | |
| 92 | |
| 93 end_eof: | |
| 94 xoptarg = nextArg = NULL; | |
| 95 return EOF; | |
| 96 | |
| 97 end_error: | |
| 98 xoptarg = NULL; | |
| 99 return '?'; | |
| 100 } |
