{"id":223,"date":"2016-02-12T02:39:39","date_gmt":"2016-02-12T02:39:39","guid":{"rendered":"http:\/\/emacslisp.com\/?p=223"},"modified":"2016-02-12T02:42:14","modified_gmt":"2016-02-12T02:42:14","slug":"tcc-struct-cstring-for-string-process-in-compiler","status":"publish","type":"post","link":"http:\/\/emacslisp.com\/?p=223","title":{"rendered":"TCC &#8211; struct CString for string process in compiler"},"content":{"rendered":"<p>struct CString is major struct for string process in TCC.<br \/>\nIt also works some api such as cstr_reset(&#8230;),cstr_ccat(&#8230;).<br \/>\nHere is example on how to convert &#8220;char *&#8221; to s.data.<\/p>\n<pre lang=\"c\" line=\"1\"> \r\n  struct CString s;\r\n\r\n  static char buf[STRING_MAX_SIZE + 1];\r\n\r\n  char *p = \"Test\";\r\n  char *p1 = p;\r\n  char *p2 = p; \r\n\r\n  cstr_reset(&s);\r\n\r\n  for(;;){\r\n    if(*p2 != '\\0')\r\n      {\r\n        p2++;\r\n      }\r\n    else\r\n      break;\r\n  }\r\n\r\n  s.data = buf;  \r\n\r\n  while (p1 < p2) {\r\n    cstr_ccat(&#038;s, *p1);\r\n    p1++;\r\n  }\r\n  \r\n  printf(\"%s\",(char *)s.data);\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>struct CString is major struct for string process in TCC. It also works some api such as cstr_reset(&#8230;),cstr_ccat(&#8230;). Here is example on how to convert &#8220;char *&#8221; to s.data. struct CString s; static char buf[STRING_MAX_SIZE + 1]; char *p = &#8220;Test&#8221;; char *p1 = p; char *p2 = p; cstr_reset(&#038;s); for(;;){ if(*p2 != &#8216;\\0&#8217;) { [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,10],"tags":[],"class_list":["post-223","post","type-post","status-publish","format-standard","hentry","category-tcc-","category-tcc-source-code-analysis"],"_links":{"self":[{"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/posts\/223","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/emacslisp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=223"}],"version-history":[{"count":1,"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/posts\/223\/revisions"}],"predecessor-version":[{"id":224,"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/posts\/223\/revisions\/224"}],"wp:attachment":[{"href":"http:\/\/emacslisp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/emacslisp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=223"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/emacslisp.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}