Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
Language: Cpp

# --- Indentation ---
IndentWidth: 3
TabWidth: 3
UseTab: Never

# --- Column width ---
ColumnLimit: 80

# --- Alignment ---
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false

# --- Braces (Allman for functions/classes, inline for control flow) ---
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false

# --- Constructor initializer lists ---
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 3
NamespaceIndentation: None

# --- Continuation indent ---
ContinuationIndentWidth: 3
Cpp11BracedListStyle: true
DerivePointerAlignment: false

# --- Function definitions ---
IncludeBlocks: Preserve
IndentCaseLabels: true
IndentGotoLabels: true
IndentPPDirectives: AfterHash
IndentWrappedFunctionNames: true

# --- Line breaking ---
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200

# --- Namespace ---
SortIncludes: false
SortUsingDeclarations: false
Standard: c++17

# --- Spaces ---
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInContainerLiterals: true

# --- Statement folding ---
SpaceAfterLogicalNot: false
StatementMacros:
- TODO
- FIXME

# --- Wrap ---
BinPackArguments: true
BinPackLongBracedList: false
BinPackParameters: false
CompactNamespaces: false
PenaltyBreakFirstLessLess: 0
46 changes: 23 additions & 23 deletions common/i18n.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,34 @@
#define _I18N_H_

#ifdef HAVE_CONFIG_H
#include "config.h" // IWYU pragma: associated
# include "config.h" // IWYU pragma: associated
#endif

#ifdef ENABLE_NLS
#include <locale.h>
# include <libintl.h>
# define _(String) gettext (String)
# ifdef gettext_noop
# define N_(String) gettext_noop (String)
# else
# define N_(String) (String)
# endif
# include <locale.h>
# include <libintl.h>
# define _(String) gettext(String)
# ifdef gettext_noop
# define N_(String) gettext_noop(String)
# else
# define N_(String) (String)
# endif
#else
/* Stubs that do something close enough. */
# undef textdomain
# define textdomain(String) (String)
# undef gettext
# define gettext(String) (String)
# undef dgettext
# define dgettext(Domain,Message) (Message)
# undef dcgettext
# define dcgettext(Domain,Message,Type) (Message)
# undef bindtextdomain
# define bindtextdomain(Domain,Directory) (Domain)
# undef _
# define _(String) (String)
# undef N_
# define N_(String) (String)
# undef textdomain
# define textdomain(String) (String)
# undef gettext
# define gettext(String) (String)
# undef dgettext
# define dgettext(Domain, Message) (Message)
# undef dcgettext
# define dcgettext(Domain, Message, Type) (Message)
# undef bindtextdomain
# define bindtextdomain(Domain, Directory) (Domain)
# undef _
# define _(String) (String)
# undef N_
# define N_(String) (String)
#endif


Expand Down
69 changes: 35 additions & 34 deletions common/raptoptions.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* raptoptions.cc - configuration handling
*
* Copyright (c) 2000, 2001 Conectiva S/A
*
*
* Copyright (c) 2000, 2001 Conectiva S/A
*
* Author: Alfredo K. Kojima <kojima@conectiva.com.br>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
Expand All @@ -20,7 +20,7 @@
* USA
*/

#include "config.h" // IWYU pragma: associated
#include "config.h" // IWYU pragma: associated

#include "raptoptions.h"

Expand Down Expand Up @@ -77,10 +77,10 @@ bool RAPTOptions::store()

bool RAPTOptions::restore()
{
string pkg, line;
string pkg, line;
packageOptions o;

//cout << "bool RAPTOptions::restore()" << endl;
// cout << "bool RAPTOptions::restore()" << endl;

ifstream in;
if (!RPackageOptionsFile(in))
Expand All @@ -95,9 +95,9 @@ bool RAPTOptions::restore()
}

// upgrade code for older synaptic versions, can go away in the future
if(FileExists(RConfDir()+"/preferences"))
rename(string(RConfDir()+"/preferences").c_str(),
string(RStateDir()+"/preferences").c_str());
if (FileExists(RConfDir() + "/preferences"))
rename(string(RConfDir() + "/preferences").c_str(),
string(RStateDir() + "/preferences").c_str());


// pining stuff
Expand All @@ -106,7 +106,7 @@ bool RAPTOptions::restore()
if (!FileExists(File))
return true;

