1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
//------------------------------------------------------------------------------
// gb_find_dot: find the first two occurences of '.' in a string
//------------------------------------------------------------------------------
// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//------------------------------------------------------------------------------
// s has the form 'plus.times.double' for a semiring, or 'plus.single' for a
// binary operator, or 'abs.int8' for a unary operator. In all such cases, one
// or two dots ('.') must be found. If no dots are found, position [0] and [1]
// are both -1. If one dot is found, s [position [0]] == '.', and position [1]
// is -1. If two dots are found, s [position [0]] == '.' is the first dot, and
// s [position [1]] == '.' is the second.
#include "gb_interface.h"
void gb_find_dot // find 1st and 2nd dot ('.') in a string
(
int32_t position [2], // positions of one or two dots
const char *s // null-terminated string to search
)
{
position [0] = -1 ;
position [1] = -1 ;
for (int32_t k = 0 ; s [k] != '\0' ; k++)
{
if (s [k] == '.')
{
if (position [0] == -1)
{
// first dot has been found
position [0] = k ;
}
else
{
// 2nd dot has been found; the search is done
position [1] = k ;
return ;
}
}
}
}
|