Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > e3d62627d1d1aab7ab1be2dd7f65a872 > files > 301

ecl-10.4.1-1.fc14.x86_64.rpm

<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>2.6.&#160;Strings</title><link rel="stylesheet" href="ecl.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"><link rel="home" href="index.html" title="The ECL manual"><link rel="up" href="ch25.html" title="Chapter&#160;2.&#160;Manipulating Lisp objects"><link rel="prev" href="ch25s05.html" title="2.5.&#160;Arrays"><link rel="next" href="ch25s07.html" title="2.7.&#160;Bitvectors"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">2.6.&#160;Strings</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch25s05.html">Prev</a>&#160;</td><th width="60%" align="center">Chapter&#160;2.&#160;Manipulating Lisp objects</th><td width="20%" align="right">&#160;<a accesskey="n" href="ch25s07.html">Next</a></td></tr></table><hr></div><div class="section" title="2.6.&#160;Strings"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="Internals-Strings"></a>2.6.&#160;Strings</h2></div></div></div><p>A string, both in Common-Lisp and in <span class="application">ECL</span> is nothing but a vector of
  characters. Therefore, almost everything mentioned in the section of arrays
  remains valid here. The only important difference is that <span class="application">ECL</span> stores
  strings as a lisp object with a pointer to a zero terminated C string. Thus, if
  a string has <em class="replaceable"><code>n</code></em> characters, <span class="application">ECL</span> will reserve <em class="replaceable"><code>n</code></em>+1 bytes for the
  string. This allows us to pass the string <code class="literal">self</code> pointer to any C
  routine.</p><p>If <em class="replaceable"><code>x</code></em> is a lisp object of type string, we can access the following fields:</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><code class="literal">x-&gt;string.dim</code></span></p></td><td><p>Maximum number of characters that it can contain.</p></td></tr><tr><td><p><span class="term"><code class="literal">x-&gt;string.fillp</code></span></p></td><td><p>Actual number of characters in the string.</p></td></tr><tr><td><p><span class="term"><code class="literal">x-&gt;string.self</code></span></p></td><td><p>Pointer to the characters.</p></td></tr><tr><td><p><span class="term"><code class="literal">x-&gt;string.hasfillp</code></span></p></td><td><p>True if <code class="literal">x-&gt;string.fillp</code> can be smaller than <code class="literal">x-&gt;string.dim</code>.</p></td></tr></tbody></table></div><div class="blockquote"><blockquote class="blockquote"><pre class="screen"><a class="indexterm" name="id678626"></a>&#8212; Function: <span class="returnvalue">cl_object</span> <code class="function">make_simple_string</code> (<span class="type">char</span> <code class="varname">*</code><code class="varname">s</code>)</pre><pre class="screen"><a class="indexterm" name="id678657"></a>&#8212; Function: <span class="returnvalue">cl_object</span> <code class="function">make_string_copy</code> (<span class="type">char</span> <code class="varname">*</code><code class="varname">s</code>)</pre><p>Both routines build a lisp string from a C string. <code class="literal">make_string_copy</code>
   allocates new space and copies the content of the string to
   it. <code class="literal">make_simple_string</code> simply uses the memory pointed by <em class="replaceable"><code>s</code></em>, which
   should not be deallocated. Both routines use <code class="literal">strlen</code> to calculate the
   length of the string.</p></blockquote></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch25s05.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="ch25.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="ch25s07.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">2.5.&#160;Arrays&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;2.7.&#160;Bitvectors</td></tr></table></div></body></html>