FileFd Fd(File, FileFd::ReadOnly);
FileFd Fd(File, FileFd::ReadOnly);
pkgTagFile TF(&Fd);
if (_error->PendingError() == true) {
return false;
Expand All @@ -115,9 +115,8 @@ bool RAPTOptions::restore()
while (TF.Step(Tags) == true) {
string Name = Tags.FindS("Package");
if (Name.empty() == true)
return _error->
Error(_
("Invalid record in the preferences file, no Package header"));
return _error->Error(
_("Invalid record in the preferences file, no Package header"));
if (Name == "*")
Name = string();

Expand All @@ -127,15 +126,17 @@ bool RAPTOptions::restore()
continue;

const char *Word = Start;
for (; Word != End && isspace(*Word) == 0; Word++);
for (; Word != End && isspace(*Word) == 0; Word++)
;

// Parse the type, we are only interesseted in "version" for now
pkgVersionMatch::MatchType Type;
if (stringcasecmp(Start, Word, "version") == 0 && Name.empty() == false)
Type = pkgVersionMatch::Version;
else
continue;
for (; Word != End && isspace(*Word) != 0; Word++);
for (; Word != End && isspace(*Word) != 0; Word++)
;

setPackageLock(Name.c_str(), true);
}
Expand All @@ -156,20 +157,20 @@ bool RAPTOptions::getPackageDebconf(const char *package)
if (_packageOptions.find(tmp) == _packageOptions.end())
return false;

//cout << "getPackageOrphaned("<<package<<") called"<<endl;
// cout << "getPackageOrphaned("<<package<<") called"<<endl;
return _packageOptions[tmp].isDebconf;
}


void RAPTOptions::setPackageDebconf(const char *package, bool flag)
{
//cout << "debconf called pkg: " << package << endl;
// cout << "debconf called pkg: " << package << endl;
_packageOptions[string(package)].isDebconf = flag;
}

void RAPTOptions::rereadDebconf()
{
//cout << "void RAPTOptions::rereadDebconf()" << endl;
// cout << "void RAPTOptions::rereadDebconf()" << endl;

// forget about any previously debconf packages
for (packageOptionsIter it = _roptions->_packageOptions.begin();
Expand All @@ -178,23 +179,23 @@ void RAPTOptions::rereadDebconf()
}

// read dir
const char infodir[] = "/var/lib/dpkg/info";
const char infodir[] = "/var/lib/dpkg/info";
const char configext[] = ".config";

DIR *dir;
DIR *dir;
struct dirent *dent;
char *point;
char *point;

if ((dir = opendir(infodir)) == NULL) {
//cerr << "Error opening " << infodir << endl;
// cerr << "Error opening " << infodir << endl;
return;
}
for (int i = 3; (dent = readdir(dir)); i++) {
if ((point = strrchr(dent->d_name, '.')) == NULL)
continue;
if (strcmp(point, configext) == 0) {
memset(point, 0, strlen(point));
//cout << (dent->d_name) << endl;
// cout << (dent->d_name) << endl;
setPackageDebconf(dent->d_name, true);
}
}
Expand All @@ -209,23 +210,23 @@ void RAPTOptions::rereadOrphaned()
(*it).second.isOrphaned = false;
}

//mvo: call deborphan and read package list from it
// TODO: make deborphan a library to make this cleaner
// mvo: call deborphan and read package list from it
// TODO: make deborphan a library to make this cleaner
FILE *fp;
char buf[255];
char cmd[] = "/usr/bin/deborphan";
//FIXME: fail silently if deborphan is not installed - change this?
char buf[255];
char cmd[] = "/usr/bin/deborphan";
// FIXME: fail silently if deborphan is not installed - change this?
if (!FileExists(cmd))
return;
fp = popen(cmd, "r");
if (fp == NULL) {
//cerr << "deborphan failed" << endl;
// cerr << "deborphan failed" << endl;
return;
}
while (fgets(buf, sizeof(buf), fp) != NULL) {
// remove newline at end and strip architecture suffix
buf[strcspn(buf, "\n:")] = '\0';
//cout << "buf: " << buf << endl;
// cout << "buf: " << buf << endl;
setPackageOrphaned(buf, true);
}
pclose(fp);
Expand All @@ -239,14 +240,14 @@ bool RAPTOptions::getPackageOrphaned(const char *package)
if (_packageOptions.find(tmp) == _packageOptions.end())
return false;

//cout << "getPackageOrphaned("<<package<<") called"<<endl;
// cout << "getPackageOrphaned("<<package<<") called"<<endl;
return _packageOptions[tmp].isOrphaned;
}


void RAPTOptions::setPackageOrphaned(const char *package, bool flag)
{
//cout << "orphaned called pkg: " << package << endl;
// cout << "orphaned called pkg: " << package << endl;
_packageOptions[string(package)].isOrphaned = flag;
}

Expand Down
Loading