root/doc_inner/gnu_global/S/37691.html

/* [<][>][^][v][top][bottom][index][help] */
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>doc_inner/doxygen/latex/cmem_8c_source.tex</title>
<meta name='robots' content='noindex,nofollow' />
<meta name='generator' content='GLOBAL-6.6.14' />
<meta http-equiv='Content-Style-Type' content='text/css' />
<link rel='stylesheet' type='text/css' href='../style.css' />
</head>
<body>
<a id='TOP' name='TOP'></a><h2 class='header'><a href='../mains.html'>root</a>/<a href='../files/42014.html'>doc_inner</a>/<a href='../files/42015.html'>doxygen</a>/<a href='../files/42016.html'>latex</a>/cmem_8c_source.tex</h2>
<em class='comment'>/* [&lt;][&gt;][^][v][top]<a href='#BOTTOM'>[bottom]</a><a href='../mains.html'>[index]</a><a href='../help.html'>[help]</a> */</em>
<hr />
<pre>
<a id='L1' name='L1'></a>\doxysection{cmem.\+c}
<a id='L2' name='L2'></a>\label{cmem_8c_source}\index{src/cmem.c@{src/cmem.c}}
<a id='L3' name='L3'></a>\textbf{ Go to the documentation of this file.}
<a id='L4' name='L4'></a>\begin{DoxyCode}{0}
<a id='L5' name='L5'></a>\DoxyCodeLine{00001\ \textcolor{preprocessor}{\#include\ "{}cmem.h"{}}}
<a id='L6' name='L6'></a>\DoxyCodeLine{00002\ }
<a id='L7' name='L7'></a>\DoxyCodeLine{00003\ \textcolor{keywordtype}{long}\ str2l\_range(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *str,\ \textcolor{keywordtype}{long}\ min,\ \textcolor{keywordtype}{long}\ max,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *name)\ \{}
<a id='L8' name='L8'></a>\DoxyCodeLine{00004\ \ \ \ \ \textcolor{keywordtype}{char}\ *endptr\ =\ NULL;}
<a id='L9' name='L9'></a>\DoxyCodeLine{00005\ \ \ \ \ \textcolor{keywordtype}{long}\ val\ =\ strtol(str,\ \&amp;endptr,\ 10);}
<a id='L10' name='L10'></a>\DoxyCodeLine{00006\ \ \ \ \ \textcolor{keywordflow}{if}(endptr\ ==\ str)\ \{}
<a id='L11' name='L11'></a>\DoxyCodeLine{00007\ \ \ \ \ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}\%s:\ Not\ specified.\(\backslash\)n"{}},\ name);}
<a id='L12' name='L12'></a>\DoxyCodeLine{00008\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
<a id='L13' name='L13'></a>\DoxyCodeLine{00009\ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}(*endptr\ !=\ \textcolor{charliteral}{'\(\backslash\)0'})\ \{}
<a id='L14' name='L14'></a>\DoxyCodeLine{00010\ \ \ \ \ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}\%s:\ \`{}\%s'\ is\ not\ integer.\(\backslash\)n"{}},\ name,\ str);}
<a id='L15' name='L15'></a>\DoxyCodeLine{00011\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
<a id='L16' name='L16'></a>\DoxyCodeLine{00012\ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}(val\ &lt;\ min\ ||\ max\ &lt;\ val)\ \{}
<a id='L17' name='L17'></a>\DoxyCodeLine{00013\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(max\ ==\ LONG\_MAX)\ \{}
<a id='L18' name='L18'></a>\DoxyCodeLine{00014\ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}\%s:\ \%s\ out\ of\ range:\ \%ld\ -\/\(\backslash\)n"{}},\ str,\ name,\ min);}
<a id='L19' name='L19'></a>\DoxyCodeLine{00015\ \ \ \ \ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \{}
<a id='L20' name='L20'></a>\DoxyCodeLine{00016\ \ \ \ \ \ \ \ \ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}\%s:\ \%s\ out\ of\ range:\ \%ld\ -\/\ \%ld\(\backslash\)n"{}},\ str,\ name,\ min,\ max);}
<a id='L21' name='L21'></a>\DoxyCodeLine{00017\ \ \ \ \ \ \ \ \ \}}
<a id='L22' name='L22'></a>\DoxyCodeLine{00018\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
<a id='L23' name='L23'></a>\DoxyCodeLine{00019\ \ \ \ \ \}}
<a id='L24' name='L24'></a>\DoxyCodeLine{00020\ \ \ \ \ \textcolor{keywordflow}{return}\ val;}
<a id='L25' name='L25'></a>\DoxyCodeLine{00021\ \}}
<a id='L26' name='L26'></a>\DoxyCodeLine{00022\ }
<a id='L27' name='L27'></a>\DoxyCodeLine{00023\ \textcolor{keywordtype}{void}\ *malloc\_chk(\textcolor{keywordtype}{size\_t}\ size,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *tag)}
<a id='L28' name='L28'></a>\DoxyCodeLine{00024\ \{}
<a id='L29' name='L29'></a>\DoxyCodeLine{00025\ \ \ \ \ \textcolor{keywordtype}{void}\ *p\ =\ NULL;}
<a id='L30' name='L30'></a>\DoxyCodeLine{00026\ }
<a id='L31' name='L31'></a>\DoxyCodeLine{00027\ \ \ \ \ \textcolor{keywordflow}{if}((p\ =\ malloc(size))\ ==\ NULL)\ \{}
<a id='L32' name='L32'></a>\DoxyCodeLine{00028\ \ \ \ \ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}\%s:\ cannot\ allocate\ memory\(\backslash\)n"{}},\ tag);}
<a id='L33' name='L33'></a>\DoxyCodeLine{00029\ \ \ \ \ \ \ \ \ exit(1);}
<a id='L34' name='L34'></a>\DoxyCodeLine{00030\ \ \ \ \ \}}
<a id='L35' name='L35'></a>\DoxyCodeLine{00031\ \ \ \ \ \textcolor{keywordflow}{return}\ memset(p,\ 0,\ size);}
<a id='L36' name='L36'></a>\DoxyCodeLine{00032\ \}}
<a id='L37' name='L37'></a>\DoxyCodeLine{00033\ }
<a id='L38' name='L38'></a>\DoxyCodeLine{00034\ \textcolor{keywordtype}{void}\ *calloc\_chk(\textcolor{keywordtype}{size\_t}\ nmemb,\ \textcolor{keywordtype}{size\_t}\ size,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *tag)}
<a id='L39' name='L39'></a>\DoxyCodeLine{00035\ \{}
<a id='L40' name='L40'></a>\DoxyCodeLine{00036\ \ \ \ \ \textcolor{keywordtype}{void}\ *p\ =\ NULL;}
<a id='L41' name='L41'></a>\DoxyCodeLine{00037\ }
<a id='L42' name='L42'></a>\DoxyCodeLine{00038\ \ \ \ \ \textcolor{keywordflow}{if}((p\ =\ calloc(nmemb,\ size))\ ==\ NULL)\ \{}
<a id='L43' name='L43'></a>\DoxyCodeLine{00039\ \ \ \ \ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}\%s:\ cannot\ allocate\ memory\(\backslash\)n"{}},\ tag);}
<a id='L44' name='L44'></a>\DoxyCodeLine{00040\ \ \ \ \ \ \ \ \ exit(1);}
<a id='L45' name='L45'></a>\DoxyCodeLine{00041\ \ \ \ \ \}}
<a id='L46' name='L46'></a>\DoxyCodeLine{00042\ \ \ \ \ \textcolor{keywordflow}{return}\ p;}
<a id='L47' name='L47'></a>\DoxyCodeLine{00043\ \}}
<a id='L48' name='L48'></a>\DoxyCodeLine{00044\ }
<a id='L49' name='L49'></a>\DoxyCodeLine{00045\ \textcolor{keywordtype}{char}\ *strdup\_chk(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *s,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *tag)}
<a id='L50' name='L50'></a>\DoxyCodeLine{00046\ \{}
<a id='L51' name='L51'></a>\DoxyCodeLine{00047\ \ \ \ \ assert(s\ !=\ NULL);}
<a id='L52' name='L52'></a>\DoxyCodeLine{00048\ \ \ \ \ \textcolor{keywordtype}{char}\ *t\ =\ malloc\_chk(strlen(s)\ +\ 1,\ tag);}
<a id='L53' name='L53'></a>\DoxyCodeLine{00049\ \ \ \ \ strcpy(t,\ s);}
<a id='L54' name='L54'></a>\DoxyCodeLine{00050\ \ \ \ \ \textcolor{keywordflow}{return}\ t;}
<a id='L55' name='L55'></a>\DoxyCodeLine{00051\ \}}
<a id='L56' name='L56'></a>\DoxyCodeLine{00052\ }
<a id='L57' name='L57'></a>\DoxyCodeLine{00053\ \textcolor{keywordtype}{char}\ *strndup\_chk(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *s,\ \textcolor{keywordtype}{size\_t}\ len,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *tag)}
<a id='L58' name='L58'></a>\DoxyCodeLine{00054\ \{}
<a id='L59' name='L59'></a>\DoxyCodeLine{00055\ \ \ \ \ assert(s\ !=\ NULL);}
<a id='L60' name='L60'></a>\DoxyCodeLine{00056\ \ \ \ \ \textcolor{keywordtype}{char}\ *t\ =\ NULL;}
<a id='L61' name='L61'></a>\DoxyCodeLine{00057\ }
<a id='L62' name='L62'></a>\DoxyCodeLine{00058\ \ \ \ \ \textcolor{keywordflow}{if}(len\ &lt;\ strlen(s))\ \{}
<a id='L63' name='L63'></a>\DoxyCodeLine{00059\ \ \ \ \ \ \ \ \ t\ =\ malloc\_chk(len\ +\ 1,\ tag);}
<a id='L64' name='L64'></a>\DoxyCodeLine{00060\ \ \ \ \ \ \ \ \ strncpy(t,\ s,\ len);}
<a id='L65' name='L65'></a>\DoxyCodeLine{00061\ \ \ \ \ \ \ \ \ t[len]\ =\ \textcolor{charliteral}{'\(\backslash\)0'};}
<a id='L66' name='L66'></a>\DoxyCodeLine{00062\ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \{}
<a id='L67' name='L67'></a>\DoxyCodeLine{00063\ \ \ \ \ \ \ \ \ t\ =\ strdup\_chk(s,\ tag);}
<a id='L68' name='L68'></a>\DoxyCodeLine{00064\ \ \ \ \ \}}
<a id='L69' name='L69'></a>\DoxyCodeLine{00065\ \ \ \ \ \textcolor{keywordflow}{return}\ t;}
<a id='L70' name='L70'></a>\DoxyCodeLine{00066\ \}}
<a id='L71' name='L71'></a>\DoxyCodeLine{00067\ }
<a id='L72' name='L72'></a>\DoxyCodeLine{00068\ \textcolor{keywordtype}{void}\ strip\_end(\textcolor{keywordtype}{char}\ *s)}
<a id='L73' name='L73'></a>\DoxyCodeLine{00069\ \{}
<a id='L74' name='L74'></a>\DoxyCodeLine{00070\ \ \ \ \ \textcolor{keywordflow}{for}(\textcolor{keywordtype}{int}\ i\ =\ strlen(s)\ -\/\ 1;\ i\ &gt;\ 0\ \&amp;\&amp;\ (s[i]\ ==\ \textcolor{charliteral}{'\(\backslash\)n'}\ ||\ s[i]\ ==\ \textcolor{charliteral}{'\(\backslash\)r'}\ ||\ s[i]\ ==\ \textcolor{charliteral}{'\ '}\ ||\ s[i]\ ==\ \textcolor{charliteral}{'\(\backslash\)t'});\ i-\/-\/)\ \{}
<a id='L75' name='L75'></a>\DoxyCodeLine{00071\ \ \ \ \ \ \ \ \ s[i]\ =\ \textcolor{charliteral}{'\(\backslash\)0'};}
<a id='L76' name='L76'></a>\DoxyCodeLine{00072\ \ \ \ \ \}}
<a id='L77' name='L77'></a>\DoxyCodeLine{00073\ \}}
<a id='L78' name='L78'></a>\DoxyCodeLine{00074\ }
<a id='L79' name='L79'></a>\DoxyCodeLine{00075\ \textcolor{keywordtype}{void}\ strip\_casl2\_comment(\textcolor{keywordtype}{char}\ *s)}
<a id='L80' name='L80'></a>\DoxyCodeLine{00076\ \{}
<a id='L81' name='L81'></a>\DoxyCodeLine{00077\ \ \ \ \ \textcolor{keywordtype}{bool}\ quoting\ =\ \textcolor{keyword}{false};}
<a id='L82' name='L82'></a>\DoxyCodeLine{00078\ }
<a id='L83' name='L83'></a>\DoxyCodeLine{00079\ \ \ \ \ \textcolor{keywordflow}{for}(\textcolor{keywordtype}{int}\ i\ =\ 0;\ s[i];\ i++)\ \{}
<a id='L84' name='L84'></a>\DoxyCodeLine{00080\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ 「'」で囲まれた文字列の場合。「''」は無視\ */}}
<a id='L85' name='L85'></a>\DoxyCodeLine{00081\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}(s[i]\ ==\ \textcolor{charliteral}{'\(\backslash\)''}\ \&amp;\&amp;\ s[i+1]\ !=\ \textcolor{charliteral}{'\(\backslash\)''}\ \&amp;\&amp;\ (quoting\ ==\ \textcolor{keyword}{false}\ ||\ s[i-\/1]\ !=\ \textcolor{charliteral}{'\(\backslash\)''}))\ \{}
<a id='L86' name='L86'></a>\DoxyCodeLine{00082\ \ \ \ \ \ \ \ \ \ \ \ \ quoting\ =\ !quoting;}
<a id='L87' name='L87'></a>\DoxyCodeLine{00083\ \ \ \ \ \ \ \ \ \textcolor{comment}{/*\ 「'」で囲まれた文字列でない場合、文字列末尾の「;」以降を削除\ */}}
<a id='L88' name='L88'></a>\DoxyCodeLine{00084\ \ \ \ \ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}(quoting\ ==\ \textcolor{keyword}{false}\ \&amp;\&amp;\ s[i]\ ==\ \textcolor{charliteral}{';'})\ \{}
<a id='L89' name='L89'></a>\DoxyCodeLine{00085\ \ \ \ \ \ \ \ \ \ \ \ \ s[i]\ =\ \textcolor{charliteral}{'\(\backslash\)0'};}
<a id='L90' name='L90'></a>\DoxyCodeLine{00086\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
<a id='L91' name='L91'></a>\DoxyCodeLine{00087\ \ \ \ \ \ \ \ \ \}}
<a id='L92' name='L92'></a>\DoxyCodeLine{00088\ \ \ \ \ \}}
<a id='L93' name='L93'></a>\DoxyCodeLine{00089\ \}}
<a id='L94' name='L94'></a>\DoxyCodeLine{00090\ }
<a id='L95' name='L95'></a>\DoxyCodeLine{00091\ \textcolor{keywordtype}{char}\ *strrev(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *s)}
<a id='L96' name='L96'></a>\DoxyCodeLine{00092\ \{}
<a id='L97' name='L97'></a>\DoxyCodeLine{00093\ \ \ \ \ \textcolor{keywordtype}{char}\ *t\ =\ strdup\_chk(s,\ \textcolor{stringliteral}{"{}strrev.t"{}});}
<a id='L98' name='L98'></a>\DoxyCodeLine{00094\ \ \ \ \ \textcolor{keywordtype}{int}\ l\ =\ strlen(t);}
<a id='L99' name='L99'></a>\DoxyCodeLine{00095\ }
<a id='L100' name='L100'></a>\DoxyCodeLine{00096\ \ \ \ \ \textcolor{keywordflow}{for}(\textcolor{keywordtype}{int}\ i\ =\ 0;\ i\ &lt;\ l-\/1-\/i;\ i++)\ \{}
<a id='L101' name='L101'></a>\DoxyCodeLine{00097\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{char}\ tmp\ =\ t[i];}
<a id='L102' name='L102'></a>\DoxyCodeLine{00098\ \ \ \ \ \ \ \ \ t[i]\ =\ t[l-\/1-\/i];}
<a id='L103' name='L103'></a>\DoxyCodeLine{00099\ \ \ \ \ \ \ \ \ t[l-\/1-\/i]\ =\ tmp;}
<a id='L104' name='L104'></a>\DoxyCodeLine{00100\ \ \ \ \ \}}
<a id='L105' name='L105'></a>\DoxyCodeLine{00101\ \ \ \ \ \textcolor{keywordflow}{return}\ t;}
<a id='L106' name='L106'></a>\DoxyCodeLine{00102\ \}}
<a id='L107' name='L107'></a>
<a id='L108' name='L108'></a>\end{DoxyCode}
</pre>
<hr />
<a id='BOTTOM' name='BOTTOM'></a>
<em class='comment'>/* [&lt;][&gt;][^][v]<a href='#TOP'>[top]</a>[bottom]<a href='../mains.html'>[index]</a><a href='../help.html'>[help]</a> */</em>
</body>
</html>

/* [<][>][^][v][top][bottom][index][help] */