mirror of
https://github.com/acpica/acpica/
synced 2025-01-27 19:55:25 +03:00
Migrate memmoves to utility procedures
date 2002.12.19.23.43.00; author rmoore1; state Exp;
This commit is contained in:
parent
c0ae8b1008
commit
4c3d6f4dc3
@ -2,7 +2,7 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Module Name: acpisrc.h - Include file for AcpiSrc utility
|
||||
* $Revision: 1.20 $
|
||||
* $Revision: 1.21 $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
@ -412,4 +412,17 @@ AsInsertPrefix (
|
||||
char *Keyword,
|
||||
UINT8 Type);
|
||||
|
||||
char *
|
||||
AsInsertData (
|
||||
char *Buffer,
|
||||
char *BufferToAdd,
|
||||
UINT32 LengthToAdd);
|
||||
|
||||
char *
|
||||
AsRemoveData (
|
||||
char *StartPointer,
|
||||
char *EndPointer);
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Module Name: ascase - Source conversion - lower/upper case utilities
|
||||
* $Revision: 1.3 $
|
||||
* $Revision: 1.4 $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
@ -201,8 +201,7 @@ AsLowerCaseString (
|
||||
{
|
||||
if ((SubBuffer[0] == ' ') && (SubBuffer[1] == ' '))
|
||||
{
|
||||
memmove (SubBuffer + 8, SubBuffer, strlen (SubBuffer) + 1);
|
||||
memmove (SubBuffer, " ", 8);
|
||||
AsInsertData (SubBuffer, " ", 8);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Module Name: asconvrt - Source conversion code
|
||||
* $Revision: 1.39 $
|
||||
* $Revision: 1.40 $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
@ -334,7 +334,6 @@ AsTrimLines (
|
||||
char *Buffer,
|
||||
char *Filename)
|
||||
{
|
||||
UINT32 Length;
|
||||
char *SubBuffer = Buffer;
|
||||
char *StartWhiteSpace = NULL;
|
||||
UINT32 SpaceCount = 0;
|
||||
@ -368,9 +367,9 @@ AsTrimLines (
|
||||
{
|
||||
SpaceCount += (SubBuffer - StartWhiteSpace);
|
||||
|
||||
Length = strlen (SubBuffer) + 1;
|
||||
/* Remove the spaces */
|
||||
|
||||
memmove (StartWhiteSpace, SubBuffer, Length);
|
||||
SubBuffer = AsRemoveData (StartWhiteSpace, SubBuffer);
|
||||
StartWhiteSpace = NULL;
|
||||
}
|
||||
|
||||
@ -423,8 +422,6 @@ AsReplaceHeader (
|
||||
char *Buffer,
|
||||
char *NewHeader)
|
||||
{
|
||||
UINT32 Length;
|
||||
UINT32 HdrLength;
|
||||
char *SubBuffer;
|
||||
char *TokenEnd;
|
||||
|
||||
@ -442,16 +439,9 @@ AsReplaceHeader (
|
||||
TokenEnd = strstr (SubBuffer, "*/");
|
||||
TokenEnd = AsSkipPastChar (TokenEnd, '\n');
|
||||
|
||||
/* Move up the rest of the buffer to delete the header */
|
||||
/* Delete old header, insert new one */
|
||||
|
||||
Length = strlen (TokenEnd) + 1;
|
||||
memmove (SubBuffer, TokenEnd, Length);
|
||||
|
||||
/* Insert the new header */
|
||||
|
||||
HdrLength = strlen (NewHeader);
|
||||
memmove (SubBuffer + HdrLength, SubBuffer, Length);
|
||||
memmove (SubBuffer, NewHeader, HdrLength);
|
||||
AsReplaceData (SubBuffer, TokenEnd - SubBuffer, NewHeader, strlen (NewHeader));
|
||||
}
|
||||
|
||||
|
||||
@ -639,19 +629,15 @@ AsBracesOnSameLine (
|
||||
(*Beginning != ','))
|
||||
{
|
||||
Beginning++;
|
||||
*Beginning = 0;
|
||||
|
||||
SubBuffer++;
|
||||
Length = strlen (SubBuffer);
|
||||
|
||||
Gbl_MadeChanges = TRUE;
|
||||
|
||||
#ifdef ADD_EXTRA_WHITESPACE
|
||||
memmove (Beginning + 3, SubBuffer, Length+4);
|
||||
memmove (Beginning, " {\n", 3);
|
||||
AsReplaceData (Beginning, SubBuffer-Beginning, " {\n", 3);
|
||||
#else
|
||||
memmove (Beginning + 2, SubBuffer, Length+3);
|
||||
memmove (Beginning, " {", 2);
|
||||
AsReplaceData (Beginning, SubBuffer-Beginning, " {", 2);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -730,11 +716,11 @@ AsTabify4 (
|
||||
|
||||
NewSubBuffer = (SubBuffer + 1) - 4;
|
||||
*NewSubBuffer = '\t';
|
||||
NewSubBuffer++;
|
||||
|
||||
Gbl_MadeChanges = TRUE;
|
||||
SubBuffer++;
|
||||
memmove ((NewSubBuffer + 1), SubBuffer, strlen (SubBuffer) + 1);
|
||||
SubBuffer = NewSubBuffer;
|
||||
/* Remove the spaces */
|
||||
|
||||
SubBuffer = AsRemoveData (NewSubBuffer, SubBuffer + 1);
|
||||
}
|
||||
|
||||
if ((Column % 4) == 0)
|
||||
@ -940,9 +926,9 @@ AsTabify8 (
|
||||
TabCount++;
|
||||
}
|
||||
|
||||
Gbl_MadeChanges = TRUE;
|
||||
memmove (NewSubBuffer, SubBuffer, strlen (SubBuffer) + 1);
|
||||
SubBuffer = NewSubBuffer;
|
||||
/* Remove the spaces */
|
||||
|
||||
SubBuffer = AsRemoveData (NewSubBuffer, SubBuffer);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -1218,13 +1204,7 @@ AsInsertPrefix (
|
||||
{
|
||||
/* Already present, add spaces after to align structure members */
|
||||
|
||||
Gbl_MadeChanges = TRUE;
|
||||
SubString = SubBuffer + KeywordLength;
|
||||
StrLength = strlen (SubString);
|
||||
|
||||
memmove (SubString + 8, SubString, StrLength + 1);
|
||||
memmove (SubString, " ", 8);
|
||||
|
||||
AsInsertData (SubBuffer + KeywordLength, " ", 8);
|
||||
goto Next;
|
||||
}
|
||||
|
||||
@ -1254,12 +1234,12 @@ AsInsertPrefix (
|
||||
/*
|
||||
* Use "if (TrailingSpaces > 1)" if we want to ignore casts
|
||||
*/
|
||||
SubBuffer = SubString + InsertLength;
|
||||
|
||||
if (TrailingSpaces > InsertLength)
|
||||
{
|
||||
/* Move the keyword */
|
||||
/* Insert the keyword */
|
||||
|
||||
SubBuffer = SubString + InsertLength;
|
||||
memmove (SubBuffer, SubString, KeywordLength);
|
||||
|
||||
/* Insert the keyword */
|
||||
@ -1268,14 +1248,7 @@ AsInsertPrefix (
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Make room for the insertion */
|
||||
|
||||
SubBuffer = SubString + InsertLength;
|
||||
memmove (SubBuffer, SubString, StrLength+1);
|
||||
|
||||
/* Insert the keyword */
|
||||
|
||||
memmove (SubString, InsertString, InsertLength);
|
||||
AsInsertData (SubString, InsertString, InsertLength);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Module Name: asremove - Source conversion - removal functions
|
||||
* $Revision: 1.4 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
*
|
||||
* 1. Copyright Notice
|
||||
*
|
||||
* Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
|
||||
* Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 2. License
|
||||
@ -566,6 +566,7 @@ AsRemoveEmptyBlocks (
|
||||
}
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* FUNCTION: AsRemoveDebugMacros
|
||||
|
@ -2,7 +2,7 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Module Name: asutils - common utilities
|
||||
* $Revision: 1.5 $
|
||||
* $Revision: 1.8 $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
*
|
||||
* 1. Copyright Notice
|
||||
*
|
||||
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
|
||||
* Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 2. License
|
||||
@ -201,10 +201,8 @@ AsReplaceData (
|
||||
/*
|
||||
* Buffer is a string, so the length must include the terminating zero
|
||||
*/
|
||||
|
||||
BufferLength = strlen (Buffer) + 1;
|
||||
|
||||
|
||||
if (LengthToRemove != LengthToAdd)
|
||||
{
|
||||
/*
|
||||
@ -212,7 +210,6 @@ AsReplaceData (
|
||||
* 1) If adding more bytes than removing, make room for the new data
|
||||
* 2) if removing more bytes than adding, delete the extra space
|
||||
*/
|
||||
|
||||
if (LengthToRemove > 0)
|
||||
{
|
||||
Gbl_MadeChanges = TRUE;
|
||||
@ -220,11 +217,9 @@ AsReplaceData (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Now we can move in the new data
|
||||
*/
|
||||
|
||||
if (LengthToAdd > 0)
|
||||
{
|
||||
Gbl_MadeChanges = TRUE;
|
||||
@ -235,3 +230,78 @@ AsReplaceData (
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* FUNCTION: AsInsertData
|
||||
*
|
||||
* DESCRIPTION: This function inserts and removes data from the file buffer.
|
||||
* if more data is inserted than is removed, the data in the buffer
|
||||
* is moved to make room. If less data is inserted than is removed,
|
||||
* the remaining data is moved to close the hole.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
char *
|
||||
AsInsertData (
|
||||
char *Buffer,
|
||||
char *BufferToAdd,
|
||||
UINT32 LengthToAdd)
|
||||
{
|
||||
UINT32 BufferLength;
|
||||
|
||||
|
||||
if (LengthToAdd > 0)
|
||||
{
|
||||
/*
|
||||
* Buffer is a string, so the length must include the terminating zero
|
||||
*/
|
||||
BufferLength = strlen (Buffer) + 1;
|
||||
|
||||
/*
|
||||
* Move some of the existing data
|
||||
* 1) If adding more bytes than removing, make room for the new data
|
||||
* 2) if removing more bytes than adding, delete the extra space
|
||||
*/
|
||||
Gbl_MadeChanges = TRUE;
|
||||
memmove ((Buffer + LengthToAdd), Buffer, BufferLength);
|
||||
|
||||
/*
|
||||
* Now we can move in the new data
|
||||
*/
|
||||
memmove (Buffer, BufferToAdd, LengthToAdd);
|
||||
}
|
||||
|
||||
return (Buffer + LengthToAdd);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* FUNCTION: AsRemoveData
|
||||
*
|
||||
* DESCRIPTION: This function inserts and removes data from the file buffer.
|
||||
* if more data is inserted than is removed, the data in the buffer
|
||||
* is moved to make room. If less data is inserted than is removed,
|
||||
* the remaining data is moved to close the hole.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
char *
|
||||
AsRemoveData (
|
||||
char *StartPointer,
|
||||
char *EndPointer)
|
||||
{
|
||||
UINT32 BufferLength;
|
||||
|
||||
|
||||
/*
|
||||
* Buffer is a string, so the length must include the terminating zero
|
||||
*/
|
||||
BufferLength = strlen (EndPointer) + 1;
|
||||
|
||||
Gbl_MadeChanges = TRUE;
|
||||
memmove (StartPointer, EndPointer, BufferLength);
|
||||
|
||||
return (StartPointer);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user