Skip to content

Commit

Permalink
Merge pull request #2204 from dgovil/remove-register
Browse files Browse the repository at this point in the history
Remove use of the register keyword

(Internal change: 2269187)
  • Loading branch information
pixar-oss committed Mar 31, 2023
2 parents da2b53c + 29a1846 commit 0d9f904
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 45 deletions.
8 changes: 4 additions & 4 deletions pxr/base/arch/stackTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,10 @@ nonLockingLinux__execve (const char *file,

#if defined (ARCH_CPU_ARM)
{
register long __file_result asm ("x0") = (long)file;
register char* const* __argv asm ("x1") = argv;
register char* const* __envp asm ("x2") = envp;
register long __num_execve asm ("x8") = 221;
long __file_result asm ("x0") = (long)file;
char* const* __argv asm ("x1") = argv;
char* const* __envp asm ("x2") = envp;
long __num_execve asm ("x8") = 221;
__asm__ __volatile__ (
"svc 0"
: "=r" (__file_result)
Expand Down
24 changes: 12 additions & 12 deletions pxr/usd/sdf/path.lex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -978,9 +978,9 @@ extern int pathYylex \
*/
YY_DECL
{
register yy_state_type yy_current_state;
register char *yy_cp, *yy_bp;
register int yy_act;
yy_state_type yy_current_state;
char *yy_cp, *yy_bp;
int yy_act;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

yylval = yylval_param;
Expand Down Expand Up @@ -1296,9 +1296,9 @@ case YY_STATE_EOF(INITIAL):
static int yy_get_next_buffer (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
register char *source = yyg->yytext_ptr;
register int number_to_move, i;
char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
char *source = yyg->yytext_ptr;
int number_to_move, i;
int ret_val;

if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
Expand Down Expand Up @@ -1430,8 +1430,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner)

static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
{
register yy_state_type yy_current_state;
register char *yy_cp;
yy_state_type yy_current_state;
char *yy_cp;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

yy_current_state = yyg->yy_start;
Expand All @@ -1456,9 +1456,9 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
*/
static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
{
register int yy_is_jam;
int yy_is_jam;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
register char *yy_cp = yyg->yy_c_buf_p;
char *yy_cp = yyg->yy_c_buf_p;

yy_current_state = yy_nxt[yy_current_state][1];
yy_is_jam = (yy_current_state <= 0);
Expand Down Expand Up @@ -2228,7 +2228,7 @@ int pathYylex_destroy (yyscan_t yyscanner)
#ifndef yytext_ptr
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
{
register int i;
int i;
for ( i = 0; i < n; ++i )
s1[i] = s2[i];
}
Expand All @@ -2237,7 +2237,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yysca
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
{
register int n;
int n;
for ( n = 0; s[n]; ++n )
;

Expand Down
15 changes: 14 additions & 1 deletion pxr/usd/sdf/sdfGenAsciiParsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,27 @@ def _canonicalizeFiles(sourceFiles, generatedFiles):
replacements.append((oldFileName, newFileName))

for renamedFile in renamed:
print('Fixing line directives in ' + basename(renamedFile))
print('Canonicalizing ' + basename(renamedFile))

with open(renamedFile, 'r+') as inputFile:
data = inputFile.read()

# find and replace all generated file names
print('... Fixing line directives')
for oldFileName, newFileName in replacements:
data = data.replace(oldFileName, newFileName)

# flex versions older than 2.6 emit the register keyword
# which is no longer supported as of C++17. To support
# these versions, we manually strip 'register' from each
# .lex.cpp file. This is hacky, since it could affect
# hand-written parser code that uses the word "register".
# In practice, none of our parser code does this.
#
# XXX: Remove this when we stop supporting older flex versions
if renamedFile.endswith('.lex.cpp'):
print('... Removing register keyword')
data = data.replace("register ", "")

# we seek to 0 and truncate as we intend
# to overwrite the existing data in the file
Expand Down
24 changes: 12 additions & 12 deletions pxr/usd/sdf/textFileFormat.lex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4361,9 +4361,9 @@ extern int textFileFormatYylex \
*/
YY_DECL
{
register yy_state_type yy_current_state;
register char *yy_cp, *yy_bp;
register int yy_act;
yy_state_type yy_current_state;
char *yy_cp, *yy_bp;
int yy_act;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

yylval = yylval_param;
Expand Down Expand Up @@ -5063,9 +5063,9 @@ case YY_STATE_EOF(SLASHTERIX_COMMENT):
static int yy_get_next_buffer (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
register char *source = yyg->yytext_ptr;
register int number_to_move, i;
char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
char *source = yyg->yytext_ptr;
int number_to_move, i;
int ret_val;

if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
Expand Down Expand Up @@ -5197,8 +5197,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner)

static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
{
register yy_state_type yy_current_state;
register char *yy_cp;
yy_state_type yy_current_state;
char *yy_cp;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

yy_current_state = yyg->yy_start;
Expand All @@ -5223,9 +5223,9 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
*/
static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
{
register int yy_is_jam;
int yy_is_jam;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
register char *yy_cp = yyg->yy_c_buf_p;
char *yy_cp = yyg->yy_c_buf_p;

yy_current_state = yy_nxt[yy_current_state][1];
yy_is_jam = (yy_current_state <= 0);
Expand Down Expand Up @@ -5995,7 +5995,7 @@ int textFileFormatYylex_destroy (yyscan_t yyscanner)
#ifndef yytext_ptr
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
{
register int i;
int i;
for ( i = 0; i < n; ++i )
s1[i] = s2[i];
}
Expand All @@ -6004,7 +6004,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yysca
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
{
register int n;
int n;
for ( n = 0; s[n]; ++n )
;

Expand Down
15 changes: 14 additions & 1 deletion third_party/renderman-24/plugin/hdPrman/hdPrmanGenParsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,27 @@ def _canonicalizeFiles(sourceFiles, generatedFiles):
replacements.append((oldFileName, newFileName))

for renamedFile in renamed:
print('Fixing line directives in ' + basename(renamedFile))
print('Canonicalizing ' + basename(renamedFile))

with open(renamedFile, 'r+') as inputFile:
data = inputFile.read()

# find and replace all generated file names
print('... Fixing line directives')
for oldFileName, newFileName in replacements:
data = data.replace(oldFileName, newFileName)

# flex versions older than 2.6 emit the register keyword
# which is no longer supported as of C++17. To support
# these versions, we manually strip 'register' from each
# .lex.cpp file. This is hacky, since it could affect
# hand-written parser code that uses the word "register".
# In practice, none of our parser code does this.
#
# XXX: Remove this when we stop supporting older flex versions
if renamedFile.endswith('.lex.cpp'):
print('... Removing register keyword')
data = data.replace("register ", "")

# we seek to 0 and truncate as we intend
# to overwrite the existing data in the file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,9 +800,9 @@ extern int virtualStructConditionalGrammarYylex \
*/
YY_DECL
{
register yy_state_type yy_current_state;
register char *yy_cp, *yy_bp;
register int yy_act;
yy_state_type yy_current_state;
char *yy_cp, *yy_bp;
int yy_act;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

yylval = yylval_param;
Expand Down Expand Up @@ -857,7 +857,7 @@ YY_DECL
yy_match:
do
{
register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
if ( yy_accept[yy_current_state] )
{
yyg->yy_last_accepting_state = yy_current_state;
Expand Down Expand Up @@ -1197,9 +1197,9 @@ case YY_STATE_EOF(INITIAL):
static int yy_get_next_buffer (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
register char *source = yyg->yytext_ptr;
register int number_to_move, i;
char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
char *source = yyg->yytext_ptr;
int number_to_move, i;
int ret_val;

if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
Expand Down Expand Up @@ -1331,15 +1331,15 @@ static int yy_get_next_buffer (yyscan_t yyscanner)

static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
{
register yy_state_type yy_current_state;
register char *yy_cp;
yy_state_type yy_current_state;
char *yy_cp;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;

yy_current_state = yyg->yy_start;

for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
{
register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
if ( yy_accept[yy_current_state] )
{
yyg->yy_last_accepting_state = yy_current_state;
Expand All @@ -1364,11 +1364,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
*/
static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
{
register int yy_is_jam;
int yy_is_jam;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
register char *yy_cp = yyg->yy_c_buf_p;
char *yy_cp = yyg->yy_c_buf_p;

register YY_CHAR yy_c = 1;
YY_CHAR yy_c = 1;
if ( yy_accept[yy_current_state] )
{
yyg->yy_last_accepting_state = yy_current_state;
Expand Down Expand Up @@ -2151,7 +2151,7 @@ int virtualStructConditionalGrammarYylex_destroy (yyscan_t yyscanner)
#ifndef yytext_ptr
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
{
register int i;
int i;
for ( i = 0; i < n; ++i )
s1[i] = s2[i];
}
Expand All @@ -2160,7 +2160,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yysca
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
{
register int n;
int n;
for ( n = 0; s[n]; ++n )
;

Expand Down

0 comments on commit 0d9f904

Please sign in to comment.