source: buchla-68k/libsm/strrevi.c@ f806726

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

Zero redundant declarations.

  • Property mode set to 100644
File size: 933 bytes
Line 
1/*
2 =============================================================================
3 strrevi.c -- reverse a string in place
4 Version 1 -- 1988-02-03 -- D.N. Lynx Crowe
5
6 char *
7 strrevi(s)
8 char *s;
9
10 Reverses string 's1' in place. Returns 's1'.
11 =============================================================================
12*/
13
14#include "ram.h"
15
16int8_t *strrevi(int8_t *s)
17{
18 register int8_t *p1, *p2;
19 register int32_t i;
20 register int8_t c;
21
22 p1 = s; /* initialize left end pointer */
23 p2 = s; /* initialize right end pointer */
24 i = 0L; /* initialize character count */
25
26 while (*p2) { /* find the right end of the string */
27
28 ++i;
29 ++p2;
30 }
31
32 --p2; /* adjust right end pointer */
33 i >>= 1; /* calculate swap count */
34
35 while (i--) { /* for each pair of characters ... */
36
37 c = *p2; /* ... swap right and left characters */
38 *p2-- = *p1;
39 *p1++ = c;
40 }
41
42 return(s); /* return pointer to reversed string */
43}
Note: See TracBrowser for help on using the repository browser.