MCPcopy Create free account
hub / github.com/NetHack/NetHack / new_resource_macro

Function new_resource_macro

win/X11/winX.c:780–811  ·  view source on GitHub ↗

caller found "#define"; parse into macro name and its expansion value */

Source from the content-addressed store, hash-verified

778
779/* caller found "#define"; parse into macro name and its expansion value */
780static boolean
781new_resource_macro(
782 String inbuf, /* points past '#define' rather than to start of buffer */
783 unsigned numdefs) /* array slot to fill */
784{
785 String p, q;
786
787 /* we expect inbuf to be terminated by newline; get rid of it */
788 q = eos(inbuf);
789 if (q > inbuf && q[-1] == '\n')
790 q[-1] = '\0';
791
792 /* figure out macro's name */
793 for (p = inbuf; *p == ' ' || *p == '\t'; ++p)
794 continue; /* skip whitespace */
795 for (q = p; *q && *q != ' ' && *q != '\t'; ++q)
796 continue; /* token consists of non-whitespace */
797 Strcat(q, " "); /* guarantee something beyond '#define FOO' */
798 *q++ = '\0'; /* p..(q-1) contains macro name */
799 if (!*p) /* invalid definition: '#define' followed by nothing */
800 return FALSE;
801 def_rsrc_macr[numdefs] = dupstr(p);
802
803 /* figure out macro's value; empty value is supported but not expected */
804 while (*q == ' ' || *q == '\t')
805 ++q; /* skip whitespace between name and value */
806 for (p = eos(q); --p > q && (*p == ' ' || *p == '\t'); )
807 continue; /* discard trailing whitespace */
808 *++p = '\0'; /* q..p contains macro value */
809 def_rsrc_valu[numdefs] = dupstr(q);
810 return TRUE;
811}
812
813/* read the template NetHack.ad into default_resource_data[] to supply
814 fallback resources to XtAppInitialize() */

Callers 1

load_default_resourcesFunction · 0.85

Calls 2

eosFunction · 0.85
dupstrFunction · 0.85

Tested by

no test coverage detected