Donny9 commented on code in PR #6783:
URL: https://github.com/apache/incubator-nuttx/pull/6783#discussion_r998800066


##########
libs/libc/time/lib_localtime.c:
##########
@@ -611,168 +700,229 @@ static int tzload(FAR const char *name,
     }
 
   nread = _NX_READ(fid, up->buf, sizeof up->buf);

Review Comment:
   Done!



##########
libs/libc/time/lib_localtime.c:
##########
@@ -794,62 +944,123 @@ static int tzload(FAR const char *name,
       sp->typecnt + 2 <= TZ_MAX_TYPES)
     {
       FAR struct state_s *ts = &lsp->u.st;
-      int result;
 
       up->buf[nread - 1] = '\0';
-      result = tzparse(&up->buf[1], ts, FALSE);
-      if (result == 0 && ts->typecnt == 2 &&
-          sp->charcnt + ts->charcnt <= TZ_MAX_CHARS)
-        {
-          for (i = 0; i < 2; ++i)
-            {
-              ts->ttis[i].tt_abbrind += sp->charcnt;
-            }
+      if (tzparse(&up->buf[1], ts, sp) == 0)
+        {
+          /* Attempt to reuse existing abbreviations.
+           * Without this, America/Anchorage would be right on
+           * the edge after 2037 when TZ_MAX_CHARS is 50, as
+           * sp->charcnt equals 40 (for LMT AST AWT APT AHST
+           * AHDT YST AKDT AKST) and ts->charcnt equals 10
+           * (for AKST AKDT).  Reusing means sp->charcnt can
+           * stay 40 in this example.
+           */
 
-          for (i = 0; i < ts->charcnt; ++i)
+          int gotabbr = 0;
+          int charcnt = sp->charcnt;
+          for (i = 0; i < ts->typecnt; i++)
             {
-              sp->chars[sp->charcnt++] = ts->chars[i];
-            }
+              char *tsabbr = ts->chars + ts->ttis[i].tt_desigidx;

Review Comment:
   Done!



##########
libs/libc/time/lib_localtime.c:
##########
@@ -1768,13 +2053,14 @@ static FAR struct tm *gmtsub(FAR const time_t *timep,
   if (!g_gmt_isset)
     {
 #ifndef __KERNEL__
-      if (up_interrupt_context())
+      if (up_interrupt_context() || (sched_idletask() && OSINIT_IDLELOOP()))
         {
           return NULL;
         }
 #endif
 
-      nxmutex_lock(&g_gmt_lock);
+      nxrmutex_lock(&g_gmt_lock);
+
       if (!g_gmt_isset)
         {
           g_gmt_ptr = lib_malloc(sizeof *g_gmt_ptr);

Review Comment:
   Done!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to