diff mbox series

%Z [PATCH v6]

Message ID 20230731142420.23766-1-lancasterharp@gmail.com
State New
Headers show
Series %Z [PATCH v6] | expand

Commit Message

Stanley Lancaster July 31, 2023, 2:24 p.m. UTC
---
 time/strptime_l.c   | 19 ++++++++++++++-----
 time/tst-strptime.c |  2 ++
 2 files changed, 16 insertions(+), 5 deletions(-)

Comments

Adhemerval Zanella Netto Aug. 2, 2023, 5:16 p.m. UTC | #1
Add a proper subject on each new version, the initial one you use should be
ok.

On 31/07/23 11:24, Stanley Lancaster via Libc-alpha wrote:
> ---
>  time/strptime_l.c   | 19 ++++++++++++++-----
>  time/tst-strptime.c |  2 ++
>  2 files changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/time/strptime_l.c b/time/strptime_l.c
> index 85c3249fcc..1b84065c19 100644
> --- a/time/strptime_l.c
> +++ b/time/strptime_l.c
> @@ -770,11 +770,20 @@ __strptime_internal (const char *rp, const char *fmt, struct tm *tmp,
>  	  break;
>  	case 'Z':
>  	  /* Read timezone but perform no conversion.  */
> -	  while (ISSPACE (*rp))
> -	    rp++;
> -	  while (!ISSPACE (*rp) && *rp != '\0')
> -	    rp++;
> -	  break;
> +		{
> +			while (ISSPACE (*rp))
> +	    	rp++;
> +			/* Read timezone but perform no conversion.  */
> +			/* we recognize the format [-+a-zA-Z0-9]{3,} */
> +			const char* start_rp = rp;
> +
> +			while ((*rp >= 'A' && *rp <= 'Z') || 
> +				(*rp >= 'a' && *rp <= 'z') || 
> +				(*rp >= '0' && *rp <= '9'))
> +				rp++;
> +			if (start_rp+3 < rp)
> +				return NULL;

Indentation is off here, along with style.  It should be like:

         {
           while (ISSPACE (*rp))
             rp++;
           const char* start_rp = rp;
           while ((*rp >= 'A' && *rp <= 'Z')
                  || (*rp >= 'a' && *rp <= 'z')
                  || (*rp >= 'a' && *rp <= 'z'))
             rp++;
           if (start_rp+3 < rp)
             return NULL;
         }
         break;

> +		}

Missing break here, I am not sure it haven't triggered any regression failure
on your side.  At least aarch64 bot did trigger the CI failure.

>  	case 'z':
>  	  /* We recognize four formats:
>  	     1. Two digits specify hours.
> diff --git a/time/tst-strptime.c b/time/tst-strptime.c
> index 3dae9e0594..40145cb109 100644
> --- a/time/tst-strptime.c
> +++ b/time/tst-strptime.c
> @@ -48,6 +48,8 @@ static const struct
>      6, 0, 0, 1 },
>    { "en_US.ISO-8859-1", "2000-01-01 08:12:21 PM", "%Y-%m-%d %I:%M:%S %p",
>      6, 0, 0, 1 },
> +  { "en_US.ISO-8859-1", "2000-01-01 08:12:21 AM CST/", "%Y-%m-%d %I:%M:%S %p %Z/", 

Extra end of line whitespace.

> +    6, 0, 0, 1},
>    { "ja_JP.EUC-JP", "2001 20 \xb7\xee", "%Y %U %a", 1, 140, 4, 21 },
>    { "ja_JP.EUC-JP", "2001 21 \xb7\xee", "%Y %W %a", 1, 140, 4, 21 },
>    /* Most of the languages do not need the declension of the month names
Carlos O'Donell Aug. 14, 2023, 1:48 p.m. UTC | #2
On 7/31/23 10:24, Stanley Lancaster via Libc-alpha wrote:
> ---
>  time/strptime_l.c   | 19 ++++++++++++++-----
>  time/tst-strptime.c |  2 ++
>  2 files changed, 16 insertions(+), 5 deletions(-)

This fails pre-commit CI for i686, arm, and aarch64:

https://patchwork.sourceware.org/project/glibc/patch/20230731142420.23766-1-lancasterharp@gmail.com/

Please have a look at the regressions.

Please make sure you test with `make check` and review the results.

> 
> diff --git a/time/strptime_l.c b/time/strptime_l.c
> index 85c3249fcc..1b84065c19 100644
> --- a/time/strptime_l.c
> +++ b/time/strptime_l.c
> @@ -770,11 +770,20 @@ __strptime_internal (const char *rp, const char *fmt, struct tm *tmp,
>  	  break;
>  	case 'Z':
>  	  /* Read timezone but perform no conversion.  */
> -	  while (ISSPACE (*rp))
> -	    rp++;
> -	  while (!ISSPACE (*rp) && *rp != '\0')
> -	    rp++;
> -	  break;
> +		{
> +			while (ISSPACE (*rp))
> +	    	rp++;
> +			/* Read timezone but perform no conversion.  */
> +			/* we recognize the format [-+a-zA-Z0-9]{3,} */
> +			const char* start_rp = rp;
> +
> +			while ((*rp >= 'A' && *rp <= 'Z') || 
> +				(*rp >= 'a' && *rp <= 'z') || 
> +				(*rp >= '0' && *rp <= '9'))
> +				rp++;
> +			if (start_rp+3 < rp)
> +				return NULL;
> +		}
>  	case 'z':
>  	  /* We recognize four formats:
>  	     1. Two digits specify hours.
> diff --git a/time/tst-strptime.c b/time/tst-strptime.c
> index 3dae9e0594..40145cb109 100644
> --- a/time/tst-strptime.c
> +++ b/time/tst-strptime.c
> @@ -48,6 +48,8 @@ static const struct
>      6, 0, 0, 1 },
>    { "en_US.ISO-8859-1", "2000-01-01 08:12:21 PM", "%Y-%m-%d %I:%M:%S %p",
>      6, 0, 0, 1 },
> +  { "en_US.ISO-8859-1", "2000-01-01 08:12:21 AM CST/", "%Y-%m-%d %I:%M:%S %p %Z/", 
> +    6, 0, 0, 1},
>    { "ja_JP.EUC-JP", "2001 20 \xb7\xee", "%Y %U %a", 1, 140, 4, 21 },
>    { "ja_JP.EUC-JP", "2001 21 \xb7\xee", "%Y %W %a", 1, 140, 4, 21 },
>    /* Most of the languages do not need the declension of the month names
diff mbox series

Patch

diff --git a/time/strptime_l.c b/time/strptime_l.c
index 85c3249fcc..1b84065c19 100644
--- a/time/strptime_l.c
+++ b/time/strptime_l.c
@@ -770,11 +770,20 @@  __strptime_internal (const char *rp, const char *fmt, struct tm *tmp,
 	  break;
 	case 'Z':
 	  /* Read timezone but perform no conversion.  */
-	  while (ISSPACE (*rp))
-	    rp++;
-	  while (!ISSPACE (*rp) && *rp != '\0')
-	    rp++;
-	  break;
+		{
+			while (ISSPACE (*rp))
+	    	rp++;
+			/* Read timezone but perform no conversion.  */
+			/* we recognize the format [-+a-zA-Z0-9]{3,} */
+			const char* start_rp = rp;
+
+			while ((*rp >= 'A' && *rp <= 'Z') || 
+				(*rp >= 'a' && *rp <= 'z') || 
+				(*rp >= '0' && *rp <= '9'))
+				rp++;
+			if (start_rp+3 < rp)
+				return NULL;
+		}
 	case 'z':
 	  /* We recognize four formats:
 	     1. Two digits specify hours.
diff --git a/time/tst-strptime.c b/time/tst-strptime.c
index 3dae9e0594..40145cb109 100644
--- a/time/tst-strptime.c
+++ b/time/tst-strptime.c
@@ -48,6 +48,8 @@  static const struct
     6, 0, 0, 1 },
   { "en_US.ISO-8859-1", "2000-01-01 08:12:21 PM", "%Y-%m-%d %I:%M:%S %p",
     6, 0, 0, 1 },
+  { "en_US.ISO-8859-1", "2000-01-01 08:12:21 AM CST/", "%Y-%m-%d %I:%M:%S %p %Z/", 
+    6, 0, 0, 1},
   { "ja_JP.EUC-JP", "2001 20 \xb7\xee", "%Y %U %a", 1, 140, 4, 21 },
   { "ja_JP.EUC-JP", "2001 21 \xb7\xee", "%Y %W %a", 1, 140, 4, 21 },
   /* Most of the languages do not need the declension of the month names