unsignedlen=FITSuint_(strlen(string),__func__,(int)__LINE__);// Get the length of the input string using strlen() function, and store it in the variable len
returnstrcpy((char*)alloc(len+1),string);
returnstrcpy((char*)alloc(len+1),string);// Allocate memory for a new string of length len+1, and copy the input string into the newly allocated memory
}
/* similar for reasonable size strings, but return length of input as well */
char*
dupstr_n(constchar*string,unsignedint*lenout)
{
size_tlen=strlen(string);
size_tlen=strlen(string);// Get the length of the input string using strlen() function
if(len>=LARGEST_INT)
panic("string too long");
*lenout=(unsignedint)len;
returnstrcpy((char*)alloc(len+1),string);
if(len>=LARGEST_INT)// If the length exceeds a predefined constant LARGEST_INT, which represents the maximum length allowed
panic("string too long");// Raise an error or handle the situation when the string is too long
*lenout=(unsignedint)len;// Store the length of the input string in the variable lenout
returnstrcpy((char*)alloc(len+1),string);// Allocate memory for a new string of length len+1, copy the input string into the newly allocated memory, and return the new string
}
/* cast to int or panic on overflow; use via macro */
int
FITSint_(LUA_INTEGERi,constchar*file,intline)
{
intiret=(int)i;
intiret=(int)i;// Cast the input parameter i to int type and store it in the variable iret
if(iret!=i)
panic("Overflow at %s:%d",file,line);
returniret;
if(iret!=i)// If the casted value is not equal to the original input value
panic("Overflow at %s:%d",file,line);// Raise an error or handle the situation when overflow occurs