]>
git.saurik.com Git - apt.git/blob - apt-private/private-output.cc
2120b7a83674ddfb6db28a013565f4368f2daa5a
1 // Include files /*{{{*/
4 #include <apt-pkg/configuration.h>
5 #include <apt-pkg/strutl.h>
6 #include <apt-pkg/error.h>
7 #include <apt-pkg/cachefile.h>
8 #include <apt-pkg/pkgrecords.h>
9 #include <apt-pkg/policy.h>
10 #include <apt-pkg/depcache.h>
11 #include <apt-pkg/pkgcache.h>
12 #include <apt-pkg/cacheiterators.h>
14 #include <apt-private/private-output.h>
15 #include <apt-private/private-cachefile.h>
26 #include <sys/ioctl.h>
33 std::ostream
c0out(0);
34 std::ostream
c1out(0);
35 std::ostream
c2out(0);
36 std::ofstream
devnull("/dev/null");
39 unsigned int ScreenWidth
= 80 - 1; /* - 1 for the cursor */
41 // SigWinch - Window size change signal handler /*{{{*/
42 // ---------------------------------------------------------------------
44 static void SigWinch(int)
50 if (ioctl(1, TIOCGWINSZ
, &ws
) != -1 && ws
.ws_col
>= 5)
51 ScreenWidth
= ws
.ws_col
- 1;
55 bool InitOutput() /*{{{*/
57 if (!isatty(STDOUT_FILENO
) && _config
->FindI("quiet", -1) == -1)
58 _config
->Set("quiet","1");
60 c0out
.rdbuf(cout
.rdbuf());
61 c1out
.rdbuf(cout
.rdbuf());
62 c2out
.rdbuf(cout
.rdbuf());
63 if (_config
->FindI("quiet",0) > 0)
64 c0out
.rdbuf(devnull
.rdbuf());
65 if (_config
->FindI("quiet",0) > 1)
66 c1out
.rdbuf(devnull
.rdbuf());
68 // deal with window size changes
69 signal(SIGWINCH
,SigWinch
);
74 _config
->Set("APT::Color", "false");
75 _config
->Set("APT::Color::Highlight", "");
76 _config
->Set("APT::Color::Neutral", "");
79 _config
->CndSet("APT::Color::Highlight", "\x1B[32m");
80 _config
->CndSet("APT::Color::Neutral", "\x1B[0m");
82 _config
->CndSet("APT::Color::Red", "\x1B[31m");
83 _config
->CndSet("APT::Color::Green", "\x1B[32m");
84 _config
->CndSet("APT::Color::Yellow", "\x1B[33m");
85 _config
->CndSet("APT::Color::Blue", "\x1B[34m");
86 _config
->CndSet("APT::Color::Magenta", "\x1B[35m");
87 _config
->CndSet("APT::Color::Cyan", "\x1B[36m");
88 _config
->CndSet("APT::Color::White", "\x1B[37m");
94 static std::string
GetArchiveSuite(pkgCacheFile
&/*CacheFile*/, pkgCache::VerIterator ver
) /*{{{*/
96 std::string suite
= "";
97 if (ver
&& ver
.FileList())
99 pkgCache::VerFileIterator VF
= ver
.FileList();
100 for (; VF
.end() == false ; ++VF
)
102 if(VF
.File() == NULL
|| VF
.File().Archive() == NULL
)
103 suite
= suite
+ "," + _("unknown");
105 suite
= suite
+ "," + VF
.File().Archive();
106 //suite = VF.File().Archive();
108 suite
= suite
.erase(0, 1);
113 static std::string
GetFlagsStr(pkgCacheFile
&CacheFile
, pkgCache::PkgIterator P
)/*{{{*/
115 pkgDepCache
*DepCache
= CacheFile
.GetDepCache();
116 pkgDepCache::StateCache
&state
= (*DepCache
)[P
];
118 std::string flags_str
;
119 if (state
.NowBroken())
121 if (P
.CurrentVer() && state
.Upgradable() && state
.CandidateVer
!= NULL
)
123 else if (P
.CurrentVer() != NULL
)
130 static std::string
GetCandidateVersion(pkgCacheFile
&CacheFile
, pkgCache::PkgIterator P
)/*{{{*/
132 pkgPolicy
*policy
= CacheFile
.GetPolicy();
133 pkgCache::VerIterator cand
= policy
->GetCandidateVer(P
);
135 return cand
? cand
.VerStr() : "(none)";
138 static std::string
GetInstalledVersion(pkgCacheFile
&/*CacheFile*/, pkgCache::PkgIterator P
)/*{{{*/
140 pkgCache::VerIterator inst
= P
.CurrentVer();
142 return inst
? inst
.VerStr() : "(none)";
145 static std::string
GetVersion(pkgCacheFile
&/*CacheFile*/, pkgCache::VerIterator V
)/*{{{*/
147 pkgCache::PkgIterator P
= V
.ParentPkg();
148 if (V
== P
.CurrentVer())
150 std::string inst_str
= DeNull(V
.VerStr());
151 #if 0 // FIXME: do we want this or something like this?
152 pkgDepCache
*DepCache
= CacheFile
.GetDepCache();
153 pkgDepCache::StateCache
&state
= (*DepCache
)[P
];
154 if (state
.Upgradable())
155 return "**"+inst_str
;
161 return DeNull(V
.VerStr());
165 static std::string
GetArchitecture(pkgCacheFile
&CacheFile
, pkgCache::PkgIterator P
)/*{{{*/
167 pkgPolicy
*policy
= CacheFile
.GetPolicy();
168 pkgCache::VerIterator inst
= P
.CurrentVer();
169 pkgCache::VerIterator cand
= policy
->GetCandidateVer(P
);
171 // this may happen for packages in dpkg "deinstall ok config-file" state
172 if (inst
.IsGood() == false && cand
.IsGood() == false)
173 return P
.VersionList().Arch();
175 return inst
? inst
.Arch() : cand
.Arch();
178 static std::string
GetShortDescription(pkgCacheFile
&CacheFile
, pkgRecords
&records
, pkgCache::PkgIterator P
)/*{{{*/
180 pkgPolicy
*policy
= CacheFile
.GetPolicy();
182 pkgCache::VerIterator ver
;
184 ver
= P
.CurrentVer();
186 ver
= policy
->GetCandidateVer(P
);
188 std::string ShortDescription
= "(none)";
191 pkgCache::DescIterator Desc
= ver
.TranslatedDescription();
192 pkgRecords::Parser
& parser
= records
.Lookup(Desc
.FileList());
194 ShortDescription
= parser
.ShortDesc();
196 return ShortDescription
;
199 void ListSingleVersion(pkgCacheFile
&CacheFile
, pkgRecords
&records
, /*{{{*/
200 pkgCache::VerIterator V
, std::ostream
&out
,
201 bool include_summary
)
203 pkgCache::PkgIterator P
= V
.ParentPkg();
205 pkgDepCache
*DepCache
= CacheFile
.GetDepCache();
206 pkgDepCache::StateCache
&state
= (*DepCache
)[P
];
208 std::string suite
= GetArchiveSuite(CacheFile
, V
);
209 std::string name_str
= P
.Name();
211 if (_config
->FindB("APT::Cmd::use-format", false))
213 std::string format
= _config
->Find("APT::Cmd::format", "${db::Status-Abbrev} ${Package} ${Version} ${Origin} ${Description}");
214 std::string output
= format
;
216 output
= SubstVar(output
, "${db::Status-Abbrev}", GetFlagsStr(CacheFile
, P
));
217 output
= SubstVar(output
, "${Package}", name_str
);
218 output
= SubstVar(output
, "${installed:Version}", GetInstalledVersion(CacheFile
, P
));
219 output
= SubstVar(output
, "${candidate:Version}", GetCandidateVersion(CacheFile
, P
));
220 output
= SubstVar(output
, "${Version}", GetVersion(CacheFile
, V
));
221 output
= SubstVar(output
, "${Description}", GetShortDescription(CacheFile
, records
, P
));
222 output
= SubstVar(output
, "${Origin}", GetArchiveSuite(CacheFile
, V
));
225 // raring/linux-kernel version [upradable: new-version]
227 pkgPolicy
*policy
= CacheFile
.GetPolicy();
228 std::string VersionStr
= GetVersion(CacheFile
, V
);
229 std::string CandidateVerStr
= GetCandidateVersion(CacheFile
, P
);
230 std::string InstalledVerStr
= GetInstalledVersion(CacheFile
, P
);
231 std::string StatusStr
;
232 if(P
.CurrentVer() == V
&&
233 state
.Upgradable() &&
234 state
.CandidateVer
!= NULL
&&
235 policy
->GetCandidateVer(P
) != P
.CurrentVer())
237 strprintf(StatusStr
, _("[installed,upgradable to: %s]"),
238 CandidateVerStr
.c_str());
239 } else if (P
.CurrentVer() == V
) {
240 if(!V
.Downloadable())
241 StatusStr
= _("[installed,local]");
243 if(V
.Automatic() && state
.Garbage
)
244 StatusStr
= _("[installed,auto-removable]");
245 else if (state
.Flags
& pkgCache::Flag::Auto
)
246 StatusStr
= _("[installed,automatic]");
248 StatusStr
= _("[installed]");
249 } else if (P
.CurrentVer() &&
250 policy
->GetCandidateVer(P
) == V
&&
251 state
.Upgradable()) {
252 strprintf(StatusStr
, _("[upgradable from: %s]"),
253 InstalledVerStr
.c_str());
255 if (V
.ParentPkg()->CurrentState
== pkgCache::State::ConfigFiles
)
256 StatusStr
= _("[residual-config]");
260 out
<< std::setiosflags(std::ios::left
)
261 << _config
->Find("APT::Color::Highlight", "")
263 << _config
->Find("APT::Color::Neutral", "")
267 << GetArchitecture(CacheFile
, P
);
269 out
<< " " << StatusStr
;
273 << " " << GetShortDescription(CacheFile
, records
, P
)
279 // ShowList - Show a list /*{{{*/
280 // ---------------------------------------------------------------------
281 /* This prints out a string of space separated words with a title and
282 a two space indent line wraped to the current screen width. */
283 bool ShowList(ostream
&out
,string Title
,string List
,string VersionsList
)
285 if (List
.empty() == true)
287 // trim trailing space
288 int NonSpace
= List
.find_last_not_of(' ');
291 List
= List
.erase(NonSpace
+ 1);
292 if (List
.empty() == true)
296 // Acount for the leading space
297 int ScreenWidth
= ::ScreenWidth
- 3;
299 out
<< Title
<< endl
;
300 string::size_type Start
= 0;
301 string::size_type VersionsStart
= 0;
302 while (Start
< List
.size())
304 if(_config
->FindB("APT::Get::Show-Versions",false) == true &&
305 VersionsList
.size() > 0) {
306 string::size_type End
;
307 string::size_type VersionsEnd
;
309 End
= List
.find(' ',Start
);
310 VersionsEnd
= VersionsList
.find('\n', VersionsStart
);
312 out
<< " " << string(List
,Start
,End
- Start
) << " (" <<
313 string(VersionsList
,VersionsStart
,VersionsEnd
- VersionsStart
) <<
316 if (End
== string::npos
|| End
< Start
)
317 End
= Start
+ ScreenWidth
;
320 VersionsStart
= VersionsEnd
+ 1;
322 string::size_type End
;
324 if (Start
+ ScreenWidth
>= List
.size())
327 End
= List
.rfind(' ',Start
+ScreenWidth
);
329 if (End
== string::npos
|| End
< Start
)
330 End
= Start
+ ScreenWidth
;
331 out
<< " " << string(List
,Start
,End
- Start
) << endl
;
339 // ShowBroken - Debugging aide /*{{{*/
340 // ---------------------------------------------------------------------
341 /* This prints out the names of all the packages that are broken along
342 with the name of each each broken dependency and a quite version
345 The output looks like:
346 The following packages have unmet dependencies:
347 exim: Depends: libc6 (>= 2.1.94) but 2.1.3-10 is to be installed
348 Depends: libldap2 (>= 2.0.2-2) but it is not going to be installed
349 Depends: libsasl7 but it is not going to be installed
351 static void ShowBrokenPackage(ostream
&out
, pkgCacheFile
* const Cache
, pkgCache::PkgIterator
const &Pkg
, bool const Now
)
355 if ((*Cache
)[Pkg
].NowBroken() == false)
360 if ((*Cache
)[Pkg
].InstBroken() == false)
364 // Print out each package and the failed dependencies
365 out
<< " " << Pkg
.FullName(true) << " :";
366 unsigned const Indent
= Pkg
.FullName(true).size() + 3;
368 pkgCache::VerIterator Ver
;
371 Ver
= Pkg
.CurrentVer();
373 Ver
= (*Cache
)[Pkg
].InstVerIter(*Cache
);
375 if (Ver
.end() == true)
381 for (pkgCache::DepIterator D
= Ver
.DependsList(); D
.end() == false;)
383 // Compute a single dependency element (glob or)
384 pkgCache::DepIterator Start
;
385 pkgCache::DepIterator End
;
386 D
.GlobOr(Start
,End
); // advances D
388 if ((*Cache
)->IsImportantDep(End
) == false)
393 if (((*Cache
)[End
] & pkgDepCache::DepGNow
) == pkgDepCache::DepGNow
)
398 if (((*Cache
)[End
] & pkgDepCache::DepGInstall
) == pkgDepCache::DepGInstall
)
406 for (unsigned J
= 0; J
!= Indent
; J
++)
410 if (FirstOr
== false)
412 for (unsigned J
= 0; J
!= strlen(End
.DepType()) + 3; J
++)
416 out
<< ' ' << End
.DepType() << ": ";
419 out
<< Start
.TargetPkg().FullName(true);
421 // Show a quick summary of the version requirements
422 if (Start
.TargetVer() != 0)
423 out
<< " (" << Start
.CompType() << " " << Start
.TargetVer() << ")";
425 /* Show a summary of the target package if possible. In the case
426 of virtual packages we show nothing */
427 pkgCache::PkgIterator Targ
= Start
.TargetPkg();
428 if (Targ
->ProvidesList
== 0)
431 pkgCache::VerIterator Ver
= (*Cache
)[Targ
].InstVerIter(*Cache
);
433 Ver
= Targ
.CurrentVer();
435 if (Ver
.end() == false)
438 ioprintf(out
,_("but %s is installed"),Ver
.VerStr());
440 ioprintf(out
,_("but %s is to be installed"),Ver
.VerStr());
444 if ((*Cache
)[Targ
].CandidateVerIter(*Cache
).end() == true)
446 if (Targ
->ProvidesList
== 0)
447 out
<< _("but it is not installable");
449 out
<< _("but it is a virtual package");
452 out
<< (Now
?_("but it is not installed"):_("but it is not going to be installed"));
466 void ShowBroken(ostream
&out
, CacheFile
&Cache
, bool const Now
)
468 if (Cache
->BrokenCount() == 0)
471 out
<< _("The following packages have unmet dependencies:") << endl
;
472 for (unsigned J
= 0; J
< Cache
->Head().PackageCount
; J
++)
474 pkgCache::PkgIterator
const I(Cache
,Cache
.List
[J
]);
475 ShowBrokenPackage(out
, &Cache
, I
, Now
);
478 void ShowBroken(ostream
&out
, pkgCacheFile
&Cache
, bool const Now
)
480 if (Cache
->BrokenCount() == 0)
483 out
<< _("The following packages have unmet dependencies:") << endl
;
484 for (pkgCache::PkgIterator Pkg
= Cache
->PkgBegin(); Pkg
.end() == false; ++Pkg
)
485 ShowBrokenPackage(out
, &Cache
, Pkg
, Now
);
488 // ShowNew - Show packages to newly install /*{{{*/
489 // ---------------------------------------------------------------------
491 void ShowNew(ostream
&out
,CacheFile
&Cache
)
493 /* Print out a list of packages that are going to be installed extra
494 to what the user asked */
497 for (unsigned J
= 0; J
< Cache
->Head().PackageCount
; J
++)
499 pkgCache::PkgIterator
I(Cache
,Cache
.List
[J
]);
500 if (Cache
[I
].NewInstall() == true) {
501 List
+= I
.FullName(true) + " ";
502 VersionsList
+= string(Cache
[I
].CandVersion
) + "\n";
506 ShowList(out
,_("The following NEW packages will be installed:"),List
,VersionsList
);
509 // ShowDel - Show packages to delete /*{{{*/
510 // ---------------------------------------------------------------------
512 void ShowDel(ostream
&out
,CacheFile
&Cache
)
514 /* Print out a list of packages that are going to be removed extra
515 to what the user asked */
518 for (unsigned J
= 0; J
< Cache
->Head().PackageCount
; J
++)
520 pkgCache::PkgIterator
I(Cache
,Cache
.List
[J
]);
521 if (Cache
[I
].Delete() == true)
523 if ((Cache
[I
].iFlags
& pkgDepCache::Purge
) == pkgDepCache::Purge
)
524 List
+= I
.FullName(true) + "* ";
526 List
+= I
.FullName(true) + " ";
528 VersionsList
+= string(Cache
[I
].CandVersion
)+ "\n";
532 ShowList(out
,_("The following packages will be REMOVED:"),List
,VersionsList
);
535 // ShowKept - Show kept packages /*{{{*/
536 // ---------------------------------------------------------------------
538 void ShowKept(ostream
&out
,CacheFile
&Cache
)
542 for (unsigned J
= 0; J
< Cache
->Head().PackageCount
; J
++)
544 pkgCache::PkgIterator
I(Cache
,Cache
.List
[J
]);
547 if (Cache
[I
].Upgrade() == true || Cache
[I
].Upgradable() == false ||
548 I
->CurrentVer
== 0 || Cache
[I
].Delete() == true)
551 List
+= I
.FullName(true) + " ";
552 VersionsList
+= string(Cache
[I
].CurVersion
) + " => " + Cache
[I
].CandVersion
+ "\n";
554 ShowList(out
,_("The following packages have been kept back:"),List
,VersionsList
);
557 // ShowUpgraded - Show upgraded packages /*{{{*/
558 // ---------------------------------------------------------------------
560 void ShowUpgraded(ostream
&out
,CacheFile
&Cache
)
564 for (unsigned J
= 0; J
< Cache
->Head().PackageCount
; J
++)
566 pkgCache::PkgIterator
I(Cache
,Cache
.List
[J
]);
569 if (Cache
[I
].Upgrade() == false || Cache
[I
].NewInstall() == true)
572 List
+= I
.FullName(true) + " ";
573 VersionsList
+= string(Cache
[I
].CurVersion
) + " => " + Cache
[I
].CandVersion
+ "\n";
575 ShowList(out
,_("The following packages will be upgraded:"),List
,VersionsList
);
578 // ShowDowngraded - Show downgraded packages /*{{{*/
579 // ---------------------------------------------------------------------
581 bool ShowDowngraded(ostream
&out
,CacheFile
&Cache
)
585 for (unsigned J
= 0; J
< Cache
->Head().PackageCount
; J
++)
587 pkgCache::PkgIterator
I(Cache
,Cache
.List
[J
]);
590 if (Cache
[I
].Downgrade() == false || Cache
[I
].NewInstall() == true)
593 List
+= I
.FullName(true) + " ";
594 VersionsList
+= string(Cache
[I
].CurVersion
) + " => " + Cache
[I
].CandVersion
+ "\n";
596 return ShowList(out
,_("The following packages will be DOWNGRADED:"),List
,VersionsList
);
599 // ShowHold - Show held but changed packages /*{{{*/
600 // ---------------------------------------------------------------------
602 bool ShowHold(ostream
&out
,CacheFile
&Cache
)
606 for (unsigned J
= 0; J
< Cache
->Head().PackageCount
; J
++)
608 pkgCache::PkgIterator
I(Cache
,Cache
.List
[J
]);
609 if (Cache
[I
].InstallVer
!= (pkgCache::Version
*)I
.CurrentVer() &&
610 I
->SelectedState
== pkgCache::State::Hold
) {
611 List
+= I
.FullName(true) + " ";
612 VersionsList
+= string(Cache
[I
].CurVersion
) + " => " + Cache
[I
].CandVersion
+ "\n";
616 return ShowList(out
,_("The following held packages will be changed:"),List
,VersionsList
);
619 // ShowEssential - Show an essential package warning /*{{{*/
620 // ---------------------------------------------------------------------
621 /* This prints out a warning message that is not to be ignored. It shows
622 all essential packages and their dependents that are to be removed.
623 It is insanely risky to remove the dependents of an essential package! */
624 bool ShowEssential(ostream
&out
,CacheFile
&Cache
)
628 bool *Added
= new bool[Cache
->Head().PackageCount
];
629 for (unsigned int I
= 0; I
!= Cache
->Head().PackageCount
; I
++)
632 for (unsigned J
= 0; J
< Cache
->Head().PackageCount
; J
++)
634 pkgCache::PkgIterator
I(Cache
,Cache
.List
[J
]);
635 if ((I
->Flags
& pkgCache::Flag::Essential
) != pkgCache::Flag::Essential
&&
636 (I
->Flags
& pkgCache::Flag::Important
) != pkgCache::Flag::Important
)
639 // The essential package is being removed
640 if (Cache
[I
].Delete() == true)
642 if (Added
[I
->ID
] == false)
645 List
+= I
.FullName(true) + " ";
646 //VersionsList += string(Cache[I].CurVersion) + "\n"; ???
652 if (I
->CurrentVer
== 0)
655 // Print out any essential package depenendents that are to be removed
656 for (pkgCache::DepIterator D
= I
.CurrentVer().DependsList(); D
.end() == false; ++D
)
658 // Skip everything but depends
659 if (D
->Type
!= pkgCache::Dep::PreDepends
&&
660 D
->Type
!= pkgCache::Dep::Depends
)
663 pkgCache::PkgIterator P
= D
.SmartTargetPkg();
664 if (Cache
[P
].Delete() == true)
666 if (Added
[P
->ID
] == true)
671 snprintf(S
,sizeof(S
),_("%s (due to %s) "),P
.FullName(true).c_str(),I
.FullName(true).c_str());
673 //VersionsList += "\n"; ???
679 return ShowList(out
,_("WARNING: The following essential packages will be removed.\n"
680 "This should NOT be done unless you know exactly what you are doing!"),List
,VersionsList
);
684 // Stats - Show some statistics /*{{{*/
685 // ---------------------------------------------------------------------
687 void Stats(ostream
&out
,pkgDepCache
&Dep
)
689 unsigned long Upgrade
= 0;
690 unsigned long Downgrade
= 0;
691 unsigned long Install
= 0;
692 unsigned long ReInstall
= 0;
693 for (pkgCache::PkgIterator I
= Dep
.PkgBegin(); I
.end() == false; ++I
)
695 if (Dep
[I
].NewInstall() == true)
699 if (Dep
[I
].Upgrade() == true)
702 if (Dep
[I
].Downgrade() == true)
706 if (Dep
[I
].Delete() == false && (Dep
[I
].iFlags
& pkgDepCache::ReInstall
) == pkgDepCache::ReInstall
)
710 ioprintf(out
,_("%lu upgraded, %lu newly installed, "),
714 ioprintf(out
,_("%lu reinstalled, "),ReInstall
);
716 ioprintf(out
,_("%lu downgraded, "),Downgrade
);
718 ioprintf(out
,_("%lu to remove and %lu not upgraded.\n"),
719 Dep
.DelCount(),Dep
.KeepCount());
721 if (Dep
.BadCount() != 0)
722 ioprintf(out
,_("%lu not fully installed or removed.\n"),
726 // YnPrompt - Yes No Prompt. /*{{{*/
727 // ---------------------------------------------------------------------
728 /* Returns true on a Yes.*/
729 bool YnPrompt(bool Default
)
731 /* nl_langinfo does not support LANGUAGE setting, so we unset it here
732 to have the help-message (hopefully) match the expected characters */
733 char * language
= getenv("LANGUAGE");
734 if (language
!= NULL
)
735 language
= strdup(language
);
736 if (language
!= NULL
)
737 unsetenv("LANGUAGE");
740 // TRANSLATOR: Yes/No question help-text: defaulting to Y[es]
741 // e.g. "Do you want to continue? [Y/n] "
742 // The user has to answer with an input matching the
743 // YESEXPR/NOEXPR defined in your l10n.
744 c2out
<< " " << _("[Y/n]") << " " << std::flush
;
746 // TRANSLATOR: Yes/No question help-text: defaulting to N[o]
747 // e.g. "Should this file be removed? [y/N] "
748 // The user has to answer with an input matching the
749 // YESEXPR/NOEXPR defined in your l10n.
750 c2out
<< " " << _("[y/N]") << " " << std::flush
;
752 if (language
!= NULL
)
754 setenv("LANGUAGE", language
, 0);
758 if (_config
->FindB("APT::Get::Assume-Yes",false) == true)
760 // TRANSLATOR: "Yes" answer printed for a yes/no question if --assume-yes is set
761 c1out
<< _("Y") << std::endl
;
764 else if (_config
->FindB("APT::Get::Assume-No",false) == true)
766 // TRANSLATOR: "No" answer printed for a yes/no question if --assume-no is set
767 c1out
<< _("N") << std::endl
;
771 char response
[1024] = "";
772 std::cin
.getline(response
, sizeof(response
));
777 if (strlen(response
) == 0)
783 Res
= regcomp(&Pattern
, nl_langinfo(YESEXPR
),
784 REG_EXTENDED
|REG_ICASE
|REG_NOSUB
);
788 regerror(Res
,&Pattern
,Error
,sizeof(Error
));
789 return _error
->Error(_("Regex compilation error - %s"),Error
);
792 Res
= regexec(&Pattern
, response
, 0, NULL
, 0);
798 // AnalPrompt - Annoying Yes No Prompt. /*{{{*/
799 // ---------------------------------------------------------------------
800 /* Returns true on a Yes.*/
801 bool AnalPrompt(const char *Text
)
804 std::cin
.getline(Buf
,sizeof(Buf
));
805 if (strcmp(Buf
,Text
) == 0)