source: buchla-68k/libsm/strrev.c@ ea232f9

Last change on this file since ea232f9 was b28a12e, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Zero redundant declarations.

  • Property mode set to 100644
File size: 866 bytes
Line 
1/*
2 =============================================================================
3 strrev.c -- reverse a string
4 Version 1 -- 1988-02-03 -- D.N. Lynx Crowe
5
6 char *
7 strrev(s1, s2)
8 char *s1;
9 char *s2;
10
11 Copies string 's2' into 's1'. 's1' must be large enough
12 to hold 's2'. Returns 's1'.
13 =============================================================================
14*/
15
16#include "ram.h"
17
18int8_t *strrev(int8_t *s1, int8_t *s2)
19{
20 register int8_t *s3;
21 register int32_t i;
22
23 i = 0L; /* initialize string length */
24 s3 = s1; /* initialize target left end pointer */
25
26 while (*s2) { /* find right end of source string */
27
28 ++s2;
29 ++i;
30 }
31
32 --s2; /* adjust source right end pointer */
33
34 while (i--) /* copy string in reverse */
35 *s3++ = *s2--;
36
37 *s3 = '\0'; /* terminate the string */
38 return(s1); /* return address of reversed string */
39}
Note: See TracBrowser for help on using the repository browser.