@@ -585,10 +585,11 @@ CoordinateInputType coordinateIdentifyInputType(const char *userEntryOriginal, d
585585 {
586586 coordinateInputType = COORDINATE_INPUT_TYPE_DD_MM_DASH;
587587
588- char *token = strtok (userEntry, " -" ); // Modifies the given array
588+ char *preservedPointer;
589+ char *token = strtok_r (userEntry, " -" , &preservedPointer); // Modifies the given array
589590 // We trust that token points at something because the dashCount is > 0
590591 int decimal = atoi (token); // Get DD
591- token = strtok (nullptr , " -" );
592+ token = strtok_r (nullptr , " -" , &preservedPointer );
592593 double minutes = atof (token); // Get MM.mmmmmmm
593594 *coordinate = decimal + (minutes / 60.0 );
594595 if (negativeSign)
@@ -598,12 +599,13 @@ CoordinateInputType coordinateIdentifyInputType(const char *userEntryOriginal, d
598599 {
599600 coordinateInputType = COORDINATE_INPUT_TYPE_DD_MM_SS_DASH;
600601
601- char *token = strtok (userEntry, " -" ); // Modifies the given array
602+ char *preservedPointer;
603+ char *token = strtok_r (userEntry, " -" , &preservedPointer); // Modifies the given array
602604 // We trust that token points at something because the spaceCount is > 0
603605 int decimal = atoi (token); // Get DD
604- token = strtok (nullptr , " -" );
606+ token = strtok_r (nullptr , " -" , &preservedPointer );
605607 int minutes = atoi (token); // Get MM
606- token = strtok (nullptr , " -" );
608+ token = strtok_r (nullptr , " -" , &preservedPointer );
607609
608610 // Find '.'
609611 char *decimalPtr = strchr (token, ' .' );
@@ -626,10 +628,11 @@ CoordinateInputType coordinateIdentifyInputType(const char *userEntryOriginal, d
626628 {
627629 coordinateInputType = COORDINATE_INPUT_TYPE_DD_MM;
628630
629- char *token = strtok (userEntry, " " ); // Modifies the given array
631+ char *preservedPointer;
632+ char *token = strtok_r (userEntry, " " , &preservedPointer); // Modifies the given array
630633 // We trust that token points at something because the spaceCount is > 0
631634 int decimal = atoi (token); // Get DD
632- token = strtok (nullptr , " " );
635+ token = strtok_r (nullptr , " " , &preservedPointer );
633636 double minutes = atof (token); // Get MM.mmmmmmm
634637 *coordinate = decimal + (minutes / 60.0 );
635638 if (negativeSign)
@@ -639,12 +642,13 @@ CoordinateInputType coordinateIdentifyInputType(const char *userEntryOriginal, d
639642 {
640643 coordinateInputType = COORDINATE_INPUT_TYPE_DD_MM_SS;
641644
642- char *token = strtok (userEntry, " " ); // Modifies the given array
645+ char *preservedPointer;
646+ char *token = strtok_r (userEntry, " " , &preservedPointer); // Modifies the given array
643647 // We trust that token points at something because the spaceCount is > 0
644648 int decimal = atoi (token); // Get DD
645- token = strtok (nullptr , " " );
649+ token = strtok_r (nullptr , " " , &preservedPointer );
646650 int minutes = atoi (token); // Get MM
647- token = strtok (nullptr , " " );
651+ token = strtok_r (nullptr , " " , &preservedPointer );
648652
649653 // Find '.'
650654 char *decimalPtr = strchr (token, ' .' );
0 commit comments