~ubuntu-branches/ubuntu/lucid/warzone2100/lucid

« back to all changes in this revision

Viewing changes to lib/framework/strnlen1.c

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Egger, Paul Wise, Christoph Egger
  • Date: 2009-06-29 17:12:52 UTC
  • mfrom: (1.1.11 upstream) (2.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090629171252-5ddnlfg3zfchrega
Tags: 2.2.1+dfsg1-1
[ Paul Wise ]
* New upstream release (Closes: #534962)
* Adjust the flex build-depends to take account of the conflict
  with all the versions of flex 2.5.34 (LP: #372872)
* Make the -music Recommends more strict, 2.1 music doesn't work
  with 2.2.
* Upstream moved the downloads to sourceforge, update the watch file
* Bump Standards-Version, no changes needed
* Drop use of dh_desktop since it no longer does anything
* Recommend the new warzone2100-video package, version 2.2 or similar
* Mention the warzone2100 crash reports in the -dbg package description

[ Christoph Egger ]
* Replace CC-2.0 graphic from cybersphinx, create a new tarball
* Add myself to uploaders

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
        This file is part of Warzone 2100.
3
 
        Find the length of STRING + 1, but scan at most MAXLEN bytes.
4
 
        Copyright (C) 2005-2006  Free Software Foundation, Inc.
5
 
 
6
 
        Warzone 2100 is free software; you can redistribute it and/or modify
7
 
        it under the terms of the GNU General Public License as published by
8
 
        the Free Software Foundation; either version 2 of the License, or
9
 
        (at your option) any later version.
10
 
 
11
 
        Warzone 2100 is distributed in the hope that it will be useful,
12
 
        but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 
        GNU General Public License for more details.
15
 
 
16
 
        You should have received a copy of the GNU General Public License
17
 
        along with Warzone 2100; if not, write to the Free Software
18
 
        Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 
        MA 02110-1301, USA.
20
 
 
21
 
        $Revision: 2765 $
22
 
        $Id: strnlen1.c 2765 2007-11-09 23:27:03Z muggenhor $
23
 
        $HeadURL: svn+ssh://per@svn.gna.org/svn/warzone/tags/2.1.3/lib/framework/strnlen1.c $
24
 
*/
25
 
 
26
 
/* Specification.  */
27
 
#include "strnlen1.h"
28
 
 
29
 
#include <string.h>
30
 
 
31
 
/* Find the length of STRING + 1, but scan at most MAXLEN bytes.
32
 
   If no '\0' terminator is found in that many characters, return MAXLEN.  */
33
 
/* This is the same as strnlen (string, maxlen - 1) + 1.  */
34
 
size_t strnlen1(const char* string, size_t maxlen)
35
 
{
36
 
        // Find the first NUL char
37
 
        const char* end = memchr (string, '\0', maxlen);
38
 
 
39
 
        if (end != NULL)
40
 
                return end - string + 1;
41
 
        else
42
 
                return maxlen;
43
 
}