Skip to content

Commit

Permalink
reuse argcmp
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Gatto <[email protected]>
  • Loading branch information
outscale-mgo committed Jul 29, 2024
1 parent 0a5617f commit ac8968e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions cognac_gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ ${indent_plus} } else {
${indent_plus} TRY(!aa, "$a argument missing\n");
${indent_plus} s->${snake_a}_str = aa;
${indent_plus} }
$indent_base } else if (!(aret = strcmp(str, "$a[]")) || aret == '=') {
$indent_base } else if (!(aret = argcmp(str, "$a[]")) || aret == '=') {
${indent_plus} TRY(!aa, "$a[] argument missing\n");
${indent_plus} SET_NEXT(s->${snake_a}, ${convertor}(aa), pa);
$indent_base } else
Expand Down Expand Up @@ -311,7 +311,7 @@ EOF
t=$(get_type2 "$s" "$a")
snake_n=$(to_snakecase <<< $a)

echo " if ((aret = strcmp(str, \"$a\")) == 0 || aret == '=' || aret == '.') {"
echo " if ((aret = argcmp(str, \"$a\")) == 0 || aret == '=' || aret == '.') {"
cli_c_type_parser "$a" "$t" " "
done
cat <<EOF
Expand Down Expand Up @@ -385,7 +385,7 @@ EOF
snake_a=$(to_snakecase <<< $a)

cat <<EOF
if ((aret = strcmp(next_a, "$a")) == 0 || aret == '=' || aret == '.') {
if ((aret = argcmp(next_a, "$a")) == 0 || aret == '=' || aret == '.') {
char *eq_ptr = strchr(next_a, '=');
if (eq_ptr) {
TRY((!*eq_ptr), "$a argument missing\n");
Expand Down
6 changes: 5 additions & 1 deletion main_tpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ static int argcmp2(const char *s1, const char *s2, char dst)

static int argcmp(const char *s1, const char *s2)
{
return argcmp2(s1, s2, '.');
while (*s1 == *s2 && *s1 && *s2) {
s1++;
s2++;
}
return *s1 - *s2;
}

#define MAX_FILES_PER_CMD 64
Expand Down

0 comments on commit ac8968e

Please sign in to comment.