Skip to content

Commit

Permalink
Fixed some compiler warnings
Browse files Browse the repository at this point in the history
Fixed a appversion.sh when the path may contain spaces
  • Loading branch information
s1lentq committed Feb 6, 2020
1 parent b465002 commit 3f6d9db
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 63 deletions.
4 changes: 2 additions & 2 deletions regamedll/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ else()
endif()

if (NOT DEBUG AND USE_STATIC_LIBSTDC)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-gc-sections -Wl,--version-script=${PROJECT_SOURCE_DIR}/../version_script.lds")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-gc-sections -Wl,--version-script=\"${PROJECT_SOURCE_DIR}/../version_script.lds\"")
endif()

if (USE_STATIC_LIBSTDC)
Expand Down Expand Up @@ -142,7 +142,7 @@ add_definitions(

add_library(regamedll SHARED ${appversion.sh} ${GAMEDLL_SRCS} ${ENGINE_SRCS} ${SHARED_SRCS})
set_property(TARGET regamedll PROPERTY LIBRARY_OUTPUT_NAME cs)
add_custom_target(appversion COMMAND ${PROJECT_SOURCE_DIR}/version/appversion.sh ${PROJECT_SOURCE_DIR} regamedll)
add_custom_target(appversion DEPENDS COMMAND "${PROJECT_SOURCE_DIR}/version/appversion.sh" "${PROJECT_SOURCE_DIR}")
set_target_properties(regamedll PROPERTIES PREFIX "" COMPILE_FLAGS "-m32" LINK_FLAGS "-m32" POSITION_INDEPENDENT_CODE ON)
target_link_libraries(regamedll dl aelf32)
add_dependencies(regamedll appversion)
4 changes: 2 additions & 2 deletions regamedll/dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3209,7 +3209,7 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa
{
if (pPlayer->pev->deadflag != DEAD_NO && pPlayer->m_autoBuyString[0] != '\0')
return;

pPlayer->ClearAutoBuyData();

for (int i = 1; i < CMD_ARGC_(); i++)
Expand All @@ -3229,7 +3229,7 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa
{
if (pPlayer->pev->deadflag != DEAD_NO && pPlayer->m_rebuyString)
return;

if (CMD_ARGC_() == 2)
{
pPlayer->InitRebuyData(parg1);
Expand Down
2 changes: 1 addition & 1 deletion regamedll/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6859,7 +6859,7 @@ void CBasePlayer::SendHostageIcons()
if (hostagesCount > MAX_HOSTAGE_ICON)
hostagesCount = MAX_HOSTAGE_ICON;

char buf[16];
char buf[18];
Q_snprintf(buf, ARRAYSIZE(buf), "hostage%d", hostagesCount);

if (hostagesCount)
Expand Down
22 changes: 11 additions & 11 deletions regamedll/dlls/sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ int USENTENCEG_PickSequential(int isentenceg, char *szfound, int ipick, int fres
{
char *szgroupname;
unsigned char count;
char sznum[8];
char sznum[12];

if (!fSentencesInit)
return -1;
Expand All @@ -1063,7 +1063,7 @@ int USENTENCEG_PickSequential(int isentenceg, char *szfound, int ipick, int fres

Q_strcpy(szfound, "!");
Q_strcat(szfound, szgroupname);
Q_sprintf(sznum, "%d", ipick);
Q_snprintf(sznum, sizeof(sznum), "%d", ipick);
Q_strcat(szfound, sznum);

if (ipick >= count)
Expand All @@ -1090,7 +1090,7 @@ int USENTENCEG_Pick(int isentenceg, char *szfound)
unsigned char *plru;
unsigned char i;
unsigned char count;
char sznum[8];
char sznum[12];
unsigned char ipick = 0xFF;
BOOL ffound = FALSE;

Expand Down Expand Up @@ -1121,7 +1121,7 @@ int USENTENCEG_Pick(int isentenceg, char *szfound)
{
Q_strcpy(szfound, "!");
Q_strcat(szfound, szgroupname);
Q_sprintf(sznum, "%d", ipick);
Q_snprintf(sznum, sizeof(sznum), "%d", ipick);
Q_strcat(szfound, sznum);

return ipick;
Expand Down Expand Up @@ -1243,18 +1243,18 @@ int SENTENCEG_PlaySequentialSz(edict_t *entity, const char *szgroupname, float v
NOXREF void SENTENCEG_Stop(edict_t *entity, int isentenceg, int ipick)
{
char buffer[64];
char sznum[8];
char sznum[12];

if (!fSentencesInit)
return;

if (isentenceg < 0 || ipick < 0)
return;

Q_strcpy(buffer, "!");
Q_strcat(buffer, rgsentenceg[isentenceg].szgroupname);
Q_sprintf(sznum, "%d", ipick);
Q_strcat(buffer, sznum);
Q_strlcpy(buffer, "!");
Q_strlcat(buffer, rgsentenceg[isentenceg].szgroupname);
Q_snprintf(sznum, sizeof(sznum), "%d", ipick);
Q_strlcat(buffer, sznum);

STOP_SOUND(entity, CHAN_VOICE, buffer);
}
Expand Down Expand Up @@ -1387,7 +1387,7 @@ void SENTENCEG_Init()
// convert sentence (sample) name to !sentencenum, return !sentencenum
int SENTENCEG_Lookup(const char *sample, char *sentencenum)
{
char sznum[8];
char sznum[12];
int i;

// this is a sentence name; lookup sentence number
Expand All @@ -1399,7 +1399,7 @@ int SENTENCEG_Lookup(const char *sample, char *sentencenum)
if (sentencenum)
{
Q_strcpy(sentencenum, "!");
Q_sprintf(sznum, "%d", i);
Q_snprintf(sznum, sizeof(sznum), "%d", i);
Q_strcat(sentencenum, sznum);
}

Expand Down
14 changes: 7 additions & 7 deletions regamedll/game_shared/bot/nav_area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3806,7 +3806,7 @@ void EditNavAreas(NavEditCmdType cmd)
{
lastSelectedArea = area;

char buffer[80];
char buffer[190];
char attrib[80];
char locName[80];

Expand All @@ -3829,14 +3829,14 @@ void EditNavAreas(NavEditCmdType cmd)
}
else
{
Q_sprintf(attrib, "%s%s%s%s",
Q_snprintf(attrib, sizeof(attrib), "%s%s%s%s",
(area->GetAttributes() & NAV_CROUCH) ? "CROUCH " : "",
(area->GetAttributes() & NAV_JUMP) ? "JUMP " : "",
(area->GetAttributes() & NAV_PRECISE) ? "PRECISE " : "",
(area->GetAttributes() & NAV_NO_JUMP) ? "NO_JUMP " : "");
}

Q_sprintf(buffer, "Area #%d %s %s\n", area->GetID(), locName, attrib);
Q_snprintf(buffer, sizeof(buffer), "Area #%d %s %s\n", area->GetID(), locName, attrib);
UTIL_SayTextAll(buffer, pLocalPlayer);

// do "place painting"
Expand Down Expand Up @@ -4018,8 +4018,8 @@ void EditNavAreas(NavEditCmdType cmd)
connected += markedArea->GetAdjacentCount(EAST);
connected += markedArea->GetAdjacentCount(WEST);

char buffer[80];
Q_sprintf(buffer, "Marked Area is connected to %d other Areas\n", connected);
char buffer[190];
Q_snprintf(buffer, sizeof(buffer), "Marked Area is connected to %d other Areas\n", connected);
UTIL_SayTextAll(buffer, pLocalPlayer);
}
break;
Expand Down Expand Up @@ -4065,8 +4065,8 @@ void EditNavAreas(NavEditCmdType cmd)
}
}

char buffer[80];
Q_sprintf(buffer, "Marked Area is connected to %d other Areas - there are %d total unnamed areas\n", connected, totalUnnamedAreas);
char buffer[190];
Q_snprintf(buffer, sizeof(buffer), "Marked Area is connected to %d other Areas - there are %d total unnamed areas\n", connected, totalUnnamedAreas);
UTIL_SayTextAll(buffer, pLocalPlayer);
}
}
Expand Down
80 changes: 40 additions & 40 deletions regamedll/version/appversion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

init()
{
SOURCE_DIR=$1
VERSION_FILE=$SOURCE_DIR/../gradle.properties
APPVERSION_FILE=$SOURCE_DIR/version/appversion.h
SOURCE_DIR="$@"
GIT_DIR="$SOURCE_DIR/.."
VERSION_FILE="$GIT_DIR/gradle.properties"
APPVERSION_FILE="$SOURCE_DIR/version/appversion.h"

if test -z "`git --version`"; then
echo "Please install git client"
echo "sudo apt-get install git"
exit 0
exit -1
fi

# Read old version
if [ -e $APPVERSION_FILE ]; then
OLD_VERSION=$(cat $APPVERSION_FILE | grep -wi '#define APP_VERSION' | sed -e 's/#define APP_VERSION[ \t\r\n\v\f]\+\(.*\)/\1/i' -e 's/\r//g')
if [ -e "$APPVERSION_FILE" ]; then
OLD_VERSION=$(cat "$APPVERSION_FILE" | grep -wi '#define APP_VERSION' | sed -e 's/#define APP_VERSION[ \t\r\n\v\f]\+\(.*\)/\1/i' -e 's/\r//g')
if [ $? -ne 0 ]; then
OLD_VERSION=""
else
Expand All @@ -23,29 +24,28 @@ init()
fi
fi


# Get major, minor and maintenance information from version.h
MAJOR=$(sed -nr -e '/majorVersion/ s/.*\= *//p' $VERSION_FILE | tr -d '\n\r')
# Get major, minor and maintenance information from gradle.properties
MAJOR=$(sed -nr -e '/majorVersion/ s/.*\= *//p' "$VERSION_FILE" | tr -d '\n\r')
if [ $? -ne 0 -o "$MAJOR" = "" ]; then
MAJOR=0
fi

MINOR=$(sed -nr -e '/minorVersion/ s/.*\= *//p' $VERSION_FILE | tr -d '\n\r')
MINOR=$(sed -nr -e '/minorVersion/ s/.*\= *//p' "$VERSION_FILE" | tr -d '\n\r')
if [ $? -ne 0 -o "$MINOR" = "" ]; then
MINOR=0
fi

MAINTENANCE=$(sed -nr -e '/maintenanceVersion/ s/.*\= *//p' $VERSION_FILE | tr -d '\n\r')
MAINTENANCE=$(sed -nr -e '/maintenanceVersion/ s/.*\= *//p' "$VERSION_FILE" | tr -d '\n\r')
if [ $? -ne 0 -o "$MAINTENANCE" = "" ]; then
MAINTENANCE=0
fi

BRANCH_NAME=$(git -C $SOURCE_DIR/../ rev-parse --abbrev-ref HEAD)
BRANCH_NAME=$(git -C "$GIT_DIR/" rev-parse --abbrev-ref HEAD)
if [ $? -ne 0 -o "$BRANCH_NAME" = "" ]; then
BRANCH_NAME=master
fi

COMMIT_COUNT=$(git -C $SOURCE_DIR/../ rev-list --count $BRANCH_NAME)
COMMIT_COUNT=$(git -C "$GIT_DIR/" rev-list --count $BRANCH_NAME)
if [ $? -ne 0 -o "$COMMIT_COUNT" = "" ]; then
COMMIT_COUNT=0
fi
Expand All @@ -54,17 +54,17 @@ init()
# Configure remote url repository
#
# Get remote name by current branch
BRANCH_REMOTE=$(git -C $SOURCE_DIR/../ config branch.$BRANCH_NAME.remote)
BRANCH_REMOTE=$(git -C "$GIT_DIR/" config branch.$BRANCH_NAME.remote)
if [ $? -ne 0 -o "$BRANCH_REMOTE" = "" ]; then
BRANCH_REMOTE=origin
fi

# Get commit id
COMMIT_SHA=$(git -C $SOURCE_DIR/../ rev-parse --verify HEAD)
COMMIT_SHA=$(git -C "$GIT_DIR/" rev-parse --verify HEAD)
COMMIT_SHA=${COMMIT_SHA:0:7}

# Get remote url
COMMIT_URL=$(git -C $SOURCE_DIR/../ config remote.$BRANCH_REMOTE.url)
COMMIT_URL=$(git -C "$GIT_DIR/" config remote.$BRANCH_REMOTE.url)

# Strip prefix 'git@'
COMMIT_URL=${COMMIT_URL#git@}
Expand All @@ -85,7 +85,7 @@ init()
#
# Detect local modifications
#
if [ `git -C $SOURCE_DIR/../ ls-files -m | wc -l` = 0 ]; then
if [ `git -C "$GIT_DIR/" ls-files -m | wc -l` = 0 ]; then
MODIFIED=
else
MODIFIED=+m
Expand All @@ -109,29 +109,29 @@ update_appversion()
# Write appversion.h
echo Updating appversion.h, new version is '"'$NEW_VERSION'"', the old one was $OLD_VERSION

echo -e "#ifndef __APPVERSION_H__\r">$APPVERSION_FILE
echo -e "#define __APPVERSION_H__\r">>$APPVERSION_FILE
echo -e "\r">>$APPVERSION_FILE
echo -e "//\r">>$APPVERSION_FILE
echo -e "// This file is generated automatically.\r">>$APPVERSION_FILE
echo -e "// Don't edit it.\r">>$APPVERSION_FILE
echo -e "//\r">>$APPVERSION_FILE
echo -e "\r">>$APPVERSION_FILE
echo -e "// Version defines\r">>$APPVERSION_FILE
echo -e '#define APP_VERSION "'$NEW_VERSION'"\r'>>$APPVERSION_FILE

echo -e "#define APP_VERSION_C $MAJOR,$MINOR,$MAINTENANCE,$COMMIT_COUNT\r">>$APPVERSION_FILE
echo -e '#define APP_VERSION_STRD "'$MAJOR.$MINOR.$MAINTENANCE.$COMMIT_COUNT'"\r'>>$APPVERSION_FILE
echo -e "#define APP_VERSION_FLAGS 0x0L\r">>$APPVERSION_FILE
echo -e "\r">>$APPVERSION_FILE
echo -e '#define APP_COMMIT_DATE "'$month $day $year'"\r'>>$APPVERSION_FILE
echo -e '#define APP_COMMIT_TIME "'$hours'"\r'>>$APPVERSION_FILE
echo -e "\r">>$APPVERSION_FILE

echo -e '#define APP_COMMIT_SHA "'$COMMIT_SHA'"\r'>>$APPVERSION_FILE
echo -e '#define APP_COMMIT_URL "'$COMMIT_URL'"\r'>>$APPVERSION_FILE
echo -e "\r">>$APPVERSION_FILE
echo -e "#endif //__APPVERSION_H__\r">>$APPVERSION_FILE
echo -e "#ifndef __APPVERSION_H__\r">"$APPVERSION_FILE"
echo -e "#define __APPVERSION_H__\r">>"$APPVERSION_FILE"
echo -e "\r">>"$APPVERSION_FILE"
echo -e "//\r">>"$APPVERSION_FILE"
echo -e "// This file is generated automatically.\r">>"$APPVERSION_FILE"
echo -e "// Don't edit it.\r">>"$APPVERSION_FILE"
echo -e "//\r">>"$APPVERSION_FILE"
echo -e "\r">>"$APPVERSION_FILE"
echo -e "// Version defines\r">>"$APPVERSION_FILE"
echo -e '#define APP_VERSION "'$NEW_VERSION'"\r'>>"$APPVERSION_FILE"

echo -e "#define APP_VERSION_C $MAJOR,$MINOR,$MAINTENANCE,$COMMIT_COUNT\r">>"$APPVERSION_FILE"
echo -e '#define APP_VERSION_STRD "'$MAJOR.$MINOR.$MAINTENANCE.$COMMIT_COUNT'"\r'>>"$APPVERSION_FILE"
echo -e "#define APP_VERSION_FLAGS 0x0L\r">>"$APPVERSION_FILE"
echo -e "\r">>"$APPVERSION_FILE"
echo -e '#define APP_COMMIT_DATE "'$month $day $year'"\r'>>"$APPVERSION_FILE"
echo -e '#define APP_COMMIT_TIME "'$hours'"\r'>>"$APPVERSION_FILE"
echo -e "\r">>"$APPVERSION_FILE"

echo -e '#define APP_COMMIT_SHA "'$COMMIT_SHA'"\r'>>"$APPVERSION_FILE"
echo -e '#define APP_COMMIT_URL "'$COMMIT_URL'"\r'>>"$APPVERSION_FILE"
echo -e "\r">>"$APPVERSION_FILE"
echo -e "#endif //__APPVERSION_H__\r">>"$APPVERSION_FILE"
}

# Initialise
Expand Down

0 comments on commit 3f6d9db

Please sign in to comment.