Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1735)

Side by Side Diff: src/trusted/validator/x86/testing/enuminsts/str_utils.c

Issue 9861030: Modify enuminsts to be able to communicate matched instructions accross (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 /* 7 /*
8 * str_utils.h 8 * str_utils.h
9 * 9 *
10 * Defines support string routines for the instruction enumerator. 10 * Defines support string routines for the instruction enumerator.
11 */ 11 */
12 12
13 #include "native_client/src/trusted/validator/x86/testing/enuminsts/str_utils.h" 13 #include "native_client/src/trusted/validator/x86/testing/enuminsts/str_utils.h"
14 14
15 #include <string.h> 15 #include <string.h>
16 16
17 /* If string s begins with string prefix, return a pointer to the 17 /* If string s begins with string prefix, return a pointer to the
18 * first byte after the prefix. Else return s. 18 * first byte after the prefix. Else return s.
19 */ 19 */
20 char *SkipPrefix(char *s, const char *prefix) { 20 char *SkipPrefix(char *s, const char *prefix) {
21 int plen = strlen(prefix); 21 int plen = strlen(prefix);
22 if (strncmp(s, prefix, plen) == 0) { 22 if (strncmp(s, prefix, plen) == 0) {
23 return &s[plen + 1]; 23 return &s[plen + 1];
24 } 24 }
25 return s; 25 return s;
26 } 26 }
27 27
28 /* Return a pointer to s with leading spaces removed. 28 /* Return a pointer to s with leading spaces removed.
29 */ 29 */
30 char *strip(char *s) { 30 const char *strip(const char *s) {
31 while (*s == ' ') s++; 31 while (*s == ' ') s++;
32 return s; 32 return s;
33 } 33 }
34 34
35 /* Updates the string by removing trailing spaces/newlines. */ 35 /* Updates the string by removing trailing spaces/newlines. */
36 void rstrip(char *s) { 36 void rstrip(char *s) {
37 int slen = strlen(s); 37 int slen = strlen(s);
38 while (slen > 0) { 38 while (slen > 0) {
39 --slen; 39 --slen;
40 if (!isspace(s[slen])) return; 40 if (!isspace(s[slen])) return;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 dest[i] = src[i]; 120 dest[i] = src[i];
121 if (dest[i] == c) { 121 if (dest[i] == c) {
122 dest[i] = 0; 122 dest[i] = 0;
123 break; 123 break;
124 } 124 }
125 if (dest[i] == '\0') break; 125 if (dest[i] == '\0') break;
126 i++; 126 i++;
127 if (i == n) InternalError("really long opcode"); 127 if (i == n) InternalError("really long opcode");
128 } 128 }
129 } 129 }
OLDNEW
« no previous file with comments | « src/trusted/validator/x86/testing/enuminsts/str_utils.h ('k') | src/trusted/validator/x86/testing/enuminsts/text2hex.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698