changeset 5:c79d09284c5f

encode_phone_number_arg(): don't print to stderr, just return -1 on errors
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 05 Aug 2023 03:20:11 +0000
parents d88c5ab03447
children b831ee7d512c
files libcoding/number_encode.c
diffstat 1 files changed, 5 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libcoding/number_encode.c	Sat Aug 05 03:17:09 2023 +0000
+++ b/libcoding/number_encode.c	Sat Aug 05 03:20:11 2023 +0000
@@ -68,19 +68,15 @@
 		cp++;
 	} else
 		fixp[1] = 0x81;
-	if (digit_char_to_gsm(*cp) < 0) {
-inv_arg:	fprintf(stderr, "error: invalid phone number argument\n");
+	if (digit_char_to_gsm(*cp) < 0)
 		return(-1);
-	}
 	for (ndigits = 0; ; ndigits++) {
 		c = digit_char_to_gsm(*cp);
 		if (c < 0)
 			break;
 		cp++;
-		if (ndigits >= 20) {
-			fprintf(stderr, "error: too many number digits\n");
+		if (ndigits >= 20)
 			return(-1);
-		}
 		digits[ndigits] = c;
 	}
 	if (mode)
@@ -94,11 +90,11 @@
 	if (*cp == ',') {
 		cp++;
 		if (!isdigit(*cp))
-			goto inv_arg;
+			return(-1);
 		fixp[1] = strtoul(cp, &endp, 0);
 		if (*endp)
-			goto inv_arg;
+			return(-1);
 	} else if (*cp)
-		goto inv_arg;
+		return(-1);
 	return(0);
 }